conflict-driven clause learning with two watched literals, the free variables by activity in a Heap of pairs \( ( \mathit{activity} , v ) \), the largest on top: std::priority_queue by default, or a heap of Boost or of ADS [see DaryHeap.h], with the same decisions and conflicts, since the pairs are ordered totally
More...
#include <ADS/backtrack/SatSolvers.h>
|
| | BasicCdcl (const Cnf &F, int n) |
| | the solver of the formula \( F \) of \( n \) variables, its clauses with the repeated literals merged and the tautologies dropped, and its unit clauses assigned at the level 0
|
| Result | solve (long maxConflicts=-1) |
| | the search, UNKNOWN after maxConflicts conflicts if that is \( \ge 0 \)
|
| const std::vector< bool > & | model (void) const |
| | the model found by solve()
|
| long | conflicts (void) const |
| | the conflicts met so far
|
| long | decisions (void) const |
| | the decisions taken so far
|
template<class Heap = std::priority_queue< std::pair< double , int > >>
class ADS::BasicCdcl< Heap >
conflict-driven clause learning with two watched literals, the free variables by activity in a Heap of pairs \( ( \mathit{activity} , v ) \), the largest on top: std::priority_queue by default, or a heap of Boost or of ADS [see DaryHeap.h], with the same decisions and conflicts, since the pairs are ordered totally
◆ Result
template<class Heap = std::priority_queue< std::pair< double , int > >>
the outcome of solve()
| Enumerator |
|---|
| SAT | a model found, in model()
|
| UNSAT | the formula is unsatisfiable
|
| UNKNOWN | the conflicts allowed are over before an answer
|
◆ BasicCdcl()
template<class Heap = std::priority_queue< std::pair< double , int > >>
the solver of the formula \( F \) of \( n \) variables, its clauses with the repeated literals merged and the tautologies dropped, and its unit clauses assigned at the level 0
- Precondition
- \( n \ge 0 \) and the literals of \( F \) are variables of \( [ 0 , n ) \)
◆ conflicts()
template<class Heap = std::priority_queue< std::pair< double , int > >>
◆ decisions()
template<class Heap = std::priority_queue< std::pair< double , int > >>
the decisions taken so far
◆ model()
template<class Heap = std::priority_queue< std::pair< double , int > >>
| const std::vector< bool > & ADS::BasicCdcl< Heap >::model |
( |
void | | ) |
const |
|
nodiscard |
◆ solve()
template<class Heap = std::priority_queue< std::pair< double , int > >>
the search, UNKNOWN after maxConflicts conflicts if that is \( \ge 0 \)
In pseudocode (conflict-driven clause learning, beyond the book, after Marques-Silva and Sakallah and after Chaff), the trail the literals assigned in order, each with its level and its reason, the clause that forced it:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{solve}( \mathit{maxConflicts} ) \cr
2 & \quad \textbf{if}\ F \text{ has an empty clause }\ \textbf{then
return}\ \text{UNSAT} \cr
3 & \quad \textbf{loop} \cr
4 & \qquad \kappa \gets \mathrm{propagate}() \cr
5 & \qquad \textbf{if}\ \kappa \ne \textbf{nil}\ \textbf{then}\quad
\triangleright\ \text{a conflict} \cr
6 & \qquad\quad \textbf{if}\ \text{the level is } 0\ \textbf{then
return}\ \text{UNSAT} \cr
7 & \qquad\quad ( C , b ) \gets \mathrm{analyze}( \kappa );
\ \text{cancel the levels above } b \cr
8 & \qquad\quad \text{assign the first literal of } C \text{, with}
\text{ the reason } C \text{ if } |C| > 1 \cr
9 & \qquad\quad \textbf{if}\ \text{the conflicts are }
\mathit{maxConflicts}\ \textbf{then return}\ \text{UNKNOWN} \cr
10 & \qquad\quad \textbf{if}\ \text{the budget is over }
\ \textbf{then}\ \text{cancel the levels above } 0;
\ \text{the budget } 100\, \mathrm{luby}( k ) \text{ for the }
k \text{-th restart} \cr
11 & \qquad \textbf{else} \cr
12 & \qquad\quad v \gets \text{the free variable of largest activity}
\cr
13 & \qquad\quad \textbf{if}\ v = \textbf{nil}\ \textbf{then return}
\ \text{SAT} \cr
14 & \qquad\quad \text{open a level and give } v \text{ its saved}
\text{ phase} \cr
15 & \textbf{function}\ \mathrm{propagate}() \cr
16 & \quad \textbf{foreach}\ \ell \text{ of the trail not}
\text{ propagated yet}\ \textbf{do} \cr
17 & \qquad \textbf{foreach}\ c \text{ watching } \lnot \ell
\ \textbf{do}\quad \triangleright\ \lnot \ell \text{ now false} \cr
18 & \qquad\quad \textbf{if}\ \text{the other watch of } c \text{ is}
\text{ true }\ \textbf{then continue} \cr
19 & \qquad\quad \textbf{if}\ \text{a literal of } c \text{ not}
\text{ watched is not false }\ \textbf{then}\ \text{watch it}
\text{ instead};\ \textbf{continue} \cr
20 & \qquad\quad \textbf{if}\ \text{the other watch is false }
\ \textbf{then return}\ c \cr
21 & \qquad\quad \text{assign the other watch, with the reason } c \cr
22 & \quad \textbf{return nil} \cr
23 & \textbf{function}\ \mathrm{analyze}( \kappa ) \cr
24 & \quad C \gets ();\ P \gets 0 \cr
25 & \quad \textbf{repeat} \cr
26 & \qquad \textbf{foreach}\ q \in \kappa \text{, but the literal}
\text{ resolved on, of a variable } v \text{ not seen, of a level}
\text{ above } 0\ \textbf{do} \cr
27 & \qquad\quad \text{mark } v \text{ as seen and raise its}
\text{ activity} \cr
28 & \qquad\quad \textbf{if}\ v \text{ is of the current level }
\ \textbf{then}\ P \gets P + 1\ \textbf{else}\ \text{append } q
\text{ to } C \cr
29 & \qquad p \gets \text{the last literal of the trail whose variable}
\text{ is seen};\ \kappa \gets \text{its reason};\ P \gets P - 1
\cr
30 & \quad \textbf{until}\ P = 0\quad \triangleright\ p \text{ is}
\text{ the first unique implication point} \cr
31 & \quad \textbf{return}\ ( \lnot p \cdot C , \text{the largest}
\text{ level of } C \text{, } 0 \text{ if } C = () )
\end{array}}
\]
- Postcondition
- SAT means that model() passes satCertificate()
The documentation for this class was generated from the following file: