Package solver.constraints

Examples of solver.constraints.Operator


     * Generate valid tuples for VAR1 OP VAR2, where OP in {"=", "!=", ">","<",">=","<="}
     *
     * @return a Tuples object, reserved for a table constraint
     */
    public static Tuples arithm(IntVar VAR1, String OP, IntVar VAR2) {
        final Operator op = Operator.get(OP);
        return generateTuples(new TupleValidator() {
            @Override
            public boolean valid(int... values) {
                switch (op) {
                    case LT:
View Full Code Here


   */
  public static Tuples scalar(IntVar[] VARS, final int[] COEFFS, final String OPERATOR, IntVar SCALAR, final int SCALAR_COEFF) {
    if(OPERATOR.equals("=")){
      return scalar(VARS,COEFFS,SCALAR,SCALAR_COEFF);
    }
    final Operator op = Operator.get(OPERATOR);
        return generateTuples(new TupleValidator() {
            @Override
            public boolean valid(int... values) {
                int scalar = 0;
                for (int i = 0; i < values.length - 1; i++) {
View Full Code Here

     *
     * @param VARS concerned variables
     * @return a Tuples object, reserved for a table constraint
     */
    public static Tuples sum(IntVar[] VARS, final String OPERATOR, IntVar SUM) {
        final Operator op = Operator.get(OPERATOR);
        return generateTuples(new TupleValidator() {
            @Override
            public boolean valid(int... values) {
                int sum = 0;
                for (int i = 0; i < values.length - 1; i++) {
View Full Code Here

        Solution solution = new Solution();
        solution.record(solver);
        solutions.add(solution);
        // aim at better solutions
        Constraint[] better = new Constraint[n];
        Operator symbol = Operator.GT;
        if(policy==ResolutionPolicy.MINIMIZE){
                    symbol = Operator.LT;
        }
        for(int i=0;i<n;i++){
          better[i] = ICF.arithm(objectives[i],symbol.toString(),vals[i]);
        }
        solver.post(LCF.or(better));
      }
    };
  }
View Full Code Here

TOP

Related Classes of solver.constraints.Operator

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.