Package solver.exception

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


     * @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

     * @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

     * @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

                    }
                }

                @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

        return var.hasNot();
    }

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

        return ESat.UNDEFINED;
    }

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

        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

                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

        matcher = Sp.matcher(duration);
        if (matcher.find() && matcher.groupCount() == 2) {
            double seconds = Double.parseDouble(matcher.group(1));
            milliseconds += (int) (seconds * 1000);
        }
        if (milliseconds == 0) throw new SolverException("Duration cannot be parsed or must be positive" + duration);
        return milliseconds;
    }
View Full Code Here

TOP

Related Classes of solver.exception.SolverException

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.