yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Minisat::Solver Class Reference

#include <Solver.h>

+ Inheritance diagram for Minisat::Solver:
+ Collaboration diagram for Minisat::Solver:

Data Structures

struct  ShrinkStackElem
 
struct  VarData
 
struct  VarOrderLt
 
struct  Watcher
 
struct  WatcherDeleted
 

Public Member Functions

 Solver ()
 
virtual ~Solver ()
 
Var newVar (lbool upol=l_Undef, bool dvar=true)
 
void releaseVar (Lit l)
 
bool addClause (const vec< Lit > &ps)
 
bool addEmptyClause ()
 
bool addClause (Lit p)
 
bool addClause (Lit p, Lit q)
 
bool addClause (Lit p, Lit q, Lit r)
 
bool addClause (Lit p, Lit q, Lit r, Lit s)
 
bool addClause_ (vec< Lit > &ps)
 
bool simplify ()
 
bool solve (const vec< Lit > &assumps)
 
lbool solveLimited (const vec< Lit > &assumps)
 
bool solve ()
 
bool solve (Lit p)
 
bool solve (Lit p, Lit q)
 
bool solve (Lit p, Lit q, Lit r)
 
bool okay () const
 
bool implies (const vec< Lit > &assumps, vec< Lit > &out)
 
ClauseIterator clausesBegin () const
 
ClauseIterator clausesEnd () const
 
TrailIterator trailBegin () const
 
TrailIterator trailEnd () const
 
void toDimacs (FILE *f, const vec< Lit > &assumps)
 
void toDimacs (const char *file, const vec< Lit > &assumps)
 
void toDimacs (FILE *f, Clause &c, vec< Var > &map, Var &max)
 
void toDimacs (const char *file)
 
void toDimacs (const char *file, Lit p)
 
void toDimacs (const char *file, Lit p, Lit q)
 
void toDimacs (const char *file, Lit p, Lit q, Lit r)
 
void setPolarity (Var v, lbool b)
 
void setDecisionVar (Var v, bool b)
 
lbool value (Var x) const
 
lbool value (Lit p) const
 
lbool modelValue (Var x) const
 
lbool modelValue (Lit p) const
 
int nAssigns () const
 
int nClauses () const
 
int nLearnts () const
 
int nVars () const
 
int nFreeVars () const
 
void printStats () const
 
void setConfBudget (int64_t x)
 
void setPropBudget (int64_t x)
 
void budgetOff ()
 
void interrupt ()
 
void clearInterrupt ()
 
virtual void garbageCollect ()
 
void checkGarbage (double gf)
 
void checkGarbage ()
 

Data Fields

vec< lboolmodel
 
LSet conflict
 
int verbosity
 
double var_decay
 
double clause_decay
 
double random_var_freq
 
double random_seed
 
bool luby_restart
 
int ccmin_mode
 
int phase_saving
 
bool rnd_pol
 
bool rnd_init_act
 
double garbage_frac
 
int min_learnts_lim
 
int restart_first
 
double restart_inc
 
double learntsize_factor
 
double learntsize_inc
 
int learntsize_adjust_start_confl
 
double learntsize_adjust_inc
 
uint64_t solves
 
uint64_t starts
 
uint64_t decisions
 
uint64_t rnd_decisions
 
uint64_t propagations
 
uint64_t conflicts
 
uint64_t dec_vars
 
uint64_t num_clauses
 
uint64_t num_learnts
 
uint64_t clauses_literals
 
uint64_t learnts_literals
 
uint64_t max_literals
 
uint64_t tot_literals
 

Protected Member Functions

void insertVarOrder (Var x)
 
Lit pickBranchLit ()
 
void newDecisionLevel ()
 
void uncheckedEnqueue (Lit p, CRef from=CRef_Undef)
 
bool enqueue (Lit p, CRef from=CRef_Undef)
 
CRef propagate ()
 
void cancelUntil (int level)
 
void analyze (CRef confl, vec< Lit > &out_learnt, int &out_btlevel)
 
void analyzeFinal (Lit p, LSet &out_conflict)
 
bool litRedundant (Lit p)
 
lbool search (int nof_conflicts)
 
lbool solve_ ()
 
void reduceDB ()
 
void removeSatisfied (vec< CRef > &cs)
 
void rebuildOrderHeap ()
 
void varDecayActivity ()
 
void varBumpActivity (Var v, double inc)
 
void varBumpActivity (Var v)
 
void claDecayActivity ()
 
void claBumpActivity (Clause &c)
 
void attachClause (CRef cr)
 
void detachClause (CRef cr, bool strict=false)
 
void removeClause (CRef cr)
 
bool isRemoved (CRef cr) const
 
bool locked (const Clause &c) const
 
bool satisfied (const Clause &c) const
 
int decisionLevel () const
 
uint32_t abstractLevel (Var x) const
 
CRef reason (Var x) const
 
int level (Var x) const
 
double progressEstimate () const
 
bool withinBudget () const
 
void relocAll (ClauseAllocator &to)
 

Static Protected Member Functions

static VarData mkVarData (CRef cr, int l)
 
static double drand (double &seed)
 
static int irand (double &seed, int size)
 

Protected Attributes

vec< CRefclauses
 
vec< CReflearnts
 
vec< Littrail
 
vec< int > trail_lim
 
vec< Litassumptions
 
VMap< double > activity
 
VMap< lboolassigns
 
VMap< char > polarity
 
VMap< lbooluser_pol
 
VMap< char > decision
 
VMap< VarDatavardata
 
OccLists< Lit, vec< Watcher >
, WatcherDeleted, MkIndexLit
watches
 
Heap< Var, VarOrderLtorder_heap
 
bool ok
 
double cla_inc
 
double var_inc
 
int qhead
 
int simpDB_assigns
 
int64_t simpDB_props
 
double progress_estimate
 
bool remove_satisfied
 
Var next_var
 
ClauseAllocator ca
 
vec< Varreleased_vars
 
vec< Varfree_vars
 
VMap< char > seen
 
vec< ShrinkStackElemanalyze_stack
 
vec< Litanalyze_toclear
 
vec< Litadd_tmp
 
double max_learnts
 
double learntsize_adjust_confl
 
int learntsize_adjust_cnt
 
int64_t conflict_budget
 
int64_t propagation_budget
 
bool asynch_interrupt
 

Detailed Description

Definition at line 37 of file Solver.h.

Constructor & Destructor Documentation

Solver::Solver ( )

Definition at line 56 of file Solver.cc.

56  :
57 
58  // Parameters (user settable):
59  //
60  verbosity (0)
68  , rnd_pol (false)
74 
75  // Parameters (the rest):
76  //
77  , learntsize_factor((double)1/(double)3), learntsize_inc(1.1)
78 
79  // Parameters (experimental):
80  //
82  , learntsize_adjust_inc (1.5)
83 
84  // Statistics: (formerly in 'SolverStats')
85  //
88 
89  , watches (WatcherDeleted(ca))
90  , order_heap (VarOrderLt(activity))
91  , ok (true)
92  , cla_inc (1)
93  , var_inc (1)
94  , qhead (0)
95  , simpDB_assigns (-1)
96  , simpDB_props (0)
97  , progress_estimate (0)
98  , remove_satisfied (true)
99  , next_var (0)
100 
101  // Resource constraints:
102  //
103  , conflict_budget (-1)
104  , propagation_budget (-1)
105  , asynch_interrupt (false)
106 {}
static DoubleOption opt_garbage_frac(_cat,"gc-frac","The fraction of wasted memory allowed before a garbage collection is triggered", 0.20, DoubleRange(0, false, HUGE_VAL, false))
double clause_decay
Definition: Solver.h:130
double learntsize_inc
Definition: Solver.h:144
ClauseAllocator ca
Definition: Solver.h:216
bool luby_restart
Definition: Solver.h:133
static IntOption opt_phase_saving(_cat,"phase-saving","Controls the level of phase saving (0=none, 1=limited, 2=full)", 2, IntRange(0, 2))
int restart_first
Definition: Solver.h:141
static DoubleOption opt_random_seed(_cat,"rnd-seed","Used by the random variable selection", 91648253, DoubleRange(0, false, HUGE_VAL, false))
double learntsize_adjust_inc
Definition: Solver.h:147
uint64_t num_clauses
Definition: Solver.h:152
double learntsize_factor
Definition: Solver.h:143
int min_learnts_lim
Definition: Solver.h:139
int ccmin_mode
Definition: Solver.h:134
double cla_inc
Definition: Solver.h:208
int learntsize_adjust_start_confl
Definition: Solver.h:146
uint64_t starts
Definition: Solver.h:151
int64_t conflict_budget
Definition: Solver.h:235
static DoubleOption opt_random_var_freq(_cat,"rnd-freq","The frequency with which the decision heuristic tries to choose a random variable", 0, DoubleRange(0, true, 1, true))
uint64_t dec_vars
Definition: Solver.h:152
static BoolOption opt_luby_restart(_cat,"luby","Use the Luby restart sequence", true)
static DoubleOption opt_var_decay(_cat,"var-decay","The variable activity decay factor", 0.95, DoubleRange(0, false, 1, false))
uint64_t learnts_literals
Definition: Solver.h:152
static BoolOption opt_rnd_init_act(_cat,"rnd-init","Randomize the initial activity", false)
bool asynch_interrupt
Definition: Solver.h:237
uint64_t decisions
Definition: Solver.h:151
double random_var_freq
Definition: Solver.h:131
uint64_t num_learnts
Definition: Solver.h:152
double progress_estimate
Definition: Solver.h:213
uint64_t clauses_literals
Definition: Solver.h:152
static DoubleOption opt_clause_decay(_cat,"cla-decay","The clause activity decay factor", 0.999, DoubleRange(0, false, 1, false))
double garbage_frac
Definition: Solver.h:138
int phase_saving
Definition: Solver.h:135
bool rnd_init_act
Definition: Solver.h:137
Heap< Var, VarOrderLt > order_heap
Definition: Solver.h:205
int64_t propagation_budget
Definition: Solver.h:236
VMap< double > activity
Definition: Solver.h:196
uint64_t propagations
Definition: Solver.h:151
static IntOption opt_restart_first(_cat,"rfirst","The base restart interval", 100, IntRange(1, INT32_MAX))
int simpDB_assigns
Definition: Solver.h:211
static DoubleOption opt_restart_inc(_cat,"rinc","Restart interval increase factor", 2, DoubleRange(1, false, HUGE_VAL, false))
double var_decay
Definition: Solver.h:129
uint64_t solves
Definition: Solver.h:151
double restart_inc
Definition: Solver.h:142
uint64_t max_literals
Definition: Solver.h:152
int64_t simpDB_props
Definition: Solver.h:212
double var_inc
Definition: Solver.h:209
static IntOption opt_min_learnts_lim(_cat,"min-learnts","Minimum learnt clause limit", 0, IntRange(0, INT32_MAX))
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203
uint64_t rnd_decisions
Definition: Solver.h:151
double random_seed
Definition: Solver.h:132
static IntOption opt_ccmin_mode(_cat,"ccmin-mode","Controls conflict clause minimization (0=none, 1=basic, 2=deep)", 2, IntRange(0, 2))
uint64_t conflicts
Definition: Solver.h:151
uint64_t tot_literals
Definition: Solver.h:152
bool remove_satisfied
Definition: Solver.h:214
bool rnd_pol
Definition: Solver.h:136
Solver::~Solver ( )
virtual

