Package edu.cmu.cs.fusion

Examples of edu.cmu.cs.fusion.Relationship


    x = new AbstractObjectLabel("x");
    y = new AbstractObjectLabel("y");
    z = new AbstractObjectLabel("z");

    d1 = new RelationshipDelta();
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d2 = new RelationshipDelta();
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d3 = new RelationshipDelta();
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d4 = new RelationshipDelta();
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU_STAR);
  }
View Full Code Here


  @Test
  public void testPolarize() {
    RelationshipDelta polar = d1.polarize();
   
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    polar = d4.polarize();
   
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.TRU_STAR);
  }
View Full Code Here

    list = new LinkedList<RelationshipDelta>();
    list.add(d1);
    list.add(d2);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.FAL_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    list = new LinkedList<RelationshipDelta>();
    list.add(d2);
    list.add(d4);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    list = new LinkedList<RelationshipDelta>();
    list.add(d1);
    list.add(d2);
    list.add(d3);
    list.add(d4);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);
  }
View Full Code Here

    delta = new RelationshipDelta();
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
   
    //test an equal delta
    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
   
    //test a more precise delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU);
    assertTrue(delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
   
    //test a more and less precise delta
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    //test a less precise U delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a thrashing delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a delta which is less precise when star is used.
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {x, z}), SevenPointLattice.TRU_STAR);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
   
    //another star, but equal precise
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU_STAR);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a more and the star used
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.FAL);
    assertTrue(delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
  }
View Full Code Here

    x = new AbstractObjectLabel("x");
    y = new AbstractObjectLabel("y");
    z = new AbstractObjectLabel("z");

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c1 = new RelationshipContext(true).applyChangesFromDelta(delta);
   
    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c2 = new RelationshipContext(true).applyChangesFromDelta(delta);

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c3 = new RelationshipContext(true).applyChangesFromDelta(delta);

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c4 = new RelationshipContext(true).applyChangesFromDelta(delta);
   
   
    d1 = new RelationshipDelta();
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d2 = new RelationshipDelta();
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d3 = new RelationshipDelta();
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d4 = new RelationshipDelta();
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU_STAR);
}
View Full Code Here

}
 
  @Test
  public void testJoinSame() {
    RelationshipContext joined = c1.join(c2);
    assertTrue(joined.getRelationship(new Relationship(tA, new ObjectLabel[] {w, y})) == ThreeValue.TRUE);
    assertTrue(joined.getRelationship(new Relationship(tA, new ObjectLabel[] {w, z})) == ThreeValue.FALSE);
    assertTrue(joined.getRelationship(new Relationship(tA, new ObjectLabel[] {x, y})) == ThreeValue.UNKNOWN);
    assertTrue(joined.getRelationship(new Relationship(tA, new ObjectLabel[] {x, z})) == ThreeValue.UNKNOWN);
    assertTrue(joined.getRelationship(new Relationship(tB, new ObjectLabel[] {y, z})) == ThreeValue.UNKNOWN);
    assertTrue(joined.getRelationship(new Relationship(tB, new ObjectLabel[] {z, y})) == ThreeValue.UNKNOWN);
  }
View Full Code Here

  @Test
  public void testApplyChangesToContext() {
    RelationshipContext applied;
   
    applied = c1.applyChangesFromDelta(d1);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {y, z})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {z, y})) == ThreeValue.UNKNOWN);
 
    applied = c1.applyChangesFromDelta(d2);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, y})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {y, z})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {z, y})) == ThreeValue.UNKNOWN);

    applied = c1.applyChangesFromDelta(d3);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, y})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, z})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {y, z})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {z, y})) == ThreeValue.UNKNOWN);

    applied = c1.applyChangesFromDelta(d4);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {w, z})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, y})) == ThreeValue.TRUE);
    assertTrue(applied.getRelationship(new Relationship(tA, new ObjectLabel[] {x, z})) == ThreeValue.FALSE);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {y, z})) == ThreeValue.UNKNOWN);
    assertTrue(applied.getRelationship(new Relationship(tB, new ObjectLabel[] {z, y})) == ThreeValue.UNKNOWN);
  }
View Full Code Here

   
    changes = b1.applyChangesFromDelta(delta);
    assertTrue(b1.isMorePreciseOrEqualTo(changes));
    assertTrue(changes.isMorePreciseOrEqualTo(b1));
   
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.UNK);
    changes = b1.applyChangesFromDelta(delta);
    assertTrue(b1.isMorePreciseOrEqualTo(changes));
    assertTrue(!changes.isMorePreciseOrEqualTo(b1));
  }
View Full Code Here

   
    Constraint noEffectCons = new Constraint("", op, trigger, new TruePredicate(), req, effects);

   
    RelationshipDelta startRels = new RelationshipDelta();
    startRels.setRelationship(new Relationship(utils.getRelation(0), new ObjectLabel[]{labels[0], labels[1]}), SevenPointLattice.TRU);
    startRels.setRelationship(new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[1], labels[6]}), SevenPointLattice.TRU);
    RelationshipContext rels = new RelationshipContext(false).applyChangesFromDelta(startRels);
   
    //R0(0, 1) R1(1, 6)

    Substitution partialSub = new Substitution();
View Full Code Here

    effects.add(RelEffect.createAddEffect(utils.getRelation(1), new SpecVar[] {utils.getVar(1), utils.getVar(1)}));

    Constraint severalEffectCons = new Constraint("", op, trigger, new TruePredicate(), req, effects);
   
    RelationshipDelta startRels = new RelationshipDelta();
    startRels.setRelationship(new Relationship(utils.getRelation(0), new ObjectLabel[]{labels[0], labels[1]}), SevenPointLattice.TRU);
    startRels.setRelationship(new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[1], labels[6]}), SevenPointLattice.TRU);
    RelationshipContext rels = new RelationshipContext(false).applyChangesFromDelta(startRels);

    Substitution partialSub = new Substitution();
    partialSub = partialSub.addSub(utils.getVar(0), labels[0]);
    partialSub = partialSub.addSub(utils.getVar(1), labels[1]);
    partialSub = partialSub.addSub(Constraint.RESULT, labels[6]);
    partialSub = partialSub.addSub(Constraint.RECEIVER, labels[3]);

    this.variant = Variant.PRAGMATIC_VARIANT;
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, rels, null, types, new InferenceEnvironment(null), variant);   
    Pair<RelationshipDelta, Substitution> deltas = runFullyBound(env, partialSub, severalEffectCons);

    Relationship eRel1 = new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[6], labels[1]});
    Relationship eRel2 = new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[1], labels[1]});

    assertEquals(2, deltas.fst().numberOfChanges());
    assertEquals(SevenPointLattice.FAL, deltas.fst().getValue(eRel1));
    assertEquals(SevenPointLattice.TRU, deltas.fst().getValue(eRel2));
//    assertEquals(SpecDelta.createSubstitutionSpecDelta(partialSub), deltas.snd());
View Full Code Here

TOP

Related Classes of edu.cmu.cs.fusion.Relationship

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.