ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Minisat::SimpSolver Class Reference

#include <SimpSolver.h>

Inheritance diagram for Minisat::SimpSolver:
Collaboration diagram for Minisat::SimpSolver:

Classes

struct  ClauseDeleted
 
struct  ElimLt
 

Public Member Functions

 SimpSolver ()
 
 ~SimpSolver ()
 
Var newVar (bool polarity=true, bool dvar=true)
 
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_ (vec< Lit > &ps)
 
bool substitute (Var v, Lit x)
 
void setFrozen (Var v, bool b)
 
bool isEliminated (Var v) const
 
bool solve (const vec< Lit > &assumps, bool do_simp=true, bool turn_off_simp=false)
 
lbool solveLimited (const vec< Lit > &assumps, bool do_simp=true, bool turn_off_simp=false)
 
bool solve (bool do_simp=true, bool turn_off_simp=false)
 
bool solve (Lit p, bool do_simp=true, bool turn_off_simp=false)
 
bool solve (Lit p, Lit q, bool do_simp=true, bool turn_off_simp=false)
 
bool solve (Lit p, Lit q, Lit r, bool do_simp=true, bool turn_off_simp=false)
 
bool eliminate (bool turn_off_elim=false)
 
virtual void garbageCollect ()
 
- Public Member Functions inherited from Minisat::Solver
 Solver ()
 
virtual ~Solver ()
 