Definition at line 109 of file Solver.cc.

110 {
111 }

Member Function Documentation

uint32_t Minisat::Solver::abstractLevel ( Var  x) const
inlineprotected

Definition at line 349 of file Solver.h.

349 { return 1 << (level(x) & 31); }
int level(Var x) const
Definition: Solver.h:304

+ Here is the call graph for this function:

bool Minisat::Solver::addClause ( const vec< Lit > &  ps)
inline

Definition at line 337 of file Solver.h.

337 { ps.copyTo(add_tmp); return addClause_(add_tmp); }
void copyTo(vec< T > &copy) const
Definition: Vec.h:92
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Minisat::Solver::addClause ( Lit  p)
inline

Definition at line 339 of file Solver.h.

339 { add_tmp.clear(); add_tmp.push(p); return addClause_(add_tmp); }
void push(void)
Definition: Vec.h:74
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
void clear(bool dealloc=false)
Definition: Vec.h:125
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

bool Minisat::Solver::addClause ( Lit  p,
Lit  q 
)
inline

Definition at line 340 of file Solver.h.

340 { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp); }
void push(void)
Definition: Vec.h:74
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
void clear(bool dealloc=false)
Definition: Vec.h:125
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

bool Minisat::Solver::addClause ( Lit  p,
Lit  q,
Lit  r 
)
inline

Definition at line 341 of file Solver.h.

341 { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
void push(void)
Definition: Vec.h:74
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
void clear(bool dealloc=false)
Definition: Vec.h:125
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

bool Minisat::Solver::addClause ( Lit  p,
Lit  q,
Lit  r,
Lit  s 
)
inline

Definition at line 342 of file Solver.h.

342 { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); add_tmp.push(s); return addClause_(add_tmp); }
void push(void)
Definition: Vec.h:74
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
void clear(bool dealloc=false)
Definition: Vec.h:125
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

bool Solver::addClause_ ( vec< Lit > &  ps)

Definition at line 156 of file Solver.cc.

157 {
158  assert(decisionLevel() == 0);
159  if (!ok) return false;
160 
161  // Check if clause is satisfied and remove false/duplicate literals:
162  sort(ps);
163  Lit p; int i, j;
164  for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
165  if (value(ps[i]) == l_True || ps[i] == ~p)
166  return true;
167  else if (value(ps[i]) != l_False && ps[i] != p)
168  ps[j++] = p = ps[i];
169  ps.shrink(i - j);
170 
171  if (ps.size() == 0)
172  return ok = false;
173  else if (ps.size() == 1){
174  uncheckedEnqueue(ps[0]);
175  return ok = (propagate() == CRef_Undef);
176  }else{
177  CRef cr = ca.alloc(ps, false);
178  clauses.push(cr);
179  attachClause(cr);
180  }
181 
182  return true;
183 }
RegionAllocator< uint32_t >::Ref CRef
Definition: SolverTypes.h:137
const lbool l_False((uint8_t) 1)
ClauseAllocator ca
Definition: Solver.h:216
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
void shrink(Size nelems)
Definition: Vec.h:65
void attachClause(CRef cr)
Definition: Solver.cc:186
const CRef CRef_Undef
Definition: SolverTypes.h:225
int decisionLevel() const
Definition: Solver.h:348
vec< CRef > clauses
Definition: Solver.h:190
void push(void)
Definition: Vec.h:74
Size size(void) const
Definition: Vec.h:64
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350
CRef alloc(const vec< Lit > &ps, bool learnt=false)
Definition: SolverTypes.h:245
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cc:488
const Lit lit_Undef
Definition: SolverTypes.h:77
CRef propagate()
Definition: Solver.cc:508

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Minisat::Solver::addEmptyClause ( )
inline

Definition at line 338 of file Solver.h.

338 { add_tmp.clear(); return addClause_(add_tmp); }
bool addClause_(vec< Lit > &ps)
Definition: Solver.cc:156
void clear(bool dealloc=false)
Definition: Vec.h:125
vec< Lit > add_tmp
Definition: Solver.h:227

+ Here is the call graph for this function:

void Solver::analyze ( CRef  confl,
vec< Lit > &  out_learnt,
int &  out_btlevel 
)
protected

Definition at line 298 of file Solver.cc.

