Package solver

Examples of solver.Solver.post()


        Solver s = propagators[0].getSolver();
        if (boolReif == null) {
            boolReif = bool;
            s.post(new ReificationConstraint(boolReif, this, getOpposite()));
        } else {
            s.post(ICF.arithm(bool, "=", boolReif));
        }
    }

    /**
     * Get/make the boolean variable indicating whether the constraint is satisfied or not
View Full Code Here


     */
    public final BoolVar reif() {
        if (boolReif == null) {
            Solver s = propagators[0].getSolver();
            boolReif = VF.bool(StringUtils.randomName(), s);
            s.post(new ReificationConstraint(boolReif, this, getOpposite()));
        }
        return boolReif;
    }

    /**
 
View Full Code Here

    //une variable par case avec pour domaine la reine qui l attaque. (les reines sont ainsi designees par les valeurs, et les cases par les variables)
    for (int i = 0; i < X.length; i++) {
      X[i] = VariableFactory.enumerated("Q" + i, 1, n*n, pb);
    }
    IntVar N = VariableFactory.fixed(val,pb);
    pb.post(IntConstraintFactory.nvalues(X,N));
    //i appartient a la variable j ssi la case i est sur une ligne/colonne/diagonale de j
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        //pour chaque case
        for (int k = 1; k <= n; k++) {
View Full Code Here

      for (int j = 1; j <= n; j++) {
        //pour chaque case
        for (int k = 1; k <= n; k++) {
          for (int l = 1; l <= n; l++) {
            if (!(k == i || l == j || Math.abs(i - k) == Math.abs(j - l))) {
              pb.post(IntConstraintFactory.arithm(X[n * (i - 1) + j - 1], "!=", (k - 1) * n + l));
            }
          }
        }
      }
    }
View Full Code Here

    // continuous views of FD variables
    RealVar[] realViews = VariableFactory.real(kid_price, precision);

    // kids must have different gifts
        solver.post(IntConstraintFactory.alldifferent(kid_gift, "AC"));
    // associate each kid with his gift cost
        for (int i = 0; i < n_kids; i++) {
            solver.post(IntConstraintFactory.element(kid_price[i], gift_price, kid_gift[i]));
        }
    // compute total cost
View Full Code Here

    // kids must have different gifts
        solver.post(IntConstraintFactory.alldifferent(kid_gift, "AC"));
    // associate each kid with his gift cost
        for (int i = 0; i < n_kids; i++) {
            solver.post(IntConstraintFactory.element(kid_price[i], gift_price, kid_gift[i]));
        }
    // compute total cost
        solver.post(IntConstraintFactory.sum(kid_price, total_cost));

    // compute average cost (i.e. average gift cost per kid)
View Full Code Here

    // associate each kid with his gift cost
        for (int i = 0; i < n_kids; i++) {
            solver.post(IntConstraintFactory.element(kid_price[i], gift_price, kid_gift[i]));
        }
    // compute total cost
        solver.post(IntConstraintFactory.sum(kid_price, total_cost));

    // compute average cost (i.e. average gift cost per kid)
    RealVar[] allRV = ArrayUtils.append(realViews,new RealVar[]{average,average_deviation});
    solver.post(new RealConstraint(
        "Avg/AvgDev",
View Full Code Here

    // compute total cost
        solver.post(IntConstraintFactory.sum(kid_price, total_cost));

    // compute average cost (i.e. average gift cost per kid)
    RealVar[] allRV = ArrayUtils.append(realViews,new RealVar[]{average,average_deviation});
    solver.post(new RealConstraint(
        "Avg/AvgDev",
        "({0}+{1}+{2})/3={3};(abs({0}-{3})+abs({1}-{3})+abs({2}-{3}))/3={4}",
        allRV)
    );
View Full Code Here

            return makeScalar(VARS, COEFFS, SCALAR, 1);
        }
        int[] b = Scalar.getScalarBounds(VARS, COEFFS);
        Solver s = VARS[0].getSolver();
        IntVar p = VF.bounded(StringUtils.randomName(), b[0], b[1], s);
        s.post(makeScalar(VARS, COEFFS, p, 1));
        return arithm(p, OPERATOR, SCALAR);
    }

    private static Constraint makeScalar(IntVar[] VARS, int[] COEFFS, IntVar SCALAR, int SCALAR_COEF) {
        int maxDomSize = SCALAR.getDomainSize();
View Full Code Here

            return b;
        } else {
            Solver solver = a.getSolver();
            IntVar z = new IntervalIntVarImpl(StringUtils.randomName(),
                    Math.max(a.getLB(), b.getLB()), Math.max(a.getUB(), b.getUB()), solver);
            solver.post(IntConstraintFactory.maximum(z, a, b));
            return z;
        }
    }
}
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.