Class for model enumeration with minimization and projection. More...
#include <model_enumerators.h>
Classes | |
class | BacktrackFinder |
class | ModelFinder |
class | RecordFinder |
class | SolutionQueue |
Public Types | |
enum | ProjectOptions { project_enable_simple = 1, project_use_heuristic = 2, project_save_progress = 4, project_enable_full = 6 } |
Projective solution enumeration and options. More... | |
enum | Strategy { strategy_auto = 0, strategy_backtrack = 1, strategy_record = 2 } |
Enumeration algorithms. More... | |
Public Member Functions | |
ModelEnumerator (Strategy st=strategy_auto) | |
bool | projectionEnabled () const |
void | setStrategy (Strategy st=strategy_auto, uint32 projection=0) |
Configure strategy. | |
Strategy | strategy () const |
~ModelEnumerator () | |
Protected Member Functions | |
ConPtr | doInit (SharedContext &ctx, MinimizeConstraint *m, int numModels) |
Shall prepare the enumerator and freeze any enumeration-related variable. | |
bool | supportsParallel () const |
Returns whether or not this enumerator supports parallel search. | |
bool | supportsRestarts () const |
Returns whether or not this enumerator supports full restarts once a model was found. | |
Private Types | |
enum | { detect_strategy_flag = 4u, trivial_flag = 8u, strategy_opts_mask = 15u } |
typedef SolutionQueue * | QPtr |
Private Member Functions | |
void | addProjectVar (SharedContext &ctx, Var v, bool mark) |
bool | detectStrategy () const |
void | initProjection (SharedContext &ctx) |
uint32 | numProjectionVars () const |
uint32 | projectOpts () const |
Var | projectVar (uint32 i) const |
bool | trivial () const |
Private Attributes | |
uint32 | options_ |
VarVec * | project_ |
QPtr | queue_ |
Class for model enumeration with minimization and projection.
This class implements algorithms for enumerating models with or without optimization and/or projection. It supports two different algorithms (strategies), first, enumeration via restricted backjumping, and second, enumeration via recording of solution nogoods.
The first strategy, strategy_backtrack, maintains a special backtracking level to suppress certain backjumps that could otherwise "re-open" search spaces already visited. If projection is not active, no extra nogoods are created. Otherwise, the number of additional solution nogoods is linear in the number of projection atoms.
The second strategy, strategy_record, enumerates models by recording nogoods for found solutions. In general, this strategy is exponential in space (bounded by the number of solutions). On the other hand, if optimization is active, additional nogoods are not needed because the optimization constraint already serves as solution nogood.
There is also a third strategy, strategy_auto, provided for convenience. This strategy automatically selects between strategy_backtrack and strategy_record based on the problem at hand. It uses strategy_record, if one of the following holds:
In all other cases, strategy_auto selects strategy_backtrack.
Definition at line 59 of file model_enumerators.h.
typedef SolutionQueue* Clasp::ModelEnumerator::QPtr [private] |
Definition at line 97 of file model_enumerators.h.
anonymous enum [private] |
Definition at line 93 of file model_enumerators.h.
Projective solution enumeration and options.
Definition at line 68 of file model_enumerators.h.
Enumeration algorithms.
strategy_auto |
Use strategy best suited to problem. |
strategy_backtrack |
Use backtrack-based enumeration. |
strategy_record |
Use nogood-based enumeration. |
Definition at line 62 of file model_enumerators.h.
Clasp::ModelEnumerator::ModelEnumerator | ( | Strategy | st = strategy_auto | ) | [explicit] |
p | The printer to use for outputting results. |
Definition at line 230 of file model_enumerators.cpp.
Definition at line 247 of file model_enumerators.cpp.
void Clasp::ModelEnumerator::addProjectVar | ( | SharedContext & | ctx, |
Var | v, | ||
bool | mark | ||
) | [private] |
Definition at line 324 of file model_enumerators.cpp.
bool Clasp::ModelEnumerator::detectStrategy | ( | ) | const [inline, private] |
Definition at line 104 of file model_enumerators.h.
EnumerationConstraint * Clasp::ModelEnumerator::doInit | ( | SharedContext & | ctx, |
MinimizeConstraint * | m, | ||
int | numModels | ||
) | [protected, virtual] |
Shall prepare the enumerator and freeze any enumeration-related variable.
Implements Clasp::Enumerator.
Definition at line 265 of file model_enumerators.cpp.
void Clasp::ModelEnumerator::initProjection | ( | SharedContext & | ctx | ) | [private] |
Definition at line 298 of file model_enumerators.cpp.
uint32 Clasp::ModelEnumerator::numProjectionVars | ( | ) | const [inline, private] |
Definition at line 101 of file model_enumerators.h.
bool Clasp::ModelEnumerator::projectionEnabled | ( | ) | const [inline] |
Definition at line 86 of file model_enumerators.h.
uint32 Clasp::ModelEnumerator::projectOpts | ( | ) | const [inline, private] |
Definition at line 103 of file model_enumerators.h.
Var Clasp::ModelEnumerator::projectVar | ( | uint32 | i | ) | const [inline, private] |
Definition at line 102 of file model_enumerators.h.
void Clasp::ModelEnumerator::setStrategy | ( | Strategy | st = strategy_auto , |
uint32 | projection = 0 |
||
) |
Configure strategy.
st Enumeration algorithm to use. projection The set of ProjectOptions to be applied or 0 to disable projective enumeration.
Definition at line 252 of file model_enumerators.cpp.
Strategy Clasp::ModelEnumerator::strategy | ( | ) | const [inline] |
Definition at line 87 of file model_enumerators.h.
bool Clasp::ModelEnumerator::supportsParallel | ( | ) | const [inline, protected, virtual] |
Returns whether or not this enumerator supports parallel search.
Reimplemented from Clasp::Enumerator.
Definition at line 90 of file model_enumerators.h.
bool Clasp::ModelEnumerator::supportsRestarts | ( | ) | const [inline, protected, virtual] |
Returns whether or not this enumerator supports full restarts once a model was found.
Reimplemented from Clasp::Enumerator.
Definition at line 89 of file model_enumerators.h.
bool Clasp::ModelEnumerator::trivial | ( | ) | const [inline, private] |
Definition at line 105 of file model_enumerators.h.
uint32 Clasp::ModelEnumerator::options_ [private] |
Definition at line 108 of file model_enumerators.h.
VarVec* Clasp::ModelEnumerator::project_ [private] |
Definition at line 107 of file model_enumerators.h.
QPtr Clasp::ModelEnumerator::queue_ [private] |
Definition at line 106 of file model_enumerators.h.