299 {
300  int pathC = 0;
301  Lit p = lit_Undef;
302 
303  // Generate conflict clause:
304  //
305  out_learnt.push(); // (leave room for the asserting literal)
306  int index = trail.size() - 1;
307 
308  do{
309  assert(confl != CRef_Undef); // (otherwise should be UIP)
310  Clause& c = ca[confl];
311 
312  if (c.learnt())
313  claBumpActivity(c);
314 
315  for (int j = (p == lit_Undef) ? 0 : 1; j < c.size(); j++){
316  Lit q = c[j];
317 
318  if (!seen[var(q)] && level(var(q)) > 0){
319  varBumpActivity(var(q));
320  seen[var(q)] = 1;
321  if (level(var(q)) >= decisionLevel())
322  pathC++;
323  else
324  out_learnt.push(q);
325  }
326  }
327 
328  // Select next clause to look at:
329  while (!seen[var(trail[index--])]);
330  p = trail[index+1];
331  confl = reason(var(p));
332  seen[var(p)] = 0;
333  pathC--;
334 
335  }while (pathC > 0);
336  out_learnt[0] = ~p;
337 
338  // Simplify conflict clause:
339  //
340  int i, j;
341  out_learnt.copyTo(analyze_toclear);
342  if (ccmin_mode == 2){
343  for (i = j = 1; i < out_learnt.size(); i++)
344  if (reason(var(out_learnt[i])) == CRef_Undef || !litRedundant(out_learnt[i]))
345  out_learnt[j++] = out_learnt[i];
346 
347  }else if (ccmin_mode == 1){
348  for (i = j = 1; i < out_learnt.size(); i++){
349  Var x = var(out_learnt[i]);
350 
351  if (reason(x) == CRef_Undef)
352  out_learnt[j++] = out_learnt[i];
353  else{
354  Clause& c = ca[reason(var(out_learnt[i]))];
355  for (int k = 1; k < c.size(); k++)
356  if (!seen[var(c[k])] && level(var(c[k])) > 0){
357  out_learnt[j++] = out_learnt[i];
358  break; }
359  }
360  }
361  }else
362  i = j = out_learnt.size();
363 
364  max_literals += out_learnt.size();
365  out_learnt.shrink(i - j);
366  tot_literals += out_learnt.size();
367 
368  // Find correct backtrack level:
369  //
370  if (out_learnt.size() == 1)
371  out_btlevel = 0;
372  else{
373  int max_i = 1;
374  // Find the first literal assigned at the next-highest level:
375  for (int i = 2; i < out_learnt.size(); i++)
376  if (level(var(out_learnt[i])) > level(var(out_learnt[max_i])))
377  max_i = i;
378  // Swap-in this literal at index 1:
379  Lit p = out_learnt[max_i];
380  out_learnt[max_i] = out_learnt[1];
381  out_learnt[1] = p;
382  out_btlevel = level(var(p));
383  }
384 
385  for (int j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0; // ('seen[]' is now cleared)
386 }
ClauseAllocator ca
Definition: Solver.h:216
CRef reason(Var x) const
Definition: Solver.h:303
int level(Var x) const
Definition: Solver.h:304
void shrink(Size nelems)
Definition: Vec.h:65
int var(Lit p)
Definition: SolverTypes.h:67
void claBumpActivity(Clause &c)
Definition: Solver.h:323
int ccmin_mode
Definition: Solver.h:134
unsigned learnt
Definition: SolverTypes.h:143
void copyTo(vec< T > &copy) const
Definition: Vec.h:92
bool litRedundant(Lit p)
Definition: Solver.cc:390
const CRef CRef_Undef
Definition: SolverTypes.h:225
int decisionLevel() const
Definition: Solver.h:348
void push(void)
Definition: Vec.h:74
Size size(void) const
Definition: Vec.h:64
vec< Lit > analyze_toclear
Definition: Solver.h:226
VMap< char > seen
Definition: Solver.h:224
int Var
Definition: SolverTypes.h:43
const Lit lit_Undef
Definition: SolverTypes.h:77
vec< Lit > trail
Definition: Solver.h:192
uint64_t max_literals
Definition: Solver.h:152
void varBumpActivity(Var v, double inc)
Definition: Solver.h:311
uint64_t tot_literals
Definition: Solver.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::analyzeFinal ( Lit  p,
LSet out_conflict 
)
protected

Definition at line 458 of file Solver.cc.

459 {
460  out_conflict.clear();
461  out_conflict.insert(p);
462 
463  if (decisionLevel() == 0)
464  return;
465 
466  seen[var(p)] = 1;
467 
468  for (int i = trail.size()-1; i >= trail_lim[0]; i--){
469  Var x = var(trail[i]);
470  if (seen[x]){
471  if (reason(x) == CRef_Undef){
472  assert(level(x) > 0);
473  out_conflict.insert(~trail[i]);
474  }else{
475  Clause& c = ca[reason(x)];
476  for (int j = 1; j < c.size(); j++)
477  if (level(var(c[j])) > 0)
478  seen[var(c[j])] = 1;
479  }
480  seen[x] = 0;
481  }
482  }
483 
484  seen[var(p)] = 0;
485 }
ClauseAllocator ca
Definition: Solver.h:216
CRef reason(Var x) const
Definition: Solver.h:303
int level(Var x) const
Definition: Solver.h:304
void insert(K k)
Definition: IntMap.h:84
int var(Lit p)
Definition: SolverTypes.h:67
void clear(bool free=false)
Definition: IntMap.h:67
vec< int > trail_lim
Definition: Solver.h:193
const CRef CRef_Undef
Definition: SolverTypes.h:225
int decisionLevel() const
Definition: Solver.h:348
Size size(void) const
Definition: Vec.h:64
VMap< char > seen
Definition: Solver.h:224
int Var
Definition: SolverTypes.h:43
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::attachClause ( CRef  cr)
protected

Definition at line 186 of file Solver.cc.

186  {
187  const Clause& c = ca[cr];
188  assert(c.size() > 1);
189  watches[~c[0]].push(Watcher(cr, c[1]));
190  watches[~c[1]].push(Watcher(cr, c[0]));
191  if (c.learnt()) num_learnts++, learnts_literals += c.size();
192  else num_clauses++, clauses_literals += c.size();
193 }
ClauseAllocator ca
Definition: Solver.h:216
uint64_t num_clauses
Definition: Solver.h:152
unsigned learnt
Definition: SolverTypes.h:143
uint64_t learnts_literals
Definition: Solver.h:152
uint64_t num_learnts
Definition: Solver.h:152
uint64_t clauses_literals
Definition: Solver.h:152
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203

+ Here is the caller graph for this function:

void Minisat::Solver::budgetOff ( )
inline

Definition at line 373 of file Solver.h.

int64_t conflict_budget
Definition: Solver.h:235
int64_t propagation_budget
Definition: Solver.h:236

+ Here is the caller graph for this function:

void Solver::cancelUntil ( int  level)
protected

Definition at line 233 of file Solver.cc.

233  {
234  if (decisionLevel() > level){
235  for (int c = trail.size()-1; c >= trail_lim[level]; c--){
236  Var x = var(trail[c]);
237  assigns [x] = l_Undef;
238  if (phase_saving > 1 || (phase_saving == 1 && c > trail_lim.last()))
239  polarity[x] = sign(trail[c]);
240  insertVarOrder(x); }
241  qhead = trail_lim[level];
244  } }
int level(Var x) const
Definition: Solver.h:304
void shrink(Size nelems)
Definition: Vec.h:65
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
const lbool l_Undef((uint8_t) 2)
const T & last(void) const
Definition: Vec.h:84
void insertVarOrder(Var x)
Definition: Solver.h:306
vec< int > trail_lim
Definition: Solver.h:193
int decisionLevel() const
Definition: Solver.h:348
VMap< char > polarity
Definition: Solver.h:198
Size size(void) const
Definition: Vec.h:64
int phase_saving
Definition: Solver.h:135
VMap< lbool > assigns
Definition: Solver.h:197
int Var
Definition: SolverTypes.h:43
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Minisat::Solver::checkGarbage ( double  gf)
inline

Definition at line 331 of file Solver.h.

331  {
332  if (ca.wasted() > ca.size() * gf)
333  garbageCollect(); }
ClauseAllocator ca
Definition: Solver.h:216
uint32_t size() const
Definition: SolverTypes.h:263
virtual void garbageCollect()
Definition: Solver.cc:1057
uint32_t wasted() const
Definition: SolverTypes.h:264

+ Here is the call graph for this function:

void Minisat::Solver::checkGarbage ( void  )
inline

Definition at line 330 of file Solver.h.

330 { return checkGarbage(garbage_frac); }
void checkGarbage()
Definition: Solver.h:330
double garbage_frac
Definition: Solver.h:138

+ Here is the caller graph for this function:

void Minisat::Solver::claBumpActivity ( Clause c)
inlineprotected

Definition at line 323 of file Solver.h.

323  {
324  if ( (c.activity() += cla_inc) > 1e20 ) {
325  // Rescale:
326  for (int i = 0; i < learnts.size(); i++)
327  ca[learnts[i]].activity() *= 1e-20;
328  cla_inc *= 1e-20; } }
ClauseAllocator ca
Definition: Solver.h:216
double cla_inc
Definition: Solver.h:208
Size size(void) const
Definition: Vec.h:64
VMap< double > activity
Definition: Solver.h:196
vec< CRef > learnts
Definition: Solver.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Minisat::Solver::claDecayActivity ( )
inlineprotected

Definition at line 322 of file Solver.h.

322 { cla_inc *= (1 / clause_decay); }
double clause_decay
Definition: Solver.h:130
double cla_inc
Definition: Solver.h:208

+ Here is the caller graph for this function:

ClauseIterator Minisat::Solver::clausesBegin ( ) const
inline

Definition at line 390 of file Solver.h.

390 { return ClauseIterator(ca, &clauses[0]); }
ClauseAllocator ca
Definition: Solver.h:216
vec< CRef > clauses
Definition: Solver.h:190
ClauseIterator Minisat::Solver::clausesEnd ( ) const
inline

Definition at line 391 of file Solver.h.

391 { return ClauseIterator(ca, &clauses[clauses.size()]); }
ClauseAllocator ca
Definition: Solver.h:216
vec< CRef > clauses
Definition: Solver.h:190
Size size(void) const
Definition: Vec.h:64

+ Here is the call graph for this function:

void Minisat::Solver::clearInterrupt ( )
inline

Definition at line 372 of file Solver.h.

372 { asynch_interrupt = false; }
bool asynch_interrupt
Definition: Solver.h:237
int Minisat::Solver::decisionLevel ( ) const
inlineprotected

Definition at line 348 of file Solver.h.

348 { return trail_lim.size(); }
vec< int > trail_lim
Definition: Solver.h:193
Size size(void) const
Definition: Vec.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::detachClause ( CRef  cr,
bool  strict = false 
)
protected

Definition at line 196 of file Solver.cc.

196  {
197  const Clause& c = ca[cr];
198  assert(c.size() > 1);
199 
200  // Strict or lazy detaching:
201  if (strict){
202  remove(watches[~c[0]], Watcher(cr, c[1]));
203  remove(watches[~c[1]], Watcher(cr, c[0]));
204  }else{
205  watches.smudge(~c[0]);
206  watches.smudge(~c[1]);
207  }
208 
209  if (c.learnt()) num_learnts--, learnts_literals -= c.size();
210  else num_clauses--, clauses_literals -= c.size();
211 }
ClauseAllocator ca
Definition: Solver.h:216
uint64_t num_clauses
Definition: Solver.h:152
unsigned learnt
Definition: SolverTypes.h:143
uint64_t learnts_literals
Definition: Solver.h:152
uint64_t num_learnts
Definition: Solver.h:152
uint64_t clauses_literals
Definition: Solver.h:152
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203

+ Here is the caller graph for this function:

static double Minisat::Solver::drand ( double &  seed)
inlinestaticprotected

Definition at line 288 of file Solver.h.

288  {
289  seed *= 1389796;
290  int q = (int)(seed / 2147483647);
291  seed -= (double)q * 2147483647;
292  return seed / 2147483647; }

+ Here is the caller graph for this function:

bool Minisat::Solver::enqueue ( Lit  p,
CRef  from = CRef_Undef 
)
inlineprotected

Definition at line 336 of file Solver.h.

336 { return value(p) != l_Undef ? value(p) != l_False : (uncheckedEnqueue(p, from), true); }
const lbool l_False((uint8_t) 1)
const lbool l_Undef((uint8_t) 2)
lbool value(Var x) const
Definition: Solver.h:350
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cc:488

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::garbageCollect ( )
virtual

Reimplemented in Minisat::SimpSolver.

Definition at line 1057 of file Solver.cc.

1058 {
1059  // Initialize the next region to a size corresponding to the estimated utilization degree. This
1060  // is not precise but should avoid some unnecessary reallocations for the new region:
1061  ClauseAllocator to(ca.size() - ca.wasted());
1062 
1063  relocAll(to);
1064  if (verbosity >= 2)
1065  printf("| Garbage collection: %12d bytes => %12d bytes |\n",
1067  to.moveTo(ca);
1068 }
ClauseAllocator ca
Definition: Solver.h:216
void relocAll(ClauseAllocator &to)
Definition: Solver.cc:1010
uint32_t size() const
Definition: SolverTypes.h:263
uint32_t wasted() const
Definition: SolverTypes.h:264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Solver::implies ( const vec< Lit > &  assumps,
vec< Lit > &  out 
)

Definition at line 889 of file Solver.cc.

890 {
892  for (int i = 0; i < assumps.size(); i++){
893  Lit a = assumps[i];
894 
895  if (value(a) == l_False){
896  cancelUntil(0);
897  return false;
898  }else if (value(a) == l_Undef)
899  uncheckedEnqueue(a);
900  }
901 
902  unsigned trail_before = trail.size();
903  bool ret = true;
904  if (propagate() == CRef_Undef){
905  out.clear();
906  for (int j = trail_before; j < trail.size(); j++)
907  out.push(trail[j]);
908  }else
909  ret = false;
910 
911  cancelUntil(0);
912  return ret;
913 }
const lbool l_False((uint8_t) 1)
const lbool l_Undef((uint8_t) 2)
void cancelUntil(int level)
Definition: Solver.cc:233
vec< int > trail_lim
Definition: Solver.h:193
const CRef CRef_Undef
Definition: SolverTypes.h:225
void push(void)
Definition: Vec.h:74
Size size(void) const
Definition: Vec.h:64
lbool value(Var x) const
Definition: Solver.h:350
void clear(bool dealloc=false)
Definition: Vec.h:125
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cc:488
vec< Lit > trail
Definition: Solver.h:192
CRef propagate()
Definition: Solver.cc:508

+ Here is the call graph for this function:

void Minisat::Solver::insertVarOrder ( Var  x)
inlineprotected

Definition at line 306 of file Solver.h.

306  {
307  if (!order_heap.inHeap(x) && decision[x]) order_heap.insert(x); }
Heap< Var, VarOrderLt > order_heap
Definition: Solver.h:205
VMap< char > decision
Definition: Solver.h:200

+ Here is the caller graph for this function:

void Minisat::Solver::interrupt ( )
inline

Definition at line 371 of file Solver.h.

371 { asynch_interrupt = true; }
bool asynch_interrupt
Definition: Solver.h:237

+ Here is the caller graph for this function:

static int Minisat::Solver::irand ( double &  seed,
int  size 
)
inlinestaticprotected

Definition at line 295 of file Solver.h.

295  {
296  return (int)(drand(seed) * size); }
static double drand(double &seed)
Definition: Solver.h:288

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Minisat::Solver::isRemoved ( CRef  cr) const
inlineprotected

Definition at line 344 of file Solver.h.

344 { return ca[cr].mark() == 1; }
ClauseAllocator ca
Definition: Solver.h:216

+ Here is the caller graph for this function:

int Minisat::Solver::level ( Var  x) const
inlineprotected

Definition at line 304 of file Solver.h.

304 { return vardata[x].level; }
VMap< VarData > vardata
Definition: Solver.h:201

+ Here is the caller graph for this function:

bool Solver::litRedundant ( Lit  p)
protected

Definition at line 390 of file Solver.cc.

391 {
392  enum { seen_undef = 0, seen_source = 1, seen_removable = 2, seen_failed = 3 };
393  assert(seen[var(p)] == seen_undef || seen[var(p)] == seen_source);
394  assert(reason(var(p)) != CRef_Undef);
395 
396  Clause* c = &ca[reason(var(p))];
398  stack.clear();
399 
400  for (uint32_t i = 1; ; i++){
401  if (i < (uint32_t)c->size()){
402  // Checking 'p'-parents 'l':
403  Lit l = (*c)[i];
404 
405  // Variable at level 0 or previously removable:
406  if (level(var(l)) == 0 || seen[var(l)] == seen_source || seen[var(l)] == seen_removable){
407  continue; }
408 
409  // Check variable can not be removed for some local reason:
410  if (reason(var(l)) == CRef_Undef || seen[var(l)] == seen_failed){
411  stack.push(ShrinkStackElem(0, p));
412  for (int i = 0; i < stack.size(); i++)
413  if (seen[var(stack[i].l)] == seen_undef){
414  seen[var(stack[i].l)] = seen_failed;
415  analyze_toclear.push(stack[i].l);
416  }
417 
418  return false;
419  }
420 
421  // Recursively check 'l':
422  stack.push(ShrinkStackElem(i, p));
423  i = 0;
424  p = l;
425  c = &ca[reason(var(p))];
426  }else{
427  // Finished with current element 'p' and reason 'c':
428  if (seen[var(p)] == seen_undef){
429  seen[var(p)] = seen_removable;
431  }
432 
433  // Terminate with success if stack is empty:
434  if (stack.size() == 0) break;
435 
436  // Continue with top element on stack:
437  i = stack.last().i;
438  p = stack.last().l;
439  c = &ca[reason(var(p))];
440 
441  stack.pop();
442  }
443  }
444 
445  return true;
446 }
ClauseAllocator ca
Definition: Solver.h:216
CRef reason(Var x) const
Definition: Solver.h:303
int level(Var x) const
Definition: Solver.h:304
int var(Lit p)
Definition: SolverTypes.h:67
const T & last(void) const
Definition: Vec.h:84
const CRef CRef_Undef
Definition: SolverTypes.h:225
void push(void)
Definition: Vec.h:74
Size size(void) const
Definition: Vec.h:64
void pop(void)
Definition: Vec.h:78
vec< Lit > analyze_toclear
Definition: Solver.h:226
vec< ShrinkStackElem > analyze_stack
Definition: Solver.h:225
void clear(bool dealloc=false)
Definition: Vec.h:125
VMap< char > seen
Definition: Solver.h:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Minisat::Solver::locked ( const Clause c) const
inlineprotected

Definition at line 345 of file Solver.h.

345 { return value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c; }
ClauseAllocator ca
Definition: Solver.h:216
CRef reason(Var x) const
Definition: Solver.h:303
int var(Lit p)
Definition: SolverTypes.h:67
const CRef CRef_Undef
Definition: SolverTypes.h:225
Clause * lea(CRef r)
Definition: SolverTypes.h:269
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static VarData Minisat::Solver::mkVarData ( CRef  cr,
int  l 
)
inlinestaticprotected

Definition at line 159 of file Solver.h.

159 { VarData d = {cr, l}; return d; }

+ Here is the caller graph for this function:

lbool Minisat::Solver::modelValue ( Var  x) const
inline

Definition at line 352 of file Solver.h.

352 { return model[x]; }
vec< lbool > model
Definition: Solver.h:122

+ Here is the caller graph for this function:

lbool Minisat::Solver::modelValue ( Lit  p) const
inline

Definition at line 353 of file Solver.h.

353 { return model[var(p)] ^ sign(p); }
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
vec< lbool > model
Definition: Solver.h:122

+ Here is the call graph for this function:

int Minisat::Solver::nAssigns ( ) const
inline

Definition at line 354 of file Solver.h.

354 { return trail.size(); }
Size size(void) const
Definition: Vec.h:64
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int Minisat::Solver::nClauses ( ) const
inline

Definition at line 355 of file Solver.h.

355 { return num_clauses; }
uint64_t num_clauses
Definition: Solver.h:152

+ Here is the caller graph for this function:

void Minisat::Solver::newDecisionLevel ( )
inlineprotected

Definition at line 346 of file Solver.h.

346 { trail_lim.push(trail.size()); }
vec< int > trail_lim
Definition: Solver.h:193
void push(void)
Definition: Vec.h:74
Size size(void) const
Definition: Vec.h:64
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Var Solver::newVar ( lbool  upol = l_Undef,
bool  dvar = true 
)

Definition at line 121 of file Solver.cc.

122 {
123  Var v;
124  if (free_vars.size() > 0){
125  v = free_vars.last();
126  free_vars.pop();
127  }else
128  v = next_var++;
129 
130  watches .init(mkLit(v, false));
131  watches .init(mkLit(v, true ));
132  assigns .insert(v, l_Undef);
133  vardata .insert(v, mkVarData(CRef_Undef, 0));
134  activity .insert(v, rnd_init_act ? drand(random_seed) * 0.00001 : 0);
135  seen .insert(v, 0);
136  polarity .insert(v, true);
137  user_pol .insert(v, upol);
138  decision .reserve(v);
139  trail .capacity(v+1);
140  setDecisionVar(v, dvar);
141  return v;
142 }
void insert(K key, V val, V pad)
Definition: IntMap.h:49
Lit mkLit(Var var, bool sign=false)
Definition: SolverTypes.h:63
vec< Var > free_vars
Definition: Solver.h:219
const lbool l_Undef((uint8_t) 2)
const T & last(void) const
Definition: Vec.h:84
void setDecisionVar(Var v, bool b)
Definition: Solver.h:361
void reserve(K key, V pad)
Definition: IntMap.h:47
const CRef CRef_Undef
Definition: SolverTypes.h:225
int capacity(void) const
Definition: Vec.h:67
VMap< char > polarity
Definition: Solver.h:198
VMap< lbool > user_pol
Definition: Solver.h:199
Size size(void) const
Definition: Vec.h:64
bool rnd_init_act
Definition: Solver.h:137
void pop(void)
Definition: Vec.h:78
VMap< double > activity
Definition: Solver.h:196
static double drand(double &seed)
Definition: Solver.h:288
VMap< char > seen
Definition: Solver.h:224
VMap< lbool > assigns
Definition: Solver.h:197
int Var
Definition: SolverTypes.h:43
vec< Lit > trail
Definition: Solver.h:192
VMap< VarData > vardata
Definition: Solver.h:201
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203
static VarData mkVarData(CRef cr, int l)
Definition: Solver.h:159
double random_seed
Definition: Solver.h:132
VMap< char > decision
Definition: Solver.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int Minisat::Solver::nFreeVars ( ) const
inline

Definition at line 359 of file Solver.h.

359 { return (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]); }
uint64_t dec_vars
Definition: Solver.h:152
vec< int > trail_lim
Definition: Solver.h:193
Size size(void) const
Definition: Vec.h:64
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

int Minisat::Solver::nLearnts ( ) const
inline

Definition at line 356 of file Solver.h.

356 { return num_learnts; }
uint64_t num_learnts
Definition: Solver.h:152

+ Here is the caller graph for this function:

int Minisat::Solver::nVars ( ) const
inline

Definition at line 357 of file Solver.h.

357 { return next_var; }

+ Here is the caller graph for this function:

bool Minisat::Solver::okay ( ) const
inline

Definition at line 388 of file Solver.h.

388 { return ok; }
Lit Solver::pickBranchLit ( )
protected

Definition at line 251 of file Solver.cc.

252 {
253  Var next = var_Undef;
254 
255  // Random decision:
256  if (drand(random_seed) < random_var_freq && !order_heap.empty()){
257  next = order_heap[irand(random_seed,order_heap.size())];
258  if (value(next) == l_Undef && decision[next])
259  rnd_decisions++; }
260 
261  // Activity based decision:
262  while (next == var_Undef || value(next) != l_Undef || !decision[next])
263  if (order_heap.empty()){
264  next = var_Undef;
265  break;
266  }else
267  next = order_heap.removeMin();
268 
269  // Choose polarity based on different polarity modes (global or per-variable):
270  if (next == var_Undef)
271  return lit_Undef;
272  else if (user_pol[next] != l_Undef)
273  return mkLit(next, user_pol[next] == l_True);
274  else if (rnd_pol)
275  return mkLit(next, drand(random_seed) < 0.5);
276  else
277  return mkLit(next, polarity[next]);
278 }
Lit mkLit(Var var, bool sign=false)
Definition: SolverTypes.h:63
const lbool l_Undef((uint8_t) 2)
const Var var_Undef
Definition: SolverTypes.h:47
double random_var_freq
Definition: Solver.h:131
VMap< char > polarity
Definition: Solver.h:198
VMap< lbool > user_pol
Definition: Solver.h:199
Heap< Var, VarOrderLt > order_heap
Definition: Solver.h:205
static double drand(double &seed)
Definition: Solver.h:288
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350
static int irand(double &seed, int size)
Definition: Solver.h:295
int Var
Definition: SolverTypes.h:43
const Lit lit_Undef
Definition: SolverTypes.h:77
uint64_t rnd_decisions
Definition: Solver.h:151
double random_seed
Definition: Solver.h:132
VMap< char > decision
Definition: Solver.h:200
bool rnd_pol
Definition: Solver.h:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::printStats ( ) const

Definition at line 993 of file Solver.cc.

994 {
995  double cpu_time = cpuTime();
996  double mem_used = memUsedPeak();
997  printf("restarts : %" PRIu64 "\n", starts);
998  printf("conflicts : %-12" PRIu64 " (%.0f /sec)\n", conflicts , conflicts /cpu_time);
999  printf("decisions : %-12" PRIu64 " (%4.2f %% random) (%.0f /sec)\n", decisions, (float)rnd_decisions*100 / (float)decisions, decisions /cpu_time);
1000  printf("propagations : %-12" PRIu64 " (%.0f /sec)\n", propagations, propagations/cpu_time);
1001  printf("conflict literals : %-12" PRIu64 " (%4.2f %% deleted)\n", tot_literals, (max_literals - tot_literals)*100 / (double)max_literals);
1002  if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used);
1003  printf("CPU time : %g s\n", cpu_time);
1004 }
static double cpuTime(void)
Definition: System.h:65
uint64_t starts
Definition: Solver.h:151
uint64_t decisions
Definition: Solver.h:151
uint64_t propagations
Definition: Solver.h:151
uint64_t max_literals
Definition: Solver.h:152
double memUsedPeak(bool strictlyPeak=false)
Definition: System.cc:96
uint64_t rnd_decisions
Definition: Solver.h:151
uint64_t conflicts
Definition: Solver.h:151
uint64_t tot_literals
Definition: Solver.h:152

