public class LexicoDecorator<T extends ISolver> extends SolverDecorator<T> implements IOptimizationProblem
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<IVecInt> |
criteria |
protected int |
currentCriterion |
protected boolean |
isSolutionOptimal |
protected boolean[] |
prevboolmodel |
protected IConstr |
prevConstr |
protected int[] |
prevfullmodel |
protected int[] |
prevmodelwithinternalvars |
| Constructor and Description |
|---|
LexicoDecorator(T solver) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCriterion(IVecInt literals) |
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.
|
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.
|
void |
discardCurrentSolution()
Discard the current solution in the optimization problem.
|
protected IConstr |
discardSolutionsForOptimizing() |
protected java.lang.Number |
evaluate() |
protected java.lang.Number |
evaluate(int criterion) |
protected void |
fixCriterionValue() |
void |
forceObjectiveValueTo(java.lang.Number forcedValue)
Force the value of the objective function.
|
java.lang.Number |
getObjectiveValue()
Read only access to the value of the objective function for the current
solution.
|
java.lang.Number |
getObjectiveValue(int criterion) |
boolean |
hasNoObjectiveFunction()
If the optimization problem has no objective function, then it is a
simple decision problem.
|
boolean |
isOptimal()
Allows to check afterwards if the solution provided by the solver is
optimal or not.
|
protected boolean |
manageUnsatCase() |
int[] |
model()
Provide a model (if any) for a satisfiable formula.
|
boolean |
model(int var)
Provide the truth value of a specific variable in the model.
|
int[] |
modelWithInternalVariables()
That method is designed to be used to retrieve the real model of the
current set of constraints, i.e.
|
boolean |
nonOptimalMeansSatisfiable()
A suboptimal solution has different meaning depending of the optimization
problem considered.
|
int |
numberOfCriteria() |
void |
setTimeoutForFindingBetterSolution(int seconds)
Allow to set a specific timeout when the solver is in optimization mode.
|
addAllClauses, addAtLeast, addAtMost, addBlockingClause, addClause, addExactly, clearDecorated, clearLearntClauses, decorated, expireTimeout, findModel, findModel, getLogPrefix, getSearchListener, getSolvingEngine, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, isSolverKeptHot, isVerbose, nConstraints, newVar, newVar, nextFreeVarId, nVars, primeImplicant, primeImplicant, printInfos, printInfos, printStat, printStat, printStat, realNumberOfVariables, registerLiteral, removeConstr, removeSubsumedConstr, reset, setDBSimplificationAllowed, setExpectedNumberOfClauses, setKeepSolverHot, setLogPrefix, setSearchListener, setTimeout, setTimeoutMs, setTimeoutOnConflicts, setUnitClauseProvider, setVerbose, toString, toString, unsatExplanationclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfindModel, findModel, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, nConstraints, newVar, nVars, primeImplicant, primeImplicant, printInfos, printInfosprotected final java.util.List<IVecInt> criteria
protected int currentCriterion
protected IConstr prevConstr
protected int[] prevfullmodel
protected int[] prevmodelwithinternalvars
protected boolean[] prevboolmodel
protected boolean isSolutionOptimal
public LexicoDecorator(T solver)
public void addCriterion(IVecInt literals)
public boolean admitABetterSolution()
throws TimeoutException
IOptimizationProblemadmitABetterSolution in interface IOptimizationProblemTimeoutException - if the solver cannot answer in reasonable time.ISolver.setTimeout(int)public boolean admitABetterSolution(IVecInt assumps) throws TimeoutException
IOptimizationProblemadmitABetterSolution in interface IOptimizationProblemassumps - a set of literals in Dimacs format.TimeoutException - if the solver cannot answer in reasonable time.ISolver.setTimeout(int)protected boolean manageUnsatCase()
public int numberOfCriteria()
protected void fixCriterionValue()
throws ContradictionException
ContradictionExceptionpublic int[] model()
IProblemmodel in interface IProblemmodel in class SolverDecorator<T extends ISolver>IProblem.isSatisfiable(),
IProblem.isSatisfiable(IVecInt)public boolean model(int var)
RandomAccessModelmodel in interface RandomAccessModelmodel in class SolverDecorator<T extends ISolver>var - the variable id in Dimacs format#model()public int[] modelWithInternalVariables()
ISolvermodelWithInternalVariables in interface ISolvermodelWithInternalVariables in class SolverDecorator<T extends ISolver>IProblem.model(),
ModelIteratorpublic boolean hasNoObjectiveFunction()
IOptimizationProblemhasNoObjectiveFunction in interface IOptimizationProblempublic boolean nonOptimalMeansSatisfiable()
IOptimizationProblemnonOptimalMeansSatisfiable in interface IOptimizationProblempublic java.lang.Number calculateObjective()
IOptimizationProblemcalculateObjective in interface IOptimizationProblemIOptimizationProblem.getObjectiveValue()public java.lang.Number getObjectiveValue()
IOptimizationProblemgetObjectiveValue in interface IOptimizationProblempublic java.lang.Number getObjectiveValue(int criterion)
public void forceObjectiveValueTo(java.lang.Number forcedValue)
throws ContradictionException
IOptimizationProblemforceObjectiveValueTo in interface IOptimizationProblemContradictionExceptionpublic void discard()
throws ContradictionException
IOptimizationProblemdiscard in interface IOptimizationProblemContradictionException - if a trivial inconsistency is detected.IOptimizationProblem.discardCurrentSolution()public void discardCurrentSolution()
throws ContradictionException
IOptimizationProblemdiscardCurrentSolution in interface IOptimizationProblemContradictionException - if a trivial inconsistency is detected.protected IConstr discardSolutionsForOptimizing() throws ContradictionException
ContradictionExceptionprotected java.lang.Number evaluate()
protected java.lang.Number evaluate(int criterion)
public boolean isOptimal()
IOptimizationProblemisOptimal in interface IOptimizationProblempublic void setTimeoutForFindingBetterSolution(int seconds)
IOptimizationProblemsetTimeoutForFindingBetterSolution in interface IOptimizationProblem