Package solver

Examples of solver.Solver


    BoolVar[][] M;

    @Override
    public void createSolver() {
        solver = new Solver();
    }
View Full Code Here


    Constraint[] counts;

    @Override
    public void createSolver() {
        solver = new Solver("Magic series");
    }
View Full Code Here

  // METHODS
  //***********************************************************************************

  @Override
  public void createSolver() {
    solver = new Solver("bin packing sample");
  }
View Full Code Here

    solver.post(ICF.table(vars,tuples,"STR2+"));
  }

  @Override
  public void createSolver(){
    solver = new Solver("Table sample");
  }
View Full Code Here

        return o;
    }

    @Test(groups = {"1s"})
    public void testEmptySolver() {
        Solver solver = new Solver();
        File file = null;
        try {
            file = write(solver);
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

        Assert.assertNotNull(solver);
    }

    @Test(groups = {"1s"})
    public void testEngine1() {
        IPropagationEngine eng = new TwoBucketPropagationEngine(new Solver());
        File file = null;
        try {
            file = write(eng);
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

        Assert.assertNotNull(eng);
    }

    @Test(groups = {"1s"})
    public void testEngine2() {
        IPropagationEngine eng = new SevenQueuesPropagatorEngine(new Solver());
        File file = null;
        try {
            file = write(eng);
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

        Assert.assertNotNull(eng);
    }

    @Test(groups = {"1s"})
    public void testIntegerVariable() {
        Solver s = new Solver();
        IntVar var = VariableFactory.enumerated("v", 1, 10, s);
        File file = null;
        try {
            file = write(var);
        } catch (IOException e) {
View Full Code Here

        Assert.assertNotNull(var);
    }

    @Test(groups = {"1s"})
    public void testConstraint() {
        Solver s = new Solver();
        IntVar var = VariableFactory.enumerated("v", 1, 10, s);
        Constraint c = IntConstraintFactory.arithm(var, "=", 0);
        File file = null;
        try {
            file = write(c);
View Full Code Here

        Assert.assertNotNull(c);
    }

    @Test(groups = {"1s"})
    public void testNQueen() {
        Solver s = new Solver();
        int n = 8;
        IntVar[] vars = new IntVar[n];
        for (int i = 0; i < vars.length; i++) {
            vars[i] = VariableFactory.enumerated("Q_" + i, 1, n, s);
        }


        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int k = j - i;
                Constraint neq = IntConstraintFactory.arithm(vars[i], "!=", vars[j]);
                s.post(neq);
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }


        File file = null;
        try {
            file = write(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
        s = null;
        try {
            s = (Solver) read(file);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        Assert.assertNotNull(s);
        s.findAllSolutions();
        Assert.assertEquals(s.getMeasures().getSolutionCount(), 92, "nb sol incorrect");
    }
View Full Code Here

TOP

Related Classes of solver.Solver

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.