+ Here is the call graph for this function:

double Solver::progressEstimate ( ) const
protected

Definition at line 798 of file Solver.cc.

799 {
800  double progress = 0;
801  double F = 1.0 / nVars();
802 
803  for (int i = 0; i <= decisionLevel(); i++){
804  int beg = i == 0 ? 0 : trail_lim[i - 1];
805  int end = i == decisionLevel() ? trail.size() : trail_lim[i];
806  progress += pow(F, i) * (end - beg);
807  }
808 
809  return progress / nVars();
810 }
vec< int > trail_lim
Definition: Solver.h:193
int nVars() const
Definition: Solver.h:357
int decisionLevel() const
Definition: Solver.h:348
Size size(void) const
Definition: Vec.h:64
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CRef Solver::propagate ( )
protected

Definition at line 508 of file Solver.cc.

509 {
510  CRef confl = CRef_Undef;
511  int num_props = 0;
512 
513  while (qhead < trail.size()){
514  Lit p = trail[qhead++]; // 'p' is enqueued fact to propagate.
515  vec<Watcher>& ws = watches.lookup(p);
516  Watcher *i, *j, *end;
517  num_props++;
518 
519  for (i = j = (Watcher*)ws, end = i + ws.size(); i != end;){
520  // Try to avoid inspecting the clause:
521  Lit blocker = i->blocker;
522  if (value(blocker) == l_True){
523  *j++ = *i++; continue; }
524 
525  // Make sure the false literal is data[1]:
526  CRef cr = i->cref;
527  Clause& c = ca[cr];
528  Lit false_lit = ~p;
529  if (c[0] == false_lit)
530  c[0] = c[1], c[1] = false_lit;
531  assert(c[1] == false_lit);
532  i++;
533 
534  // If 0th watch is true, then clause is already satisfied.
535  Lit first = c[0];
536  Watcher w = Watcher(cr, first);
537  if (first != blocker && value(first) == l_True){
538  *j++ = w; continue; }
539 
540  // Look for new watch:
541  for (int k = 2; k < c.size(); k++)
542  if (value(c[k]) != l_False){
543  c[1] = c[k]; c[k] = false_lit;
544  watches[~c[1]].push(w);
545  goto NextClause; }
546 
547  // Did not find watch -- clause is unit under assignment:
548  *j++ = w;
549  if (value(first) == l_False){
550  confl = cr;
551  qhead = trail.size();
552  // Copy the remaining watches:
553  while (i < end)
554  *j++ = *i++;
555  }else
556  uncheckedEnqueue(first, cr);
557 
558  NextClause:;
559  }
560  ws.shrink(i - j);
561  }
562  propagations += num_props;
563  simpDB_props -= num_props;
564 
565  return confl;
566 }
RegionAllocator< uint32_t >::Ref CRef
Definition: SolverTypes.h:137
const lbool l_False((uint8_t) 1)
ClauseAllocator ca
Definition: Solver.h:216
void shrink(Size nelems)
Definition: Vec.h:65
const CRef CRef_Undef
Definition: SolverTypes.h:225
Size size(void) const
Definition: Vec.h:64
uint64_t propagations
Definition: Solver.h:151
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cc:488
vec< Lit > trail
Definition: Solver.h:192
int64_t simpDB_props
Definition: Solver.h:212
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CRef Minisat::Solver::reason ( Var  x) const
inlineprotected

