Examples of Solver


Examples of solver.Solver

            return VAR;
        }
        if (Configuration.ENABLE_VIEWS) {
            return new OffsetView(VAR, CSTE, VAR.getSolver());
        } else {
            Solver s = VAR.getSolver();
            int lb = VAR.getLB() + CSTE;
            int ub = VAR.getUB() + CSTE;
            String name = "(" + VAR.getName() + "+" + CSTE + ")";
            IntVar ov;
            if (VAR.hasEnumeratedDomain()) {
                ov = enumerated(name, lb, ub, s);
            } else {
                ov = bounded(name, lb, ub, s);
            }
            s.post(ICF.arithm(ov, "-", VAR, "=", CSTE));
            return ov;
        }
    }
View Full Code Here

Examples of solver.Solver

  IntVar[] starts, ends;
  IntVar maxEnd;

  @Override
  public void createSolver(){
    solver = new Solver("schedule");
  }
View Full Code Here

Examples of solver.Solver

            return new BoolNotView(BOOL, BOOL.getSolver());
        } else {
            if (BOOL.hasNot()) {
                return BOOL.not();
            } else {
                Solver s = BOOL.getSolver();
                BoolVar ov = bool("not(" + BOOL.getName() + ")", s);
                s.post(ICF.arithm(ov, "!=", BOOL));
                BOOL._setNot(ov);
                ov._setNot(BOOL);
                ov.setNot(true);
                return ov;
            }
View Full Code Here

Examples of solver.Solver

   * Make an or constraint
   * @param BOOLS an array of boolean variable
   * @return a constraint or ensuring that at least one variables in BOOLS is set to true
   */
  public static Constraint or(BoolVar... BOOLS){
    Solver s = BOOLS[0].getSolver();
    IntVar sum = VariableFactory.bounded(StringUtils.randomName(),0,BOOLS.length,s);
    s.post(IntConstraintFactory.sum(BOOLS,sum));
    return IntConstraintFactory.arithm(sum,">=",1);
  }
View Full Code Here

Examples of solver.Solver

     */
    public static IntVar minus(IntVar VAR) {
        if (Configuration.ENABLE_VIEWS) {
            return new MinusView(VAR, VAR.getSolver());
        } else {
            Solver s = VAR.getSolver();
            int ub = -VAR.getLB();
            int lb = -VAR.getUB();
            String name = "-(" + VAR.getName() + ")";
            IntVar ov;
            if (VAR.hasEnumeratedDomain()) {
                ov = enumerated(name, lb, ub, s);
            } else {
                ov = bounded(name, lb, ub, s);
            }
            s.post(ICF.arithm(ov, "+", VAR, "=", 0));
            return ov;
        }
    }
View Full Code Here

Examples of solver.Solver

                var = VAR;
            } else {
                if (Configuration.ENABLE_VIEWS) {
                    var = new ScaleView(VAR, CSTE, VAR.getSolver());
                } else {
                    Solver s = VAR.getSolver();
                    int lb = VAR.getLB() * CSTE;
                    int ub = VAR.getUB() * CSTE;
                    String name = "(" + VAR.getName() + "*" + CSTE + ")";
                    IntVar ov;
                    if (VAR.hasEnumeratedDomain()) {
                        ov = enumerated(name, lb, ub, s);
                    } else {
                        ov = bounded(name, lb, ub, s);
                    }
                    s.post(ICF.times(VAR, CSTE, ov));
                    return ov;
                }
            }
            return var;
        }
View Full Code Here

Examples of solver.Solver

        } else if (VAR.getLB() >= 0) {
            return VAR;
        } else if (VAR.getUB() <= 0) {
            return minus(VAR);
        } else {
            Solver s = VAR.getSolver();
            int ub = Math.max(-VAR.getLB(), VAR.getUB());
            String name = "|" + VAR.getName() + "|";
            IntVar abs;
            if (VAR.hasEnumeratedDomain()) {
                abs = enumerated(name, 0, ub, s);
            } else {
                abs = bounded(name, 0, ub, s);
            }
            s.post(IntConstraintFactory.absolute(abs, VAR));
            return abs;
        }
    }
View Full Code Here

Examples of solver.Solver

    IntVar[] vars;
    Constraint[] cstrs;

    @Override
    public void createSolver() {
        solver = new Solver("Ordering " + n);
    }
View Full Code Here

Examples of solver.Solver

     */
    public static RealVar real(IntVar VAR, double PRECISION) {
        if (Configuration.ENABLE_VIEWS) {
            return new RealView(VAR, PRECISION);
        } else {
            Solver s = VAR.getSolver();
            double lb = VAR.getLB();
            double ub = VAR.getUB();
            RealVar rv = real("(real)" + VAR.getName(), lb, ub, PRECISION, s);
            s.post(new IntEqRealConstraint(VAR, rv, PRECISION));
            return rv;
        }
    }
View Full Code Here

Examples of solver.Solver

        if (Configuration.ENABLE_VIEWS) {
            for (int i = 0; i < VARS.length; i++) {
                reals[i] = real(VARS[i], PRECISION);
            }
        } else {
            Solver s = VARS[0].getSolver();
            for (int i = 0; i < VARS.length; i++) {
                double lb = VARS[i].getLB();
                double ub = VARS[i].getUB();
                reals[i] = real("(real)" + VARS[i].getName(), lb, ub, PRECISION, s);
            }
            s.post(new IntEqRealConstraint(VARS, reals, PRECISION));
        }
        return reals;
    }
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.