Package solver.constraints.nary.cnf

Examples of solver.constraints.nary.cnf.LogOp


    @Test(groups = "1s")
    public void test31() {
        Solver solver = new Solver();
        BoolVar[] bvars = VariableFactory.boolArray("b", 2, solver);
        LogOp tree = LogOp.or(bvars[0], bvars[1].not());
        SatFactory.addClauses(tree, solver);

        try {
            solver.propagate();
            bvars[0].instantiateTo(0, Cause.Null);
View Full Code Here


    @Test(groups = "1s")
    public void test32() {
        Solver solver = new Solver();
        BoolVar[] bvars = VariableFactory.boolArray("b", 2, solver);
        LogOp tree = LogOp.or(bvars[0], bvars[1].not());
        SatFactory.addClauses(tree, solver);

        try {
            solver.propagate();
            bvars[1].instantiateTo(1, Cause.Null);
View Full Code Here

    @Test(groups = "1s")
    public void test33() {
        Solver solver = new Solver();
        BoolVar[] bvars = VariableFactory.boolArray("b", 3, solver);
        LogOp tree = LogOp.or(bvars[0], bvars[1].not(), bvars[2].not());
        SatFactory.addClauses(tree, solver);

        try {
            solver.propagate();
            bvars[0].instantiateTo(0, Cause.Null);
View Full Code Here

        for (int seed = 0; seed < 2000; seed++) {
            long n1, n2;
            {
                Solver solver = new Solver();
                BoolVar[] bvars = VariableFactory.boolArray("b", 3, solver);
                LogOp tree = LogOp.ifOnlyIf(
                        LogOp.and(bvars[1], bvars[2]),
                        bvars[0]);
                SatFactory.addClauses(tree, solver);

                solver.set(IntStrategyFactory.random_bound(bvars, seed));
View Full Code Here

            boolean b2 = rand.nextBoolean();
            boolean s1, s2;
            {
                Solver solver = new Solver();
                BoolVar[] bvars = VariableFactory.boolArray("b", 3, solver);
                LogOp tree = LogOp.ifOnlyIf(
                        LogOp.and(bvars[1], bvars[2]),
                        bvars[0]);
                SatFactory.addClauses(tree, solver);
                try {
                    solver.propagate();
View Full Code Here

        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);

        Assert.assertEquals(l.toString(), "(e and (b or a or not(c)) and (b or a or not(d)))");
    }
View Full Code Here

        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);

        Assert.assertEquals(root.toString(), "(d or c or not(a) or b)");
    }
View Full Code Here

        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

        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);

        Assert.assertEquals(root.toString(), "(((not(a) and b) and not(c)) and not(d))");
    }
View Full Code Here

        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);

        Assert.assertEquals(root.toString(), "(d and c and not(a) and b)");
    }
View Full Code Here

TOP

Related Classes of solver.constraints.nary.cnf.LogOp

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.