clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | List of all members
Clasp::Solver Class Reference

clasp's Solver class. More...

#include <solver.h>

Collaboration diagram for Clasp::Solver:
Collaboration graph

Classes

struct  DBInfo
 

Public Types

typedef PodVector< Constraint * >
::type 
ConstraintDB
 
typedef const ConstraintDBDBRef
 
typedef SingleOwnerPtr
< DecisionHeuristic
Heuristic
 

Public Member Functions

const SharedContextsharedContext () const
 Returns a pointer to the shared context object of this solver. More...
 
SatPreprocessorsatPrepro () const
 Returns a pointer to the sat-preprocessor used by this solver. More...
 
const SolverParamsconfiguration () const
 Returns the configuration for this object. More...
 
const SolveParamssearchConfig () const
 Returns the solve parameters for this object. More...
 
const Heuristicheuristic () const
 
uint32 id () const
 
Heuristicheuristic ()
 
VarInfo varInfo (Var v) const
 
const SymbolTablesymbolTable () const
 
Literal tagLiteral () const
 
void add (Constraint *c)
 Adds the problem constraint c to the solver. More...
 
bool add (const ClauseRep &c, bool isNew=true)
 Adds a suitable representation of the given clause to the solver. More...
 
bool allowImplicit (const ClauseRep &c) const
 Returns whether c can be stored in the shared short implication graph. More...
 
PostPropagatorgetPost (uint32 prio) const
 Returns the post propagator with the given priority or 0 if no such post propagator exists. More...
 
bool addPost (PostPropagator *p)
 Adds p as post propagator to this solver. More...
 
void removePost (PostPropagator *p)
 Removes p from the solver's list of post propagators. More...
 
CDNL-functions.
ValueRep search (SearchLimits &limit, double randf=0.0)
 Searches for a model as long as the given limit is not reached. More...
 
ValueRep search (uint64 maxC, uint32 maxL, bool local=false, double rp=0.0)
 
bool pushRoot (const LitVec &path)
 Adds path to the current root-path and adjusts the root-level accordingly. More...
 
bool pushRoot (Literal p)
 
void setEnumerationConstraint (Constraint *c)
 
void pushRootLevel (uint32 i=1)
 Moves the root-level i levels down (i.e. away from the top-level). More...
 
bool popRootLevel (uint32 i=1, LitVec *popped=0, bool aux=true)
 Moves the root-level i levels up (i.e. towards the top-level). More...
 
void clearStopConflict ()
 Removes a previously set stop conflict and restores the root level. More...
 
uint32 rootLevel () const
 Returns the current root level. More...
 
bool clearAssumptions ()
 Removes any implications made between the top-level and the root-level. More...
 
void addLearnt (LearntConstraint *c, uint32 size, ConstraintType type)
 Adds the learnt constraint c to the solver. More...
 
void addLearnt (LearntConstraint *c, uint32 size)
 
uint32 receive (SharedLiterals **out, uint32 maxOut) const
 Tries to receive at most maxOut clauses. More...
 
SharedLiteralsdistribute (const Literal *lits, uint32 size, const ClauseInfo &extra)
 Distributes the clause in lits via the distributor. More...
 
void restart ()
 Returns to the maximum of rootLevel() and backtrackLevel() and increases the number of restarts. More...
 
void setBacktrackLevel (uint32 dl)
 Sets the backtracking level to dl. More...
 
uint32 backtrackLevel () const
 Returns the current backtracking level. More...
 
bool splittable () const
 Returns whether the solver can split-off work. More...
 
bool split (LitVec &out)
 Tries to split-off disjoint work from the solver's currrent guiding path and returns it in out. More...
 
void copyGuidingPath (LitVec &out)
 Copies the solver's currrent guiding path to gp. More...
 
bool simplify ()
 If called on top-level, removes SAT-clauses + Constraints for which Constraint::simplify returned true. More...
 
void shuffleOnNextSimplify ()
 Shuffle constraints upon next simplification. More...
 
Var pushTagVar (bool pushToRoot)
 Requests a special aux variable for tagging conditional knowledge. More...
 
void removeConditional ()
 Removes all conditional knowledge, i.e. all previously tagged learnt clauses. More...
 
void strengthenConditional ()
 Resolves all tagged clauses with the tag literal and thereby strengthens the learnt db. More...
 
bool force (const Literal &p, const Antecedent &a)
 Sets the literal p to true and schedules p for propagation. More...
 
bool force (const Literal &p, const Antecedent &a, uint32 data)
 
bool force (Literal p, uint32 dl, const Antecedent &r, uint32 d=UINT32_MAX)
 Assigns p at dl because of r. More...
 
bool force (Literal p)
 Assigns p as a fact at decision level 0. More...
 
bool assume (const Literal &p)
 Assumes the literal p if possible. More...
 
bool decideNextBranch (double f=0.0)
 Selects and assumes the next branching literal by calling the installed decision heuristic. More...
 
void setStopConflict ()
 Sets a conflict that forces the solver to terminate its search. More...
 
