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;
114 extra_frozen.
push(v);
123 printf(
"===============================================================================\n");
130 for (
int i = 0; i < extra_frozen.
size(); i++)
141 for (
int i = 0; i < ps.
size(); i++)
153 for (
int i = 0; i < ps.
size(); i++)
169 for (
int i = 0; i < c.
size(); i++){
188 for (
int i = 0; i < c.
size(); i++){
209 for (
int i = 0; i < c.
size(); i++)
220 for (
int i = 0; i < c.
size(); i++)
243 bool ps_smallest = _ps.
size() < _qs.
size();
244 const Clause& ps = ps_smallest ? _qs : _ps;
245 const Clause& qs = ps_smallest ? _ps : _qs;
248 for (i = 0; i < qs.
size(); i++){
249 if (
var(qs[i]) != v){
250 for (j = 0; j < ps.
size(); j++)
251 if (
var(ps[j]) ==
var(qs[i])) {
257 out_clause.
push(qs[i]);
262 for (i = 0; i < ps.
size(); i++)
264 out_clause.
push(ps[i]);
275 bool ps_smallest = _ps.
size() < _qs.
size();
276 const Clause& ps = ps_smallest ? _qs : _ps;
277 const Clause& qs = ps_smallest ? _ps : _qs;
278 const Lit* __ps = (
const Lit*)ps;
279 const Lit* __qs = (
const Lit*)qs;
283 for (
int i = 0; i < qs.
size(); i++){
284 if (
var(__qs[i]) != v){
285 for (
int j = 0; j < ps.
size(); j++)
286 if (
var(__ps[j]) ==
var(__qs[i])) {
287 if (__ps[j] == ~__qs[i])
310 for (i = 0; i <
touched.size(); i++)
313 for (j = 0; j < cs.
size(); j++)
314 if (
ca[cs[j]].
mark() == 0){
334 for (
int i = 0; i < c.
size(); i++)
354 int deleted_literals = 0;
375 if (c.
mark())
continue;
377 if (verbose &&
verbosity >= 2 && cnt++ % 1000 == 0)
378 printf(
"subsumption left: %10d (%10d subsumed, %10d deleted literals)\r",
subsumption_queue.size(), subsumed, deleted_literals);
384 for (
int i = 1; i < c.
size(); i++)
392 for (
int j = 0; j < _cs.
size(); j++)
426 for (
int i = 0; i < c.
size(); i++)
453 for (
int i = 0; i < cls.
size(); i++)
454 if (!
asymm(v, cls[i]))
470 int first = elimclauses.
size();
475 for (
int i = 0; i < c.
size(); i++){
485 elimclauses[v_pos] = elimclauses[first];
486 elimclauses[first] = tmp;
505 for (i = 0; i < cls.
size(); i++)
506 (find(
ca[cls[i]],
mkLit(v)) ?
pos : neg).push(cls[i]);
514 for (i = 0; i <
pos.size(); i++)
515 for (j = 0; j < neg.
size(); j++)
526 for (i = 0; i < neg.
size(); i++)
531 for (i = 0; i <
pos.size(); i++)
540 for (i = 0; i <
pos.size(); i++)
541 for (j = 0; j < neg.
size(); j++)
545 for (i = 0; i < cls.
size(); i++)
565 if (!
ok)
return false;
572 for (
int i = 0; i < cls.
size(); i++){
575 subst_clause.
clear();
576 for (
int j = 0; j < c.
size(); j++){
621 int toPerform =
clauses.size()<=4800000;
624 printf(
"c Too many clauses... No preprocessing\n");
633 ok =
false;
goto cleanup; }
644 for (
int cnt = 0; !
elim_heap.empty(); cnt++){
652 printf(
"elimination left: %10d\r",
elim_heap.size());
656 bool was_frozen =
frozen[elim] != 0;
659 ok =
false;
goto cleanup; }
660 frozen[elim] = was_frozen; }
665 ok =
false;
goto cleanup; }
684 ca.extra_clause_field =
false;
696 printf(
"c | Eliminated clauses: %10.2f Mb |\n",
706 for (i = j = 0; i <
clauses.size(); i++)
724 for (i = 0; i <
nVars(); i++){
726 for (
int j = 0; j < cs.
size(); j++)
752 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
771 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)
void setFrozen(Var v, bool b)
bool implied(const vec< Lit > &c)
Queue< CRef > subsumption_queue
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)
bool isEliminated(Var v) const
virtual void garbageCollect()
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
bool backwardSubsumptionCheck(bool verbose=false)
void gatherTouchedClauses()
void relocAll(ClauseAllocator &to)
vec< uint32_t > elimclauses
int decisionLevel() const
bool addClause_(vec< Lit > &ps)
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
void cancelUntil(int level)
void relocAll(ClauseAllocator &to)
void removeClause(CRef cr)
void detachClause(CRef cr, bool strict=false)
void attachClause(CRef cr)
bool enqueue(Lit p, CRef from=CRef_Undef)
Var newVar(bool polarity=true, bool dvar=true)
void setDecisionVar(Var v, bool b)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
lbool modelValue(Var x) const
bool satisfied(const Clause &c) const
void clear(bool dealloc=false)
RegionAllocator< uint32_t >::Ref CRef
Lit mkLit(Var var, bool sign=false)