Esempio n. 1
0
 @Test(groups = "1s", timeOut = 60000)
 public void test14() {
   Model model = new Model();
   BoolVar a = model.boolVar("a");
   BoolVar b = model.boolVar("b");
   LogOp l = LogOp.or(a, b, a.not(), a.not());
   ILogical ll = LogicTreeToolBox.toCNF(l, model);
   Assert.assertEquals(ll.toString(), "cste -- 1 = 1");
 }
Esempio n. 2
0
 @Test(groups = "1s", timeOut = 60000)
 public void test11() {
   Model model = new Model();
   BoolVar a = model.boolVar("a");
   BoolVar b = model.boolVar("b");
   LogOp l = LogOp.or(LogOp.and(a, b.not()), LogOp.and(a.not(), b), LogOp.and(a.not(), b.not()));
   ILogical ll = LogicTreeToolBox.toCNF(l, model);
   Assert.assertEquals(ll.toString(), "(not(b) or not(a))");
 }
Esempio n. 3
0
  @Test(groups = "1s", timeOut = 60000)
  public void test3() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");

    LogOp root = LogOp.or(LogOp.and(a, b), c);
    root = LogicTreeToolBox.developOr(root);
    Assert.assertEquals(root.toString(), "((a or c) and (b or c))");
  }
Esempio n. 4
0
  @Test(groups = "1s", timeOut = 60000)
  public void test6() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar b = model.boolVar("b");

    LogOp root = LogOp.implies(a, b);

    ILogical l = LogicTreeToolBox.toCNF(root, model);

    Assert.assertEquals(l.toString(), "(b or not(a))");
  }
Esempio n. 5
0
  @Test(groups = "1s", timeOut = 60000)
  public void test7() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");

    LogOp root = LogOp.ifThenElse(a, b, c);

    ILogical l = LogicTreeToolBox.toCNF(root, model);

    Assert.assertEquals(l.toString(), "((a or c) and (b or c) and (b or not(a)))");
  }
Esempio n. 6
0
  @Test(groups = "1s", timeOut = 60000)
  public void test4() {
    Model model = new Model();

    BoolVar a = model.boolVar("a").not();
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");
    BoolVar d = model.boolVar("d");

    LogOp root = LogOp.nor(LogOp.or(LogOp.nand(a, b), c), d);

    LogicTreeToolBox.expandNot(root);

    Assert.assertEquals(root.toString(), "(((not(a) and b) and not(c)) and not(d))");
  }
Esempio n. 7
0
  @Test(groups = "1s", timeOut = 60000)
  public void test2() {
    Model model = new Model();

    BoolVar a = model.boolVar("a").not();
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");
    BoolVar d = model.boolVar("d");

    LogOp root = LogOp.or(LogOp.or(LogOp.or(a, b), c), d);

    LogicTreeToolBox.merge(LogOp.Operator.OR, root);

    Assert.assertEquals(root.toString(), "(d or c or not(a) or b)");
  }
Esempio n. 8
0
  @Test(groups = "1s", timeOut = 60000)
  public void test1() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");
    BoolVar d = model.boolVar("d");

    LogOp root = LogOp.nand(LogOp.nor(a, b), LogOp.or(c, d));

    ILogical l = LogicTreeToolBox.toCNF(root, model);

    Assert.assertEquals(l.toString(), "((a or b or not(c)) and (a or b or not(d)))");
  }
Esempio n. 9
0
  @Test(groups = "1s", timeOut = 60000)
  public void test9() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar na = a.not();
    BoolVar b = model.boolVar("b");
    BoolVar c = model.boolVar("c");
    BoolVar d = model.boolVar("d");

    LogOp root = LogOp.and(a, b, na, c, d);

    ILogical l = LogicTreeToolBox.toCNF(root, model);

    Assert.assertEquals(l.toString(), "cste -- 0 = 0");
  }
Esempio n. 10
0
  @Test(groups = "1s", timeOut = 60000)
  public void test8() {
    Model model = new Model();

    BoolVar a = model.boolVar("a");
    BoolVar na = a.not();
    BoolVar b = model.boolVar("b");
    BoolVar nb = b.not();
    BoolVar c = model.boolVar("c");
    BoolVar d = model.boolVar("d");

    LogOp root = LogOp.and(LogOp.or(a, b, na), LogOp.or(c, d), LogOp.or(b, nb));

    ILogical l = LogicTreeToolBox.toCNF(root, model);

    Assert.assertEquals(l.toString(), "(c or d)");
  }