bool propagate ()
 
bool propagateUntil (PostPropagator *p)
 
bool test (Literal p, PostPropagator *c)
 Executes a one-step lookahead on p. More...
 
uint32 estimateBCP (const Literal &p, int maxRecursionDepth=5) const
 Estimates the number of assignments following from setting p to true. More...
 
uint32 inDegree (WeightLitVec &out)
 Computes the number of in-edges for each assigned literal. More...
 
DBInfo reduceLearnts (float remMax, const ReduceStrategy &rs=ReduceStrategy())
 Removes upto remMax percent of the learnt nogoods. More...
 
bool resolveConflict ()
 Resolves the active conflict using the selected strategy. More...
 
bool backtrack ()
 Backtracks the last decision and sets the backtrack-level to the resulting decision level. More...
 
void undoUntil (uint32 dl)
 Undoes all assignments up to (but not including) decision level dl. More...
 
uint32 undoUntil (uint32 dl, bool popBtLevel)
 
Var pushAuxVar ()
 Adds a new auxiliary variable to this solver. More...
 
void popAuxVar (uint32 num=UINT32_MAX)
 Pops the num most recently added auxiliary variables from this solver. More...
 
Watch management

Functions for setting/removing watches.

Precondition
validVar(v)
uint32 numWatches (Literal p) const
 Returns the number of constraints watching the literal p. More...
 
bool hasWatch (Literal p, Constraint *c) const
 Returns true if the constraint c watches the literal p. More...
 
bool hasWatch (Literal p, ClauseHead *c) const
 
GenericWatchgetWatch (Literal p, Constraint *c) const
 Returns c's watch-structure associated with p. More...
 
void addWatch (Literal p, Constraint *c, uint32 data=0)
 Adds c to the watch-list of p. More...
 
void addWatch (Literal p, const ClauseWatch &w)
 Adds w to the clause watch-list of p. More...
 
void removeWatch (const Literal &p, Constraint *c)
 Removes c from p's watch-list. More...
 
void removeWatch (const Literal &p, ClauseHead *c)
 
void addUndoWatch (uint32 dl, Constraint *c)
 Adds c to the watch-list of decision-level dl. More...
 
bool removeUndoWatch (uint32 dl, Constraint *c)
 Removes c from the watch-list of the decision level dl. More...
 
Misc functions

Low-level implementation functions. Use with care and only if you know what you are doing!

bool addPost (PostPropagator *p, bool init)
 
bool setReason (Literal p, const Antecedent &x, uint32 data=UINT32_MAX)
 Updates the reason for p being tue. More...
 
void requestData (Var v)
 Request additional reason data slot for variable v. More...
 
void setPref (Var v, ValueSet::Value which, ValueRep to)
 
void reason (Literal p, LitVec &out)
 Returns the reason for p being true as a set of literals. More...
 
uint32 updateLearnt (Literal p, const Literal *first, const Literal *last, uint32 cLbd, bool forceUp=false)
 Computes a new lbd for the antecedent of p given as the range [first, last). More...
 
bool ccMinimize (Literal p, CCMinRecursive *rec) const
 Visitor function for antecedents used during conflict clause minimization. More...
 
bool learntLimit (const SearchLimits &x) const
 Returns true if number of learnts exceeds x.learnts or the soft memory limit is exceeded. More...
 
void * allocSmall ()
 Allocates a small block (32-bytes) from the solver's small block pool. More...
 
void freeSmall (void *m)
 Frees a small block previously allocated from the solver's small block pool. More...
 
void addLearntBytes (uint32 bytes)
 
void freeLearntBytes (uint64 bytes)
 
uint32 simplifyConflictClause (LitVec &cc, ClauseInfo &info, ClauseHead *rhs)
 simplifies cc and returns finalizeConflictClause(cc, info); More...
 
uint32 finalizeConflictClause (LitVec &cc, ClauseInfo &info, uint32 ccRepMode=0)
 
uint32 countLevels (const Literal *first, const Literal *last, uint32 maxLevels)
 
bool hasLevel (uint32 dl) const
 
bool frozenLevel (uint32 dl) const
 
void markLevel (uint32 dl)
 
void freezeLevel (uint32 dl)
 
void unmarkLevel (uint32 dl)
 
void unfreezeLevel (uint32 dl)
 
void markSeen (Var v)
 
void markSeen (Literal p)
 
void clearSeen (Var v)
 

Construction/Destruction/Setup

class SharedContext
 

state inspection

Functions for inspecting the state of the solver & search.

Note
validVar(v) is a precondition for all functions that take a variable as parameter.
SolverStrategies strategy
 
RNG rng
 
ValueVec model
 
SolverStats stats
 
uint32 numProblemVars () const
 Returns the number of problem variables. More...
 
uint32 numAuxVars () const
 Returns the number of active solver-local aux variables. More...
 
uint32 numVars () const
 Returns the number of solver variables, i.e. numProblemVars() + numAuxVars() More...
 
bool validVar (Var var) const
 Returns true if var represents a valid variable in this solver. More...
 
