コード例 #1
0
 @Override
 public void propagate(int evtmask) throws ContradictionException {
   if (!antecedent.isInstantiated()) {
     if (!PropUtil.isKerSubsetEnv(result, consequent)
         || !PropUtil.isKerSubsetEnv(consequent, result)) {
       antecedent.instantiateTo(0, this);
     } else if (!PropUtil.isKerSubsetEnv(result, alternative)
         || !PropUtil.isKerSubsetEnv(alternative, result)) {
       antecedent.instantiateTo(1, this);
     } else {
       ISetIterator iter = result.getUB().iterator();
       while (iter.hasNext()) {
         int i = iter.nextInt();
         if (!consequent.getUB().contains(i) && !alternative.getUB().contains(i)) {
           result.remove(i, this);
         } else if (consequent.getLB().contains(i) && alternative.getLB().contains(i)) {
           result.force(i, this);
         }
       }
     }
   }
   if (antecedent.isInstantiated()) {
     if (antecedent.getValue() == 1) {
       PropUtil.envSubsetEnv(result, consequent, this);
       PropUtil.envSubsetEnv(consequent, result, this);
       PropUtil.kerSubsetKer(result, consequent, this);
       PropUtil.kerSubsetKer(consequent, result, this);
     } else {
       PropUtil.envSubsetEnv(result, alternative, this);
       PropUtil.envSubsetEnv(alternative, result, this);
       PropUtil.kerSubsetKer(result, alternative, this);
       PropUtil.kerSubsetKer(alternative, result, this);
     }
   }
 }
コード例 #2
0
ファイル: LogicTreeTest.java プロジェクト: kaktus40/choco3
  @Test(groups = "1s", timeOut = 60000)
  public void test17() {
    Model model = new Model();
    IntVar a = model.intVar("a", -1, 1, false);
    BoolVar b1 = model.boolVar("b1");
    BoolVar b2 = model.boolVar("b2");
    model.arithm(a, "=", 0).reifyWith(b1);
    model.arithm(a, ">", 0).reifyWith(b2);

    model.addClauses(new BoolVar[0], new BoolVar[] {b1, b2});
    model.getMinisat().getPropSat().initialize();
    try {
      model.getSolver().propagate();
      b1.instantiateTo(1, Cause.Null);
      model.getSolver().propagate();
    } catch (ContradictionException ex) {
      Assert.fail();
    }
    Assert.assertTrue(b1.isInstantiatedTo(1));
    Assert.assertTrue(b2.isInstantiatedTo(0));
    Assert.assertTrue(a.isInstantiatedTo(0));
  }