clingo
|
Base class for (boolean) constraints to be used in a Solver. More...
#include <constraint.h>
Classes | |
struct | PropResult |
Type used as return type for Constraint::propagate. More... | |
Public Member Functions | |
Constraint () | |
virtual Constraint * | cloneAttach (Solver &other)=0 |
Returns a clone of this and adds necessary watches to the given solver. More... | |
virtual void | destroy (Solver *s=0, bool detach=false) |
Default is to call delete this. More... | |
virtual ConstraintType | type () const |
Returns the type of this constraint. More... | |
virtual PropResult | propagate (Solver &s, Literal p, uint32 &data)=0 |
virtual void | reason (Solver &s, Literal p, LitVec &lits)=0 |
virtual bool | minimize (Solver &s, Literal p, CCMinRecursive *rec) |
virtual void | undoLevel (Solver &s) |
Called when the solver undid a decision level watched by this constraint. More... | |
virtual bool | simplify (Solver &s, bool reinit=false) |
virtual uint32 | estimateComplexity (const Solver &s) const |
Returns an estimate of the constraint's complexity relative to a clause (complexity = 1). More... | |
virtual ClauseHead * | clause () |
Shall return this if constraint is a clause, otherwise 0. More... | |
virtual bool | valid (Solver &s) |
Shall return whether the constraint is valid (i.e. not conflicting) w.r.t the current assignment in s. More... | |
Protected Member Functions | |
virtual | ~Constraint () |
Base class for (boolean) constraints to be used in a Solver.
Base class for (boolean) constraints like e.g. clauses. Concrete constraint classes define representations for constraints over boolean variables. Each constraint class must define a method for inference (derive information from an assignment), it must be able to detect conflicts (i.e. detect when the current assignment makes the constraint unsatisfiable) and to return a reason for inferred literals as well as conflicts (as a set of literals).
Clasp::Constraint::Constraint | ( | ) |
|
protectedvirtual |
|
virtual |
Shall return this if constraint is a clause, otherwise 0.
The default implementation returns 0.
Reimplemented in Clasp::ClauseHead.
|
pure 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.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::mt::SharedLitsClause, Clasp::LoopFormula, Clasp::PostPropagator, Clasp::DomainHeuristic, Clasp::Clause, Clasp::MinimizeConstraint, Clasp::ModelEnumerator::BacktrackFinder, Clasp::WeightConstraint, Clasp::ModelEnumerator::RecordFinder, and Clasp::CBConsequences::CBFinder.
|
virtual |
Default is to call delete this.
Reimplemented in Clasp::DomainHeuristic::DomMinimize, Clasp::mt::SharedLitsClause, Clasp::LoopFormula, Clasp::UncoreMinimize, Clasp::Clause, Clasp::DefaultMinimize, Clasp::MinimizeConstraint, Clasp::EnumerationConstraint, Clasp::Lookahead, Clasp::WeightConstraint, Clasp::CBConsequences::CBFinder, and Clasp::ModelEnumerator::ModelFinder.
|
virtual |
Returns an estimate of the constraint's complexity relative to a clause (complexity = 1).
Reimplemented in Clasp::WeightConstraint.
|
virtual |
Called during minimization of learnt clauses.
Reimplemented in Clasp::mt::SharedLitsClause, Clasp::LoopFormula, Clasp::Clause, Clasp::DefaultMinimize, and Clasp::WeightConstraint.
|
pure virtual |
Propagate is called for each constraint that watches p. It shall enqueue all consequences of p becoming true.
s | The solver in which p became true. |
p | A literal watched by this constraint that recently became true. |
data | The data-blob that this constraint passed when the watch for p was registered. |
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::LoopFormula, Clasp::UncoreMinimize, Clasp::ClauseHead, Clasp::PostPropagator, Clasp::DomainHeuristic, Clasp::DefaultMinimize, Clasp::EnumerationConstraint, Clasp::ModelEnumerator::BacktrackFinder, and Clasp::WeightConstraint.
Implemented in Clasp::DomainHeuristic::DomMinimize, Clasp::mt::SharedLitsClause, Clasp::LoopFormula, Clasp::UncoreMinimize, Clasp::PostPropagator, Clasp::DomainHeuristic, Clasp::Clause, Clasp::DefaultMinimize, Clasp::EnumerationConstraint, Clasp::ModelEnumerator::BacktrackFinder, and Clasp::WeightConstraint.
|
virtual |
Simplify this constraint.
Reimplemented in Clasp::DomainHeuristic::DomMinimize, Clasp::mt::SharedLitsClause, Clasp::LoopFormula, Clasp::UncoreMinimize, Clasp::Clause, Clasp::EnumerationConstraint, Clasp::WeightConstraint, and Clasp::ModelEnumerator::ModelFinder.
|
virtual |
Returns the type of this constraint.
Reimplemented in Clasp::LoopFormula, Clasp::ClauseHead, and Clasp::LearntConstraint.
|
virtual |
Called when the solver undid a decision level watched by this constraint.
s | the solver in which the decision level is undone. |
Reimplemented in Clasp::DomainHeuristic, Clasp::DefaultMinimize, Clasp::Lookahead, and Clasp::WeightConstraint.
|
virtual |
Shall return whether the constraint is valid (i.e. not conflicting) w.r.t the current assignment in s.
Reimplemented in Clasp::UncoreMinimize, Clasp::EnumerationConstraint, and Clasp::DefaultUnfoundedCheck.