bool auxVar (Var var) const
 Returns true if var is a solver-local aux var. More...
 
uint32 numAssignedVars () const
 Returns the number of assigned variables. More...
 
uint32 numFreeVars () const
 Returns the number of free variables. More...
 
ValueRep value (Var v) const
 Returns the value of v w.r.t the current assignment. More...
 
ValueRep topValue (Var v) const
 Returns the value of v w.r.t the top level. More...
 
ValueSet pref (Var v) const
 Returns the set of preferred values of v. More...
 
bool isTrue (Literal p) const
 Returns true if p is true w.r.t the current assignment. More...
 
bool isFalse (Literal p) const
 Returns true if p is false w.r.t the current assignment. More...
 
Literal trueLit (Var v) const
 Returns the literal of v being true in the current assignment. More...
 
uint32 level (Var v) const
 Returns the decision level on which v was assigned. More...
 
bool seen (Var v) const
 Returns true if v is currently marked as seen. More...
 
bool seen (Literal p) const
 Returns true if the literal p is currently marked as seen. More...
 
uint32 decisionLevel () const
 Returns the current decision level. More...
 
bool validLevel (uint32 dl) const
 
uint32 levelStart (uint32 dl) const
 Returns the starting position of decision level dl in the trail. More...
 
Literal decision (uint32 dl) const
 Returns the decision literal of the decision level dl. More...
 
bool hasConflict () const
 Returns true, if the current assignment is conflicting. More...
 
bool hasStopConflict () const
 
uint32 queueSize () const
 Returns the number of (unprocessed) literals in the propagation queue. More...
 
uint32 numConstraints () const
 Number of problem constraints in this solver. More...
 
uint32 numLearntConstraints () const
 Returns the number of constraints that are currently in the solver's learnt database. More...
 
const Antecedentreason (Literal p) const
 Returns the reason for p being true. More...
 
uint32 reasonData (Literal p) const
 Returns the additional reason data associated with p. More...
 
const LitVectrail () const
 Returns the current (partial) assignment as a set of true literals. More...
 
const Assignmentassignment () const
 
const LitVecconflict () const
 Returns the current conflict as a set of literals. More...
 
const LitVecconflictClause () const
 Returns the most recently derived conflict clause. More...
 
const LitVecsymmetric () const
 Returns the set of eliminated literals that are unconstraint w.r.t the last model. More...
 
ConstraintenumerationConstraint () const
 Returns the enumeration constraint set by the enumerator used. More...
 
DBRef constraints () const
 
LearntConstraintgetLearnt (uint32 idx) const
 Returns the idx'th learnt constraint. More...
 

Detailed Description

clasp's Solver class.

A Solver-object maintains the state and provides the functions necessary to implement our CDNL-algorithm.

The interface supports incremental solving (search under assumptions) as well as solution enumeration. To make this possible the solver maintains two special decision levels: the root-level and the backtrack-level.

The root-level is the lowest decision level to which a search can return. Conflicts on the root-level are non-resolvable and end a search - the root-level therefore acts as an artificial top-level during search. Incremental solving is then implemented by first adding a list of unit assumptions and second initializing the root-level to the current decision level. Once search terminates assumptions can be undone by calling clearAssumptions and a new a search can be started using different assumptions.

For model enumeration the solver maintains a backtrack-level which restricts backjumping in order to prevent repeating already enumerated solutions. The solver will never backjump above that level and conflicts on the backtrack-level are resolved by backtracking, i.e. flipping the corresponding decision literal.

See also
"Conflict-Driven Answer Set Enumeration" for a detailed description of this approach.

Member Typedef Documentation

Member Function Documentation

void Clasp::Solver::add ( Constraint c)

Adds the problem constraint c to the solver.

Problem constraints shall only be added to the master solver of a SharedContext object and only during the setup phase.

Precondition
this == sharedContext()->master() && !sharedContext()->frozen().
bool Clasp::Solver::add ( const ClauseRep c,
bool  isNew = true 
)

Adds a suitable representation of the given clause to the solver.

Depending on the type and size of the given clause, the function either adds a (learnt) constraint to this solver or an implication to the shared implication graph.

Note
If c is a problem clause, the precondition of add(Constraint* c) applies.

Here is the call graph for this function:

void Clasp::Solver::addLearnt ( LearntConstraint c,
uint32  size,
ConstraintType  type 
)
inline

Adds the learnt constraint c to the solver.

Here is the call graph for this function:

void Clasp::Solver::addLearnt ( LearntConstraint c,
uint32  size 
)
inline

Here is the call graph for this function:

void Clasp::Solver::addLearntBytes ( uint32  bytes)
inline
bool Clasp::Solver::addPost ( PostPropagator p)
inline

Adds p as post propagator to this solver.

Precondition
p was not added previously and is not part of any other solver.
Note
Post propagators are stored and called in priority order.
See also
PostPropagator::priority()

Here is the call graph for this function:

bool Clasp::Solver::addPost ( PostPropagator p,
bool  init 
)
inline