Definition at line 303 of file Solver.h.

303 { return vardata[x].reason; }
VMap< VarData > vardata
Definition: Solver.h:201

+ Here is the caller graph for this function:

void Solver::rebuildOrderHeap ( )
protected

Definition at line 625 of file Solver.cc.

626 {
627  vec<Var> vs;
628  for (Var v = 0; v < nVars(); v++)
629  if (decision[v] && value(v) == l_Undef)
630  vs.push(v);
631  order_heap.build(vs);
632 }
const lbool l_Undef((uint8_t) 2)
int nVars() const
Definition: Solver.h:357
void push(void)
Definition: Vec.h:74
Heap< Var, VarOrderLt > order_heap
Definition: Solver.h:205
lbool value(Var x) const
Definition: Solver.h:350
int Var
Definition: SolverTypes.h:43
VMap< char > decision
Definition: Solver.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::reduceDB ( )
protected

Definition at line 583 of file Solver.cc.

584 {
585  int i, j;
586  double extra_lim = cla_inc / learnts.size(); // Remove any clause below this activity
587 
589  // Don't delete binary or locked clauses. From the rest, delete clauses from the first half
590  // and clauses with activity smaller than 'extra_lim':
591  for (i = j = 0; i < learnts.size(); i++){
592  Clause& c = ca[learnts[i]];
593  if (c.size() > 2 && !locked(c) && (i < learnts.size() / 2 || c.activity() < extra_lim))
594  removeClause(learnts[i]);
595  else
596  learnts[j++] = learnts[i];
597  }
598  learnts.shrink(i - j);
599  checkGarbage();
600 }
bool locked(const Clause &c) const
Definition: Solver.h:345
ClauseAllocator ca
Definition: Solver.h:216
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
double cla_inc
Definition: Solver.h:208
float & activity()
Definition: SolverTypes.h:214
void checkGarbage()
Definition: Solver.h:330
Size size(void) const
Definition: Vec.h:64
void removeClause(CRef cr)
Definition: Solver.cc:214
vec< CRef > learnts
Definition: Solver.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::releaseVar ( Lit  l)

Definition at line 147 of file Solver.cc.

148 {
149  if (value(l) == l_Undef){
150  addClause(l);
151  released_vars.push(var(l));
152  }
153 }
int var(Lit p)
Definition: SolverTypes.h:67
bool addClause(const vec< Lit > &ps)
Definition: Solver.h:337
const lbool l_Undef((uint8_t) 2)
void push(void)
Definition: Vec.h:74
lbool value(Var x) const
Definition: Solver.h:350
vec< Var > released_vars
Definition: Solver.h:218

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::relocAll ( ClauseAllocator to)
protected

Definition at line 1010 of file Solver.cc.

1011 {
1012  // All watchers:
1013  //
1014  watches.cleanAll();
1015  for (int v = 0; v < nVars(); v++)
1016  for (int s = 0; s < 2; s++){
1017  Lit p = mkLit(v, s);
1018  vec<Watcher>& ws = watches[p];
1019  for (int j = 0; j < ws.size(); j++)
1020  ca.reloc(ws[j].cref, to);
1021  }
1022 
1023  // All reasons:
1024  //
1025  for (int i = 0; i < trail.size(); i++){
1026  Var v = var(trail[i]);
1027 
1028  // Note: it is not safe to call 'locked()' on a relocated clause. This is why we keep
1029  // 'dangling' reasons here. It is safe and does not hurt.
1030  if (reason(v) != CRef_Undef && (ca[reason(v)].reloced() || locked(ca[reason(v)]))){
1031  assert(!isRemoved(reason(v)));
1032  ca.reloc(vardata[v].reason, to);
1033  }
1034  }
1035 
1036  // All learnt:
1037  //
1038  int i, j;
1039  for (i = j = 0; i < learnts.size(); i++)
1040  if (!isRemoved(learnts[i])){
1041  ca.reloc(learnts[i], to);
1042  learnts[j++] = learnts[i];
1043  }
1044  learnts.shrink(i - j);
1045 
1046  // All original:
1047  //
1048  for (i = j = 0; i < clauses.size(); i++)
1049  if (!isRemoved(clauses[i])){
1050  ca.reloc(clauses[i], to);
1051  clauses[j++] = clauses[i];
1052  }
1053  clauses.shrink(i - j);
1054 }
bool locked(const Clause &c) const
Definition: Solver.h:345
ClauseAllocator ca
Definition: Solver.h:216
CRef reason(Var x) const
Definition: Solver.h:303
Lit mkLit(Var var, bool sign=false)
Definition: SolverTypes.h:63
void shrink(Size nelems)
Definition: Vec.h:65
int var(Lit p)
Definition: SolverTypes.h:67
int nVars() const
Definition: Solver.h:357
const CRef CRef_Undef
Definition: SolverTypes.h:225
vec< CRef > clauses
Definition: Solver.h:190
Size size(void) const
Definition: Vec.h:64
void reloc(CRef &cr, ClauseAllocator &to)
Definition: SolverTypes.h:279
vec< CRef > learnts
Definition: Solver.h:191
int Var
Definition: SolverTypes.h:43
vec< Lit > trail
Definition: Solver.h:192
bool isRemoved(CRef cr) const
Definition: Solver.h:344
VMap< VarData > vardata
Definition: Solver.h:201
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
Definition: Solver.h:203

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::removeClause ( CRef  cr)
protected

Definition at line 214 of file Solver.cc.

