Package edu.cmu.cs.fusion.constraint

Examples of edu.cmu.cs.fusion.constraint.Substitution


  @Test
  public void testEmptyValidLabels() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
    Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
View Full Code Here


 
  @Test
  public void testFindLabelsOneOption() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
    Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
   
    fv = fv.addVar(new SpecVar("c"), "Narf");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
    Substitution sub = itr.next();
    assertTrue(!itr.hasNext());   
   
    assertEquals(3, sub.size());
    assertEquals(labels[0], sub.getSub(new SpecVar("a")));
    assertEquals(labels[1], sub.getSub(new SpecVar("b")));
    assertEquals(labels[7], sub.getSub(new SpecVar("c")));
  }
View Full Code Here

  @Test
  public void testFindLabelsAliasesAllDefinite() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
    Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
   
    fv = fv.addVar(new SpecVar("c"), "Foo");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
    Substitution subA = itr.next();
    assertTrue(itr.hasNext());
    Substitution subB = itr.next();
    assertTrue(itr.hasNext());   
    Substitution subC = itr.next();
    assertTrue(!itr.hasNext());   
   
    assertEquals(3, subA.size());
    assertEquals(3, subB.size());
    assertEquals(3, subC.size());
   
    if (subA.getSub(new SpecVar("c")).equals(labels[0])) {
      if (subB.getSub(new SpecVar("c")).equals(labels[3])) {
        assertEquals(labels[4], subC.getSub(new SpecVar("c")))
      }
      else {
        assertEquals(labels[4], subB.getSub(new SpecVar("c")))
        assertEquals(labels[3], subC.getSub(new SpecVar("c")));       
      }
    }
    else if (subA.getSub(new SpecVar("c")).equals(labels[3])) {
      if (subB.getSub(new SpecVar("c")).equals(labels[0])) {
        assertEquals(labels[4], subC.getSub(new SpecVar("c")))
      }
      else {
        assertEquals(labels[4], subB.getSub(new SpecVar("c")))
        assertEquals(labels[0], subC.getSub(new SpecVar("c")));       
      }
    }
    else {
      assertEquals(labels[4], subA.getSub(new SpecVar("c")))
      if (subB.getSub(new SpecVar("c")).equals(labels[0])) {
        assertEquals(labels[3], subC.getSub(new SpecVar("c")))
      }
      else {
        assertEquals(labels[3], subB.getSub(new SpecVar("c")))
        assertEquals(labels[0], subC.getSub(new SpecVar("c")));       
      }
    }
  }
View Full Code Here

 
  @Test
  public void testFindLabelsPossibleFromSuperTypes() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
    Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
   
    fv = fv.addVar(new SpecVar("c"), "Baz");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
    Substitution subA = itr.next();
    assertTrue(itr.hasNext());
    Substitution subB = itr.next();
    assertTrue(itr.hasNext());
    Substitution subC = itr.next();
    assertTrue(itr.hasNext());
    Substitution subD = itr.next();
    assertTrue(!itr.hasNext())
   
    assertEquals(3, subA.size());
    assertEquals(3, subB.size());
    assertEquals(3, subC.size());
    assertEquals(3, subD.size());
   
    List<ObjectLabel> possible = new LinkedList<ObjectLabel>();
    possible.add(subA.getSub(new SpecVar("c")));
    possible.add(subB.getSub(new SpecVar("c")));
    possible.add(subC.getSub(new SpecVar("c")));
    possible.add(subD.getSub(new SpecVar("c")));
   
    assertTrue(possible.contains(labels[1]));
    assertTrue(possible.contains(labels[2]));
    assertTrue(possible.contains(labels[5]));
    assertTrue(possible.contains(labels[6]));
View Full Code Here

    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(2), 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[1]);

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

    Relationship eRel = new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[6], labels[1]});
View Full Code Here

    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(2), new ObjectLabel[]{labels[1], labels[2]}), 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[1]);

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

    Relationship eRel = new Relationship(utils.getRelation(1), new ObjectLabel[]{labels[6], labels[1]});
View Full Code Here

  public void testTrueUnkown() throws FusionException {
    RelationshipDelta startRels = new RelationshipDelta();
    startRels.setRelationship(new Relationship(utils.getRelation(0), new ObjectLabel[]{labels[0], labels[1]}), 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[1]);

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

    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, rels, null, types, new InferenceEnvironment(null), variant);   
    Pair<RelationshipDelta, Substitution> deltas = runFullyBound(env, partialSub, possCons);
View Full Code Here

    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[1]}), SevenPointLattice.FAL);
    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[2]}), SevenPointLattice.TRU);
    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[6]}), SevenPointLattice.FAL);
    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[1]);

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

    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, rels, null, types, new InferenceEnvironment(null), variant);   
    Pair<RelationshipDelta, Substitution> deltas = runFullyBound(env, partialSub, possCons);
View Full Code Here

    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[1]}), SevenPointLattice.FAL);
    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[2]}), SevenPointLattice.FAL);
    startRels.setRelationship(new Relationship(utils.getRelation(2), new ObjectLabel[]{labels[1], labels[6]}), SevenPointLattice.FAL);
    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[1]);

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

    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, rels, null, types, new InferenceEnvironment(null), variant);   
    Pair<RelationshipDelta, Substitution> deltas = runFullyBound(env, partialSub, possCons);
View Full Code Here

  public void testUnknown() throws FusionException {
    RelationshipDelta startRels = new RelationshipDelta();
    startRels.setRelationship(new Relationship(utils.getRelation(0), new ObjectLabel[]{labels[0], labels[1]}), SevenPointLattice.UNK);
    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[1]);

   
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, rels, null, types, new InferenceEnvironment(null), variant);   
    Pair<RelationshipDelta, Substitution> deltas = runFullyBound(env, partialSub, cons);
View Full Code Here

TOP

Related Classes of edu.cmu.cs.fusion.constraint.Substitution

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.