33static const char* _cat =
"SIMP";
35static BoolOption opt_use_asymm (_cat,
"asymm",
"Shrink clauses by asymmetric branching.",
false);
36static BoolOption opt_use_rcheck (_cat,
"rcheck",
"Check if a clause is already implied. (costly)",
false);
37static BoolOption opt_use_elim (_cat,
"elim",
"Perform variable elimination.",
true);
38static IntOption opt_grow (_cat,
"grow",
"Allow a variable elimination step to grow by a number of clauses.", 0);
39static 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));
40static 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));
41static 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));
67 ca.extra_clause_field =
true;
113 extra_frozen.
push(v);
122 printf(
"===============================================================================\n");
129 for (
int i = 0; i < extra_frozen.
size(); i++)
140 for (
int i = 0; i < ps.
size(); i++)
163 for (
int i = 0; i < c.
size(); i++){
182 for (
int i = 0; i < c.
size(); i++){
224 bool ps_smallest = _ps.
size() < _qs.
size();
225 const Clause& ps = ps_smallest ? _qs : _ps;
226 const Clause& qs = ps_smallest ? _ps : _qs;
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]))
239 out_clause.
push(qs[i]);
244 for (i = 0; i < ps.
size(); i++)
246 out_clause.
push(ps[i]);
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;
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]))
270 if (__ps[j] == ~__qs[i])
293 for (i = 0; i <
touched.size(); i++)
296 for (j = 0; j < cs.
size(); j++)
297 if (
ca[cs[j]].
mark() == 0){
317 for (
int i = 0; i < c.
size(); i++)
337 int deleted_literals = 0;
358 if (c.
mark())
continue;
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);
367 for (
int i = 1; i < c.
size(); i++)
375 for (
int j = 0; j < _cs.
size(); j++)
409 for (
int i = 0; i < c.
size(); i++)
436 for (
int i = 0; i < cls.
size(); i++)
437 if (!
asymm(v, cls[i]))
453 int first = elimclauses.
size();
458 for (
int i = 0; i < c.
size(); i++){
468 elimclauses[v_pos] = elimclauses[first];
469 elimclauses[first] = tmp;
488 for (i = 0; i < cls.
size(); i++)
489 (find(
ca[cls[i]],
mkLit(v)) ?
pos : neg).push(cls[i]);
497 for (i = 0; i <
pos.size(); i++)
498 for (
int j = 0; j < neg.
size(); j++)
509 for (
int i = 0; i < neg.
size(); i++)
513 for (
int i = 0; i <
pos.size(); i++)
518 for (i = 0; i < cls.
size(); i++)
523 for (i = 0; i <
pos.size(); i++)
524 for (
int j = 0; j < neg.
size(); j++)
545 if (!
ok)
return false;
552 for (
int i = 0; i < cls.
size(); i++){
555 subst_clause.
clear();
556 for (
int j = 0; j < c.
size(); j++){
603 ok =
false;
goto cleanup; }
614 for (
int cnt = 0; !
elim_heap.empty(); cnt++){
622 printf(
"elimination left: %10d\r",
elim_heap.size());
626 bool was_frozen =
frozen[elim];
629 ok =
false;
goto cleanup; }
630 frozen[elim] = was_frozen; }
635 ok =
false;
goto cleanup; }
654 ca.extra_clause_field =
false;
666 printf(
"| Eliminated clauses: %10.2f Mb |\n",
677 for (i = j = 0; i <
clauses.size(); i++)
695 for (i = 0; i <
nVars(); i++){
697 for (
int j = 0; j < cs.
size(); j++)
723 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START typedef signed char value
void moveTo(ClauseAllocator &to)
Lit subsumes(const Clause &other) const
bool substitute(Var v, Lit x)
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
void removeClause(CRef cr)
Queue< CRef > subsumption_queue
bool implied(const vec< Lit > &c)
bool eliminate(bool turn_off_elim=false)
bool strengthenClause(CRef cr, Lit l)
Var newVar(bool polarity=true, bool dvar=true)
void updateElimHeap(Var v)
vec< uint32_t > elimclauses
bool asymm(Var v, CRef cr)
bool merge(const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
bool addClause_(vec< Lit > &ps)
bool isEliminated(Var v) const
virtual void garbageCollect()
bool backwardSubsumptionCheck(bool verbose=false)
void gatherTouchedClauses()
void relocAll(ClauseAllocator &to)
void setFrozen(Var v, bool b)
bool addClause_(vec< Lit > &ps)
void cancelUntil(int level)
lbool modelValue(Var x) const
void relocAll(ClauseAllocator &to)
void removeClause(CRef cr)
void detachClause(CRef cr, bool strict=false)
void attachClause(CRef cr)
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
int decisionLevel() const
Var newVar(bool polarity=true, bool dvar=true)
void setDecisionVar(Var v, bool b)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
bool enqueue(Lit p, CRef from=CRef_Undef)
bool satisfied(const Clause &c) const
void clear(bool dealloc=false)
RegionAllocator< uint32_t >::Ref CRef
Lit mkLit(Var var, bool sign=false)