Here is the call graph for this function:

void Clasp::Solver::addUndoWatch ( uint32  dl,
Constraint c 
)
inline

Adds c to the watch-list of decision-level dl.

Constraints in the watch-list of a decision level are notified when that decision level is about to be backtracked.

Precondition
validLevel(dl)

Here is the call graph for this function:

void Clasp::Solver::addWatch ( Literal  p,
Constraint c,
uint32  data = 0 
)
inline

Adds c to the watch-list of p.

When p becomes true, c->propagate(p, data, *this) is called.

Postcondition
hasWatch(p, c) == true

Here is the call graph for this function:

void Clasp::Solver::addWatch ( Literal  p,
const ClauseWatch w 
)
inline

Adds w to the clause watch-list of p.

Here is the call graph for this function:

void* Clasp::Solver::allocSmall ( )
inline

Allocates a small block (32-bytes) from the solver's small block pool.

Here is the call graph for this function:

bool Clasp::Solver::allowImplicit ( const ClauseRep c) const
inline

Returns whether c can be stored in the shared short implication graph.

Here is the call graph for this function:

const Assignment& Clasp::Solver::assignment ( ) const
inline
bool Clasp::Solver::assume ( const Literal p)

Assumes the literal p if possible.

If p is currently unassigned, sets p to true and starts a new decision level.

Precondition
validVar(p.var()) == true
Parameters
pThe literal to assume.
Returns
!isFalse(p)

Here is the call graph for this function:

bool Clasp::Solver::auxVar ( Var  var) const
inline

Returns true if var is a solver-local aux var.

Here is the call graph for this function:

bool Clasp::Solver::backtrack ( )

Backtracks the last decision and sets the backtrack-level to the resulting decision level.

Returns

Here is the call graph for this function:

uint32 Clasp::Solver::backtrackLevel ( ) const
inline

Returns the current backtracking level.

bool Clasp::Solver::ccMinimize ( Literal  p,
CCMinRecursive rec 
) const
inline

Visitor function for antecedents used during conflict clause minimization.

Here is the call graph for this function:

bool Clasp::Solver::clearAssumptions ( )

Removes any implications made between the top-level and the root-level.

The function also resets the current backtrack-level and re-assigns learnt facts.

Note
Equivalent to popRootLevel(rootLevel()) followed by simplify().

Here is the call graph for this function:

void Clasp::Solver::clearSeen ( Var  v)
inline

Here is the call graph for this function:

void Clasp::Solver::clearStopConflict ( )

Removes a previously set stop conflict and restores the root level.

Here is the call graph for this function:

const SolverParams & Clasp::Solver::configuration ( ) const

Returns the configuration for this object.

Here is the call graph for this function:

const LitVec& Clasp::Solver::conflict ( ) const
inline

Returns the current conflict as a set of literals.

const LitVec& Clasp::Solver::conflictClause ( ) const
inline

Returns the most recently derived conflict clause.

DBRef Clasp::Solver::constraints ( ) const
inline
void Clasp::Solver::copyGuidingPath ( LitVec out)

Copies the solver's currrent guiding path to gp.

Note
The solver's guiding path consists of:
  • the decisions from levels [1, rootLevel()]
  • any literals that are implied on a level <= rootLevel() because of newly learnt information. This particularly includes literals that were flipped during model enumeration.
Parameters
[out]gpwhere to store the guiding path

Here is the call graph for this function:

uint32 Clasp::Solver::countLevels ( const Literal first,
const Literal last,
uint32  maxLevels 
)

Here is the call graph for this function:

bool Clasp::Solver::decideNextBranch ( double  f = 0.0)

Selects and assumes the next branching literal by calling the installed decision heuristic.

Precondition
queueSize() == 0
Note
The next decision literal will be selected randomly with probability f.
Returns
  • true if the assignment is not total and a literal was assumed (or forced).
  • false otherwise
See also
DecisionHeuristic

Here is the call graph for this function:

Literal Clasp::Solver::decision ( uint32  dl) const
inline

Returns the decision literal of the decision level dl.

Precondition
validLevel(dl)

Here is the call graph for this function:

uint32 Clasp::Solver::decisionLevel ( ) const
inline

Returns the current decision level.

SharedLiterals * Clasp::Solver::distribute ( const Literal lits,
uint32  size,
const ClauseInfo extra 
)

Distributes the clause in lits via the distributor.

The function first calls the distribution strategy to decides whether the clause is a valid candidate for distribution. If so and a distributor was set, it distributes the clause and returns a handle to the now shared literals of the clause. Otherwise, it returns 0.

Parameters
ownerThe solver that created the clause.
litsThe literals of the clause.
sizeThe number of literals in the clause.
extraAdditional information about the clause.
Note
If the return value is not null, it is the caller's responsibility to release the returned handle (i.e. by calling release()).
If the clause contains aux vars, it is not distributed.

Here is the call graph for this function:

Constraint* Clasp::Solver::enumerationConstraint ( ) const
inline

Returns the enumeration constraint set by the enumerator used.