214  {
215  Clause& c = ca[cr];
216  detachClause(cr);
217  // Don't leave pointers to free'd memory!
218  if (locked(c)) vardata[var(c[0])].reason = CRef_Undef;
219  c.mark(1);
220  ca.free(cr);
221 }
bool locked(const Clause &c) const
Definition: Solver.h:345
ClauseAllocator ca
Definition: Solver.h:216
int var(Lit p)
Definition: SolverTypes.h:67
void detachClause(CRef cr, bool strict=false)
Definition: Solver.cc:196
const CRef CRef_Undef
Definition: SolverTypes.h:225
VMap< VarData > vardata
Definition: Solver.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::removeSatisfied ( vec< CRef > &  cs)
protected

Definition at line 603 of file Solver.cc.

604 {
605  int i, j;
606  for (i = j = 0; i < cs.size(); i++){
607  Clause& c = ca[cs[i]];
608  if (satisfied(c))
609  removeClause(cs[i]);
610  else{
611  // Trim clause:
612  assert(value(c[0]) == l_Undef && value(c[1]) == l_Undef);
613  for (int k = 2; k < c.size(); k++)
614  if (value(c[k]) == l_False){
615  c[k--] = c[c.size()-1];
616  c.pop();
617  }
618  cs[j++] = cs[i];
619  }
620  }
621  cs.shrink(i - j);
622 }
const lbool l_False((uint8_t) 1)
ClauseAllocator ca
Definition: Solver.h:216
const lbool l_Undef((uint8_t) 2)
Size size(void) const
Definition: Vec.h:64
void removeClause(CRef cr)
Definition: Solver.cc:214
lbool value(Var x) const
Definition: Solver.h:350
bool satisfied(const Clause &c) const
Definition: Solver.cc:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Solver::satisfied ( const Clause c) const
protected

Definition at line 224 of file Solver.cc.

224  {
225  for (int i = 0; i < c.size(); i++)
226  if (value(c[i]) == l_True)
227  return true;
228  return false; }
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

lbool Solver::search ( int  nof_conflicts)
protected

Definition at line 704 of file Solver.cc.

