A variable state independent decision heuristic favoring variables that were active in recent conflicts. More...
#include <heuristics.h>
Classes | |
struct | CmpScore |
Public Member Functions | |
bool | bump (const Solver &s, const WeightLitVec &lits, double adj) |
Shall bump the activity of literals in lits by lits.second * adj. | |
ClaspVsids_t (double d=0.95, const HeuParams ¶ms=HeuParams()) | |
void | endInit (Solver &) |
void | newConstraint (const Solver &s, const Literal *first, LitVec::size_type size, ConstraintType t) |
void | simplify (const Solver &, LitVec::size_type) |
void | startInit (const Solver &s) |
void | undoUntil (const Solver &, LitVec::size_type) |
void | updateReason (const Solver &s, const LitVec &lits, Literal resolveLit) |
void | updateVar (const Solver &s, Var v, uint32 n) |
Protected Types | |
typedef PodVector< int32 >::type | OccVec |
typedef PodVector< ScoreType > ::type | ScoreVec |
typedef bk_lib::indexed_priority_queue < CmpScore > | VarOrder |
Protected Member Functions | |
Literal | doSelect (Solver &s) |
Implements the actual selection process. | |
void | incOcc (Literal p) |
virtual void | initScores (Solver &s, bool moms) |
void | normalize () |
int | occ (Var v) const |
Literal | selectRange (Solver &s, const Literal *first, const Literal *last) |
void | updateVarActivity (Var v, double f=1.0) |
Protected Attributes | |
const double | decay_ |
double | inc_ |
OccVec | occ_ |
ScoreVec | score_ |
TypeSet | types_ |
VarOrder | vars_ |
A variable state independent decision heuristic favoring variables that were active in recent conflicts.
This heuristic combines ideas from VSIDS and BerkMin. Literal Selection works as in VSIDS but var activities are increased as in BerkMin.
Definition at line 260 of file heuristics.h.
typedef PodVector<int32>::type Clasp::ClaspVsids_t< ScoreType >::OccVec [protected] |
Definition at line 278 of file heuristics.h.
typedef PodVector<ScoreType>::type Clasp::ClaspVsids_t< ScoreType >::ScoreVec [protected] |
Definition at line 277 of file heuristics.h.
typedef bk_lib::indexed_priority_queue<CmpScore> Clasp::ClaspVsids_t< ScoreType >::VarOrder [protected] |
Definition at line 298 of file heuristics.h.
Clasp::ClaspVsids_t< ScoreType >::ClaspVsids_t | ( | double | d = 0.95 , |
const HeuParams & | params = HeuParams() |
||
) | [explicit] |
d | Set initial inc-factor to 1.0/d. |
Definition at line 481 of file heuristics.cpp.
bool Clasp::ClaspVsids_t< ScoreType >::bump | ( | const Solver & | , |
const WeightLitVec & | , | ||
double | |||
) | [virtual] |
Shall bump the activity of literals in lits by lits.second * adj.
The default-implementation is a noop and always returns false.
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 583 of file heuristics.cpp.
Literal Clasp::ClaspVsids_t< ScoreType >::doSelect | ( | Solver & | ) | [protected, virtual] |
Implements the actual selection process.
Implements Clasp::DecisionHeuristic.
Reimplemented in Clasp::DomainHeuristic.
Definition at line 599 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::endInit | ( | Solver & | ) | [virtual] |
Called once after all problem constraints are known to the solver and the problem was simplified. The default-implementation is a noop.
s | The solver in which this heuristic is used. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 501 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::incOcc | ( | Literal | p | ) | [inline, protected] |
Definition at line 288 of file heuristics.h.
void Clasp::ClaspVsids_t< ScoreType >::initScores | ( | Solver & | s, |
bool | moms | ||
) | [protected, virtual] |
Reimplemented in Clasp::DomainHeuristic.
Definition at line 522 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::newConstraint | ( | const Solver & | , |
const Literal * | , | ||
LitVec::size_type | , | ||
ConstraintType | |||
) | [virtual] |
Called whenever a new constraint is added to the solver s. The default-implementation is a noop.
s | The solver to which the constraint is added. |
first | First literal of the new constraint. |
size | Size of the new constraint. |
t | Type of the new constraint. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 564 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::normalize | ( | ) | [protected] |
Definition at line 548 of file heuristics.cpp.
int Clasp::ClaspVsids_t< ScoreType >::occ | ( | Var | v | ) | const [inline, protected] |
Definition at line 289 of file heuristics.h.
Literal Clasp::ClaspVsids_t< ScoreType >::selectRange | ( | Solver & | , |
const Literal * | first, | ||
const Literal * | |||
) | [protected, virtual] |
Shall select one of the literals in the range [first, last).
s | The solver that needs a new decision variable. |
first | Pointer to first literal in range. |
last | Pointer to the end of the range. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 606 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::simplify | ( | const Solver & | , |
LitVec::size_type | |||
) | [virtual] |
Called on decision level 0. Variables that are assigned on this level may be removed from any decision heuristic.
s | The solver that reached decision level 0. |
st | The position in the trail of the first new learnt fact. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 541 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::startInit | ( | const Solver & | ) | [virtual] |
Called once after all problem variables are known to the solver. The default-implementation is a noop.
s | The solver in which this heuristic is used. |
Reimplemented from Clasp::DecisionHeuristic.
Reimplemented in Clasp::DomainHeuristic.
Definition at line 493 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::undoUntil | ( | const Solver & | , |
LitVec::size_type | |||
) | [virtual] |
Called whenever the solver backracks. Literals in the range [s.trail()[st], s.trail().size()) are subject to backtracking. The default-implementation is a noop.
s | The solver that is about to backtrack. |
st | Position in the trail of the first literal that will be backtracked. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 590 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::updateReason | ( | const Solver & | , |
const LitVec & | , | ||
Literal | |||
) | [virtual] |
Called for each new reason-set that is traversed during conflict analysis. The default-implementation is a noop.
s | The solver in which the conflict is analyzed. |
lits | The current reason-set under inspection. |
resolveLit | The literal that is currently resolved. |
Reimplemented from Clasp::DecisionHeuristic.
Definition at line 579 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::updateVar | ( | const Solver & | , |
Var | , | ||
uint32 | |||
) | [virtual] |
Called if the state of one or more variables changed. A state change is one of:
s | Solver in which the state change occurred. |
v | The first variable affected by the change. |
n | The range of variables affected, i.e. [v, v+n). |
Implements Clasp::DecisionHeuristic.
Definition at line 511 of file heuristics.cpp.
void Clasp::ClaspVsids_t< ScoreType >::updateVarActivity | ( | Var | v, |
double | f = 1.0 |
||
) | [inline, protected] |
Definition at line 280 of file heuristics.h.
const double Clasp::ClaspVsids_t< ScoreType >::decay_ [protected] |
Definition at line 302 of file heuristics.h.
double Clasp::ClaspVsids_t< ScoreType >::inc_ [protected] |
Definition at line 303 of file heuristics.h.
OccVec Clasp::ClaspVsids_t< ScoreType >::occ_ [protected] |
Definition at line 300 of file heuristics.h.
ScoreVec Clasp::ClaspVsids_t< ScoreType >::score_ [protected] |
Definition at line 299 of file heuristics.h.
TypeSet Clasp::ClaspVsids_t< ScoreType >::types_ [protected] |
Definition at line 304 of file heuristics.h.
VarOrder Clasp::ClaspVsids_t< ScoreType >::vars_ [protected] |
Definition at line 301 of file heuristics.h.