Var newVar (bool polarity=true, bool dvar=true)
 
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_ (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
 
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, bool 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 setConfBudget (int64_t x)
 
void setPropBudget (int64_t x)
 
void budgetOff ()
 
void interrupt ()
 
void clearInterrupt ()
 
void checkGarbage (double gf)
 
void checkGarbage ()
 

Public Attributes

int grow
 
int clause_lim
 
int subsumption_lim
 
double simp_garbage_frac
 
bool use_asymm
 
bool use_rcheck
 
bool use_elim
 
int merges
 
int asymm_lits
 
int eliminated_vars
 
- Public Attributes inherited from Minisat::Solver
vec< lboolmodel
 
vec< Litconflict
 
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 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 clauses_literals
 
uint64_t learnts_literals
 
uint64_t max_literals
 
uint64_t tot_literals
 

Protected Member Functions

lbool solve_ (bool do_simp=true, bool turn_off_simp=false)
 
bool asymm (Var v, CRef cr)
 
bool asymmVar (Var v)
 
void updateElimHeap (Var v)
 
void gatherTouchedClauses ()
 
bool merge (const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
 
bool merge (const Clause &_ps, const Clause &_qs, Var v, int &size)
 
bool backwardSubsumptionCheck (bool verbose=false)
 
bool eliminateVar (Var v)
 
void extendModel ()
 
void removeClause (CRef cr)
 
bool strengthenClause (CRef cr, Lit l)
 
void cleanUpClauses ()
 
bool implied (const vec< Lit > &c)
 
void relocAll (ClauseAllocator &to)
 
- Protected Member Functions inherited from Minisat::Solver
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, vec< Lit > &out_conflict)
 
bool litRedundant (Lit p, uint32_t abstract_levels)
 
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 locked (const Clause &c) const
 
bool satisfied (const Clause &c) const
 
void relocAll (ClauseAllocator &to)
 
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
 

Protected Attributes

int elimorder
 
bool use_simplification
 
vec< uint32_telimclauses
 
vec< char > touched
 
OccLists< Var, vec< CRef >, ClauseDeletedoccurs
 
vec< int > n_occ
 
Heap< ElimLtelim_heap
 
Queue< CRefsubsumption_queue
 
vec< char > frozen
 
vec< char > eliminated
 
int bwdsub_assigns
 
int n_touched
 
CRef bwdsub_tmpunit
 
- Protected Attributes inherited from Minisat::Solver
bool ok
 
vec< CRefclauses
 
vec< CReflearnts
 
double cla_inc
 
vec< double > activity
 
double var_inc
 
OccLists< Lit, vec< Watcher >, WatcherDeletedwatches
 
vec< lboolassigns
 
vec< char > polarity
 
vec< char > decision
 
vec< Littrail
 
vec< int > trail_lim
 
vec< VarDatavardata
 
int qhead
 
int simpDB_assigns
 
int64_t simpDB_props
 
vec< Litassumptions
 
Heap< VarOrderLtorder_heap
 
double progress_estimate
 
bool remove_satisfied
 
ClauseAllocator ca
 
vec< char > seen
 
vec< Litanalyze_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
 

Additional Inherited Members

- Static Protected Member Functions inherited from Minisat::Solver
static VarData mkVarData (CRef cr, int l)
 
static double drand (double &seed)
 
static int irand (double &seed, int size)
 

Detailed Description

Definition at line 34 of file SimpSolver.h.

Constructor & Destructor Documentation

◆ SimpSolver()

SimpSolver::SimpSolver ( )

Definition at line 48 of file SimpSolver.cpp.

48 :
49 grow (opt_grow)
50 , clause_lim (opt_clause_lim)
51 , subsumption_lim (opt_subsumption_lim)
52 , simp_garbage_frac (opt_simp_garbage_frac)
53 , use_asymm (opt_use_asymm)
54 , use_rcheck (opt_use_rcheck)
55 , use_elim (opt_use_elim)
56 , merges (0)
57 , asymm_lits (0)
58 , eliminated_vars (0)
59 , elimorder (1)
60 , use_simplification (true)
63 , bwdsub_assigns (0)
64 , n_touched (0)
65{
66 vec<Lit> dummy(1,lit_Undef);
67 ca.extra_clause_field = true; // NOTE: must happen before allocating the dummy clause below.
68 bwdsub_tmpunit = ca.alloc(dummy);
69 remove_satisfied = false;
70}
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
Definition SimpSolver.h:132
Heap< ElimLt > elim_heap
Definition SimpSolver.h:134
bool remove_satisfied
Definition Solver.h:192
ClauseAllocator ca
Definition Solver.h:194
const Lit lit_Undef
Definition SolverTypes.h:74

◆ ~SimpSolver()

SimpSolver::~SimpSolver ( )

Definition at line 73 of file SimpSolver.cpp.

74{
75}

Member Function Documentation

◆ addClause() [1/4]

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

Definition at line 178 of file SimpSolver.h.

178{ ps.copyTo(add_tmp); return addClause_(add_tmp); }
bool addClause_(vec< Lit > &ps)
vec< Lit > add_tmp
Definition Solver.h:202
Here is the call graph for this function:

◆ addClause() [2/4]

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

Definition at line 180 of file SimpSolver.h.

180{ add_tmp.clear(); add_tmp.push(p); return addClause_(add_tmp); }
Cube * p
Definition exorList.c:222
Here is the call graph for this function:

◆ addClause() [3/4]

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

Definition at line 181 of file SimpSolver.h.

181{ add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ addClause() [4/4]

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

Definition at line 182 of file SimpSolver.h.

182{ add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ addClause_()

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

Definition at line 137 of file SimpSolver.cpp.

138{
139#ifndef NDEBUG
140 for (int i = 0; i < ps.size(); i++)
141 assert(!isEliminated(var(ps[i])));
142#endif
143
144 int nclauses = clauses.size();
145
146 if (use_rcheck && implied(ps))
147 return true;
148
149 if (!Solver::addClause_(ps))
150 return false;
151
152 if (use_simplification && clauses.size() == nclauses + 1){
153 CRef cr = clauses.last();
154 const Clause& c = ca[cr];
155
156 // NOTE: the clause is added to the queue immediately and then
157 // again during 'gatherTouchedClauses()'. If nothing happens
158 // in between, it will only be checked once. Otherwise, it may
159 // be checked twice unnecessarily. This is an unfortunate
160 // consequence of how backward subsumption is used to mimic
161 // forward subsumption.
162 subsumption_queue.insert(cr);
163 for (int i = 0; i < c.size(); i++){
164 occurs[var(c[i])].push(cr);
165 n_occ[toInt(c[i])]++;
166 touched[var(c[i])] = 1;
167 n_touched++;
168 if (elim_heap.inHeap(var(c[i])))
169 elim_heap.increase(var(c[i]));
170 }
171 }
172
173 return true;
174}
Queue< CRef > subsumption_queue
Definition SimpSolver.h:135
bool implied(const vec< Lit > &c)
bool isEliminated(Var v) const
Definition SimpSolver.h:170
vec< char > touched
Definition SimpSolver.h:130
bool addClause_(vec< Lit > &ps)
Definition Solver.cpp:134
vec< CRef > clauses
Definition Solver.h:173
int size(void) const
Definition Vec.h:65
int toInt(Var v)
Definition SolverTypes.h:67
int var(Lit p)
Definition SolverTypes.h:64
RegionAllocator< uint32_t >::Ref CRef
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addEmptyClause()

bool Minisat::SimpSolver::addEmptyClause ( )
inline

Definition at line 179 of file SimpSolver.h.

179{ add_tmp.clear(); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ asymm()

bool SimpSolver::asymm ( Var v,
CRef cr )
protected

Definition at line 400 of file SimpSolver.cpp.

401{
402 Clause& c = ca[cr];
403 assert(decisionLevel() == 0);
404
405 if (c.mark() || satisfied(c)) return true;
406
407 trail_lim.push(trail.size());
408 Lit l = lit_Undef;
409 for (int i = 0; i < c.size(); i++)
410 if (var(c[i]) != v && value(c[i]) != l_False)
411 uncheckedEnqueue(~c[i]);
412 else
413 l = c[i];
414
415 if (propagate() != CRef_Undef){
416 cancelUntil(0);
417 asymm_lits++;
418 if (!strengthenClause(cr, l))
419 return false;
420 }else
421 cancelUntil(0);
422
423 return true;
424}
#define l_False
Definition bmcBmcS.c:36
ABC_NAMESPACE_IMPL_START typedef signed char value
bool strengthenClause(CRef cr, Lit l)
CRef propagate()
Definition Solver.cpp:451
void cancelUntil(int level)
Definition Solver.cpp:209
vec< int > trail_lim
Definition Solver.h:184
vec< Lit > trail
Definition Solver.h:183
int decisionLevel() const
Definition Solver.h:320
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition Solver.cpp:431
bool satisfied(const Clause &c) const
Definition Solver.cpp:200
const CRef CRef_Undef
Here is the call graph for this function:
Here is the caller graph for this function:

◆ asymmVar()

bool SimpSolver::asymmVar ( Var v)
protected

Definition at line 427 of file SimpSolver.cpp.

428{
430
431 const vec<CRef>& cls = occurs.lookup(v);
432
433 if (value(v) != l_Undef || cls.size() == 0)
434 return true;
435
436 for (int i = 0; i < cls.size(); i++)
437 if (!asymm(v, cls[i]))
438 return false;
439
441}
#define l_Undef
Definition bmcBmcS.c:34
bool asymm(Var v, CRef cr)
bool backwardSubsumptionCheck(bool verbose=false)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ backwardSubsumptionCheck()

bool SimpSolver::backwardSubsumptionCheck ( bool verbose = false)
protected

Definition at line 333 of file SimpSolver.cpp.

334{
335 int cnt = 0;
336 int subsumed = 0;
337 int deleted_literals = 0;
338 assert(decisionLevel() == 0);
339
340 while (subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()){
341
342 // Empty subsumption queue and return immediately on user-interrupt:
343 if (asynch_interrupt){
344 subsumption_queue.clear();
345 bwdsub_assigns = trail.size();
346 break; }
347
348 // Check top-level assignments by creating a dummy clause and placing it in the queue:
349 if (subsumption_queue.size() == 0 && bwdsub_assigns < trail.size()){
350 Lit l = trail[bwdsub_assigns++];
351 ca[bwdsub_tmpunit][0] = l;
352 ca[bwdsub_tmpunit].calcAbstraction();
354
355 CRef cr = subsumption_queue.peek(); subsumption_queue.pop();
356 Clause& c = ca[cr];
357
358 if (c.mark()) continue;
359
360 if (verbose && verbosity >= 2 && cnt++ % 1000 == 0)
361 printf("subsumption left: %10d (%10d subsumed, %10d deleted literals)\r", subsumption_queue.size(), subsumed, deleted_literals);
362
363 assert(c.size() > 1 || value(c[0]) == l_True); // Unit-clauses should have been propagated before this point.
364
365 // Find best variable to scan:
366 Var best = var(c[0]);
367 for (int i = 1; i < c.size(); i++)
368 if (occurs[var(c[i])].size() < occurs[best].size())
369 best = var(c[i]);
370
371 // Search all candidates:
372 vec<CRef>& _cs = occurs.lookup(best);
373 CRef* cs = (CRef*)_cs;
374
375 for (int j = 0; j < _cs.size(); j++)
376 if (c.mark())
377 break;
378 else if (!ca[cs[j]].mark() && cs[j] != cr && (subsumption_lim == -1 || ca[cs[j]].size() < subsumption_lim)){
379 Lit l = c.subsumes(ca[cs[j]]);
380
381 if (l == lit_Undef)
382 subsumed++, removeClause(cs[j]);
383 else if (l != lit_Error){
384 deleted_literals++;
385
386 if (!strengthenClause(cs[j], ~l))
387 return false;
388
389 // Did current candidate get deleted from cs? Then check candidate at index j again:
390 if (var(l) == best)
391 j--;
392 }
393 }
394 }
395
396 return true;
397}
#define l_True
Definition bmcBmcS.c:35
Lit subsumes(const Clause &other) const
void removeClause(CRef cr)
lbool value(Var x) const
Definition Solver.h:322
bool asynch_interrupt
Definition Solver.h:212
const Lit lit_Error
Definition SolverTypes.h:75
unsigned long long size
Definition giaNewBdd.h:39
signed char mark
Definition value.h:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanUpClauses()

void SimpSolver::cleanUpClauses ( )
protected

Definition at line 673 of file SimpSolver.cpp.

674{
675 occurs.cleanAll();
676 int i,j;
677 for (i = j = 0; i < clauses.size(); i++)
678 if (ca[clauses[i]].mark() == 0)
679 clauses[j++] = clauses[i];
680 clauses.shrink(i - j);
681}
Here is the caller graph for this function:

◆ eliminate()

bool SimpSolver::eliminate ( bool turn_off_elim = false)

Definition at line 588 of file SimpSolver.cpp.

589{
590 if (!simplify())
591 return false;
592 else if (!use_simplification)
593 return true;
594
595 // Main simplification loop:
596 //
597 while (n_touched > 0 || bwdsub_assigns < trail.size() || elim_heap.size() > 0){
598
600 // printf(" ## (time = %6.2f s) BWD-SUB: queue = %d, trail = %d\n", cpuTime(), subsumption_queue.size(), trail.size() - bwdsub_assigns);
601 if ((subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()) &&
603 ok = false; goto cleanup; }
604
605 // Empty elim_heap and return immediately on user-interrupt:
606 if (asynch_interrupt){
607 assert(bwdsub_assigns == trail.size());
608 assert(subsumption_queue.size() == 0);
609 assert(n_touched == 0);
610 elim_heap.clear();
611 goto cleanup; }
612
613 // printf(" ## (time = %6.2f s) ELIM: vars = %d\n", cpuTime(), elim_heap.size());
614 for (int cnt = 0; !elim_heap.empty(); cnt++){
615 Var elim = elim_heap.removeMin();
616
617 if (asynch_interrupt) break;
618
619 if (isEliminated(elim) || value(elim) != l_Undef) continue;
620
621 if (verbosity >= 2 && cnt % 100 == 0)
622 printf("elimination left: %10d\r", elim_heap.size());
623
624 if (use_asymm){
625 // Temporarily freeze variable. Otherwise, it would immediately end up on the queue again:
626 bool was_frozen = frozen[elim];
627 frozen[elim] = true;
628 if (!asymmVar(elim)){
629 ok = false; goto cleanup; }
630 frozen[elim] = was_frozen; }
631
632 // At this point, the variable may have been set by assymetric branching, so check it
633 // again. Also, don't eliminate frozen variables:
634 if (use_elim && value(elim) == l_Undef && !frozen[elim] && !eliminateVar(elim)){
635 ok = false; goto cleanup; }
636
638 }
639
640 assert(subsumption_queue.size() == 0);
641 }
642 cleanup:
643
644 // If no more simplification is needed, free all simplification-related data structures:
645 if (turn_off_elim){
646 touched .clear(true);
647 occurs .clear(true);
648 n_occ .clear(true);
649 elim_heap.clear(true);
650 subsumption_queue.clear(true);
651
652 use_simplification = false;
653 remove_satisfied = true;
654 ca.extra_clause_field = false;
655
656 // Force full cleanup (this is safe and desirable since it only happens once):
659 }else{
660 // Cheaper cleanup:
661 cleanUpClauses(); // TODO: can we make 'cleanUpClauses()' not be linear in the problem size somehow?
662 checkGarbage();
663 }
664
665 if (verbosity >= 1 && elimclauses.size() > 0)
666 printf("| Eliminated clauses: %10.2f Mb |\n",
667 double(elimclauses.size() * sizeof(uint32_t)) / (1024*1024));
668
669 return ok;
670}
unsigned int uint32_t
Definition Fxch.h:32
bool eliminateVar(Var v)
vec< uint32_t > elimclauses
Definition SimpSolver.h:129
vec< char > frozen
Definition SimpSolver.h:136
virtual void garbageCollect()
void checkGarbage()
Definition Solver.h:305
void rebuildOrderHeap()
Definition Solver.cpp:561
bool simplify()
Definition Solver.cpp:579
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eliminateVar()

bool SimpSolver::eliminateVar ( Var v)
protected

Definition at line 477 of file SimpSolver.cpp.

478{
479 assert(!frozen[v]);
480 assert(!isEliminated(v));
481 assert(value(v) == l_Undef);
482 int i;
483
484 // Split the occurrences into positive and negative:
485 //
486 const vec<CRef>& cls = occurs.lookup(v);
487 vec<CRef> pos, neg;
488 for (i = 0; i < cls.size(); i++)
489 (find(ca[cls[i]], mkLit(v)) ? pos : neg).push(cls[i]);
490
491 // Check wether the increase in number of clauses stays within the allowed ('grow'). Moreover, no
492 // clause must exceed the limit on the maximal clause size (if it is set):
493 //
494 int cnt = 0;
495 int clause_size = 0;
496
497 for (i = 0; i < pos.size(); i++)
498 for (int j = 0; j < neg.size(); j++)
499 if (merge(ca[pos[i]], ca[neg[j]], v, clause_size) &&
500 (++cnt > cls.size() + grow || (clause_lim != -1 && clause_size > clause_lim)))
501 return true;
502
503 // Delete and store old clauses:
504 eliminated[v] = true;
505 setDecisionVar(v, false);
507
508 if (pos.size() > neg.size()){
509 for (int i = 0; i < neg.size(); i++)
510 mkElimClause(elimclauses, v, ca[neg[i]]);
511 mkElimClause(elimclauses, mkLit(v));
512 }else{
513 for (int i = 0; i < pos.size(); i++)
514 mkElimClause(elimclauses, v, ca[pos[i]]);
515 mkElimClause(elimclauses, ~mkLit(v));
516 }
517
518 for (i = 0; i < cls.size(); i++)
519 removeClause(cls[i]);
520
521 // Produce clauses in cross product:
522 vec<Lit>& resolvent = add_tmp;
523 for (i = 0; i < pos.size(); i++)
524 for (int j = 0; j < neg.size(); j++)
525 if (merge(ca[pos[i]], ca[neg[j]], v, resolvent) && !addClause_(resolvent))
526 return false;
527
528 // Free occurs list for this variable:
529 occurs[v].clear(true);
530
531 // Free watchers lists for this variable, if possible:
532 if (watches[ mkLit(v)].size() == 0) watches[ mkLit(v)].clear(true);
533 if (watches[~mkLit(v)].size() == 0) watches[~mkLit(v)].clear(true);
534
536}
bool merge(const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
vec< char > eliminated
Definition SimpSolver.h:137
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
Definition Solver.h:179
void setDecisionVar(Var v, bool b)
Definition Solver.h:332
bool pos
Definition globals.c:30
Lit mkLit(Var var, bool sign=false)
Definition SolverTypes.h:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extendModel()

void SimpSolver::extendModel ( )
protected

Definition at line 571 of file SimpSolver.cpp.

572{
573 int i, j;
574 Lit x;
575
576 for (i = elimclauses.size()-1; i > 0; i -= j){
577 for (j = elimclauses[i--]; j > 1; j--, i--)
579 goto next;
580
581 x = toLit(elimclauses[i]);
582 model[var(x)] = lbool(!sign(x));
583 next:;
584 }
585}
lbool modelValue(Var x) const
Definition Solver.h:324
vec< lbool > model
Definition Solver.h:111
Lit toLit(int i)
Definition SolverTypes.h:69
bool sign(Lit p)
Definition SolverTypes.h:63
signed char lbool
Definition satVec.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ garbageCollect()

void SimpSolver::garbageCollect ( )
virtual

Reimplemented from Minisat::Solver.

Definition at line 712 of file SimpSolver.cpp.

713{
714 // Initialize the next region to a size corresponding to the estimated utilization degree. This
715 // is not precise but should avoid some unnecessary reallocations for the new region:
716 ClauseAllocator to(ca.size() - ca.wasted());
717
719 to.extra_clause_field = ca.extra_clause_field; // NOTE: this is important to keep (or lose) the extra fields.
720 relocAll(to);
722 if (verbosity >= 2)
723 printf("| Garbage collection: %12d bytes => %12d bytes |\n",
725 to.moveTo(ca);
726}
void relocAll(ClauseAllocator &to)
void relocAll(ClauseAllocator &to)
Definition Solver.cpp:878
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gatherTouchedClauses()

void SimpSolver::gatherTouchedClauses ( )
protected

Definition at line 284 of file SimpSolver.cpp.

285{
286 if (n_touched == 0) return;
287
288 int i,j;
289 for (i = j = 0; i < subsumption_queue.size(); i++)
290 if (ca[subsumption_queue[i]].mark() == 0)
291 ca[subsumption_queue[i]].mark(2);
292
293 for (i = 0; i < touched.size(); i++)
294 if (touched[i]){
295 const vec<CRef>& cs = occurs.lookup(i);
296 for (j = 0; j < cs.size(); j++)
297 if (ca[cs[j]].mark() == 0){
298 subsumption_queue.insert(cs[j]);
299 ca[cs[j]].mark(2);
300 }
301 touched[i] = 0;
302 }
303
304 for (i = 0; i < subsumption_queue.size(); i++)
305 if (ca[subsumption_queue[i]].mark() == 2)
306 ca[subsumption_queue[i]].mark(0);
307
308 n_touched = 0;
309}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ implied()

bool SimpSolver::implied ( const vec< Lit > & c)
protected

Definition at line 312 of file SimpSolver.cpp.

313{
314 assert(decisionLevel() == 0);
315
316 trail_lim.push(trail.size());
317 for (int i = 0; i < c.size(); i++)
318 if (value(c[i]) == l_True){
319 cancelUntil(0);
320 return false;
321 }else if (value(c[i]) != l_False){
322 assert(value(c[i]) == l_Undef);
323 uncheckedEnqueue(~c[i]);
324 }
325
326 bool result = propagate() != CRef_Undef;
327 cancelUntil(0);
328 return result;
329}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEliminated()

bool Minisat::SimpSolver::isEliminated ( Var v) const
inline

Definition at line 170 of file SimpSolver.h.

170{ return eliminated[v]; }
Here is the caller graph for this function:

◆ merge() [1/2]

bool SimpSolver::merge ( const Clause & _ps,
const Clause & _qs,
Var v,
int & size )
protected

Definition at line 253 of file SimpSolver.cpp.

254{
255 merges++;
256
257 bool ps_smallest = _ps.size() < _qs.size();
258 const Clause& ps = ps_smallest ? _qs : _ps;
259 const Clause& qs = ps_smallest ? _ps : _qs;
260 const Lit* __ps = (const Lit*)ps;
261 const Lit* __qs = (const Lit*)qs;
262
263 size = ps.size()-1;
264
265 for (int i = 0; i < qs.size(); i++){
266 if (var(__qs[i]) != v){
267 for (int j = 0; j < ps.size(); j++)
268 if (var(__ps[j]) == var(__qs[i]))
269 {
270 if (__ps[j] == ~__qs[i])
271 return false;
272 else
273 goto next;
274 }
275 size++;
276 }
277 next:;
278 }
279
280 return true;
281}
Here is the call graph for this function:

◆ merge() [2/2]

bool SimpSolver::merge ( const Clause & _ps,
const Clause & _qs,
Var v,
vec< Lit > & out_clause )
protected

Definition at line 219 of file SimpSolver.cpp.

220{
221 merges++;
222 out_clause.clear();
223
224 bool ps_smallest = _ps.size() < _qs.size();
225 const Clause& ps = ps_smallest ? _qs : _ps;
226 const Clause& qs = ps_smallest ? _ps : _qs;
227 int i, j;
228
229 for (i = 0; i < qs.size(); i++){
230 if (var(qs[i]) != v){
231 for (j = 0; j < ps.size(); j++)
232 if (var(ps[j]) == var(qs[i]))
233 {
234 if (ps[j] == ~qs[i])
235 return false;
236 else
237 goto next;
238 }
239 out_clause.push(qs[i]);
240 }
241 next:;
242 }
243
244 for (i = 0; i < ps.size(); i++)
245 if (var(ps[i]) != v)
246 out_clause.push(ps[i]);
247
248 return true;
249}
void clear(bool dealloc=false)
Definition Vec.h:126
void push(void)
Definition Vec.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ newVar()

Var SimpSolver::newVar ( bool polarity = true,
bool dvar = true )

Definition at line 78 of file SimpSolver.cpp.

78 {
79 Var v = Solver::newVar(sign, dvar);
80
81 frozen .push((char)false);
82 eliminated.push((char)false);
83
85 n_occ .push(0);
86 n_occ .push(0);
87 occurs .init(v);
88 touched .push(0);
89 elim_heap .insert(v);
90 }
91 return v; }
Var newVar(bool polarity=true, bool dvar=true)
Definition Solver.cpp:116
Here is the call graph for this function:

◆ relocAll()

void SimpSolver::relocAll ( ClauseAllocator & to)
protected

Definition at line 688 of file SimpSolver.cpp.

689{
690 if (!use_simplification) return;
691
692 // All occurs lists:
693 //
694 int i;
695 for (i = 0; i < nVars(); i++){
696 vec<CRef>& cs = occurs[i];
697 for (int j = 0; j < cs.size(); j++)
698 ca.reloc(cs[j], to);
699 }
700
701 // Subsumption queue:
702 //
703 for (i = 0; i < subsumption_queue.size(); i++)
704 ca.reloc(subsumption_queue[i], to);
705
706 // Temporary clause:
707 //
708 ca.reloc(bwdsub_tmpunit, to);
709}
int nVars() const
Definition Solver.h:329
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeClause()

void SimpSolver::removeClause ( CRef cr)
protected

Definition at line 177 of file SimpSolver.cpp.

178{
179 const Clause& c = ca[cr];
180
182 for (int i = 0; i < c.size(); i++){
183 n_occ[toInt(c[i])]--;
184 updateElimHeap(var(c[i]));
185 occurs.smudge(var(c[i]));
186 }
187
189}
void updateElimHeap(Var v)
Definition SimpSolver.h:171
void removeClause(CRef cr)
Definition Solver.cpp:190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFrozen()

void Minisat::SimpSolver::setFrozen ( Var v,
bool b )
inline

Definition at line 183 of file SimpSolver.h.

183{ frozen[v] = (char)b; if (use_simplification && !b) { updateElimHeap(v); } }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve() [1/5]

bool Minisat::SimpSolver::solve ( bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 185 of file SimpSolver.h.

185{ budgetOff(); assumptions.clear(); return solve_(do_simp, turn_off_simp) == l_True; }
void budgetOff()
Definition Solver.h:344
lbool solve_()
Definition Solver.cpp:753
vec< Lit > assumptions
Definition Solver.h:189
Here is the call graph for this function:

◆ solve() [2/5]

bool Minisat::SimpSolver::solve ( const vec< Lit > & assumps,
bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 189 of file SimpSolver.h.

189 {
190 budgetOff(); assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp) == l_True; }
Here is the call graph for this function:

◆ solve() [3/5]

bool Minisat::SimpSolver::solve ( Lit p,
bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 186 of file SimpSolver.h.

186{ budgetOff(); assumptions.clear(); assumptions.push(p); return solve_(do_simp, turn_off_simp) == l_True; }
Here is the call graph for this function:

◆ solve() [4/5]

bool Minisat::SimpSolver::solve ( Lit p,
Lit q,
bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 187 of file SimpSolver.h.

187{ budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_(do_simp, turn_off_simp) == l_True; }
Here is the call graph for this function:

◆ solve() [5/5]

bool Minisat::SimpSolver::solve ( Lit p,
Lit q,
Lit r,
bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 188 of file SimpSolver.h.

188{ budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(do_simp, turn_off_simp) == l_True; }
Here is the call graph for this function:

◆ solve_()

lbool SimpSolver::solve_ ( bool do_simp = true,
bool turn_off_simp = false )
protected

Definition at line 95 of file SimpSolver.cpp.

96{
97 vec<Var> extra_frozen;
98 lbool result = l_True;
99
100 do_simp &= use_simplification;
101
102 if (do_simp){
103 // Assumptions must be temporarily frozen to run variable elimination:
104 for (int i = 0; i < assumptions.size(); i++){
105 Var v = var(assumptions[i]);
106
107 // If an assumption has been eliminated, remember it.
108 assert(!isEliminated(v));
109
110 if (!frozen[v]){
111 // Freeze and store.
112 setFrozen(v, true);
113 extra_frozen.push(v);
114 } }
115
116 result = lbool(eliminate(turn_off_simp));
117 }
118
119 if (result == l_True)
120 result = Solver::solve_();
121 else if (verbosity >= 1)
122 printf("===============================================================================\n");
123
124 if (result == l_True)
125 extendModel();
126
127 if (do_simp)
128 // Unfreeze the assumptions that were frozen:
129 for (int i = 0; i < extra_frozen.size(); i++)
130 setFrozen(extra_frozen[i], false);
131
132 return result;
133}
bool eliminate(bool turn_off_elim=false)
void setFrozen(Var v, bool b)
Definition SimpSolver.h:183
Here is the call graph for this function:

◆ solveLimited()

lbool Minisat::SimpSolver::solveLimited ( const vec< Lit > & assumps,
bool do_simp = true,
bool turn_off_simp = false )
inline

Definition at line 192 of file SimpSolver.h.

192 {
193 assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp); }
Here is the call graph for this function:

◆ strengthenClause()

bool SimpSolver::strengthenClause ( CRef cr,
Lit l )
protected

Definition at line 192 of file SimpSolver.cpp.

193{
194 Clause& c = ca[cr];
195 assert(decisionLevel() == 0);
197
198 // FIX: this is too inefficient but would be nice to have (properly implemented)
199 // if (!find(subsumption_queue, &c))
200 subsumption_queue.insert(cr);
201
202 if (c.size() == 2){
203 removeClause(cr);
204 c.strengthen(l);
205 }else{
206 detachClause(cr, true);
207 c.strengthen(l);
208 attachClause(cr);
209 remove(occurs[var(l)], cr);
210 n_occ[toInt(l)]--;
212 }
213
214 return c.size() == 1 ? enqueue(c[0]) && propagate() == CRef_Undef : true;
215}
void strengthen(Lit p)
void detachClause(CRef cr, bool strict=false)
Definition Solver.cpp:173
void attachClause(CRef cr)
Definition Solver.cpp:164
bool enqueue(Lit p, CRef from=CRef_Undef)
Definition Solver.h:311
Here is the call graph for this function:
Here is the caller graph for this function:

◆ substitute()

bool SimpSolver::substitute ( Var v,
Lit x )

Definition at line 539 of file SimpSolver.cpp.

540{
541 assert(!frozen[v]);
542 assert(!isEliminated(v));
543 assert(value(v) == l_Undef);
544
545 if (!ok) return false;
546
547 eliminated[v] = true;
548 setDecisionVar(v, false);
549 const vec<CRef>& cls = occurs.lookup(v);
550
551 vec<Lit>& subst_clause = add_tmp;
552 for (int i = 0; i < cls.size(); i++){
553 Clause& c = ca[cls[i]];
554
555 subst_clause.clear();
556 for (int j = 0; j < c.size(); j++){
557 Lit p = c[j];
558 subst_clause.push(var(p) == v ? x ^ sign(p) : p);
559 }
560
561 removeClause(cls[i]);
562
563 if (!addClause_(subst_clause))
564 return ok = false;
565 }
566
567 return true;
568}
Here is the call graph for this function:

◆ updateElimHeap()

void Minisat::SimpSolver::updateElimHeap ( Var v)
inlineprotected

Definition at line 171 of file SimpSolver.h.

171 {
173 // if (!frozen[v] && !isEliminated(v) && value(v) == l_Undef)
174 if (elim_heap.inHeap(v) || (!frozen[v] && !isEliminated(v) && value(v) == l_Undef))
175 elim_heap.update(v); }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ asymm_lits

int Minisat::SimpSolver::asymm_lits

Definition at line 97 of file SimpSolver.h.

◆ bwdsub_assigns

int Minisat::SimpSolver::bwdsub_assigns
protected

Definition at line 138 of file SimpSolver.h.

◆ bwdsub_tmpunit

CRef Minisat::SimpSolver::bwdsub_tmpunit
protected

Definition at line 143 of file SimpSolver.h.

◆ clause_lim

int Minisat::SimpSolver::clause_lim

Definition at line 85 of file SimpSolver.h.

◆ elim_heap

Heap<ElimLt> Minisat::SimpSolver::elim_heap
protected

Definition at line 134 of file SimpSolver.h.

◆ elimclauses

vec<uint32_t> Minisat::SimpSolver::elimclauses
protected

Definition at line 129 of file SimpSolver.h.

◆ eliminated

vec<char> Minisat::SimpSolver::eliminated
protected

Definition at line 137 of file SimpSolver.h.

◆ eliminated_vars

int Minisat::SimpSolver::eliminated_vars

Definition at line 98 of file SimpSolver.h.

◆ elimorder

int Minisat::SimpSolver::elimorder
protected

Definition at line 127 of file SimpSolver.h.

◆ frozen

vec<char> Minisat::SimpSolver::frozen
protected

Definition at line 136 of file SimpSolver.h.

◆ grow

int Minisat::SimpSolver::grow

Definition at line 84 of file SimpSolver.h.

◆ merges

int Minisat::SimpSolver::merges

Definition at line 96 of file SimpSolver.h.

◆ n_occ

vec<int> Minisat::SimpSolver::n_occ
protected

Definition at line 133 of file SimpSolver.h.

◆ n_touched

int Minisat::SimpSolver::n_touched
protected

Definition at line 139 of file SimpSolver.h.

◆ occurs

OccLists<Var, vec<CRef>, ClauseDeleted> Minisat::SimpSolver::occurs
protected

Definition at line 132 of file SimpSolver.h.

◆ simp_garbage_frac

double Minisat::SimpSolver::simp_garbage_frac

Definition at line 88 of file SimpSolver.h.

◆ subsumption_lim

int Minisat::SimpSolver::subsumption_lim

Definition at line 87 of file SimpSolver.h.

◆ subsumption_queue

Queue<CRef> Minisat::SimpSolver::subsumption_queue
protected

Definition at line 135 of file SimpSolver.h.

◆ touched

vec<char> Minisat::SimpSolver::touched
protected

Definition at line 130 of file SimpSolver.h.

◆ use_asymm

bool Minisat::SimpSolver::use_asymm

Definition at line 90 of file SimpSolver.h.

◆ use_elim

bool Minisat::SimpSolver::use_elim

Definition at line 92 of file SimpSolver.h.

◆ use_rcheck

bool Minisat::SimpSolver::use_rcheck

Definition at line 91 of file SimpSolver.h.

◆ use_simplification

bool Minisat::SimpSolver::use_simplification
protected

Definition at line 128 of file SimpSolver.h.


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