uint32 Clasp::Solver::estimateBCP ( const Literal p,
int  maxRecursionDepth = 5 
) const

Estimates the number of assignments following from setting p to true.

Note
For the estimate only binary clauses are considered.

Here is the call graph for this function:

uint32 Clasp::Solver::finalizeConflictClause ( LitVec cc,
ClauseInfo info,
uint32  ccRepMode = 0 
)

Here is the call graph for this function:

bool Clasp::Solver::force ( const Literal p,
const Antecedent a 
)
inline

Sets the literal p to true and schedules p for propagation.

Setting a literal p to true means assigning the appropriate value to p's variable. That is: value_false if p is a negative literal and value_true if p is a positive literal.

Parameters
pThe literal that should become true.
aThe reason for the literal to become true or 0 if no reason exists.
Returns
  • false if p is already false
  • otherwise true.
Precondition
hasConflict() == false
a.isNull() == false || decisionLevel() <= rootLevel() || SearchStrategy == no_learning
Postcondition
p.var() == trueValue(p) || p.var() == falseValue(p) && hasConflict() == true
Note
if setting p to true leads to a conflict, the nogood that caused the conflict can be requested using the conflict() function.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Precondition
data == UINT32_MAX || requestData(p.var()) was called during setup

Here is the call graph for this function:

bool Clasp::Solver::force ( const Literal p,
const Antecedent a,
uint32  data 
)
inline

Here is the call graph for this function:

bool Clasp::Solver::force ( Literal  p,
uint32  dl,
const Antecedent r,
uint32  d = UINT32_MAX 
)
inline

Assigns p at dl because of r.

Precondition
dl <= decisionLevel()
Note
If dl < ul = max(rootLevel(), backtrackLevel()), p is actually assigned at ul but the solver stores enough information to reassign p on backtracking.

Here is the call graph for this function:

bool Clasp::Solver::force ( Literal  p)
inline

Assigns p as a fact at decision level 0.

Here is the call graph for this function:

void Clasp::Solver::freeLearntBytes ( uint64  bytes)
inline
void Clasp::Solver::freeSmall ( void *  m)
inline

Frees a small block previously allocated from the solver's small block pool.

Here is the call graph for this function:

void Clasp::Solver::freezeLevel ( uint32  dl)
inline

Here is the call graph for this function:

bool Clasp::Solver::frozenLevel ( uint32  dl) const
inline

Here is the call graph for this function:

LearntConstraint& Clasp::Solver::getLearnt ( uint32  idx) const
inline

Returns the idx'th learnt constraint.

Precondition
idx < numLearntConstraints()

Here is the call graph for this function:

PostPropagator * Clasp::Solver::getPost ( uint32  prio) const

Returns the post propagator with the given priority or 0 if no such post propagator exists.

Here is the call graph for this function:

GenericWatch * Clasp::Solver::getWatch ( Literal  p,
Constraint c 
) const

Returns c's watch-structure associated with p.

Note
returns 0, if hasWatch(p, c) == false

Here is the call graph for this function:

bool Clasp::Solver::hasConflict ( ) const
inline

Returns true, if the current assignment is conflicting.

bool Clasp::Solver::hasLevel ( uint32  dl) const
inline

Here is the call graph for this function:

bool Clasp::Solver::hasStopConflict ( ) const
inline

Here is the call graph for this function:

bool Clasp::Solver::hasWatch ( Literal  p,
Constraint c 
) const

Returns true if the constraint c watches the literal p.

Here is the call graph for this function:

bool Clasp::Solver::hasWatch ( Literal  p,
ClauseHead c 
) const

Here is the call graph for this function:

const Heuristic& Clasp::Solver::heuristic ( ) const
inline
Heuristic& Clasp::Solver::heuristic ( )
inline
uint32 Clasp::Solver::id ( ) const
inline
uint32 Clasp::Solver::inDegree ( WeightLitVec out)

Computes the number of in-edges for each assigned literal.

Precondition
!hasConflict()
Note
For a literal p assigned on level level(p), only in-edges from levels < level(p) are counted.
Returns
The maximum number of in-edges.

Here is the call graph for this function:

bool Clasp::Solver::isFalse ( Literal  p) const
inline

Returns true if p is false w.r.t the current assignment.

Here is the call graph for this function:

bool Clasp::Solver::isTrue ( Literal  p) const
inline

Returns true if p is true w.r.t the current assignment.

Here is the call graph for this function:

bool Clasp::Solver::learntLimit ( const SearchLimits x) const
inline

Returns true if number of learnts exceeds x.learnts or the soft memory limit is exceeded.

Here is the call graph for this function:

uint32 Clasp::Solver::level ( Var  v) const
inline

Returns the decision level on which v was assigned.

Note
The returned value is only meaningful if value(v) != value_free.

Here is the call graph for this function:

uint32 Clasp::Solver::levelStart ( uint32  dl) const
inline

Returns the starting position of decision level dl in the trail.

Precondition
validLevel(dl)

Here is the call graph for this function:

