public ChocoSolver(SolvableModel model, int seed) { initModel(model); solver.addGoal( new DomOverWDegBranchingNew( solver, solver.getVar(model.getVariables()), new IncreasingDomain(), seed)); }
@Test public void test2() { CPSolver s = new CPSolver(); RealVar alpha = s.createRealVal("alpha", -5.5 * Math.PI, -1.5 * Math.PI); RealExp exp = new RealCos(s, alpha); s.post(s.makeEquation(exp, s.cst(1.0))); boolean first = false; s.setFirstSolution(first); s.generateSearchStrategy(); s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain())); s.launch(); assertTrue(s.getNbSolutions() >= 2); }
public ChocoSolver( SolvableModel model, int seed, SharedHeuristicWeights sharedVariablesWeight, SharedHeuristicWeights sharedConstraintsWeight) { initModel(model); solver.addGoal( new DomOverWDegBranchingSharedWeights( solver, solver.getVar(model.getVariables()), new IncreasingDomain(), seed, sharedVariablesWeight, sharedConstraintsWeight)); }
@Test public void test1() { CPSolver s = new CPSolver(); RealVar alpha = s.createRealVal("alpha", -Math.PI, Math.PI); RealExp exp = new RealMinus(s, new RealCos(s, alpha), new RealSin(s, alpha)); SConstraint c = s.makeEquation(exp, s.cst(0.0)); LOGGER.info("c = " + c.pretty()); s.post(s.makeEquation(exp, s.cst(0.0))); boolean first = false; s.setFirstSolution(first); s.generateSearchStrategy(); s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain())); s.launch(); assertTrue("Nb sols", s.getNbSolutions() >= 2); assertTrue("Precision", Math.abs(Math.cos(alpha.getInf()) - Math.sin(alpha.getInf())) < 1e-8); }
@Test public void test2bis() { CPModel m = new CPModel(); RealVariable alpha = makeRealVar("alpha", -5.5 * Math.PI, -1.5 * Math.PI); m.addVariable(alpha); m.addConstraint(eq(cos(alpha), 1)); CPSolver s = new CPSolver(); s.read(m); boolean first = false; s.setFirstSolution(first); s.generateSearchStrategy(); s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain())); s.launch(); assertTrue(s.getNbSolutions() >= 2); }
public void setHeuristic(ChocoHeuristic heuristic) { switch (heuristic) { case MIN_DOMAIN: { solver.setVarIntSelector(new MinDomain(solver, solver.getVar(model.getVariables()))); break; } case DOM_OVER_WDEG: { solver.addGoal( new DomOverWDegBranchingNew( solver, solver.getVar(model.getVariables()), new IncreasingDomain(), 1)); break; } case DEFAULT: { // default heuristic break; } } }
@Test public void test1bis() { CPModel m = new CPModel(); RealVariable alpha = makeRealVar("alpha", -Math.PI, Math.PI); Constraint exp = eq(cos(alpha), sin(alpha)); m.addConstraint(exp); CPSolver s = new CPSolver(); s.read(m); LOGGER.info("eq = " + s.getCstr(exp).pretty()); boolean first = false; s.setFirstSolution(first); s.generateSearchStrategy(); s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain())); s.launch(); assertTrue(s.getNbSolutions() >= 2); assertTrue( Math.abs(Math.cos(s.getVar(alpha).getInf()) - Math.sin(s.getVar(alpha).getInf())) < 1e-8); }