44static const char* _cat =
"CORE";
45static const char* _cr =
"CORE -- RESTART";
46static const char* _cred =
"CORE -- REDUCE";
47static const char* _cm =
"CORE -- MINIMIZE";
48static const char* _certified =
"CORE -- CERTIFIED UNSAT";
53static BoolOption opt_incremental (_cat,
"incremental",
"Use incremental SAT solving",
false);
54static DoubleOption opt_K (_cr,
"K",
"The constant used to force restart", 0.8,
DoubleRange(0,
false, 1,
false));
55static DoubleOption opt_R (_cr,
"R",
"The constant used to block restart", 1.4,
DoubleRange(1,
false, 5,
false));
56static IntOption opt_size_lbd_queue (_cr,
"szLBDQueue",
"The size of moving average for LBD (restarts)", 50,
IntRange(10,
INT32_MAX));
57static IntOption opt_size_trail_queue (_cr,
"szTrailQueue",
"The size of moving average for trail (block restarts)", 5000,
IntRange(10,
INT32_MAX));
59static IntOption opt_first_reduce_db (_cred,
"firstReduceDB",
"The number of conflicts before the first reduce DB", 2000,
IntRange(0,
INT32_MAX));
61static IntOption opt_spec_inc_reduce_db (_cred,
"specialIncReduceDB",
"Special increment for reduce DB", 1000,
IntRange(0,
INT32_MAX));
62static IntOption opt_lb_lbd_frozen_clause (_cred,
"minLBDFrozenClause",
"Protect clauses if their LBD decrease and is lower than (for one turn)", 30,
IntRange(0,
INT32_MAX));
64static IntOption opt_lb_size_minimzing_clause (_cm,
"minSizeMinimizingClause",
"The min size required to minimize clause", 30,
IntRange(3,
INT32_MAX));
65static IntOption opt_lb_lbd_minimzing_clause (_cm,
"minLBDMinimizingClause",
"The min LBD required to minimize clause", 6,
IntRange(3,
INT32_MAX));
68static DoubleOption opt_var_decay (_cat,
"var-decay",
"The variable activity decay factor", 0.8,
DoubleRange(0,
false, 1,
false));
69static DoubleOption opt_clause_decay (_cat,
"cla-decay",
"The clause activity decay factor", 0.999,
DoubleRange(0,
false, 1,
false));
70static 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));
72static IntOption opt_ccmin_mode (_cat,
"ccmin-mode",
"Controls conflict clause minimization (0=none, 1=basic, 2=deep)", 2,
IntRange(0, 2));
73static IntOption opt_phase_saving (_cat,
"phase-saving",
"Controls the level of phase saving (0=none, 1=limited, 2=full)", 2,
IntRange(0, 2));
74static BoolOption opt_rnd_init_act (_cat,
"rnd-init",
"Randomize the initial activity",
false);
79static 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));
128 ,
solves(0),
starts(0),
decisions(0),
rnd_decisions(0),
propagations(0),
conflicts(0),
conflictsRestarts(0),
nbstopsrestarts(0),
nbstopsrestartssame(0),
lastblockatrestart(0)
217 trail .capacity(v+1);
227 if (!
ok)
return false;
230 for (
int i = 0; i < ps.
size(); i++ )
231 printf(
"%s%d ", (
toInt(ps[i]) & 1) ?
"-":
"",
toInt(ps[i]) >> 1 );
241 Lit p;
int i, j, flag = 0;
258 for (
int i = 0; i < ps.
size(); i++ )
259 printf(
"%s%d ", (
toInt(ps[i]) & 1) ?
"-":
"",
toInt(ps[i]) >> 1 );
276 else if (ps.
size() == 1){
280 CRef cr =
ca.alloc(ps,
false);
339 for (
int i = 0; i < c.
size(); i++)
357 for (
int i = 0; i < c.
size(); i++)
372 if(end==-1) end = lits.
size();
373 unsigned int nbDone = 0;
374 for(
int i=0;i<lits.
size();i++) {
375 if(nbDone>=end)
break;
385 for(
int i=0;i<lits.
size();i++) {
403 for(
int i=0;i<c.
size();i++) {
414 for(
int i=0;i<c.
size();i++) {
433 Lit p = ~out_learnt[0];
438 for(
int i = 1;i<out_learnt.
size();i++) {
444 for(
int k = 0;k<wbin.
size();k++) {
445 Lit imp = wbin[k].blocker;
451 int l = out_learnt.
size()-1;
454 for(
int i = 1;i<out_learnt.
size()-nb;i++) {
456 Lit p = out_learnt[l];
457 out_learnt[l] = out_learnt[i];
537 int index =
trail.size() - 1;
549 c[0] = c[1], c[1] = tmp;
559 if(nblevels+1<c.
lbd() ) {
579#ifdef UPDATEVARACTIVITY
582 lastDecisionLevel.push(q);
609 for(i = 0;i<selectors.
size();i++)
610 out_learnt.
push(selectors[i]);
615 for (i = 1; i < out_learnt.
size(); i++)
618 for (i = j = 1; i < out_learnt.
size(); i++)
620 out_learnt[j++] = out_learnt[i];
623 for (i = j = 1; i < out_learnt.
size(); i++){
624 Var x =
var(out_learnt[i]);
627 out_learnt[j++] = out_learnt[i];
631 for (
int k = ((c.
size()==2) ? 0:1); k < c.
size(); k++)
633 out_learnt[j++] = out_learnt[i];
638 i = j = out_learnt.
size();
656 if (out_learnt.
size() == 1)
661 for (
int i = 2; i < out_learnt.
size(); i++)
665 Lit p = out_learnt[max_i];
666 out_learnt[max_i] = out_learnt[1];
674 szWithoutSelectors = 0;
675 for(
int i=0;i<out_learnt.
size();i++) {
680 szWithoutSelectors = out_learnt.
size();
686#ifdef UPDATEVARACTIVITY
688 if(lastDecisionLevel.size()>0) {
689 for(
int i = 0;i<lastDecisionLevel.size();i++) {
690 if(
ca[
reason(
var(lastDecisionLevel[i]))].lbd()<lbd)
693 lastDecisionLevel.clear();
700 for(j = 0 ; j<selectors.
size() ; j++)
seen[
var(selectors[j])] = 0;
716 c[0] = c[1], c[1] = tmp;
719 for (
int i = 1; i < c.
size(); i++){
751 out_conflict.
clear();
752 out_conflict.
push(
p);
770 for (
int j = ((c.
size()==2) ? 0:1); j < c.
size(); j++)
817 for(
int k = 0;k<wbin.
size();k++) {
818 Lit imp = wbin[k].blocker;
827 for (i = j = (
Watcher*)ws, end = i + ws.
size(); i != end;){
831 *j++ = *i++;
continue; }
837 if (c[0] == false_lit)
838 c[0] = c[1], c[1] = false_lit;
839 assert(c[1] == false_lit);
846 *j++ = w;
continue; }
851 for (
int k = 2; k < c.
size(); k++) {
868 c[1] = c[choosenPos]; c[choosenPos] = false_lit;
872 for (
int k = 2; k < c.
size(); k++) {
875 c[1] = c[k]; c[k] = false_lit;
919 if(
ca[x].size()> 2 &&
ca[y].size()==2)
return 1;
921 if(
ca[y].size()> 2 &&
ca[x].size()==2)
return 0;
922 if(
ca[x].size()==2 &&
ca[y].size()==2)
return 0;
925 if(
ca[x].lbd()>
ca[y].lbd())
return 1;
926 if(
ca[x].lbd()<
ca[y].lbd())
return 0;
929 return ca[x].activity() <
ca[y].activity();
949 int limit =
learnts.size() / 2;
950 for (i = j = 0; i <
learnts.size(); i++){
970 for (i = j = 0; i < cs.
size(); i++){
1041 int backtrack_level;
1044 unsigned int nblevels,szWoutSelectors;
1056 printf(
"c | %8d %7d %5d | %7d %8d %8d | %5d %8d %6d %8d | %6.3f %% |\n",
1074 learnt_clause.
clear();
1076 analyze(confl, learnt_clause, selectors,backtrack_level,nblevels,szWoutSelectors);
1084 for (
int i = 0; i < learnt_clause.
size(); i++)
1086 (-2 *
sign(learnt_clause[i]) + 1) );
1090 if (learnt_clause.
size() == 1){
1093 CRef cr =
ca.alloc(learnt_clause,
true);
1094 ca[cr].setLBD(nblevels);
1095 ca[cr].setSizeWithoutSelectors(szWoutSelectors);
1096 if(nblevels<=2)
nbDL2++;
1174 double progress = 0;
1175 double F = 1.0 /
nVars();
1178 int beg = i == 0 ? 0 :
trail_lim[i - 1];
1180 progress += pow(F, i) * (end - beg);
1183 return progress /
nVars();
1188 printf(
"c---------- Glucose Stats -------------------------\n");
1189 printf(
"c restarts : %ld\n",
starts);
1192 printf(
"c nb learnts DL2 : %ld\n",
nbDL2);
1193 printf(
"c nb learnts size 2 : %ld\n",
nbBin);
1194 printf(
"c nb learnts size 1 : %ld\n",
nbUn);
1196 printf(
"c conflicts : %ld\n",
conflicts);
1197 printf(
"c decisions : %ld\n",
decisions);
1202 printf(
"c--------------------------------------------------\n");
1213 printf(
"Can not use incremental and certified unsat in the same time\n");
1219 double curTime = cpuTime();
1228 printf(
"c ========================================[ MAGIC CONSTANTS ]==============================================\n");
1229 printf(
"c | Constants are supposed to work well together :-) |\n");
1230 printf(
"c | however, if you find better choices, please let us known... |\n");
1231 printf(
"c |-------------------------------------------------------------------------------------------------------|\n");
1232 printf(
"c | | | |\n");
1233 printf(
"c | - Restarts: | - Reduce Clause DB: | - Minimize Asserting: |\n");
1238 printf(
"c | | | |\n");
1239printf(
"c ==================================[ Search Statistics (every %6d conflicts) ]=========================\n",
verbEveryConflicts);
1242 printf(
"c | RESTARTS | ORIGINAL | LEARNT | Progress |\n");
1243 printf(
"c | NB Blocked Avg Cfc | Vars Clauses Literals | Red Learnts LBD2 Removed | |\n");
1244 printf(
"c =========================================================================================================\n");
1248 int curr_restarts = 0;
1257 printf(
"c =========================================================================================================\n");
1276 double finalTime = cpuTime();
1289 int message = (status ==
l_True ? 1 : status ==
l_False ? 0 : -1);
1291 pCex =
new int[
nVars()];
1292 for (
int i = 0; i <
nVars(); i++)
1297 assert(callback_result == 0);
1312 if (
map.size() <= x ||
map[x] == -1){
1313 map.growTo(x+1, -1);
1324 for (
int i = 0; i < c.
size(); i++)
1326 fprintf(f,
"%s%d ",
sign(c[i]) ?
"-" :
"", mapVar(
var(c[i]),
map, max)+1);
1333 FILE* f = fopen(
file,
"wb");
1335 fprintf(stderr,
"could not open file %s\n",
file),
exit(1);
1345 fprintf(f,
"p cnf 1 2\n1 0\n-1 0\n");
1353 for (i = 0; i <
clauses.size(); i++)
1357 for (i = 0; i <
clauses.size(); i++)
1360 for (
int j = 0; j < c.
size(); j++)
1362 mapVar(
var(c[j]),
map, max);
1368 fprintf(f,
"p cnf %d %d\n", max, cnt);
1375 for (i = 0; i <
clauses.size(); i++)
1379 printf(
"Wrote %d clauses with %d variables.\n", cnt, max);
1394 for (v = 0; v <
nVars(); v++)
1395 for (s = 0; s < 2; s++){
1399 for (j = 0; j < ws.
size(); j++)
1400 ca.reloc(ws[j].cref, to);
1402 for (j = 0; j < ws2.
size(); j++)
1403 ca.reloc(ws2[j].cref, to);
1408 for (i = 0; i <
trail.size(); i++){
1417 for (i = 0; i <
learnts.size(); i++)
1422 for (i = 0; i <
clauses.size(); i++)
1435 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
1493 lastDecisionLevel.clear(
false);
StringOption opt_certified_file_(_certified, "certified-output", "Certified UNSAT output file", "NULL")
BoolOption opt_certified_(_certified, "certified", "Certified UNSAT using DRUP format", false)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START typedef signed char value
void moveTo(ClauseAllocator &to)
unsigned int sizeWithoutSelectors() const
bool locked(const Clause &c) const
int decisionLevel() const
static double drand(double &seed)
bool addClause_(vec< Lit > &ps)
lbool search(int nof_conflicts)
void toDimacs(FILE *f, const vec< Lit > &assumps)
int64_t lastblockatrestart
vec< int > assumptionPositions
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
void cancelUntil(int level)
unsigned int computeLBD(const vec< Lit > &lits, int end=-1)
bool litRedundant(Lit p, uint32_t abstract_levels)
vec< unsigned int > permDiff
int(* pCnfFunc)(void *p, int, int *)
int64_t conflictsRestarts
static int irand(double &seed, int size)
virtual void garbageCollect()
double progressEstimate() const
void relocAll(ClauseAllocator &to)
void removeClause(CRef cr)
void detachClause(CRef cr, bool strict=false)
void minimisationWithBinaryResolution(vec< Lit > &out_learnt)
void attachClause(CRef cr)
void removeSatisfied(vec< CRef > &cs)
void analyzeFinal(Lit p, vec< Lit > &out_conflict)
OccLists< Lit, vec< Watcher >, WatcherDeleted > watchesBin
uint32_t abstractLevel(Var x) const
static VarData mkVarData(CRef cr, int l)
int nbclausesbeforereduce
bqueue< unsigned int > trailQueue
void initNbInitialVars(int nb)
void insertVarOrder(Var x)
bool withinBudget() const
bool terminate_search_early
Heap< VarOrderLt > order_heap
void claBumpActivity(Clause &c)
unsigned int lbLBDFrozenClause
vec< int > initialPositions
int lbSizeMinimizingClause
Var newVar(bool polarity=true, bool dvar=true)
void varBumpActivity(Var v, double inc)
int64_t propagation_budget
void setDecisionVar(Var v, bool b)
void printIncrementalStats()
bqueue< unsigned int > lbdQueue
void setIncrementalMode()
vec< Lit > analyze_toclear
void analyze(CRef confl, vec< Lit > &out_learnt, vec< Lit > &selectors, int &out_btlevel, unsigned int &nblevels, unsigned int &szWithoutSelectors)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
unsigned int lbLBDMinimizingClause
int64_t nbstopsrestartssame
bool satisfied(const Clause &c) const
void copyTo_(vec< T > ©) const
void clear(bool dealloc=false)
#define LOWER_BOUND_FOR_BLOCKING_RESTART
#define RATIOREMOVECLAUSES
RegionAllocator< uint32_t >::Ref CRef
void sort(T *array, int size, LessThan lt)
RegionAllocator< uint32_t >::Ref CRef
Lit mkLit(Var var, bool sign=false)
reduceDB_lt(ClauseAllocator &ca_)