25 using namespace Minisat;
31 static const char*
_cat =
"SIMP";
36 static IntOption opt_grow (
_cat,
"grow",
"Allow a variable elimination step to grow by a number of clauses.", 0);
58 , use_simplification (
true)
60 , elim_heap (
ElimLt(n_occ))
111 extra_frozen.
push(v);
120 printf(
"===============================================================================\n");
127 for (
int i = 0; i < extra_frozen.
size(); i++)
138 for (
int i = 0; i < ps.
size(); i++)
161 for (
int i = 0; i < c.
size(); i++){
180 for (
int i = 0; i < c.
size(); i++){
222 bool ps_smallest = _ps.
size() < _qs.
size();
223 const Clause& ps = ps_smallest ? _qs : _ps;
224 const Clause& qs = ps_smallest ? _ps : _qs;
227 for (i = 0; i < qs.
size(); i++){
228 if (
var(qs[i]) != v){
229 for (j = 0; j < ps.
size(); j++)
230 if (
var(ps[j]) ==
var(qs[i]))
235 out_clause.
push(qs[i]);
240 for (i = 0; i < ps.
size(); i++)
242 out_clause.
push(ps[i]);
253 bool ps_smallest = _ps.
size() < _qs.
size();
254 const Clause& ps = ps_smallest ? _qs : _ps;
255 const Clause& qs = ps_smallest ? _ps : _qs;
256 const Lit* __ps = (
const Lit*)ps;
257 const Lit* __qs = (
const Lit*)qs;
261 for (
int i = 0; i < qs.
size(); i++){
262 if (
var(__qs[i]) != v){
263 for (
int j = 0; j < ps.
size(); j++)
264 if (
var(__ps[j]) ==
var(__qs[i]))
265 if (__ps[j] == ~__qs[i])
290 for (j = 0; j < cs.
size(); j++)
291 if (
ca[cs[j]].mark() == 0){
311 for (
int i = 0; i < c.
size(); i++)
331 int deleted_literals = 0;
352 if (c.
mark())
continue;
354 if (verbose &&
verbosity >= 2 && cnt++ % 1000 == 0)
355 printf(
"subsumption left: %10d (%10d subsumed, %10d deleted literals)\r",
subsumption_queue.
size(), subsumed, deleted_literals);
361 for (
int i = 1; i < c.
size(); i++)
369 for (
int j = 0; j < _cs.
size(); j++)
403 for (
int i = 0; i < c.
size(); i++)
430 for (
int i = 0; i < cls.
size(); i++)
431 if (!
asymm(v, cls[i]))
447 int first = elimclauses.
size();
452 for (
int i = 0; i < c.
size(); i++){
461 uint32_t tmp = elimclauses[v_pos];
462 elimclauses[v_pos] = elimclauses[first];
463 elimclauses[first] = tmp;
482 for (i = 0; i < cls.
size(); i++)
483 (
find(
ca[cls[i]],
mkLit(v)) ? pos : neg).push(cls[i]);
491 for (i = 0; i < pos.
size(); i++)
492 for (
int j = 0; j < neg.
size(); j++)
493 if (
merge(
ca[pos[i]],
ca[neg[j]], v, clause_size) &&
503 for (
int i = 0; i < neg.
size(); i++)
507 for (
int i = 0; i < pos.
size(); i++)
512 for (i = 0; i < cls.
size(); i++)
517 for (i = 0; i < pos.
size(); i++)
518 for (
int j = 0; j < neg.
size(); j++)
539 if (!
ok)
return false;
546 for (
int i = 0; i < cls.
size(); i++){
549 subst_clause.
clear();
550 for (
int j = 0; j < c.
size(); j++){
597 ok =
false;
goto cleanup; }
608 for (
int cnt = 0; !
elim_heap.empty(); cnt++){
616 printf(
"elimination left: %10d\r",
elim_heap.size());
620 bool was_frozen =
frozen[elim];
623 ok =
false;
goto cleanup; }
624 frozen[elim] = was_frozen; }
629 ok =
false;
goto cleanup; }
660 printf(
"| Eliminated clauses: %10.2f Mb |\n",
689 for (i = 0; i <
nVars(); i++){
691 for (
int j = 0; j < cs.
size(); j++)
717 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
RegionAllocator< uint32_t >::Ref CRef
void removeClause(CRef cr)
void gatherTouchedClauses()
void relocAll(ClauseAllocator &to)
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
lbool modelValue(Var x) const
static DoubleOption opt_simp_garbage_frac(_cat,"simp-gc-frac","The fraction of wasted memory allowed before a garbage collection is triggered during simplification.", 0.5, DoubleRange(0, false, HUGE_VAL, false))
static BoolOption opt_use_elim(_cat,"elim","Perform variable elimination.", true)
void setFrozen(Var v, bool b)
static IntOption opt_subsumption_lim(_cat,"sub-lim","Do not check if subsumption against a clause larger than this. -1 means no limit.", 1000, IntRange(-1, INT32_MAX))
Queue< CRef > subsumption_queue
vec< uint32_t > elimclauses
CRef alloc(const Lits &ps, bool learnt=false)
void clear(bool dealloc=false)
void attachClause(CRef cr)
Lit mkLit(Var var, bool sign)
void setDecisionVar(Var v, bool b)
void cancelUntil(int level)
void updateElimHeap(Var v)
void detachClause(CRef cr, bool strict=false)
static BoolOption opt_use_rcheck(_cat,"rcheck","Check if a clause is already implied. (costly)", false)
virtual void garbageCollect()
static int clause_size(clause *c)
bool merge(const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
static IntOption opt_clause_lim(_cat,"cl-lim","Variables are not eliminated if it produces a resolvent with a length above this limit. -1 means no limit", 20, IntRange(-1, INT32_MAX))
static BoolOption opt_use_asymm(_cat,"asymm","Shrink clauses by asymmetric branching.", false)
bool asymm(Var v, CRef cr)
int decisionLevel() const
bool implied(const vec< Lit > &c)
bool addClause_(vec< Lit > &ps)
bool strengthenClause(CRef cr, Lit l)
void clear(bool dealloc=false)
void reloc(CRef &cr, ClauseAllocator &to)
bool eliminate(bool turn_off_elim=false)
void removeClause(CRef cr)
void relocAll(ClauseAllocator &to)
bool backwardSubsumptionCheck(bool verbose=false)
bool isEliminated(Var v) const
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
static IntOption opt_grow(_cat,"grow","Allow a variable elimination step to grow by a number of clauses.", 0)
Var newVar(bool polarity=true, bool dvar=true)
bool addClause_(vec< Lit > &ps)
Var newVar(bool polarity=true, bool dvar=true)
bool enqueue(Lit p, CRef from=CRef_Undef)
Lit subsumes(const Clause &other) const
static bool find(V &ts, const T &t)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
static void mkElimClause(vec< uint32_t > &elimclauses, Lit x)
bool substitute(Var v, Lit x)
bool satisfied(const Clause &c) const
const T & last(void) const