void Clasp::Solver::markLevel ( uint32  dl)
inline

Here is the call graph for this function:

void Clasp::Solver::markSeen ( Var  v)
inline

Here is the call graph for this function:

void Clasp::Solver::markSeen ( Literal  p)
inline

Here is the call graph for this function:

uint32 Clasp::Solver::numAssignedVars ( ) const
inline

Returns the number of assigned variables.

Here is the call graph for this function:

uint32 Clasp::Solver::numAuxVars ( ) const
inline

Returns the number of active solver-local aux variables.

Here is the call graph for this function:

uint32 Clasp::Solver::numConstraints ( ) const

Number of problem constraints in this solver.

Here is the call graph for this function:

uint32 Clasp::Solver::numFreeVars ( ) const
inline

Returns the number of free variables.

The number of free variables is the number of vars that are neither assigned nor eliminated.

Here is the call graph for this function:

uint32 Clasp::Solver::numLearntConstraints ( ) const
inline

Returns the number of constraints that are currently in the solver's learnt database.

uint32 Clasp::Solver::numProblemVars ( ) const
inline

Returns the number of problem variables.

uint32 Clasp::Solver::numVars ( ) const
inline

Returns the number of solver variables, i.e. numProblemVars() + numAuxVars()

Here is the call graph for this function:

uint32 Clasp::Solver::numWatches ( Literal  p) const

Returns the number of constraints watching the literal p.

Here is the call graph for this function:

void Clasp::Solver::popAuxVar ( uint32  num = UINT32_MAX)

Pops the num most recently added auxiliary variables from this solver.

Here is the call graph for this function:

bool Clasp::Solver::popRootLevel ( uint32  i = 1,
LitVec popped = 0,
bool  aux = true 
)

Moves the root-level i levels up (i.e. towards the top-level).

The function removes all levels between the new root level and the current decision level, resets the current backtrack-level, and re-assigns any implied literals.

Parameters
iNumber of root decisions to pop.
[out]poppedOptional storage for popped root decisions.
filterWhether or not aux variables should be added to popped.
Postcondition
decisionLevel() == rootLevel()
Note
The function first calls clearStopConflict() to remove any stop conflicts.
The function does not propagate any asserted literals. It is the caller's responsibility to call propagate() after the function returned.

Here is the call graph for this function:

ValueSet Clasp::Solver::pref ( Var  v) const
inline

Returns the set of preferred values of v.

Here is the call graph for this function:

bool Clasp::Solver::propagate ( )

Propagates all enqueued literals. If a conflict arises during propagation propagate returns false and the current conflict (as a set of literals) is stored in the solver's conflict variable.

Precondition
!hasConflict()
See also
Solver::force
Solver::assume
Note
Shall not be called recursively.

Here is the call graph for this function:

bool Clasp::Solver::propagateUntil ( PostPropagator p)
inline

Does unit propagation and calls x->propagateFixpoint(*this) for all post propagators x up to but not including p.

Note
The function is meant to be called only in the context of p.
Precondition
p is a post propagator of this solver, i.e. was previously added via addPost().
Post propagators are active, i.e. the solver is fully initialized.
Var Clasp::Solver::pushAuxVar ( )

Adds a new auxiliary variable to this solver.

Auxiliary variables are local to one solver and are not considered as part of the problem. They shall be added/used only during solving, i.e. after problem setup is completed.

Here is the call graph for this function:

bool Clasp::Solver::pushRoot ( const LitVec path)

Adds path to the current root-path and adjusts the root-level accordingly.

Here is the call graph for this function:

bool Clasp::Solver::pushRoot ( Literal  p)

Here is the call graph for this function:

void Clasp::Solver::pushRootLevel ( uint32  i = 1)
inline

Moves the root-level i levels down (i.e. away from the top-level).

The root-level is similar to the top-level in that it cannot be undone during search, i.e. the solver will not resolve conflicts that are on or above the root-level.

Here is the call graph for this function:

Var Clasp::Solver::pushTagVar ( bool  pushToRoot)

Requests a special aux variable for tagging conditional knowledge.

Once a tag variable t is set, learnt clauses containing ~t are tagged as "conditional". Conditional clauses are removed once t becomes unassigned or Solver::removeConditional() is called. Furthermore, calling Solver::strengthenConditional() removes ~t from conditional clauses and transforms them to unconditional knowledge.

Note
Typically, the tag variable is a root assumption and hence true during the whole search.

Here is the call graph for this function:

uint32 Clasp::Solver::queueSize ( ) const
inline

Returns the number of (unprocessed) literals in the propagation queue.

Here is the call graph for this function:

const Antecedent& Clasp::Solver::reason ( Literal  p) const
inline

Returns the reason for p being true.

Precondition
p is true w.r.t the current assignment

Here is the call graph for this function:

void Clasp::Solver::reason ( Literal  p,
LitVec out 
)
inline

Returns the reason for p being true as a set of literals.

Here is the call graph for this function:

uint32 Clasp::Solver::reasonData ( Literal  p) const
inline

Returns the additional reason data associated with p.

