|
||||||||||
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.getObjectiveValue()); optproblem.discardCurrentSolution(); } 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. |
boolean |
admitABetterSolution(IVecInt assumps)
Look for a solution of the optimization problem when some literals are satisfied. |
Number |
calculateObjective()
Deprecated. |
void |
discard()
Deprecated. |
void |
discardCurrentSolution()
Discard the current solution in the optimization problem. |
void |
forceObjectiveValueTo(Number forcedValue)
Force the value of the objective function. |
Number |
getObjectiveValue()
Read only access to the value of the objective function for the current solution. |
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 admitABetterSolution(IVecInt assumps) throws TimeoutException
assumps
- a set of literals in Dimacs format.
TimeoutException
- if the solver cannot answer in reasonable time.ISolver.setTimeout(int)
boolean hasNoObjectiveFunction()
boolean nonOptimalMeansSatisfiable()
@Deprecated Number calculateObjective()
getObjectiveValue()
Number getObjectiveValue()
void forceObjectiveValueTo(Number forcedValue) throws ContradictionException
ContradictionException
@Deprecated void discard() throws ContradictionException
ContradictionException
- if a trivial inconsistency is detected.discardCurrentSolution()
void discardCurrentSolution() 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 |