Package solver.constraints

Examples of solver.constraints.Constraint


        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                BoolVar boolVar = VariableFactory.bool("b_" + i + "_" + j, solver);
                booleans.add(boolVar);

                Constraint c1 = precedence(planes[i], data[i][ST + j], planes[j]);
                Constraint c2 = precedence(planes[j], data[j][ST + i], planes[i]);
                Constraint cr = LogicalConstraintFactory.ifThenElse(boolVar, c1, c2);
                solver.post(cr);
            }
        }

        bVars = booleans.toArray(new BoolVar[booleans.size()]);
View Full Code Here


            }
            for (int l = 0; l < _vars.length - 1; l++) {
                for (int m = l + 1; m < _vars.length; m++) {
                    BoolVar bvar = VariableFactory.bool("b" + l + "_" + m, solver);
                    lbvars.add(bvar);
                    Constraint c1 = LogicalConstraintFactory.ifThenElse(bvar, precedence(_vars[l], _durs[l], _vars[m]), precedence(_vars[m], _durs[m], _vars[l]));
                    solver.post(c1);
                }
            }
        }
        bvars = lbvars.toArray(new BoolVar[lbvars.size()]);
View Full Code Here

  @Override
  public void buildModel() {
    x = VF.enumerated("x", 0, 3, solver);
    y = VF.enumerated("y",0,3,solver);
    z = VF.enumerated("z",0,3,solver);
    Constraint imp = LCF.and(
        ICF.arithm(x, ">", y),
        ICF.arithm(y, ">", z),
        ICF.arithm(z, ">", x)
    );
    Constraint ad = ICF.alldifferent(new IntVar[]{x, y, z}, "DEFAULT");
    Constraint nad = LCF.not(ad);
    solver.post(LCF.or(imp, nad));
  }
View Full Code Here

    @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);
        } catch (IOException e) {
            e.printStackTrace();
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]);
                s.post(neq);
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }
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]);
                s.post(neq);
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", -k));
                s.post(IntConstraintFactory.arithm(vars[i], "!=", vars[j], "+", k));
            }
        }
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


        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

            int[][] values = DomainBuilder.buildFullDomains(2, 0, 15, r, d, false);
            IntVar x = VariableFactory.enumerated("x", values[0], s);
            IntVar y = VariableFactory.enumerated("y", values[1], s);
            IntVar[] vars = new IntVar[]{b, x, y};

            Constraint cons = IntConstraintFactory.arithm(x, "=", y);
            Constraint oppCons = IntConstraintFactory.arithm(x, "!=", y);

            s.post(LogicalConstraintFactory.ifThenElse(b, cons, oppCons));
            s.set(IntStrategyFactory.lexico_LB(vars));
            s.findAllSolutions();
            long sol = s.getMeasures().getSolutionCount();
View Full Code Here

            int[][] values = DomainBuilder.buildFullDomains(2, 0, 15, r, d, false);
            IntVar x = VariableFactory.enumerated("x", values[0], s);
            IntVar y = VariableFactory.enumerated("y", values[1], s);
            IntVar[] vars = new IntVar[]{b, x, y};

            Constraint cons = IntConstraintFactory.arithm(x, "!=", y);
            Constraint oppCons = IntConstraintFactory.arithm(x, "=", y);

            Constraint cstr = LogicalConstraintFactory.ifThenElse(b, cons, oppCons);

            s.post(cstr);
            s.set(IntStrategyFactory.lexico_LB(vars));
            s.findAllSolutions();
            long sol = s.getMeasures().getSolutionCount();
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.