Here is the call graph for this function:

uint32 Clasp::Solver::receive ( SharedLiterals **  out,
uint32  maxOut 
) const

Tries to receive at most maxOut clauses.

The function queries the distributor object for new clauses to be delivered to this solver. Clauses are stored in out.

Returns
The number of clauses received.

Here is the call graph for this function:

Solver::DBInfo Clasp::Solver::reduceLearnts ( float  remMax,
const ReduceStrategy rs = ReduceStrategy() 
)

Removes upto remMax percent of the learnt nogoods.

Parameters
remMaxFraction of nogoods to remove ([0.0,1.0]).
rsStrategy to apply during nogood deletion.
Returns
The number of locked and active/glue clauses currently exempt from deletion.
Note
Nogoods that are the reason for a literal to be in the assignment are said to be locked and won't be removed.

Here is the call graph for this function:

void Clasp::Solver::removeConditional ( )

Removes all conditional knowledge, i.e. all previously tagged learnt clauses.

See also
Solver::pushTagVar()

Here is the call graph for this function:

void Clasp::Solver::removePost ( PostPropagator p)
inline

Removes p from the solver's list of post propagators.

Note
The function shall not be called during propagation of any other post propagator.
bool Clasp::Solver::removeUndoWatch ( uint32  dl,
Constraint c 
)

Removes c from the watch-list of the decision level dl.

Here is the call graph for this function:

void Clasp::Solver::removeWatch ( const Literal p,
Constraint c 
)

Removes c from p's watch-list.

Postcondition
hasWatch(p, c) == false

Here is the call graph for this function:

void Clasp::Solver::removeWatch ( const Literal p,
ClauseHead c 
)

Here is the call graph for this function:

void Clasp::Solver::requestData ( Var  v)
inline

Request additional reason data slot for variable v.

Here is the call graph for this function:

bool Clasp::Solver::resolveConflict ( )

Resolves the active conflict using the selected strategy.

If the SearchStrategy is set to learning, resolveConflict implements First-UIP learning and backjumping. Otherwise, it simply applies chronological backtracking.

Precondition
hasConflict()
Returns
  • true if the conflict was successfully resolved
  • false otherwise
Note
If decisionLevel() == rootLevel() false is returned.

Here is the call graph for this function:

void Clasp::Solver::restart ( )
inline

Returns to the maximum of rootLevel() and backtrackLevel() and increases the number of restarts.

Here is the call graph for this function:

uint32 Clasp::Solver::rootLevel ( ) const
inline

Returns the current root level.

SatPreprocessor * Clasp::Solver::satPrepro ( ) const

Returns a pointer to the sat-preprocessor used by this solver.

Here is the call graph for this function:

ValueRep Clasp::Solver::search ( SearchLimits limit,
double  randf = 0.0 
)

Searches for a model as long as the given limit is not reached.

The search function implements the CDNL-algorithm. It searches for a model as long as none of the limits given by limit is reached. The limits are updated during search.

Parameters
limitImposed limit on conflicts and number of learnt constraints.
randfPick next decision variable randomly with a probability of randf.
Returns
  • value_true: if a model was found.
  • value_false: if the problem is unsatisfiable (under assumptions, if any).
  • value_free: if search was stopped because limit was reached.
Note
search treats the root level as top-level, i.e. it will never backtrack below that level.

Here is the call graph for this function:

ValueRep Clasp::Solver::search ( uint64  maxC,
uint32  maxL,
bool  local = false,
double  rp = 0.0 
)
inline

Here is the call graph for this function:

const SolveParams & Clasp::Solver::searchConfig ( ) const

Returns the solve parameters for this object.

Here is the call graph for this function:

bool Clasp::Solver::seen ( Var  v) const
inline

Returns true if v is currently marked as seen.

Note: variables assigned on level 0 are always marked.

Here is the call graph for this function:

bool Clasp::Solver::seen ( Literal  p) const
inline

Returns true if the literal p is currently marked as seen.

Here is the call graph for this function:

void Clasp::Solver::setBacktrackLevel ( uint32  dl)
inline

Sets the backtracking level to dl.

Here is the call graph for this function:

void Clasp::Solver::setEnumerationConstraint ( Constraint c)

Here is the call graph for this function:

void Clasp::Solver::setPref ( Var  v,
ValueSet::Value  which,
ValueRep  to 
)
inline

Here is the call graph for this function:

bool Clasp::Solver::setReason ( Literal  p,
const Antecedent x,
uint32  data = UINT32_MAX 
)
inline

Updates the reason for p being tue.

Precondition
p is true and x is a valid reason for p

Here is the call graph for this function:

void Clasp::Solver::setStopConflict ( )

Sets a conflict that forces the solver to terminate its search.

Precondition
!hasConflict()
Postcondition
hasConflict()
Note
To prevent the solver from resolving the stop conflict, the function sets the root level to the current decision level. Call clearStopConflict() to remove the conflict and to restore the previous root-level.

Here is the call graph for this function:

