|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IOptimizationProblem
Represents an optimization problem. The SAT solver will find suboptimal solutions of the problem until no more solutions are available. The latest solution found will be the optimal one. Such kind of problem is supposed to be handled:
boolean isSatisfiable = false; IOptimizationProblem optproblem = (IOptimizationProblem) problem; try { while (optproblem.admitABetterSolution()) { if (!isSatisfiable) { if (optproblem.nonOptimalMeansSatisfiable()) { setExitCode(ExitCode.SATISFIABLE); if (optproblem.hasNoObjectiveFunction()) { return; } log("SATISFIABLE"); //$NON-NLS-1$ } isSatisfiable = true; log("OPTIMIZING..."); //$NON-NLS-1$ } log("Got one! Elapsed wall clock time (in seconds):" //$NON-NLS-1$ + (System.currentTimeMillis() - getBeginTime()) / 1000.0); getLogWriter().println( CURRENT_OPTIMUM_VALUE_PREFIX + optproblem.calculateObjective()); optproblem.discard(); } if (isSatisfiable) { setExitCode(ExitCode.OPTIMUM_FOUND); } else { setExitCode(ExitCode.UNSATISFIABLE); } } catch (ContradictionException ex) { assert isSatisfiable; setExitCode(ExitCode.OPTIMUM_FOUND); }
Method Summary | |
---|---|
boolean |
admitABetterSolution()
Look for a solution of the optimization problem. |
java.lang.Number |
calculateObjective()
Compute the value of the objective function for the current solution. |
void |
discard()
Discard the current solution in the optimization problem. |
boolean |
hasNoObjectiveFunction()
If the optimization problem has no objective function, then it is a simple decision problem. |
boolean |
nonOptimalMeansSatisfiable()
A suboptimal solution has different meaning depending of the optimization problem considered. |
Methods inherited from interface org.sat4j.specs.IProblem |
---|
findModel, findModel, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, model, model, nConstraints, nVars, printInfos |
Method Detail |
---|
boolean admitABetterSolution() throws TimeoutException
TimeoutException
- if the solver cannot answer in reasonable time.ISolver.setTimeout(int)
boolean hasNoObjectiveFunction()
boolean nonOptimalMeansSatisfiable()
java.lang.Number calculateObjective()
void discard() throws ContradictionException
ContradictionException
- if a trivial inconsistency is detected.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |