Exemplo n.º 1
0
  @Test(groups = "1s")
  public void testEq() throws ContradictionException {
    Solver solver = new Solver();
    IntVar x = VariableFactory.enumerated("X", 1, 6, solver);
    IntVar y = VariableFactory.enumerated("Y", 1, 6, solver);

    solver.post(IntConstraintFactory.arithm(x, "=", y));

    solver.propagate();

    x.removeValue(4, Cause.Null);

    solver.propagate();

    Assert.assertFalse(y.contains(4));
  }
Exemplo n.º 2
0
 /**
  * Default propagation test: When an opposite var is declared, the lower (resp. upper) bound
  * modification should be transposed in upper (resp. lower) bound event...
  */
 @Test(groups = "1s")
 public void testUSum2() throws ContradictionException {
   Solver sum =
       sum(
           new int[][] {{-2, 7}, {-1, 6}, {2}, {-2, 5}, {-2, 4}, {-2, 6}},
           new int[] {-7, 13, -3, -18, -24, 1},
           30,
           0);
   PropagationEngineFactory.DEFAULT.make(sum);
   Variable[] vars = sum.getVars();
   int offSet = 2; // ZERO and ONE constants
   ((IntVar) vars[offSet]).instantiateTo(-2, Cause.Null);
   ((IntVar) vars[1 + offSet]).instantiateTo(-1, Cause.Null);
   sum.propagate();
   //        sum.getSearchLoop().timeStamp++;
   ((IntVar) vars[2 + offSet]).removeValue(-2, Cause.Null);
   sum.propagate();
   Assert.assertTrue(vars[2 + offSet].isInstantiated());
 }