const SharedContext* Clasp::Solver::sharedContext ( ) const
inline

Returns a pointer to the shared context object of this solver.

void Clasp::Solver::shuffleOnNextSimplify ( )
inline

Shuffle constraints upon next simplification.

bool Clasp::Solver::simplify ( )

If called on top-level, removes SAT-clauses + Constraints for which Constraint::simplify returned true.

Note
If this method is called on a decision-level > 0, it is a noop and will simply return true.
Returns
false, if a top-level conflict is detected. Otherwise, true.

Here is the call graph for this function:

uint32 Clasp::Solver::simplifyConflictClause ( LitVec cc,
ClauseInfo info,
ClauseHead rhs 
)

simplifies cc and returns finalizeConflictClause(cc, info);

Here is the call graph for this function:

bool Clasp::Solver::split ( LitVec out)

Tries to split-off disjoint work from the solver's currrent guiding path and returns it in out.

Returns
splittable()

Here is the call graph for this function:

bool Clasp::Solver::splittable ( ) const

Returns whether the solver can split-off work.

Here is the call graph for this function:

void Clasp::Solver::strengthenConditional ( )

Resolves all tagged clauses with the tag literal and thereby strengthens the learnt db.

See also
Solver::pushTagVar()

Here is the call graph for this function:

const SymbolTable& Clasp::Solver::symbolTable ( ) const
inline

Here is the call graph for this function:

const LitVec& Clasp::Solver::symmetric ( ) const
inline

Returns the set of eliminated literals that are unconstraint w.r.t the last model.

Literal Clasp::Solver::tagLiteral ( ) const
inline
bool Clasp::Solver::test ( Literal  p,
PostPropagator c 
)

Executes a one-step lookahead on p.

Assumes p and propagates this assumption. If propagations leads to a conflict, false is returned. Otherwise the assumption is undone and the function returns true.

Parameters
pThe literal to test.
cThe constraint that wants to test p (can be 0).
Precondition
p is free
Note
If c is not null and testing p does not lead to a conflict, c->undoLevel() is called before p is undone. Hence, the range [s.levelStart(s.decisionLevel()), s.assignment().size()) contains p followed by all literals that were forced because of p.
propagateUntil(c) is used to propagate p.

Here is the call graph for this function:

ValueRep Clasp::Solver::topValue ( Var  v) const
inline

Returns the value of v w.r.t the top level.

Here is the call graph for this function:

const LitVec& Clasp::Solver::trail ( ) const
inline

Returns the current (partial) assignment as a set of true literals.

Note
Although the special var 0 always has a value it is not considered to be part of the assignment.
Literal Clasp::Solver::trueLit ( Var  v) const
inline

Returns the literal of v being true in the current assignment.

Precondition
v is assigned a value in the current assignment

Here is the call graph for this function:

void Clasp::Solver::undoUntil ( uint32  dl)

Undoes all assignments up to (but not including) decision level dl.

Precondition
dl > 0 (assignments made on decision level 0 cannot be undone)
Postcondition
decisionLevel == max(min(decisionLevel(), dl), max(rootLevel(), btLevel))

Here is the call graph for this function:

uint32 Clasp::Solver::undoUntil ( uint32  dl,
bool  popBtLevel 
)

Similar to undoUntil but optionally also pops the backtrack-level to dl if possible.

Returns
The current decision level.

Here is the call graph for this function:

void Clasp::Solver::unfreezeLevel ( uint32  dl)
inline

Here is the call graph for this function:

void Clasp::Solver::unmarkLevel ( uint32  dl)
inline

Here is the call graph for this function:

uint32 Clasp::Solver::updateLearnt ( Literal  p,
const Literal first,
const Literal last,
uint32  cLbd,
bool  forceUp = false 
)
inline

Computes a new lbd for the antecedent of p given as the range [first, last).

Parameters
pA literal implied by [first, last)
[first,last)The literals of a learnt nogood implying p.
cLbdThe current lbd of the learnt nogood.
Returns
The new lbd of the learnt nogood.
Note
If SolverStrategies::bumpVarAct is active, p's activity is increased if the new lbd is smaller than the lbd of the conflict clause that is currently being derived.

Here is the call graph for this function:

bool Clasp::Solver::validLevel ( uint32  dl) const
inline

Here is the call graph for this function:

bool Clasp::Solver::validVar ( Var  var) const
inline

Returns true if var represents a valid variable in this solver.

Here is the call graph for this function:

ValueRep Clasp::Solver::value ( Var  v) const
inline

Returns the value of v w.r.t the current assignment.

Here is the call graph for this function:

VarInfo Clasp::Solver::varInfo ( Var  v) const
inline

Here is the call graph for this function:

Friends And Related Function Documentation

friend class SharedContext
friend

Member Data Documentation

ValueVec Clasp::Solver::model

Stores the last model (if any).

RNG Clasp::Solver::rng

Random number generator for this object.

SolverStats Clasp::Solver::stats

Stores statistics about the solving process.

SolverStrategies Clasp::Solver::strategy

Strategies used by this object.


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