705 {
706  assert(ok);
707  int backtrack_level;
708  int conflictC = 0;
709  vec<Lit> learnt_clause;
710  starts++;
711 
712  for (;;){
713  CRef confl = propagate();
714  if (confl != CRef_Undef){
715  // CONFLICT
716  conflicts++; conflictC++;
717  if (decisionLevel() == 0) return l_False;
718 
719  learnt_clause.clear();
720  analyze(confl, learnt_clause, backtrack_level);
721  cancelUntil(backtrack_level);
722 
723  if (learnt_clause.size() == 1){
724  uncheckedEnqueue(learnt_clause[0]);
725  }else{
726  CRef cr = ca.alloc(learnt_clause, true);
727  learnts.push(cr);
728  attachClause(cr);
729  claBumpActivity(ca[cr]);
730  uncheckedEnqueue(learnt_clause[0], cr);
731  }
732 
735 
736  if (--learntsize_adjust_cnt == 0){
740 
741  if (verbosity >= 1)
742  printf("| %9d | %7d %8d %8d | %8d %8d %6.0f | %6.3f %% |\n",
743  (int)conflicts,
744  (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), nClauses(), (int)clauses_literals,
746  }
747 
748  }else{
749  // NO CONFLICT
750  if ((nof_conflicts >= 0 && conflictC >= nof_conflicts) || !withinBudget()){
751  // Reached bound on number of conflicts:
753  cancelUntil(0);
754  return l_Undef; }
755 
756  // Simplify the set of problem clauses:
757  if (decisionLevel() == 0 && !simplify())
758  return l_False;
759 
760  if (learnts.size()-nAssigns() >= max_learnts)
761  // Reduce the set of learnt clauses:
762  reduceDB();
763 
764  Lit next = lit_Undef;
765  while (decisionLevel() < assumptions.size()){
766  // Perform user provided assumption:
768  if (value(p) == l_True){
769  // Dummy decision level:
771  }else if (value(p) == l_False){
772  analyzeFinal(~p, conflict);
773  return l_False;
774  }else{
775  next = p;
776  break;
777  }
778  }
779 
780  if (next == lit_Undef){
781  // New variable decision:
782  decisions++;
783  next = pickBranchLit();
784 
785  if (next == lit_Undef)
786  // Model found:
787  return l_True;
788  }
789 
790  // Increase decision level and enqueue 'next'
792  uncheckedEnqueue(next);
793  }
794  }
795 }
RegionAllocator< uint32_t >::Ref CRef
Definition: SolverTypes.h:137
double learntsize_inc
Definition: Solver.h:144
LSet conflict
Definition: Solver.h:123
void reduceDB()
Definition: Solver.cc:583
const lbool l_False((uint8_t) 1)
ClauseAllocator ca
Definition: Solver.h:216
int learntsize_adjust_cnt
Definition: Solver.h:231
bool simplify()
Definition: Solver.cc:643
double learntsize_adjust_inc
Definition: Solver.h:147
bool withinBudget() const
Definition: Solver.h:374
double max_learnts
Definition: Solver.h:229
void claDecayActivity()
Definition: Solver.h:322
void claBumpActivity(Clause &c)
Definition: Solver.h:323
void newDecisionLevel()
Definition: Solver.h:346
uint64_t starts
Definition: Solver.h:151
const lbool l_Undef((uint8_t) 2)
void attachClause(CRef cr)
Definition: Solver.cc:186
void cancelUntil(int level)
Definition: Solver.cc:233
uint64_t dec_vars
Definition: Solver.h:152
vec< int > trail_lim
Definition: Solver.h:193
Lit pickBranchLit()
Definition: Solver.cc:251
uint64_t learnts_literals
Definition: Solver.h:152
const CRef CRef_Undef
Definition: SolverTypes.h:225
int decisionLevel() const
Definition: Solver.h:348
uint64_t decisions
Definition: Solver.h:151
vec< Lit > assumptions
Definition: Solver.h:194
double progress_estimate
Definition: Solver.h:213
void push(void)
Definition: Vec.h:74
int nAssigns() const
Definition: Solver.h:354
Size size(void) const
Definition: Vec.h:64
uint64_t clauses_literals
Definition: Solver.h:152
int nClauses() const
Definition: Solver.h:355
void analyzeFinal(Lit p, LSet &out_conflict)
Definition: Solver.cc:458
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350
void varDecayActivity()
Definition: Solver.h:309
void clear(bool dealloc=false)
Definition: Vec.h:125
CRef alloc(const vec< Lit > &ps, bool learnt=false)
Definition: SolverTypes.h:245
vec< CRef > learnts
Definition: Solver.h:191
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cc:488
const Lit lit_Undef
Definition: SolverTypes.h:77
void analyze(CRef confl, vec< Lit > &out_learnt, int &out_btlevel)
Definition: Solver.cc:298
vec< Lit > trail
Definition: Solver.h:192
int nLearnts() const
Definition: Solver.h:356
double progressEstimate() const
Definition: Solver.cc:798
CRef propagate()
Definition: Solver.cc:508
uint64_t conflicts
Definition: Solver.h:151
double learntsize_adjust_confl
Definition: Solver.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Minisat::Solver::setConfBudget ( int64_t  x)
inline

Definition at line 369 of file Solver.h.

369 { conflict_budget = conflicts + x; }
int64_t conflict_budget
Definition: Solver.h:235
uint64_t conflicts
Definition: Solver.h:151
void Minisat::Solver::setDecisionVar ( Var  v,
bool  b 
)
inline

Definition at line 361 of file Solver.h.

362 {
363  if ( b && !decision[v]) dec_vars++;
364  else if (!b && decision[v]) dec_vars--;
365 
366  decision[v] = b;
367  insertVarOrder(v);
368 }
void insertVarOrder(Var x)
Definition: Solver.h:306
uint64_t dec_vars
Definition: Solver.h:152
VMap< char > decision
Definition: Solver.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Minisat::Solver::setPolarity ( Var  v,
lbool  b 
)
inline

Definition at line 360 of file Solver.h.

360 { user_pol[v] = b; }
VMap< lbool > user_pol
Definition: Solver.h:199
void Minisat::Solver::setPropBudget ( int64_t  x)
inline

Definition at line 370 of file Solver.h.

int64_t propagation_budget
Definition: Solver.h:236
uint64_t propagations
Definition: Solver.h:151
bool Solver::simplify ( )

Definition at line 643 of file Solver.cc.

644 {
645  assert(decisionLevel() == 0);
646 
647  if (!ok || propagate() != CRef_Undef)
648  return ok = false;
649 
650  if (nAssigns() == simpDB_assigns || (simpDB_props > 0))
651  return true;
652 
653  // Remove satisfied clauses:
655  if (remove_satisfied){ // Can be turned off.
657 
658  // TODO: what todo in if 'remove_satisfied' is false?
659 
660  // Remove all released variables from the trail:
661  for (int i = 0; i < released_vars.size(); i++){
662  assert(seen[released_vars[i]] == 0);
663  seen[released_vars[i]] = 1;
664  }
665 
666  int i, j;
667  for (i = j = 0; i < trail.size(); i++)
668  if (seen[var(trail[i])] == 0)
669  trail[j++] = trail[i];
670  trail.shrink(i - j);
671  //printf("trail.size()= %d, qhead = %d\n", trail.size(), qhead);
672  qhead = trail.size();
673 
674  for (int i = 0; i < released_vars.size(); i++)
675  seen[released_vars[i]] = 0;
676 
677  // Released variables are now ready to be reused:
680  }
681  checkGarbage();
683 
685  simpDB_props = clauses_literals + learnts_literals; // (shouldn't depend on stats really, but it will do for now)
686 
687  return true;
688 }
static void append(const vec< T > &from, vec< T > &to)
Definition: Alg.h:79
void shrink(Size nelems)
Definition: Vec.h:65
int var(Lit p)
Definition: SolverTypes.h:67
vec< Var > free_vars
Definition: Solver.h:219
void removeSatisfied(vec< CRef > &cs)
Definition: Solver.cc:603
uint64_t learnts_literals
Definition: Solver.h:152
const CRef CRef_Undef
Definition: SolverTypes.h:225
int decisionLevel() const
Definition: Solver.h:348
void checkGarbage()
Definition: Solver.h:330
vec< CRef > clauses
Definition: Solver.h:190
void rebuildOrderHeap()
Definition: Solver.cc:625
int nAssigns() const
Definition: Solver.h:354
Size size(void) const
Definition: Vec.h:64
uint64_t clauses_literals
Definition: Solver.h:152
void clear(bool dealloc=false)
Definition: Vec.h:125
int simpDB_assigns
Definition: Solver.h:211
VMap< char > seen
Definition: Solver.h:224
vec< CRef > learnts
Definition: Solver.h:191
vec< Lit > trail
Definition: Solver.h:192
vec< Var > released_vars
Definition: Solver.h:218
int64_t simpDB_props
Definition: Solver.h:212
CRef propagate()
Definition: Solver.cc:508
bool remove_satisfied
Definition: Solver.h:214

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Minisat::Solver::solve ( const vec< Lit > &  assumps)
inline

Definition at line 386 of file Solver.h.

386 { budgetOff(); assumps.copyTo(assumptions); return solve_() == l_True; }
void budgetOff()
Definition: Solver.h:373
void copyTo(vec< T > &copy) const
Definition: Vec.h:92
vec< Lit > assumptions
Definition: Solver.h:194
const lbool l_True((uint8_t) 0)
lbool solve_()
Definition: Solver.cc:841

+ Here is the call graph for this function:

bool Minisat::Solver::solve ( )
inline

Definition at line 382 of file Solver.h.

382 { budgetOff(); assumptions.clear(); return solve_() == l_True; }
void budgetOff()
Definition: Solver.h:373
vec< Lit > assumptions
Definition: Solver.h:194
const lbool l_True((uint8_t) 0)
lbool solve_()
Definition: Solver.cc:841
void clear(bool dealloc=false)
Definition: Vec.h:125

+ Here is the call graph for this function:

bool Minisat::Solver::solve ( Lit  p)
inline

Definition at line 383 of file Solver.h.

383 { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_() == l_True; }
void budgetOff()
Definition: Solver.h:373
vec< Lit > assumptions
Definition: Solver.h:194
void push(void)
Definition: Vec.h:74
const lbool l_True((uint8_t) 0)
lbool solve_()
Definition: Solver.cc:841
void clear(bool dealloc=false)
Definition: Vec.h:125

+ Here is the call graph for this function:

bool Minisat::Solver::solve ( Lit  p,
Lit  q 
)
inline

Definition at line 384 of file Solver.h.

384 { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_() == l_True; }
void budgetOff()
Definition: Solver.h:373
vec< Lit > assumptions
Definition: Solver.h:194
void push(void)
Definition: Vec.h:74
const lbool l_True((uint8_t) 0)
lbool solve_()
Definition: Solver.cc:841
void clear(bool dealloc=false)
Definition: Vec.h:125

+ Here is the call graph for this function:

bool Minisat::Solver::solve ( Lit  p,
Lit  q,
Lit  r 
)
inline

Definition at line 385 of file Solver.h.

void budgetOff()
Definition: Solver.h:373
vec< Lit > assumptions
Definition: Solver.h:194
void push(void)
Definition: Vec.h:74
const lbool l_True((uint8_t) 0)
lbool solve_()
Definition: Solver.cc:841
void clear(bool dealloc=false)
Definition: Vec.h:125

+ Here is the call graph for this function:

lbool Solver::solve_ ( )
protected

Definition at line 841 of file Solver.cc.

842 {
843  model.clear();
844  conflict.clear();
845  if (!ok) return l_False;
846 
847  solves++;
848 
852 
855  lbool status = l_Undef;
856 
857  if (verbosity >= 1){
858  printf("============================[ Search Statistics ]==============================\n");
859  printf("| Conflicts | ORIGINAL | LEARNT | Progress |\n");
860  printf("| | Vars Clauses Literals | Limit Clauses Lit/Cl | |\n");
861  printf("===============================================================================\n");
862  }
863 
864  // Search:
865  int curr_restarts = 0;
866  while (status == l_Undef){
867  double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
868  status = search(rest_base * restart_first);
869  if (!withinBudget()) break;
870  curr_restarts++;
871  }
872 
873  if (verbosity >= 1)
874  printf("===============================================================================\n");
875 
876 
877  if (status == l_True){
878  // Extend & copy model:
879  model.growTo(nVars());
880  for (int i = 0; i < nVars(); i++) model[i] = value(i);
881  }else if (status == l_False && conflict.size() == 0)
882  ok = false;
883 
884  cancelUntil(0);
885  return status;
886 }
LSet conflict
Definition: Solver.h:123
const lbool l_False((uint8_t) 1)
int learntsize_adjust_cnt
Definition: Solver.h:231
bool luby_restart
Definition: Solver.h:133
int restart_first
Definition: Solver.h:141
bool withinBudget() const
Definition: Solver.h:374
double max_learnts
Definition: Solver.h:229
double learntsize_factor
Definition: Solver.h:143
int min_learnts_lim
Definition: Solver.h:139
void clear(bool free=false)
Definition: IntMap.h:67
int learntsize_adjust_start_confl
Definition: Solver.h:146
const lbool l_Undef((uint8_t) 2)
lbool search(int nof_conflicts)
Definition: Solver.cc:704
void cancelUntil(int level)
Definition: Solver.cc:233
int nVars() const
Definition: Solver.h:357
static double luby(double y, int x)
Definition: Solver.cc:824
int nClauses() const
Definition: Solver.h:355
vec< lbool > model
Definition: Solver.h:122
const lbool l_True((uint8_t) 0)
lbool value(Var x) const
Definition: Solver.h:350
uint64_t solves
Definition: Solver.h:151
double restart_inc
Definition: Solver.h:142
int size(void) const
Definition: IntMap.h:66
double learntsize_adjust_confl
Definition: Solver.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

lbool Minisat::Solver::solveLimited ( const vec< Lit > &  assumps)
inline

Definition at line 387 of file Solver.h.

387 { assumps.copyTo(assumptions); return solve_(); }
void copyTo(vec< T > &copy) const
Definition: Vec.h:92
vec< Lit > assumptions
Definition: Solver.h:194
lbool solve_()
Definition: Solver.cc:841

+ Here is the call graph for this function:

void Solver::toDimacs ( FILE *  f,
const vec< Lit > &  assumps 
)

Definition at line 951 of file Solver.cc.

952 {
953  // Handle case when solver is in contradictory state:
954  if (!ok){
955  fprintf(f, "p cnf 1 2\n1 0\n-1 0\n");
956  return; }
957 
958  vec<Var> map; Var max = 0;
959 
960  // Cannot use removeClauses here because it is not safe
961  // to deallocate them at this point. Could be improved.
962  int cnt = 0;
963  for (int i = 0; i < clauses.size(); i++)
964  if (!satisfied(ca[clauses[i]]))
965  cnt++;
966 
967  for (int i = 0; i < clauses.size(); i++)
968  if (!satisfied(ca[clauses[i]])){
969  Clause& c = ca[clauses[i]];
970  for (int j = 0; j < c.size(); j++)
971  if (value(c[j]) != l_False)
972  mapVar(var(c[j]), map, max);
973  }
974 
975  // Assumptions are added as unit clauses:
976  cnt += assumps.size();
977 
978  fprintf(f, "p cnf %d %d\n", max, cnt);
979 
980  for (int i = 0; i < assumps.size(); i++){
981  assert(value(assumps[i]) != l_False);
982  fprintf(f, "%s%d 0\n", sign(assumps[i]) ? "-" : "", mapVar(var(assumps[i]), map, max)+1);
983  }
984 
985  for (int i = 0; i < clauses.size(); i++)
986  toDimacs(f, ca[clauses[i]], map, max);
987 
988  if (verbosity > 0)
989  printf("Wrote DIMACS with %d variables and %d clauses.\n", max, cnt);
990 }
const lbool l_False((uint8_t) 1)
ClauseAllocator ca
Definition: Solver.h:216
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
vec< CRef > clauses
Definition: Solver.h:190
Size size(void) const
Definition: Vec.h:64
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951
lbool value(Var x) const
Definition: Solver.h:350
int Var
Definition: SolverTypes.h:43
bool satisfied(const Clause &c) const
Definition: Solver.cc:224
static Var mapVar(Var x, vec< Var > &map, Var &max)
Definition: Solver.cc:920

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Solver::toDimacs ( const char *  file,
const vec< Lit > &  assumps 
)

Definition at line 941 of file Solver.cc.

942 {
943  FILE* f = fopen(file, "wr");
944  if (f == NULL)
945  fprintf(stderr, "could not open file %s\n", file), exit(1);
946  toDimacs(f, assumps);
947  fclose(f);
948 }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951
#define NULL

+ Here is the call graph for this function:

void Solver::toDimacs ( FILE *  f,
Clause c,
vec< Var > &  map,
Var max 
)

Definition at line 930 of file Solver.cc.

931 {
932  if (satisfied(c)) return;
933 
934  for (int i = 0; i < c.size(); i++)
935  if (value(c[i]) != l_False)
936  fprintf(f, "%s%d ", sign(c[i]) ? "-" : "", mapVar(var(c[i]), map, max)+1);
937  fprintf(f, "0\n");
938 }
const lbool l_False((uint8_t) 1)
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
lbool value(Var x) const
Definition: Solver.h:350
bool satisfied(const Clause &c) const
Definition: Solver.cc:224
static Var mapVar(Var x, vec< Var > &map, Var &max)
Definition: Solver.cc:920

+ Here is the call graph for this function:

void Minisat::Solver::toDimacs ( const char *  file)
inline

Definition at line 396 of file Solver.h.

396 { vec<Lit> as; toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951

+ Here is the call graph for this function:

void Minisat::Solver::toDimacs ( const char *  file,
Lit  p 
)
inline

Definition at line 397 of file Solver.h.

397 { vec<Lit> as; as.push(p); toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951

+ Here is the call graph for this function:

void Minisat::Solver::toDimacs ( const char *  file,
Lit  p,
Lit  q 
)
inline

Definition at line 398 of file Solver.h.

398 { vec<Lit> as; as.push(p); as.push(q); toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951

+ Here is the call graph for this function:

void Minisat::Solver::toDimacs ( const char *  file,
Lit  p,
Lit  q,
Lit  r 
)
inline

Definition at line 399 of file Solver.h.

399 { vec<Lit> as; as.push(p); as.push(q); as.push(r); toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition: Solver.cc:951

+ Here is the call graph for this function:

TrailIterator Minisat::Solver::trailBegin ( ) const
inline

Definition at line 392 of file Solver.h.

392 { return TrailIterator(&trail[0]); }
vec< Lit > trail
Definition: Solver.h:192
TrailIterator Minisat::Solver::trailEnd ( ) const
inline

Definition at line 393 of file Solver.h.

393  {
394  return TrailIterator(&trail[decisionLevel() == 0 ? trail.size() : trail_lim[0]]); }
vec< int > trail_lim
Definition: Solver.h:193
int decisionLevel() const
Definition: Solver.h:348
Size size(void) const
Definition: Vec.h:64
vec< Lit > trail
Definition: Solver.h:192

+ Here is the call graph for this function:

void Solver::uncheckedEnqueue ( Lit  p,
CRef  from = CRef_Undef 
)
protected

Definition at line 488 of file Solver.cc.

489 {
490  assert(value(p) == l_Undef);
491  assigns[var(p)] = lbool(!sign(p));
492  vardata[var(p)] = mkVarData(from, decisionLevel());
493  trail.push_(p);
494 }
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
const lbool l_Undef((uint8_t) 2)
int decisionLevel() const
Definition: Solver.h:348
lbool value(Var x) const
Definition: Solver.h:350
VMap< lbool > assigns
Definition: Solver.h:197
void push_(const T &elem)
Definition: Vec.h:77
vec< Lit > trail
Definition: Solver.h:192
VMap< VarData > vardata
Definition: Solver.h:201
static VarData mkVarData(CRef cr, int l)
Definition: Solver.h:159

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

lbool Minisat::Solver::value ( Var  x) const
inline

Definition at line 350 of file Solver.h.

350 { return assigns[x]; }
VMap< lbool > assigns
Definition: Solver.h:197

+ Here is the caller graph for this function:

lbool Minisat::Solver::value ( Lit  p) const
inline

Definition at line 351 of file Solver.h.

351 { return assigns[var(p)] ^ sign(p); }
int var(Lit p)
Definition: SolverTypes.h:67
bool sign(Lit p)
Definition: SolverTypes.h:66
VMap< lbool > assigns
Definition: Solver.h:197

+ Here is the call graph for this function:

void Minisat::Solver::varBumpActivity ( Var  v,
double  inc 
)
inlineprotected

Definition at line 311 of file Solver.h.

311  {
312  if ( (activity[v] += inc) > 1e100 ) {
313  // Rescale:
314  for (int i = 0; i < nVars(); i++)
315  activity[i] *= 1e-100;
316  var_inc *= 1e-100; }
317 
318  // Update order_heap with respect to new activity:
319  if (order_heap.inHeap(v))
320  order_heap.decrease(v); }
int nVars() const
Definition: Solver.h:357
Heap< Var, VarOrderLt > order_heap
Definition: Solver.h:205
VMap< double > activity
Definition: Solver.h:196
double var_inc
Definition: Solver.h:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Minisat::Solver::varBumpActivity ( Var  v)
inlineprotected

Definition at line 310 of file Solver.h.

310 { varBumpActivity(v, var_inc); }
double var_inc
Definition: Solver.h:209
void varBumpActivity(Var v, double inc)
Definition: Solver.h:311

+ Here is the call graph for this function:

void Minisat::Solver::varDecayActivity ( )
inlineprotected

Definition at line 309 of file Solver.h.

309 { var_inc *= (1 / var_decay); }
double var_decay
Definition: Solver.h:129
double var_inc
Definition: Solver.h:209

+ Here is the caller graph for this function:

bool Minisat::Solver::withinBudget ( ) const
inlineprotected

Definition at line 374 of file Solver.h.

374  {
375  return !asynch_interrupt &&
376  (conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
377  (propagation_budget < 0 || propagations < (uint64_t)propagation_budget); }
int64_t conflict_budget
Definition: Solver.h:235
bool asynch_interrupt
Definition: Solver.h:237
int64_t propagation_budget
Definition: Solver.h:236
uint64_t propagations
Definition: Solver.h:151
uint64_t conflicts
Definition: Solver.h:151

+ Here is the caller graph for this function:

Field Documentation

VMap<double> Minisat::Solver::activity
protected

Definition at line 196 of file Solver.h.

vec<Lit> Minisat::Solver::add_tmp
protected

Definition at line 227 of file Solver.h.

vec<ShrinkStackElem> Minisat::Solver::analyze_stack
protected

Definition at line 225 of file Solver.h.

vec<Lit> Minisat::Solver::analyze_toclear
protected

Definition at line 226 of file Solver.h.

VMap<lbool> Minisat::Solver::assigns
protected

Definition at line 197 of file Solver.h.

vec<Lit> Minisat::Solver::assumptions
protected

Definition at line 194 of file Solver.h.

bool Minisat::Solver::asynch_interrupt
protected

Definition at line 237 of file Solver.h.

ClauseAllocator Minisat::Solver::ca
protected

Definition at line 216 of file Solver.h.

int Minisat::Solver::ccmin_mode

Definition at line 134 of file Solver.h.

double Minisat::Solver::cla_inc
protected

Definition at line 208 of file Solver.h.

double Minisat::Solver::clause_decay

Definition at line 130 of file Solver.h.

vec<CRef> Minisat::Solver::clauses
protected

Definition at line 190 of file Solver.h.

uint64_t Minisat::Solver::clauses_literals

Definition at line 152 of file Solver.h.

LSet Minisat::Solver::conflict

Definition at line 123 of file Solver.h.

int64_t Minisat::Solver::conflict_budget
protected

Definition at line 235 of file Solver.h.

uint64_t Minisat::Solver::conflicts

Definition at line 151 of file Solver.h.

uint64_t Minisat::Solver::dec_vars

Definition at line 152 of file Solver.h.

VMap<char> Minisat::Solver::decision
protected

Definition at line 200 of file Solver.h.

uint64_t Minisat::Solver::decisions

Definition at line 151 of file Solver.h.

vec<Var> Minisat::Solver::free_vars
protected

Definition at line 219 of file Solver.h.

double Minisat::Solver::garbage_frac

Definition at line 138 of file Solver.h.

vec<CRef> Minisat::Solver::learnts
protected

Definition at line 191 of file Solver.h.

uint64_t Minisat::Solver::learnts_literals

Definition at line 152 of file Solver.h.

int Minisat::Solver::learntsize_adjust_cnt
protected

Definition at line 231 of file Solver.h.

double Minisat::Solver::learntsize_adjust_confl
protected

Definition at line 230 of file Solver.h.

double Minisat::Solver::learntsize_adjust_inc

Definition at line 147 of file Solver.h.

int Minisat::Solver::learntsize_adjust_start_confl

Definition at line 146 of file Solver.h.

double Minisat::Solver::learntsize_factor

Definition at line 143 of file Solver.h.

double Minisat::Solver::learntsize_inc

Definition at line 144 of file Solver.h.

bool Minisat::Solver::luby_restart

Definition at line 133 of file Solver.h.

double Minisat::Solver::max_learnts
protected

Definition at line 229 of file Solver.h.

uint64_t Minisat::Solver::max_literals

Definition at line 152 of file Solver.h.

int Minisat::Solver::min_learnts_lim

Definition at line 139 of file Solver.h.

vec<lbool> Minisat::Solver::model

Definition at line 122 of file Solver.h.

Var Minisat::Solver::next_var
protected

Definition at line 215 of file Solver.h.

uint64_t Minisat::Solver::num_clauses

Definition at line 152 of file Solver.h.

uint64_t Minisat::Solver::num_learnts

Definition at line 152 of file Solver.h.

bool Minisat::Solver::ok
protected

Definition at line 207 of file Solver.h.

Heap<Var,VarOrderLt> Minisat::Solver::order_heap
protected

Definition at line 205 of file Solver.h.

int Minisat::Solver::phase_saving

Definition at line 135 of file Solver.h.

VMap<char> Minisat::Solver::polarity
protected

Definition at line 198 of file Solver.h.

double Minisat::Solver::progress_estimate
protected

Definition at line 213 of file Solver.h.

int64_t Minisat::Solver::propagation_budget
protected

Definition at line 236 of file Solver.h.

uint64_t Minisat::Solver::propagations

Definition at line 151 of file Solver.h.

int Minisat::Solver::qhead
protected

Definition at line 210 of file Solver.h.

double Minisat::Solver::random_seed

Definition at line 132 of file Solver.h.

double Minisat::Solver::random_var_freq

Definition at line 131 of file Solver.h.

vec<Var> Minisat::Solver::released_vars
protected

Definition at line 218 of file Solver.h.

bool Minisat::Solver::remove_satisfied
protected

Definition at line 214 of file Solver.h.

int Minisat::Solver::restart_first

Definition at line 141 of file Solver.h.

double Minisat::Solver::restart_inc

Definition at line 142 of file Solver.h.

uint64_t Minisat::Solver::rnd_decisions

Definition at line 151 of file Solver.h.

bool Minisat::Solver::rnd_init_act

Definition at line 137 of file Solver.h.

bool Minisat::Solver::rnd_pol

Definition at line 136 of file Solver.h.

VMap<char> Minisat::Solver::seen
protected

Definition at line 224 of file Solver.h.

int Minisat::Solver::simpDB_assigns
protected

Definition at line 211 of file Solver.h.

int64_t Minisat::Solver::simpDB_props
protected

Definition at line 212 of file Solver.h.

uint64_t Minisat::Solver::solves

Definition at line 151 of file Solver.h.

uint64_t Minisat::Solver::starts

Definition at line 151 of file Solver.h.

uint64_t Minisat::Solver::tot_literals

Definition at line 152 of file Solver.h.

vec<Lit> Minisat::Solver::trail
protected

Definition at line 192 of file Solver.h.

vec<int> Minisat::Solver::trail_lim
protected

Definition at line 193 of file Solver.h.

VMap<lbool> Minisat::Solver::user_pol
protected

Definition at line 199 of file Solver.h.

double Minisat::Solver::var_decay

Definition at line 129 of file Solver.h.

double Minisat::Solver::var_inc
protected

Definition at line 209 of file Solver.h.

VMap<VarData> Minisat::Solver::vardata
protected

Definition at line 201 of file Solver.h.

int Minisat::Solver::verbosity

Definition at line 128 of file Solver.h.

OccLists<Lit, vec<Watcher>, WatcherDeleted, MkIndexLit> Minisat::Solver::watches
protected

Definition at line 203 of file Solver.h.


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