Package solver

Examples of solver.Solver.findSolution()


      }
    } else {
      solver.set(new ConstructorIntHeur(succ,offset));
    }
    SearchMonitorFactory.limitTime(solver, TIME_LIMIT);
    solver.findSolution();
    IMeasures mes = solver.getMeasures();
    // the problem has at least one solution
    Assert.assertFalse(mes.getSolutionCount() == 0 && mes.getTimeCount() < TIME_LIMIT/1000);
  }
View Full Code Here


        // 3. Create and post constraints by using constraint factories
        solver.post(IntConstraintFactory.arithm(x, "+", y, "<", 5));
        // 4. Define the search strategy
        solver.set(IntStrategyFactory.lexico_LB(new IntVar[]{x, y}));
        // 5. Launch the resolution process
        solver.findSolution();
    }
}
View Full Code Here

                "({0}*{1})+sin({0})=1.0;ln({0}+[-0.1,0.1])>=2.6",
                Ibex.HC4,
                x, y);
        solver.post(rc);
        SMF.log(solver, true, false);
        solver.findSolution();
    }
}
View Full Code Here

    @Test(groups = "1s")
    public static void test1() {
        Solver solver = new Solver();
        IntVar[] x = VariableFactory.boundedArray("x", 10, 0, 20, solver);
        solver.post(IntConstraintFactory.subcircuit(x, 0, VariableFactory.bounded("length", 0, x.length - 1, solver)));
        solver.findSolution();
        Assert.assertEquals(1, solver.getMeasures().getSolutionCount());
    }

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

        Solver solver = new Solver();
        IntVar[] x = VariableFactory.boundedArray("x", 5, 0, 4, solver);
        IntVar[] y = VariableFactory.boundedArray("y", 5, 5, 9, solver);
        IntVar[] vars = ArrayUtils.append(x, y);
        solver.post(IntConstraintFactory.subcircuit(vars, 0, VariableFactory.bounded("length", 0, vars.length - 1, solver)));
        solver.findSolution();
        Assert.assertTrue(solver.getMeasures().getSolutionCount() > 0);
    }

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

        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
        solver.post(IntConstraintFactory.subcircuit(vars, 0, VariableFactory.bounded("length", 0, vars.length - 1, solver)));
        solver.findSolution();
        Assert.assertTrue(solver.getMeasures().getSolutionCount() == 0);
    }

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

        Solver solver = new Solver();
        SetVar v1 = VF.fixed("{0,1}", new int[]{0, 1}, solver);
        SetVar v2 = VF.set("v2", 0, 3, solver);
        solver.post(SCF.subsetEq(new SetVar[]{v1, v2}));
        solver.set(SetStrategyFactory.force_first(new SetVar[]{v1, v2}));
        if (solver.findSolution()) {
            do {
//                System.out.println(v1 + " subseteq " + v2);
            } while (solver.nextSolution());
        }
        Assert.assertEquals(solver.getMeasures().getSolutionCount(), 4);
View Full Code Here

        Solver solver = new Solver();
        solver.post(ICF.arithm(
                VF.enumerated("int", -3, 3, solver),
                "=",
                VF.minus(VF.bool("bool", solver))));
        if (solver.findSolution()) {
            do {
//        System.out.println(solver);
            } while (solver.nextSolution());
        }
        Assert.assertEquals(solver.getMeasures().getSolutionCount(), 2);
View Full Code Here

                a,
                LogicalConstraintFactory.ifThen(
                        b,
                        IntConstraintFactory.arithm(c, "=", 1))));
        solver.set(IntStrategyFactory.minDom_LB(new BoolVar[]{a, b, c}));
        if (solver.findSolution()) {
            int index = 0;
            do {
                index++;
//                System.out.println(index + " : a=" + a.getValue() + ", b=" + b.getValue() + ",c= " + c.getValue());
            }
View Full Code Here

                                return ESat.FALSE;
                        }

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

        solver.getSearchLoop().reset();
        solver.getSearchLoop().plugSearchMonitor(new IMonitorSolution() {
            @Override
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.