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));
68 ca.extra_clause_field =
true;
115 extra_frozen.
push(v);
124 printf(
"===============================================================================\n");
131 for (
int i = 0; i < extra_frozen.
size(); i++)
142 for (
int i = 0; i < ps.
size(); i++)
154 for (
int i = 0; i < ps.
size(); i++)
170 for (
int i = 0; i < c.
size(); i++){
189 for (
int i = 0; i < c.
size(); i++){
210 for (
int i = 0; i < c.
size(); i++)
221 for (
int i = 0; i < c.
size(); i++)
244 bool ps_smallest = _ps.
size() < _qs.
size();
245 const Clause& ps = ps_smallest ? _qs : _ps;
246 const Clause& qs = ps_smallest ? _ps : _qs;
249 for (i = 0; i < qs.
size(); i++){
250 if (
var(qs[i]) != v){
251 for (j = 0; j < ps.
size(); j++)
252 if (
var(ps[j]) ==
var(qs[i])) {
258 out_clause.
push(qs[i]);
263 for (i = 0; i < ps.
size(); i++)
265 out_clause.
push(ps[i]);
276 bool ps_smallest = _ps.
size() < _qs.
size();
277 const Clause& ps = ps_smallest ? _qs : _ps;
278 const Clause& qs = ps_smallest ? _ps : _qs;
279 const Lit* __ps = (
const Lit*)ps;
280 const Lit* __qs = (
const Lit*)qs;
284 for (
int i = 0; i < qs.
size(); i++){
285 if (
var(__qs[i]) != v){
286 for (
int j = 0; j < ps.
size(); j++)
287 if (
var(__ps[j]) ==
var(__qs[i])) {
288 if (__ps[j] == ~__qs[i])
311 for (i = 0; i <
touched.size(); i++)
314 for (j = 0; j < cs.
size(); j++)
315 if (
ca[cs[j]].
mark() == 0){
335 for (
int i = 0; i < c.
size(); i++)
355 int deleted_literals = 0;
376 if (c.
mark())
continue;
378 if (verbose &&
verbosity >= 2 && cnt++ % 1000 == 0)
379 printf(
"subsumption left: %10d (%10d subsumed, %10d deleted literals)\r",
subsumption_queue.size(), subsumed, deleted_literals);
385 for (
int i = 1; i < c.
size(); i++)
393 for (
int j = 0; j < _cs.
size(); j++)
427 for (
int i = 0; i < c.
size(); i++)
454 for (
int i = 0; i < cls.
size(); i++)
455 if (!
asymm(v, cls[i]))
471 int first = elimclauses.
size();
476 for (
int i = 0; i < c.
size(); i++){
486 elimclauses[v_pos] = elimclauses[first];
487 elimclauses[first] = tmp;
506 for (i = 0; i < cls.
size(); i++)
507 (find(
ca[cls[i]],
mkLit(v)) ?
pos : neg).push(cls[i]);
515 for (i = 0; i <
pos.size(); i++)
516 for (j = 0; j < neg.
size(); j++)
527 for (i = 0; i < neg.
size(); i++)
532 for (i = 0; i <
pos.size(); i++)
541 for (i = 0; i <
pos.size(); i++)
542 for (j = 0; j < neg.
size(); j++)
546 for (i = 0; i < cls.
size(); i++)
566 if (!
ok)
return false;
573 for (
int i = 0; i < cls.
size(); i++){
576 subst_clause.
clear();
577 for (
int j = 0; j < c.
size(); j++){
622 int toPerform =
clauses.size()<=4800000;
625 printf(
"c Too many clauses... No preprocessing\n");
634 ok =
false;
goto cleanup; }
645 for (
int cnt = 0; !
elim_heap.empty(); cnt++){
653 printf(
"elimination left: %10d\r",
elim_heap.size());
657 bool was_frozen =
frozen[elim] != 0;
660 ok =
false;
goto cleanup; }
661 frozen[elim] = was_frozen; }
666 ok =
false;
goto cleanup; }
685 ca.extra_clause_field =
false;
697 printf(
"c | Eliminated clauses: %10.2f Mb |\n",
707 for (i = j = 0; i <
clauses.size(); i++)
725 for (i = 0; i <
nVars(); i++){
727 for (
int j = 0; j < cs.
size(); j++)
753 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
766 ca.extra_clause_field =
true;
#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
void updateElimHeap(Var v)
bool substitute(Var v, Lit x)
void removeClause(CRef cr)
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)
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)
vec< uint32_t > elimclauses
virtual void garbageCollect()
Queue< CRef > subsumption_queue
bool backwardSubsumptionCheck(bool verbose=false)
void gatherTouchedClauses()
void relocAll(ClauseAllocator &to)
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
void setFrozen(Var v, bool b)
bool isEliminated(Var v) const
bool addClause_(vec< Lit > &ps)
bool enqueue(Lit p, CRef from=CRef_Undef)
void cancelUntil(int level)
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
void relocAll(ClauseAllocator &to)
void removeClause(CRef cr)
void setDecisionVar(Var v, bool b, bool use_oheap=true)
void detachClause(CRef cr, bool strict=false)
int decisionLevel() const
void attachClause(CRef cr)
lbool modelValue(Var x) const
Var newVar(bool polarity=true, bool dvar=true)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
bool satisfied(const Clause &c) const
void clear(bool dealloc=false)
Lit mkLit(Var var, bool sign=false)
RegionAllocator< uint32_t >::Ref CRef