Package solver.variables

Examples of solver.variables.BoolVar


    }

    @Test(groups = "1s")
    public void test8() {
        Solver solver = new Solver();
        BoolVar b1, b2, r;
        b1 = VF.bool("b1", solver);
        b2 = VF.bool("b2", solver);
        r = VF.bool("r", solver);
        SatFactory.addBoolIsLeVar(b1, b2, r);
//        SMF.log(solver, true, true);
View Full Code Here


    }

    @Test(groups = "1s")
    public void test9() {
        Solver solver = new Solver();
        BoolVar b1, b2, r;
        b1 = VF.bool("b1", solver);
        b2 = VF.bool("b2", solver);
        r = VF.bool("r", solver);
        SatFactory.addBoolIsLtVar(b1, b2, r);
//        SMF.log(solver, true, true);
View Full Code Here

    }


    private ILogical reformulate(int i, IntVar[] X, IntVar[] Y, Solver solver) {
        BoolVar b1 = VariableFactory.bool("A" + i, solver);
        solver.post(LogicalConstraintFactory.ifThenElse(b1, IntConstraintFactory.arithm(Y[i], ">", X[i]), IntConstraintFactory.arithm(Y[i], "<=", X[i])));
        if (i == X.length - 1) {
            return b1;
        } else {
            BoolVar b2 = VariableFactory.bool("B" + i, solver);
            solver.post(LogicalConstraintFactory.ifThenElse(b2, IntConstraintFactory.arithm(Y[i], "=", X[i]), IntConstraintFactory.arithm(X[i], "!=", Y[i])));
            return LogOp.or(b1, LogOp.and(b2, reformulate(i + 1, X, Y, solver)));
        }
    }
View Full Code Here

    @Test(groups = "1s")
    public void testBothOr() {
        Solver s = new Solver();

        BoolVar b = VariableFactory.bool("to be", s);

        LogOp or = LogOp.or(b, b.not());

        SatFactory.addClauses(or, s);

        BoolVar[] bs = new BoolVar[]{b};
        s.set(IntStrategyFactory.lexico_LB(bs));
View Full Code Here

    @Test(groups = "1s")
    public void test1() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver);
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);
        BoolVar d = VariableFactory.bool("d", solver);


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

        ILogical l = LogicTreeToolBox.toCNF(root, solver);
View Full Code Here

    @Test(groups = "1s")
    public void test12() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver);
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);
        BoolVar d = VariableFactory.bool("d", solver);
        BoolVar e = VariableFactory.bool("e", solver);


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

        ILogical l = LogicTreeToolBox.toCNF(root, solver);
View Full Code Here

    @Test(groups = "1s")
    public void test2() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver).not();
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);
        BoolVar d = VariableFactory.bool("d", solver);

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

        LogicTreeToolBox.merge(LogOp.Operator.OR, root);
View Full Code Here

    @Test(groups = "1s")
    public void test3() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver);
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);

        LogOp root = LogOp.or(LogOp.and(a, b), c);
        root = LogicTreeToolBox.developOr(root);
        Assert.assertEquals(root.toString(), "((a or c) and (b or c))");
    }
View Full Code Here

    @Test(groups = "1s")
    public void test4() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver).not();
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);
        BoolVar d = VariableFactory.bool("d", solver);

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

        LogicTreeToolBox.expandNot(root);
View Full Code Here

    @Test(groups = "1s")
    public void test5() {
        Solver solver = new Solver();

        BoolVar a = VariableFactory.bool("a", solver).not();
        BoolVar b = VariableFactory.bool("b", solver);
        BoolVar c = VariableFactory.bool("c", solver);
        BoolVar d = VariableFactory.bool("d", solver);

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

        LogicTreeToolBox.merge(LogOp.Operator.AND, root);
View Full Code Here

TOP

Related Classes of solver.variables.BoolVar

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.