Package solver.constraints

Examples of solver.constraints.Constraint


    @Test(groups = "1s")
    public void test22() {
        Solver solver = new Solver("Choco");
        IntVar v = VF.enumerated("v", 1, 4, solver);
        IntVar x = VF.enumerated("v", 0, 3, solver);
        solver.post(new Constraint("times", new PropScale(v, 3, x)));

        Solver copy = solver.duplicateModel();

        solver.findAllSolutions();
        copy.findAllSolutions();
View Full Code Here


    @Test(groups = "1s")
    public void test23() {
        Solver solver = new Solver("Choco");
        IntVar v = VF.enumerated("v", 1, 4, solver);
        IntVar x = VF.enumerated("v", 0, 3, solver);
        solver.post(new Constraint("times", new PropScale(v, 3, x)));

        Solver copy = solver.duplicateModel();

        solver.findAllSolutions();
        copy.findAllSolutions();
View Full Code Here

                vars[i] = VariableFactory.bounded("x_" + i, domains[i][0], domains[i][1], s);
            } else {
                vars[i] = VariableFactory.enumerated("x_" + i, domains[i], s);
            }
        }
        Constraint div = make(vars, s);
        s.post(div);
    if(bounded){
      s.set(IntStrategyFactory.random_bound(vars, seed));
    }else{
      s.set(IntStrategyFactory.random_value(vars, seed));
View Full Code Here

                vars[i] = VariableFactory.bounded("x_" + i, domains[i][0], domains[i][1], s);
            } else {
                vars[i] = VariableFactory.enumerated("x_" + i, domains[i], s);
            }
        }
        Constraint div = make(vars, s);
        s.post(div);
    if(bounded){
      s.set(IntStrategyFactory.random_bound(vars, seed));
    }else{
      s.set(IntStrategyFactory.random_value(vars, seed));
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));
            }
        }
View Full Code Here

        Y[1] = VF.bounded("Y2", 6, 7, solver);
        Y[2] = VF.bounded("Y3", 8, 11, solver);
        Y[3] = VF.bounded("Y4", 13, 16, solver);
        Y[4] = VF.bounded("Y5", 14, 18, solver);

        solver.post(new Constraint("sort", new PropSort(X, Y)));
        /*if (solver.findSolution()) {
            do {
                System.out.printf("Solution:\n");
                for (IntVar x : X) {
                    System.out.printf("%d ", x.getValue());
View Full Code Here

        // the global product itemCost[0]*itemCost[1]*itemCost[2]*itemCost[3] (equal to tmp[0]*tmp[1])
        // is too large to be used within integer ranges. Thus, we will set up a dedicated constraint
        // which uses a long to handle such a product

        solver.post(new Constraint("LargeProduct",new PropLargeProduct(tmp, 711000000)));

        // symmetry breaking
        solver.post(IntConstraintFactory.arithm(itemCost[0], "<=", itemCost[1]));
        solver.post(IntConstraintFactory.arithm(itemCost[1], "<=", itemCost[2]));
        solver.post(IntConstraintFactory.arithm(itemCost[2], "<=", itemCost[3]));
View Full Code Here

                for (int q = p; q <= u; q++) {
                    BoolVar a = VariableFactory.bool("A" + j + "_" + p + "_" + q, solver);
                    mA[j][p - l][q - p] = a;
                    listA.add(a);

                    Constraint cA = IntConstraintFactory.member(X[j], p, q);
                    Constraint ocA = IntConstraintFactory.not_member(X[j], p, q);

                    solver.post(LogicalConstraintFactory.ifThenElse(a, cA, ocA));
                }
            }
        }
View Full Code Here

TOP

Related Classes of solver.constraints.Constraint

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.