clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | Protected Member Functions | List of all members
Clasp::LearntConstraint Class Referenceabstract

Base class for learnt constraints. More...

#include <constraint.h>

Inheritance diagram for Clasp::LearntConstraint:
Inheritance graph
Collaboration diagram for Clasp::LearntConstraint:
Collaboration graph

Public Member Functions

 LearntConstraint ()
 
ConstraintType type () const
 Returns the type of this learnt constraint. More...
 
virtual bool locked (const Solver &s) const =0
 
virtual Activity activity () const
 Returns the activity of the constraint. More...
 
virtual void decreaseActivity ()
 Asks the constraint to decrease its activity. More...
 
virtual void resetActivity (Activity hint)
 Asks the constraint to reset its activity. More...
 
virtual uint32 isOpen (const Solver &s, const TypeSet &t, LitVec &freeLits)=0
 Shall return 0 if either !t.inSet(type()) or this constraint is satisfied w.r.t the current assignment. More...
 
- Public Member Functions inherited from Clasp::Constraint
 Constraint ()
 
virtual ConstraintcloneAttach (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 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 ClauseHeadclause ()
 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

 ~LearntConstraint ()
 
- Protected Member Functions inherited from Clasp::Constraint
virtual ~Constraint ()
 

Detailed Description

Base class for learnt constraints.

Base class for constraints that can be learnt during search. A learnt constraint is a constraint with the difference that it can be created and deleted dynamically during the search-process and is subject to nogood-deletion. Typical examples are conflict clauses which are created during conflict analysis and loop formulas which are created during unfounded-set checks.

A learnt constraint must additionally define the method locked in order to tell a solver if the constraint can be safely deleted or not. Furthermore whenever a solver needs to delete some learnt constraints it will first delete those with a low activity. A learnt constraint may therefore bump its activity whenever it sees fit in order to delay its deletion.

Constructor & Destructor Documentation

Clasp::LearntConstraint::LearntConstraint ( )
Clasp::LearntConstraint::~LearntConstraint ( )
protected

Member Function Documentation

Activity Clasp::LearntConstraint::activity ( ) const
virtual

Returns the activity of the constraint.

Note
A solver uses the activity-value in order to establish an ordering of learnt constraints. Whenever a solver needs to delete some learnt constraints it selects from the unlocked ones those with a low activity-value.
The default-implementation always returns 0.

Reimplemented in Clasp::LoopFormula, and Clasp::ClauseHead.

void Clasp::LearntConstraint::decreaseActivity ( )
virtual

Asks the constraint to decrease its activity.

Reimplemented in Clasp::LoopFormula, and Clasp::ClauseHead.

virtual uint32 Clasp::LearntConstraint::isOpen ( const Solver s,
const TypeSet t,
LitVec freeLits 
)
pure virtual

Shall return 0 if either !t.inSet(type()) or this constraint is satisfied w.r.t the current assignment.

If this constraint is currently not satisfied and t.inSet(type()), shall return type() and freeLits shall contain all currently unassigned literals of this constraint.

Implemented in Clasp::mt::SharedLitsClause, Clasp::LoopFormula, and Clasp::Clause.

virtual bool Clasp::LearntConstraint::locked ( const Solver s) const
pure virtual

Shall return true if this constraint can't be deleted because it currently implies one ore more literals and false otherwise.

Implemented in Clasp::LoopFormula, and Clasp::ClauseHead.

void Clasp::LearntConstraint::resetActivity ( Activity  hint)
virtual

Asks the constraint to reset its activity.

Reimplemented in Clasp::LoopFormula, and Clasp::ClauseHead.

ConstraintType Clasp::LearntConstraint::type ( ) const
virtual

Returns the type of this learnt constraint.

Note
The default implementation returns Constraint_t::learnt_conflict.

Reimplemented from Clasp::Constraint.

Reimplemented in Clasp::ClauseHead.


The documentation for this class was generated from the following files: