Package solver

Examples of solver.Solver.findSolution()


        IntVar x = VariableFactory.bounded("X", 1, 3, solver);
        IntVar y = VariableFactory.bounded("Y", 1, 3, solver);
        solver.post(IntConstraintFactory.arithm(x, ">=", y));
        solver.post(IntConstraintFactory.arithm(x, "<=", 2));

        solver.findSolution();


    }
}
View Full Code Here


            @Override
            public void onSolution() {
                solver.post(ICF.arithm(iv, ">=", 6));
            }
        });
        solver.findSolution();
        Assert.assertEquals(iv.getValue(), 2);

        solver.getSearchLoop().reset();
        solver.findSolution();
        Assert.assertEquals(iv.getValue(), 6);
View Full Code Here

        });
        solver.findSolution();
        Assert.assertEquals(iv.getValue(), 2);

        solver.getSearchLoop().reset();
        solver.findSolution();
        Assert.assertEquals(iv.getValue(), 6);
    }

    @Test(groups = "1s")
    public void test4() {
View Full Code Here

                = LCF.or(
                LCF.and(aSBetter, bBetter),
                LCF.and(aBetter, bSBetter));
        // END extra variables/constraints for guided improvement algorithm
        int nbSolution = 0;
        while (solver.findSolution()) {
            int bestA;
            int bestB;
            do {
                bestA = a.getValue();
                bestB = b.getValue();
View Full Code Here

            push(ICF.arithm(lbB, "=", bestB), stack, solver);

            solver.getEngine().flush();
            solver.getSearchLoop().reset();

            if (solver.findSolution()) {
                do {
                    //System.out.println("Found pareto optimal solution: " + a + ", " + b + ", " + c);
                    nbSolution++;
                } while (solver.nextSolution());
            }
View Full Code Here

        IntVar z = VariableFactory.enumerated("z", 1, 2, solver);
        Constraint c = LCF.or(
                ICF.arithm(x, "<", y),
                ICF.arithm(x, "<", z));
        solver.post(c);
        solver.findSolution();
        solver.unpost(c);
    }
}
View Full Code Here

        int bestvalue = b1.getValue();
        solver.getSearchLoop().reset();
        solver.post(ICF.arithm(b1, "=", bestvalue));
        solver.set(ISF.lexico_LB(new BoolVar[]{b1, b2}));
        int count = 0;
        if (solver.findSolution()) {
            do {
                count++;
//                System.out.println(b1 + " " + b2);
            } while (solver.nextSolution());
        }
View Full Code Here

    public void test1() {
        Solver s = new Solver();
        IntVar two1 = VF.fixed(2, s);
        IntVar two2 = VF.fixed(2, s);
        s.post(ICF.arithm(two1, "=", two2));
        Assert.assertTrue(s.findSolution());
        Assert.assertEquals(ESat.TRUE, s.isSatisfied());
    }


    @Test(groups = "1s")
View Full Code Here

    public void testPrevNext() {
        Solver solver = new Solver();
        BoolVar a = VF.bool("a", solver);
        BoolVar b = VF.bool("b", solver);
        solver.post(ICF.arithm(a, "+", VF.not(b), "=", 2));
        Assert.assertTrue(solver.findSolution());
    }
}
View Full Code Here

        // configure Solver
        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);
        s.post(lcstrs);
        s.set(strategy);
        // solve
        s.findSolution();
        long sol = s.getMeasures().getSolutionCount();
        Assert.assertEquals(sol, 1, "nb sol incorrect");
    }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.