Examples of SolverException


Examples of solver.exception.SolverException

     * @param policy     optimization policy, among ResolutionPolicy.MINIMIZE and ResolutionPolicy.MAXIMIZE
     * @param objectives the variables to optimize. BEWARE they should all respect the SAME optimization policy
     */
    public void findParetoFront(ResolutionPolicy policy, IntVar... objectives) {
        if (policy == ResolutionPolicy.SATISFACTION) {
            throw new SolverException("Solver.findParetoFront(...) cannot be called with ResolutionPolicy.SATISFACTION.");
        }
        if (objectives == null || objectives.length == 0) {
            throw new SolverException("No objective variable has been defined");
        }
        if (objectives.length == 1) {
            throw new SolverException("Only one objective variable has been defined. Pareto is relevant with >1 objective");
        }
        // BEWARE the usual optimization manager is only defined for mono-objective optimization
        // so we use a satisfaction manager by default (it does nothing)
        if (getObjectiveManager().isOptimization()) {
            set(new ObjectiveManager<IntVar, Integer>(null, ResolutionPolicy.SATISFACTION, false));
View Full Code Here

Examples of solver.exception.SolverException

     * @param policy    optimization policy, among ResolutionPolicy.MINIMIZE and ResolutionPolicy.MAXIMIZE
     * @param objective the variable to optimize
     */
    public void findOptimalSolution(ResolutionPolicy policy, RealVar objective, double precision) {
        if (policy == ResolutionPolicy.SATISFACTION) {
            throw new SolverException("Solver.findOptimalSolution(...) can not be called with ResolutionPolicy.SATISFACTION.");
        }
        if (objective == null) {
            throw new SolverException("No objective variable has been defined");
        }
        if (!getObjectiveManager().isOptimization()) {
            set(new ObjectiveManager<RealVar, Double>(objective, policy, precision, true));
        }
        set(new LastSolutionRecorder(new Solution(), true, this));
View Full Code Here

Examples of solver.exception.SolverException

     * @return a copy of <code>this</code>
     * @throws solver.exception.SolverException if the search has already begun.
     */
    public Solver duplicateModel() {
        if (environment.getWorldIndex() > 0) {
            throw new SolverException("Duplicating a solver cannot be achieved once the resolution has begun.");
        }
        // Create a fresh solver
        Solver clone;
        try {
            clone = new Solver(this.environment.getClass().newInstance(), this.name);
        } catch (InstantiationException | IllegalAccessException e) {
            throw new SolverException("The current solver cannot be duplicated:\n" + e.getMessage());
        }

        THashMap<Object, Object> identitymap = new THashMap<>();
        // duplicate variables
        for (int i = 0; i < this.vIdx; i++) {
View Full Code Here

Examples of solver.exception.SolverException

     * @param MIN  lower bound of the domain
     * @param MAX  upper bound of the domain
     */
    private static void checkIntVar(String NAME, int MIN, int MAX) {
        if (MIN - Integer.MIN_VALUE == 0 || MAX - Integer.MAX_VALUE == 0) {
            throw new SolverException(NAME + ": consider reducing the bounds to avoid unexpected results");
        }
        if (MAX < MIN) {
            throw new SolverException(NAME + ": wrong domain definition, lower bound > upper bound");
        }
    }
View Full Code Here

Examples of solver.exception.SolverException

     * @param MIN  lower bound of the domain
     * @param MAX  upper bound of the domain
     */
    private static void checkRealVar(String NAME, double MIN, double MAX) {
        if (MAX < MIN) {
            throw new SolverException(NAME + ": wrong domain definition, lower bound > upper bound");
        }
    }
View Full Code Here

Examples of solver.exception.SolverException

                    }
                }

                @Override
                public void explain(Deduction d, Explanation e) {
                    throw new SolverException("A task cannot explain itself yet.");
                }

            };
        } else {
            update = new IVariableMonitor() {
                @Override
                public void onUpdate(Variable var, IEventType evt) throws ContradictionException {
                    // start
                    start.updateLowerBound(end.getLB() - duration.getUB(), this);
                    start.updateUpperBound(end.getUB() - duration.getLB(), this);
                    // end
                    end.updateLowerBound(start.getLB() + duration.getLB(), this);
                    end.updateUpperBound(start.getUB() + duration.getUB(), this);
                    // duration
                    duration.updateLowerBound(end.getLB() - start.getUB(), this);
                    duration.updateUpperBound(end.getUB() - start.getLB(), this);
                }

                @Override
                public void explain(Deduction d, Explanation e) {
                    throw new SolverException("A task cannot explain itself yet.");
                }

            };
        }
        start.addMonitor(update);
View Full Code Here

Examples of solver.exception.SolverException

        return var.hasNot();
    }

    @Override
    public void _setNot(BoolVar not) {
        throw new SolverException("Unexpected call to BoolEqView._setNot()");
    }
View Full Code Here

Examples of solver.exception.SolverException

        return ESat.UNDEFINED;
    }

    @Override
    public void duplicate(Solver solver, THashMap identitymap) {
        throw new SolverException("PropOpposite cannot be duplicated!");
    }
View Full Code Here

Examples of solver.exception.SolverException

        return bVar.toString() + "=>" + trueCons.toString() + ", !" + bVar.toString() + "=>" + falseCons.toString();
    }

    @Override
    public void duplicate(Solver solver, THashMap<Object, Object> identitymap) {
        throw new SolverException("PropReif cannot be duplicated!");
    }
View Full Code Here

Examples of solver.exception.SolverException

                p = new PropLargeGAC2001(VARS, TUPLES);
                break;
            default:
            case "GACSTR+":
                if (!TUPLES.isFeasible()) {
                    throw new SolverException("GACSTR+ cannot be used with forbidden tuples.");
                }
                p = new PropLargeGACSTRPos(VARS, TUPLES);
                break;
            case "GAC2001+":
                if (!TUPLES.isFeasible()) {
                    throw new SolverException("GAC2001+ cannot be used with forbidden tuples.");
                }
                p = new PropLargeGAC2001Positive(VARS, TUPLES);
                break;
            case "GAC3rm+":
                if (!TUPLES.isFeasible()) {
                    throw new SolverException("GAC3rm+ cannot be used with forbidden tuples.");
                }
                p = new PropLargeGAC3rmPositive(VARS, TUPLES);
                break;
            case "STR2+":
                if (!TUPLES.isFeasible()) {
                    throw new SolverException("STR2+ cannot be used with forbidden tuples.");
                }
                p = new PropTableStr2(VARS, TUPLES.toMatrix());
        }
        return new Constraint("Table(" + ALGORITHM + ")", p);
    }
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.