Package edu.cmu.cs.fusion.constraint

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


  @Test
  public void testNoMatchForProduce() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("b")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("b")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
       
    assertNull(env.getInferredDelta(find, sub));
  }
View Full Code Here


  @Test
  public void testNoVariablesWork() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("b")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[0], new SpecVar[] {new SpecVar("b"), new SpecVar("a")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
    sub = sub.addSub(new SpecVar("b"), labels[1]);
   
    assertNull(env.getInferredDelta(find, sub));   
  }
View Full Code Here

  @Test
  public void testWrongValue() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("b")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createRemoveEffect(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
    sub = sub.addSub(new SpecVar("b"), labels[1]);
   
    assertNull(env.getInferredDelta(find, sub));   
  }
View Full Code Here

  @Test
  public void testThrashes() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("y")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createRemoveEffect(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("y")}));
    eff.add(RelEffect.createAddEffect(relations[1], new SpecVar[] {new SpecVar("x"), new SpecVar("x")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    assertNull(env.getInferredDelta(find, sub));     
  }
View Full Code Here

  @Test
  public void testWorksSingleStepSame() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("y")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("x")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[0], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
View Full Code Here

  @Test
  public void testWorksSingleStepDiff() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("y")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[1], new SpecVar[] {new SpecVar("x"), new SpecVar("x")}));
   
    InferredRel inf = new InferredRel(trigger, eff);
    infEnv.addRule(inf);
   
    RelationshipPredicate find = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[1], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
View Full Code Here

  @Test
  public void testWorksTwoSteps() {
    InferenceEnvironment infEnv = new InferenceEnvironment(null);
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, ctx, null, testH, infEnv, Variant.PRAGMATIC_VARIANT);
   
    RelationshipPredicate trigger = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("y")});
    List<RelEffect> eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[1], new SpecVar[] {new SpecVar("x"), new SpecVar("x")}));
   
    infEnv.addRule(new InferredRel(trigger, eff));
   
    trigger = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("x"), new SpecVar("x")});
    eff = new LinkedList<RelEffect>();
    eff.add(RelEffect.createAddEffect(relations[0], new SpecVar[] {new SpecVar("x"), new SpecVar("x")}));
   
    infEnv.addRule(new InferredRel(trigger, eff));
   
    RelationshipPredicate find = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[1], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
View Full Code Here

  }

  @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

TOP

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

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.