45static const char* _cat =
"CORE";
46static const char* _cr =
"CORE -- RESTART";
47static const char* _cred =
"CORE -- REDUCE";
48static const char* _cm =
"CORE -- MINIMIZE";
49static const char* _certified =
"CORE -- CERTIFIED UNSAT";
54static BoolOption opt_incremental (_cat,
"incremental",
"Use incremental SAT solving",
false);
55static DoubleOption opt_K (_cr,
"K",
"The constant used to force restart", 0.8,
DoubleRange(0,
false, 1,
false));
56static DoubleOption opt_R (_cr,
"R",
"The constant used to block restart", 1.4,
DoubleRange(1,
false, 5,
false));
57static IntOption opt_size_lbd_queue (_cr,
"szLBDQueue",
"The size of moving average for LBD (restarts)", 50,
IntRange(10,
INT32_MAX));
58static IntOption opt_size_trail_queue (_cr,
"szTrailQueue",
"The size of moving average for trail (block restarts)", 5000,
IntRange(10,
INT32_MAX));
60static IntOption opt_first_reduce_db (_cred,
"firstReduceDB",
"The number of conflicts before the first reduce DB", 2000,
IntRange(0,
INT32_MAX));
62static IntOption opt_spec_inc_reduce_db (_cred,
"specialIncReduceDB",
"Special increment for reduce DB", 1000,
IntRange(0,
INT32_MAX));
63static 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));
65static IntOption opt_lb_size_minimzing_clause (_cm,
"minSizeMinimizingClause",
"The min size required to minimize clause", 30,
IntRange(3,
INT32_MAX));
66static IntOption opt_lb_lbd_minimzing_clause (_cm,
"minLBDMinimizingClause",
"The min LBD required to minimize clause", 6,
IntRange(3,
INT32_MAX));
69static DoubleOption opt_var_decay (_cat,
"var-decay",
"The variable activity decay factor", 0.8,
DoubleRange(0,
false, 1,
false));
70static DoubleOption opt_clause_decay (_cat,
"cla-decay",
"The clause activity decay factor", 0.999,
DoubleRange(0,
false, 1,
false));
71static 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));
73static IntOption opt_ccmin_mode (_cat,
"ccmin-mode",
"Controls conflict clause minimization (0=none, 1=basic, 2=deep)", 2,
IntRange(0, 2));
74static IntOption opt_phase_saving (_cat,
"phase-saving",
"Controls the level of phase saving (0=none, 1=limited, 2=full)", 2,
IntRange(0, 2));
75static BoolOption opt_rnd_init_act (_cat,
"rnd-init",
"Randomize the initial activity",
false);
80static 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));
129 ,
solves(0),
starts(0),
decisions(0),
rnd_decisions(0),
propagations(0),
conflicts(0),
conflictsRestarts(0),
nbstopsrestarts(0),
nbstopsrestartssame(0),
lastblockatrestart(0)
238 trail .capacity(v+1);
271 if (!
ok)
return false;
274 for (
int i = 0; i < ps.
size(); i++ )
275 printf(
"%s%d ", (
toInt(ps[i]) & 1) ?
"-":
"",
toInt(ps[i]) >> 1 );
285 Lit p;
int i, j, flag = 0;
302 for (
int i = 0; i < ps.
size(); i++ )
303 printf(
"%s%d ", (
toInt(ps[i]) & 1) ?
"-":
"",
toInt(ps[i]) >> 1 );
320 else if (ps.
size() == 1){
324 CRef cr =
ca.alloc(ps,
false);
383 for (
int i = 0; i < c.
size(); i++)
401 for (
int i = 0; i < c.
size(); i++)
416 if(end==-1) end = lits.
size();
417 unsigned int nbDone = 0;
418 for(
int i=0;i<lits.
size();i++) {
419 if(nbDone>=end)
break;
429 for(
int i=0;i<lits.
size();i++) {
447 for(
int i=0;i<c.
size();i++) {
458 for(
int i=0;i<c.
size();i++) {
477 Lit p = ~out_learnt[0];
482 for(
int i = 1;i<out_learnt.
size();i++) {
488 for(
int k = 0;k<wbin.
size();k++) {
489 Lit imp = wbin[k].blocker;
495 int l = out_learnt.
size()-1;
498 for(
int i = 1;i<out_learnt.
size()-nb;i++) {
500 Lit p = out_learnt[l];
501 out_learnt[l] = out_learnt[i];
615 int index =
trail.size() - 1;
633 c[0] = c[1], c[1] = tmp;
643 if(nblevels+1<c.
lbd() ) {
668 #ifdef UPDATEVARACTIVITY
673 lastDecisionLevel.push(q);
676 lastDecisionLevel.push(q);
704 for(i = 0;i<selectors.
size();i++) out_learnt.
push(selectors[i]);
708 for(i = 0;i<out_learnt.
size();i++)
715 for (i = 1; i < out_learnt.
size(); i++)
718 for (i = j = 1; i < out_learnt.
size(); i++)
720 out_learnt[j++] = out_learnt[i];
723 for (i = j = 1; i < out_learnt.
size(); i++){
724 Var x =
var(out_learnt[i]);
727 out_learnt[j++] = out_learnt[i];
735 for (
int k = ((c.
size()==2) ? 0:1); k < c.
size(); k++)
737 out_learnt[j++] = out_learnt[i];
742 i = j = out_learnt.
size();
760 if (out_learnt.
size() == 1)
765 for (
int i = 2; i < out_learnt.
size(); i++)
769 Lit p = out_learnt[max_i];
770 out_learnt[max_i] = out_learnt[1];
778 szWithoutSelectors = 0;
779 for(
int i=0;i<out_learnt.
size();i++) {
784 szWithoutSelectors = out_learnt.
size();
790#ifdef UPDATEVARACTIVITY
792 if(lastDecisionLevel.size()>0) {
793 for(
int i = 0;i<lastDecisionLevel.size();i++) {
794 Lit t = lastDecisionLevel[i];
799 lastDecisionLevel.shrink_( lastDecisionLevel.size() );
810 for (j = 0; j <
jheap.size(); j++){
835 for(j = 0 ; j<selectors.
size() ; j++)
seen[
var(selectors[j])] = 0;
855 c[0] = c[1], c[1] = tmp;
858 for (
int i = 1; i < c.
size(); i++){
891 out_conflict.
push(
p);
913 for (
int j = ((c.
size()==2) ? 0:1); j < c.
size(); j++)
971 for(
int k = 0;k<wbin.
size();k++) {
972 Lit imp = wbin[k].blocker;
983 for (i = j = (
Watcher*)ws, end = i + ws.
size(); i != end;){
987 *j++ = *i++;
continue; }
993 if (c[0] == false_lit)
994 c[0] = c[1], c[1] = false_lit;
995 assert(c[1] == false_lit);
1002 *j++ = w;
continue; }
1006 int choosenPos = -1;
1007 for (
int k = 2; k < c.
size(); k++) {
1023 if(choosenPos!=-1) {
1024 c[1] = c[choosenPos]; c[choosenPos] = false_lit;
1028 for (
int k = 2; k < c.
size(); k++) {
1031 c[1] = c[k]; c[k] = false_lit;
1079 if(
ca[x].size()> 2 &&
ca[y].size()==2)
return 1;
1081 if(
ca[y].size()> 2 &&
ca[x].size()==2)
return 0;
1082 if(
ca[x].size()==2 &&
ca[y].size()==2)
return 0;
1085 if(
ca[x].lbd()>
ca[y].lbd())
return 1;
1086 if(
ca[x].lbd()<
ca[y].lbd())
return 0;
1089 return ca[x].activity() <
ca[y].activity();
1109 int limit =
learnts.size() / 2;
1110 for (i = j = 0; i <
learnts.size(); i++){
1130 for (i = j = 0; i < cs.
size(); i++){
1204 int backtrack_level;
1207 unsigned int nblevels,szWoutSelectors;
1228 printf(
"c | %8d %7d %5d | %7d %8d %8d | %5d %8d %6d %8d | %6.3f %% \n",
1247 analyze(confl, learnt_clause, selectors,backtrack_level,nblevels,szWoutSelectors);
1253 for (
int i = 0; i < learnt_clause.
size(); i++)
1255 (-2 *
sign(learnt_clause[i]) + 1) );
1259 if (learnt_clause.
size() == 1){
1262 CRef cr =
ca.alloc(learnt_clause,
true);
1263 ca[cr].setLBD(nblevels);
1264 ca[cr].setSizeWithoutSelectors(szWoutSelectors);
1265 if(nblevels<=2)
nbDL2++;
1356 double progress = 0;
1357 double F = 1.0 /
nVars();
1360 int beg = i == 0 ? 0 :
trail_lim[i - 1];
1362 progress += pow(F, i) * (end - beg);
1365 return progress /
nVars();
1370 printf(
"c---------- Glucose Stats -------------------------\n");
1371 printf(
"c restarts : %ld\n",
starts);
1374 printf(
"c nb learnts DL2 : %ld\n",
nbDL2);
1375 printf(
"c nb learnts size 2 : %ld\n",
nbBin);
1376 printf(
"c nb learnts size 1 : %ld\n",
nbUn);
1378 printf(
"c conflicts : %ld\n",
conflicts);
1379 printf(
"c decisions : %ld\n",
decisions);
1384 printf(
"c--------------------------------------------------\n");
1399 printf(
"Can not use incremental and certified unsat in the same time\n");
1408 double curTime = cpuTime();
1414 printf(
"c ========================================[ MAGIC CONSTANTS ]==============================================\n");
1415 printf(
"c | Constants are supposed to work well together :-) |\n");
1416 printf(
"c | however, if you find better choices, please let us known... |\n");
1417 printf(
"c |-------------------------------------------------------------------------------------------------------|\n");
1418 printf(
"c | | | |\n");
1419 printf(
"c | - Restarts: | - Reduce Clause DB: | - Minimize Asserting: |\n");
1424 printf(
"c | | | |\n");
1425printf(
"c ==================================[ Search Statistics (every %6d conflicts) ]=========================\n",
verbEveryConflicts);
1428 printf(
"c | RESTARTS | ORIGINAL | LEARNT | Progress |\n");
1429 printf(
"c | NB Blocked Avg Cfc | Vars Clauses Literals | Red Learnts LBD2 Removed | | pol-inconsist\n");
1430 printf(
"c =========================================================================================================\n");
1434 int curr_restarts = 0;
1443 printf(
"c =========================================================================================================\n");
1464 for (; i <
trail.size(); i++)
1486 double finalTime = cpuTime();
1499 int message = (status ==
l_True ? 1 : status ==
l_False ? 0 : -1);
1501 pCex =
new int[
nVars()];
1502 for (
int i = 0; i <
nVars(); i++)
1507 assert(callback_result == 0);
1523 if (
map.size() <= x ||
map[x] == -1){
1524 map.growTo(x+1, -1);
1535 for (
int i = 0; i < c.
size(); i++)
1537 fprintf(f,
"%s%d ",
sign(c[i]) ?
"-" :
"", mapVar(
var(c[i]),
map, max)+1);
1544 FILE* f = fopen(
file,
"wb");
1546 fprintf(stderr,
"could not open file %s\n",
file),
exit(1);
1556 fprintf(f,
"p cnf 1 2\n1 0\n-1 0\n");
1564 for (i = 0; i <
clauses.size(); i++)
1568 for (i = 0; i <
clauses.size(); i++)
1571 for (
int j = 0; j < c.
size(); j++)
1573 mapVar(
var(c[j]),
map, max);
1579 fprintf(f,
"p cnf %d %d\n", max, cnt);
1586 for (i = 0; i <
clauses.size(); i++)
1590 printf(
"Wrote %d clauses with %d variables.\n", cnt, max);
1611 for (v = 0; v <
nVars(); v++)
1612 for (s = 0; s < 2; s++){
1616 for (j = 0; j < ws.
size(); j++)
1617 ca.reloc(ws[j].cref, to);
1619 for (j = 0; j < ws2.
size(); j++)
1620 ca.reloc(ws2[j].cref, to);
1625 for (i = 0; i <
trail.size(); i++){
1638 for (i = 0; i <
learnts.size(); i++)
1643 for (i = 0; i <
clauses.size(); i++)
1656 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
1714 #ifdef UPDATEVARACTIVITY
1715 lastDecisionLevel.shrink_(lastDecisionLevel.size());
#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
vec< int > initialPositions
OccLists< Lit, vec< Watcher >, WatcherDeleted > watchesBin
void insertVarOrder(Var x)
Lit pickJustLit(int &index)
bool addClause_(vec< Lit > &ps)
bool withinBudget() const
lbool search(int nof_conflicts)
void toDimacs(FILE *f, const vec< Lit > &assumps)
bool isGateCRef(CRef cr) const
vec< int > assumptionPositions
void cancelUntil(int level)
static VarData mkVarData(CRef cr, int l)
vec< unsigned int > permDiff
uint32_t abstractLevel(Var x) const
unsigned int computeLBD(const vec< Lit > &lits, int end=-1)
bool litRedundant(Lit p, uint32_t abstract_levels)
Var getFaninVar1(Var v) const
bool locked(const Clause &c) const
vec< unsigned > var2TravId
int nbclausesbeforereduce
unsigned int lbLBDFrozenClause
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
virtual void garbageCollect()
double progressEstimate() const
void relocAll(ClauseAllocator &to)
void ResetJustData(bool fCleanMemory)
void removeClause(CRef cr)
int64_t lastblockatrestart
void setDecisionVar(Var v, bool b, bool use_oheap=true)
CRef getConfClause(CRef r)
vec< Lit > analyze_toclear
void detachClause(CRef cr, bool strict=false)
int64_t conflictsRestarts
void minimisationWithBinaryResolution(vec< Lit > &out_learnt)
int decisionLevel() const
void attachClause(CRef cr)
static double drand(double &seed)
void removeSatisfied(vec< CRef > &cs)
void analyzeFinal(Lit p, vec< Lit > &out_conflict)
Heap2< JustOrderLt2, JustKey > jheap
bqueue< unsigned int > trailQueue
Var getFaninVar0(Var v) const
void varBumpActivity(Var v, double inc)
Heap< VarOrderLt > order_heap
static int irand(double &seed, int size)
static NodeData mkNodeData()
void initNbInitialVars(int nb)
bqueue< unsigned int > lbdQueue
bool terminate_search_early
CRef gatePropagate(Lit p)
void pushJustQueue(Var v, int index)
int(* pCnfFunc)(void *p, int, int *)
int64_t nbstopsrestartssame
Var newVar(bool polarity=true, bool dvar=true)
int64_t propagation_budget
void claBumpActivity(Clause &c)
unsigned int lbLBDMinimizingClause
void printIncrementalStats()
bool isTwoFanin(Var v) const
void setIncrementalMode()
bool isRoundWatch(Var v) const
int lbSizeMinimizingClause
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)
vec< NodeData > var2NodeData
void updateJustActivity(Var v)
bool satisfied(const Clause &c) const
void copyTo_(vec< T > ©) const
void clear(bool dealloc=false)
#define LOWER_BOUND_FOR_BLOCKING_RESTART
#define RATIOREMOVECLAUSES
Lit mkLit(Var var, bool sign=false)
void sort(T *array, int size, LessThan lt)
StringOption opt_certified_file_(_certified, "certified-output", "Certified UNSAT output file", "NULL")
RegionAllocator< uint32_t >::Ref CRef
BoolOption opt_certified_(_certified, "certified", "Certified UNSAT using DRUP format", false)
reduceDB_lt(ClauseAllocator &ca_)