26 using namespace Minisat;
32 static const char*
_cat =
"CORE";
71 , learntsize_factor((double)1/(double)3), learntsize_inc(1.1)
75 , learntsize_adjust_start_confl (100)
76 , learntsize_adjust_inc (1.5)
80 , solves(0), starts(0), decisions(0), rnd_decisions(0), propagations(0), conflicts(0)
81 , dec_vars(0), clauses_literals(0), learnts_literals(0), max_literals(0), tot_literals(0)
91 , progress_estimate (0)
92 , remove_satisfied (
true)
96 , conflict_budget (-1)
97 , propagation_budget (-1)
98 , asynch_interrupt (
false)
126 trail .capacity(v+1);
135 if (!
ok)
return false;
149 else if (ps.
size() == 1){
199 for (
int i = 0; i < c.
size(); i++)
272 int index =
trail.size() - 1;
309 uint32_t abstract_level = 0;
310 for (i = 1; i < out_learnt.
size(); i++)
313 for (i = j = 1; i < out_learnt.
size(); i++)
315 out_learnt[j++] = out_learnt[i];
318 for (i = j = 1; i < out_learnt.
size(); i++){
319 Var x =
var(out_learnt[i]);
322 out_learnt[j++] = out_learnt[i];
325 for (
int k = 1; k < c.
size(); k++)
327 out_learnt[j++] = out_learnt[i];
332 i = j = out_learnt.
size();
340 if (out_learnt.
size() == 1)
345 for (
int i = 2; i < out_learnt.
size(); i++)
349 Lit p = out_learnt[max_i];
350 out_learnt[max_i] = out_learnt[1];
369 for (
int i = 1; i < c.size(); i++){
401 out_conflict.
clear();
402 out_conflict.
push(p);
417 for (
int j = 1; j < c.
size(); j++)
461 for (i = j = (
Watcher*)ws, end = i + ws.
size(); i != end;){
465 *j++ = *i++;
continue; }
471 if (c[0] == false_lit)
472 c[0] = c[1], c[1] = false_lit;
473 assert(c[1] == false_lit);
480 *j++ = w;
continue; }
483 for (
int k = 2; k < c.size(); k++)
485 c[1] = c[k]; c[k] = false_lit;
523 return ca[x].size() > 2 && (ca[y].size() == 2 || ca[x].activity() < ca[y].activity()); }
535 if (c.
size() > 2 && !
locked(c) && (i < learnts.size() / 2 || c.
activity() < extra_lim))
538 learnts[j++] = learnts[i];
548 for (i = j = 0; i < cs.
size(); i++){
629 learnt_clause.
clear();
630 analyze(confl, learnt_clause, backtrack_level);
633 if (learnt_clause.
size() == 1){
652 printf(
"| %9d | %7d %8d %8d | %8d %8d %6.0f | %6.3f %% |\n",
660 if (nof_conflicts >= 0 && conflictC >= nof_conflicts || !
withinBudget()){
711 double F = 1.0 /
nVars();
716 progress += pow(F, i) * (end - beg);
719 return progress /
nVars();
734 static double luby(
double y,
int x){
739 for (size = 1, seq = 0; size < x+1; seq++, size = 2*size+1);
765 printf(
"============================[ Search Statistics ]==============================\n");
766 printf(
"| Conflicts | ORIGINAL | LEARNT | Progress |\n");
767 printf(
"| | Vars Clauses Literals | Limit Clauses Lit/Cl | |\n");
768 printf(
"===============================================================================\n");
772 int curr_restarts = 0;
781 printf(
"===============================================================================\n");
802 if (map.
size() <= x || map[x] == -1){
814 for (
int i = 0; i < c.
size(); i++)
816 fprintf(f,
"%s%d ",
sign(c[i]) ?
"-" :
"",
mapVar(
var(c[i]), map, max)+1);
823 FILE* f = fopen(file,
"wr");
825 fprintf(stderr,
"could not open file %s\n", file),
exit(1);
835 fprintf(f,
"p cnf 1 2\n1 0\n-1 0\n");
850 for (
int j = 0; j < c.
size(); j++)
858 fprintf(f,
"p cnf %d %d\n", max, cnt);
869 printf(
"Wrote %d clauses with %d variables.\n", cnt, max);
882 for (
int v = 0; v <
nVars(); v++)
883 for (
int s = 0; s < 2; s++){
887 for (
int j = 0; j < ws.
size(); j++)
894 for (i = 0; i <
trail.size(); i++){
921 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
RegionAllocator< uint32_t >::Ref CRef
bool locked(const Clause &c) const
int learntsize_adjust_cnt
void sort(T *array, int size, LessThan lt)
static DoubleOption opt_clause_decay(_cat,"cla-decay","The clause activity decay factor", 0.999, DoubleRange(0, false, 1, false))
void relocAll(ClauseAllocator &to)
static DoubleOption opt_random_seed(_cat,"rnd-seed","Used by the random variable selection", 91648253, DoubleRange(0, false, HUGE_VAL, false))
double learntsize_adjust_inc
bool withinBudget() const
static IntOption opt_phase_saving(_cat,"phase-saving","Controls the level of phase saving (0=none, 1=limited, 2=full)", 2, IntRange(0, 2))
void claBumpActivity(Clause &c)
CRef alloc(const Lits &ps, bool learnt=false)
int learntsize_adjust_start_confl
static BoolOption opt_rnd_init_act(_cat,"rnd-init","Randomize the initial activity", false)
void attachClause(CRef cr)
Lit mkLit(Var var, bool sign)
lbool search(int nof_conflicts)
void setDecisionVar(Var v, bool b)
void cancelUntil(int level)
void insertVarOrder(Var x)
void copyTo(vec< T > ©) const
void detachClause(CRef cr, bool strict=false)
void removeSatisfied(vec< CRef > &cs)
static Var mapVar(Var x, vec< Var > &map, Var &max)
bool litRedundant(Lit p, uint32_t abstract_levels)
uint64_t learnts_literals
int decisionLevel() const
static DoubleOption opt_restart_inc(_cat,"rinc","Restart interval increase factor", 2, DoubleRange(1, false, HUGE_VAL, false))
static IntOption opt_restart_first(_cat,"rfirst","The base restart interval", 100, IntRange(1, INT32_MAX))
bool addClause_(vec< Lit > &ps)
uint64_t clauses_literals
void clear(bool dealloc=false)
reduceDB_lt(ClauseAllocator &ca_)
void reloc(CRef &cr, ClauseAllocator &to)
static DoubleOption opt_garbage_frac(_cat,"gc-frac","The fraction of wasted memory allowed before a garbage collection is triggered", 0.20, DoubleRange(0, false, HUGE_VAL, false))
void removeClause(CRef cr)
vec< Lit > analyze_toclear
void toDimacs(FILE *f, const vec< Lit > &assumps)
static double drand(double &seed)
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
static DoubleOption opt_var_decay(_cat,"var-decay","The variable activity decay factor", 0.95, DoubleRange(0, false, 1, false))
virtual void garbageCollect()
static BoolOption opt_luby_restart(_cat,"luby","Use the Luby restart sequence", true)
static int irand(double &seed, int size)
static IntOption opt_ccmin_mode(_cat,"ccmin-mode","Controls conflict clause minimization (0=none, 1=basic, 2=deep)", 2, IntRange(0, 2))
static double luby(double y, int x)
Var newVar(bool polarity=true, bool dvar=true)
void analyzeFinal(Lit p, vec< Lit > &out_conflict)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
uint32_t abstractLevel(Var x) const
void analyze(CRef confl, vec< Lit > &out_learnt, int &out_btlevel)
bool satisfied(const Clause &c) const
double progressEstimate() const
static DoubleOption opt_random_var_freq(_cat,"rnd-freq","The frequency with which the decision heuristic tries to choose a random variable", 0, DoubleRange(0, true, 1, true))
void varBumpActivity(Var v, double inc)
Heap< VarOrderLt > order_heap
static VarData mkVarData(CRef cr, int l)
const T & last(void) const
double learntsize_adjust_confl