Base class for implementing (mulit-level) minimize statements. More...
#include <minimize_constraint.h>
Public Types | |
typedef SharedMinimizeData | SharedData |
typedef const SharedData * | SharedDataP |
Public Member Functions | |
virtual bool | attach (Solver &s)=0 |
Attaches this object to the given solver. | |
Constraint * | cloneAttach (Solver &other) |
Returns a clone of this and adds necessary watches to the given solver. | |
void | destroy (Solver *, bool) |
Default is to call delete this. | |
virtual bool | handleModel (Solver &s)=0 |
Shall commit the model in s to the shared data object. | |
virtual bool | handleUnsat (Solver &s, bool upShared, LitVec &restore)=0 |
Shall handle the unsatisfiable path in s. | |
virtual bool | integrate (Solver &s)=0 |
Shall activate the minimize constraint by integrating bounds stored in the shared data object. | |
virtual bool | relax (Solver &s, bool reset)=0 |
Shall relax this constraint (i.e. remove any bounds). | |
SharedDataP | shared () const |
Returns a pointer to the shared representation of this constraint. | |
Protected Member Functions | |
MinimizeConstraint (SharedData *s) | |
bool | prepare (Solver &s, bool useTag) |
~MinimizeConstraint () | |
Protected Attributes | |
SharedData * | shared_ |
Literal | tag_ |
Base class for implementing (mulit-level) minimize statements.
A solver contains at most one minimize constraint, but a minimize constraint may represent several minimize statements. In that case, each minimize statement has a unique level (starting at 0) and minimize statements with a lower level have higher priority. Priorities are handled like in smodels, i.e. statements with lower priority become relevant only if all statements with higher priority currently have an optimal assignment.
MinimizeConstraint supports two modes of operation: if mode is set to optimize, solutions are considered optimal only if they are strictly smaller than previous solutions. Otherwise, if mode is set to enumerate a solution is valid if it is not greater than the initially set optimum. Example: m0: {a, b} m1: {c, d} All models: {a, c,...}, {a, d,...} {b, c,...}, {b, d,...} {a, b,...} Mode = optimize: {a, c, ...} (m0 = 1, m1 = 1} Mode = enumerate and initial opt=1,1: {a, c, ...}, {a, d,...}, {b, c,...}, {b, d,...}
Definition at line 272 of file minimize_constraint.h.
Definition at line 274 of file minimize_constraint.h.
typedef const SharedData* Clasp::MinimizeConstraint::SharedDataP |
Definition at line 275 of file minimize_constraint.h.
Clasp::MinimizeConstraint::MinimizeConstraint | ( | SharedData * | s | ) | [protected] |
Definition at line 150 of file minimize_constraint.cpp.
Clasp::MinimizeConstraint::~MinimizeConstraint | ( | ) | [protected] |
Definition at line 152 of file minimize_constraint.cpp.
virtual bool Clasp::MinimizeConstraint::attach | ( | Solver & | s | ) | [pure virtual] |
Attaches this object to the given solver.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
Constraint * Clasp::MinimizeConstraint::cloneAttach | ( | Solver & | other | ) | [virtual] |
Returns a clone of this and adds necessary watches to the given solver.
The function shall create and return a copy of this constraint to be used in the given solver. Furthermore, it shall add necessary watches to the given solver.
Implements Clasp::Constraint.
Reimplemented in Clasp::DomainHeuristic::DomMinimize.
Definition at line 166 of file minimize_constraint.cpp.
void Clasp::MinimizeConstraint::destroy | ( | Solver * | s, |
bool | detach | ||
) | [virtual] |
Default is to call delete this.
Reimplemented from Clasp::Constraint.
Reimplemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
Definition at line 161 of file minimize_constraint.cpp.
virtual bool Clasp::MinimizeConstraint::handleModel | ( | Solver & | s | ) | [pure virtual] |
Shall commit the model in s to the shared data object.
The return value indicates whether the model is valid w.r.t the costs stored in the shared data object.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
virtual bool Clasp::MinimizeConstraint::handleUnsat | ( | Solver & | s, |
bool | upShared, | ||
LitVec & | restore | ||
) | [pure virtual] |
Shall handle the unsatisfiable path in s.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
virtual bool Clasp::MinimizeConstraint::integrate | ( | Solver & | s | ) | [pure virtual] |
Shall activate the minimize constraint by integrating bounds stored in the shared data object.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
bool Clasp::MinimizeConstraint::prepare | ( | Solver & | s, |
bool | useTag | ||
) | [protected] |
Definition at line 155 of file minimize_constraint.cpp.
virtual bool Clasp::MinimizeConstraint::relax | ( | Solver & | s, |
bool | reset | ||
) | [pure virtual] |
Shall relax this constraint (i.e. remove any bounds).
If reset is true, shall also remove search-path related state.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::UncoreMinimize, and Clasp::DefaultMinimize.
SharedDataP Clasp::MinimizeConstraint::shared | ( | ) | const [inline] |
Returns a pointer to the shared representation of this constraint.
Definition at line 277 of file minimize_constraint.h.
SharedData* Clasp::MinimizeConstraint::shared_ [protected] |
Definition at line 302 of file minimize_constraint.h.
Literal Clasp::MinimizeConstraint::tag_ [protected] |
Definition at line 303 of file minimize_constraint.h.