Package solver

Examples of solver.Solver.post()


        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]);
                solver.post(neq);
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }
        return solver;
View Full Code Here


        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]);
                solver.post(neq);
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }
        return solver;
    }
View Full Code Here

        IntVar[] vars = new IntVar[n];
        for (int i = 0; i < vars.length; i++) {
            vars[i] = VariableFactory.enumerated("v_" + i, 0, n, s);
        }
        s.post(IntConstraintFactory.arithm(vars[0], "!=", vars[1]));

        s.set(IntStrategyFactory.lexico_LB(vars));
        s.findAllSolutions();
        long sol = s.getMeasures().getSolutionCount();
        Assert.assertEquals(sol, 6, "nb sol incorrect");
View Full Code Here

            for (int j = i + 1; j < n; j++) {
                int k = j - i;
                Constraint neq = IntConstraintFactory.arithm(vars[i], "!=", vars[j]);
                solver.post(neq);
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                solver.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }
        return solver;
    }
View Full Code Here

        float tref = sref.getMeasures().getTimeCount();

        int n1 = n / 2;

        Solver sm1 = modeler(n);
        sm1.post(IntConstraintFactory.arithm((IntVar) sm1.getVars()[0], "<=", n1));

        Solver sm2 = modeler(n);
        sm2.post(IntConstraintFactory.arithm((IntVar) sm2.getVars()[0], ">=", n1 + 1));

        ThreadSolver ts1 = new ThreadSolver(sm1);
View Full Code Here

        IntVar[] vars = new IntVar[n];
        for (int i = 0; i < vars.length; i++) {
            vars[i] = VariableFactory.bounded("v_" + i, 0, n, s);
        }
        s.post(IntConstraintFactory.arithm(vars[0], "!=", vars[1]));
        s.set(IntStrategyFactory.lexico_LB(vars));
//        ChocoLogging.toSolution();
        s.findAllSolutions();
        long sol = s.getMeasures().getSolutionCount();
        Assert.assertEquals(sol, 6, "nb sol incorrect");
View Full Code Here

        Solver sm1 = modeler(n);
        sm1.post(IntConstraintFactory.arithm((IntVar) sm1.getVars()[0], "<=", n1));

        Solver sm2 = modeler(n);
        sm2.post(IntConstraintFactory.arithm((IntVar) sm2.getVars()[0], ">=", n1 + 1));

        ThreadSolver ts1 = new ThreadSolver(sm1);
        ThreadSolver ts2 = new ThreadSolver(sm2);
//
View Full Code Here

        IntVar[] vars = new IntVar[n];
        for (int i = 0; i < vars.length; i++) {
            vars[i] = VariableFactory.bounded("v_" + i, 0, n, s);
        }
        s.post(IntConstraintFactory.arithm(vars[0], "!=", vars[1]));
        s.set(IntStrategyFactory.lexico_LB(vars));

        try {
            s.propagate();
            vars[0].instantiateTo(1, Cause.Null);
View Full Code Here

        Constraint[] cstrs = new Constraint[]{
                IntConstraintFactory.scalar(vars, coeffs, sum),
                IntConstraintFactory.arithm(sum, operatorToString(operator), constant)
        };

        s.post(cstrs);
        s.set(IntStrategyFactory.lexico_LB(vars));

        s.findAllSolutions();
    }
View Full Code Here

        IntVar sum = VariableFactory.bounded("scal", -99999999, 99999999, solver);
        Constraint[] cstrs = new Constraint[]{
                IntConstraintFactory.scalar(bins, coeffs, sum),
                IntConstraintFactory.arithm(sum, opname, b)
        };
        solver.post(cstrs);
        solver.set(IntStrategyFactory.lexico_LB(bins));
        return solver;
    }

    protected Solver intlincomb(int[][] domains, int[] coeffs, int b, int op) {
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.