ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Gluco::Solver Class Reference

#include <Solver.h>

Inheritance diagram for Gluco::Solver:
Collaboration diagram for Gluco::Solver:

Classes

struct  VarData
 
struct  VarOrderLt
 
struct  Watcher
 
struct  WatcherDeleted
 

Public Member Functions

 Solver ()
 
virtual ~Solver ()
 
void sat_solver_set_var_fanin_lit (int, int, int)
 
void sat_solver_start_new_round ()
 
void sat_solver_mark_cone (int)
 
Var newVar (bool polarity=true, bool dvar=true)
 
void addVar (Var v)
 
bool addClause (const vec< Lit > &ps)
 
bool addEmptyClause ()
 
bool addClause (Lit p)
 
bool addClause (Lit p, Lit q)
 
bool addClause (Lit p, Lit q, Lit r)
 
bool addClause_ (vec< Lit > &ps)
 
bool simplify ()
 
bool solve (const vec< Lit > &assumps)
 
lbool solveLimited (const vec< Lit > &assumps)
 
bool solve ()
 
bool solve (Lit p)
 
bool solve (Lit p, Lit q)
 
bool solve (Lit p, Lit q, Lit r)
 
bool okay () const
 
void toDimacs (FILE *f, const vec< Lit > &assumps)
 
void toDimacs (const char *file, const vec< Lit > &assumps)
 
void toDimacs (FILE *f, Clause &c, vec< Var > &map, Var &max)
 
void printLit (Lit l)
 
void printClause (CRef c)
 
void printInitialClause (CRef c)
 
void toDimacs (const char *file)
 
void toDimacs (const char *file, Lit p)
 
void toDimacs (const char *file, Lit p, Lit q)
 
void toDimacs (const char *file, Lit p, Lit q, Lit r)
 
void setPolarity (Var v, bool b)
 
void setDecisionVar (Var v, bool b)
 
lbool value (Var x) const
 
lbool value (Lit p) const
 
lbool modelValue (Var x) const
 
lbool modelValue (Lit p) const
 
int nAssigns () const
 
int nClauses () const
 
int nLearnts () const
 
int nVars () const
 
int nFreeVars () const
 
int * getCex () const
 
void setIncrementalMode ()
 
void initNbInitialVars (int nb)
 
void printIncrementalStats ()
 
void setConfBudget (int64_t x)
 
void setPropBudget (int64_t x)
 
void budgetOff ()
 
void interrupt ()
 
void clearInterrupt ()
 
virtual void reset ()
 
virtual void garbageCollect ()
 
void checkGarbage (double gf)
 
void checkGarbage ()
 

Public Attributes

int SolverType
 
void * pCnfMan
 
int(* pCnfFunc )(void *p, int, int *)
 
int nCallConfl
 
bool terminate_search_early
 
int * pstop
 
uint64_t nRuntimeLimit
 
vec< int > user_vec
 
vec< Lituser_lits
 
int jftr
 
vec< lboolmodel
 
vec< Litconflict
 
int verbosity
 
int verbEveryConflicts
 
int showModel
 
double K
 
double R
 
double sizeLBDQueue
 
double sizeTrailQueue
 
int firstReduceDB
 
int incReduceDB
 
int specialIncReduceDB
 
unsigned int lbLBDFrozenClause
 
int lbSizeMinimizingClause
 
unsigned int lbLBDMinimizingClause
 
double var_decay
 
double clause_decay
 
double random_var_freq
 
double random_seed
 
int ccmin_mode
 
int phase_saving
 
bool rnd_pol
 
bool rnd_init_act
 
double garbage_frac
 
FILE * certifiedOutput
 
bool certifiedUNSAT
 
int64_t nbRemovedClauses
 
int64_t nbReducedClauses
 
int64_t nbDL2
 
int64_t nbBin
 
int64_t nbUn
 
int64_t nbReduceDB
 
int64_t solves
 
int64_t starts
 
int64_t decisions
 
int64_t rnd_decisions
 
int64_t propagations
 
int64_t conflicts
 
int64_t conflictsRestarts
 
int64_t nbstopsrestarts
 
int64_t nbstopsrestartssame
 
int64_t lastblockatrestart
 
int64_t dec_vars
 
int64_t clauses_literals
 
int64_t learnts_literals
 
int64_t max_literals
 
int64_t tot_literals
 

Protected Member Functions

void insertVarOrder (Var x)
 
Lit pickBranchLit ()
 
void newDecisionLevel ()
 
void uncheckedEnqueue (Lit p, CRef from=CRef_Undef)
 
bool enqueue (Lit p, CRef from=CRef_Undef)
 
CRef propagate ()
 
void cancelUntil (int level)
 
void analyze (CRef confl, vec< Lit > &out_learnt, vec< Lit > &selectors, int &out_btlevel, unsigned int &nblevels, unsigned int &szWithoutSelectors)
 
void analyzeFinal (Lit p, vec< Lit > &out_conflict)
 
bool litRedundant (Lit p, uint32_t abstract_levels)
 
lbool search (int nof_conflicts)
 
lbool solve_ ()
 
void reduceDB ()
 
void removeSatisfied (vec< CRef > &cs)
 
void rebuildOrderHeap ()
 
void varDecayActivity ()
 
void varBumpActivity (Var v, double inc)
 
void varBumpActivity (Var v)
 
void claDecayActivity ()
 
void claBumpActivity (Clause &c)
 
void attachClause (CRef cr)
 
void detachClause (CRef cr, bool strict=false)
 
void removeClause (CRef cr)
 
bool locked (const Clause &c) const
 
bool satisfied (const Clause &c) const
 
unsigned int computeLBD (const vec< Lit > &lits, int end=-1)
 
unsigned int computeLBD (const Clause &c)
 
void minimisationWithBinaryResolution (vec< Lit > &out_learnt)
 
void relocAll (ClauseAllocator &to)
 
int decisionLevel () const
 
uint32_t abstractLevel (Var x) const
 
CRef reason (Var x) const
 
int level (Var x) const
 
double progressEstimate () const
 
bool withinBudget () const
 
bool isSelector (Var v)
 

Static Protected Member Functions

static VarData mkVarData (CRef cr, int l)
 
static double drand (double &seed)
 
static int irand (double &seed, int size)
 

Protected Attributes

long curRestart
 
int lastIndexRed
 
bool ok
 
double cla_inc
 
vec< double > activity
 
double var_inc
 
OccLists< Lit, vec< Watcher >, WatcherDeletedwatches
 
OccLists< Lit, vec< Watcher >, WatcherDeletedwatchesBin
 
vec< CRefclauses
 
vec< CReflearnts
 
vec< lboolassigns
 
vec< char > polarity
 
vec< char > decision
 
vec< Littrail
 
vec< int > nbpos
 
vec< int > trail_lim
 
vec< VarDatavardata
 
int qhead
 
int simpDB_assigns
 
int64_t simpDB_props
 
vec< Litassumptions
 
Heap< VarOrderLtorder_heap
 
double progress_estimate
 
bool remove_satisfied
 
vec< unsigned int > permDiff
 
ClauseAllocator ca
 
int nbclausesbeforereduce
 
bqueue< unsigned int > trailQueue
 
bqueue< unsigned int > lbdQueue
 
float sumLBD
 
int sumAssumptions
 
vec< char > seen
 
vec< Litanalyze_stack
 
vec< Litanalyze_toclear
 
vec< Litadd_tmp
 
unsigned int MYFLAG
 
double max_learnts
 
double learntsize_adjust_confl
 
int learntsize_adjust_cnt
 
int64_t conflict_budget
 
int64_t propagation_budget
 
bool asynch_interrupt
 
int incremental
 
int nbVarsInitialFormula
 
double totalTime4Sat
 
double totalTime4Unsat
 
int nbSatCalls
 
int nbUnsatCalls
 
vec< int > assumptionPositions
 
vec< int > initialPositions
 

Detailed Description

Definition at line 47 of file Solver.h.

Constructor & Destructor Documentation

◆ Solver()

Solver::Solver ( )

Definition at line 90 of file Glucose.cpp.

90 :
91
92 // Parameters (user settable):
93 //
94 SolverType(0)
95 , pCnfFunc(NULL)
96 , nCallConfl(1000)
98 , pstop(NULL)
99 , nRuntimeLimit(0)
100
101 , verbosity (0)
102 , verbEveryConflicts(10000)
103 , showModel (0)
104 , K (opt_K)
105 , R (opt_R)
106 , sizeLBDQueue (opt_size_lbd_queue)
107 , sizeTrailQueue (opt_size_trail_queue)
108 , firstReduceDB (opt_first_reduce_db)
109 , incReduceDB (opt_inc_reduce_db)
110 , specialIncReduceDB (opt_spec_inc_reduce_db)
111 , lbLBDFrozenClause (opt_lb_lbd_frozen_clause)
112 , lbSizeMinimizingClause (opt_lb_size_minimzing_clause)
113 , lbLBDMinimizingClause (opt_lb_lbd_minimzing_clause)
114 , var_decay (opt_var_decay)
115 , clause_decay (opt_clause_decay)
116 , random_var_freq (opt_random_var_freq)
117 , random_seed (opt_random_seed)
118 , ccmin_mode (opt_ccmin_mode)
119 , phase_saving (opt_phase_saving)
120 , rnd_pol (false)
121 , rnd_init_act (opt_rnd_init_act)
122 , garbage_frac (opt_garbage_frac)
123 , certifiedOutput (NULL)
125 // Statistics: (formerly in 'SolverStats')
126 //
130 , curRestart(1)
131
132 , ok (true)
133 , cla_inc (1)
134 , var_inc (1)
137 , qhead (0)
138 , simpDB_assigns (-1)
139 , simpDB_props (0)
142 , remove_satisfied (true)
143
144 // Resource constraints:
145 //
146 , conflict_budget (-1)
147 , propagation_budget (-1)
148 , asynch_interrupt (false)
149 , incremental(opt_incremental)
151{
152 MYFLAG=0;
153 // Initialize only first time. Useful for incremental solving, useless otherwise
154 lbdQueue.initSize(sizeLBDQueue);
155 trailQueue.initSize(sizeTrailQueue);
156 sumLBD = 0;
160
161
162 if(certifiedUNSAT) {
163 if(!strcmp(opt_certified_file_,"NULL")) {
164 certifiedOutput = fopen("/dev/stdout", "wb");
165 } else {
166 certifiedOutput = fopen(opt_certified_file_, "wb");
167 }
168 // fprintf(certifiedOutput,"o proof DRUP\n");
169 }
170}
StringOption opt_certified_file_(_certified, "certified-output", "Certified UNSAT output file", "NULL")
BoolOption opt_certified_(_certified, "certified", "Certified UNSAT using DRUP format", false)
#define INT32_MAX
Definition pstdint.h:415
int64_t rnd_decisions
Definition Solver.h:194
int64_t starts
Definition Solver.h:194
double progress_estimate
Definition Solver.h:252
FILE * certifiedOutput
Definition Solver.h:188
int64_t nbReducedClauses
Definition Solver.h:194
int specialIncReduceDB
Definition Solver.h:170
double K
Definition Solver.h:162
double var_decay
Definition Solver.h:177
int64_t max_literals
Definition Solver.h:195
double sizeTrailQueue
Definition Solver.h:165
int nbUnsatCalls
Definition Solver.h:295
int64_t lastblockatrestart
Definition Solver.h:194
bool rnd_pol
Definition Solver.h:183
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
Definition Solver.h:234
double var_inc
Definition Solver.h:232
double clause_decay
Definition Solver.h:178
int SolverType
Definition Solver.h:50
double garbage_frac
Definition Solver.h:185
int64_t nbReduceDB
Definition Solver.h:194
int ccmin_mode
Definition Solver.h:181
float sumLBD
Definition Solver.h:266
double totalTime4Unsat
Definition Solver.h:294
int(* pCnfFunc)(void *p, int, int *)
Definition Solver.h:59
int nCallConfl
Definition Solver.h:60
int64_t conflictsRestarts
Definition Solver.h:194
int64_t nbDL2
Definition Solver.h:194
int incReduceDB
Definition Solver.h:169
double R
Definition Solver.h:163
int64_t solves
Definition Solver.h:194
bool certifiedUNSAT
Definition Solver.h:189
int simpDB_assigns
Definition Solver.h:248
int64_t propagations
Definition Solver.h:194
double sizeLBDQueue
Definition Solver.h:164
vec< double > activity
Definition Solver.h:231
int64_t nbstopsrestarts
Definition Solver.h:194
double random_var_freq
Definition Solver.h:179
int nbSatCalls
Definition Solver.h:295
int64_t learnts_literals
Definition Solver.h:195
int verbEveryConflicts
Definition Solver.h:159
ClauseAllocator ca
Definition Solver.h:261
OccLists< Lit, vec< Watcher >, WatcherDeleted > watchesBin
Definition Solver.h:236
int64_t conflict_budget
Definition Solver.h:286
uint64_t nRuntimeLimit
Definition Solver.h:63
bool remove_satisfied
Definition Solver.h:253
int nbVarsInitialFormula
Definition Solver.h:293
int * pstop
Definition Solver.h:62
bool asynch_interrupt
Definition Solver.h:288
int nbclausesbeforereduce
Definition Solver.h:263
int64_t simpDB_props
Definition Solver.h:249
bqueue< unsigned int > trailQueue
Definition Solver.h:265
int64_t clauses_literals
Definition Solver.h:195
bool terminate_search_early
Definition Solver.h:61
int64_t decisions
Definition Solver.h:194
Heap< VarOrderLt > order_heap
Definition Solver.h:251
int firstReduceDB
Definition Solver.h:168
double totalTime4Sat
Definition Solver.h:294
int incremental
Definition Solver.h:292
unsigned int lbLBDFrozenClause
Definition Solver.h:171
int64_t nbRemovedClauses
Definition Solver.h:194
int64_t tot_literals
Definition Solver.h:195
int lbSizeMinimizingClause
Definition Solver.h:174
int64_t dec_vars
Definition Solver.h:195
int showModel
Definition Solver.h:160
bool rnd_init_act
Definition Solver.h:184
int phase_saving
Definition Solver.h:182
int verbosity
Definition Solver.h:158
int64_t nbBin
Definition Solver.h:194
int64_t propagation_budget
Definition Solver.h:287
int64_t conflicts
Definition Solver.h:194
bqueue< unsigned int > lbdQueue
Definition Solver.h:265
double random_seed
Definition Solver.h:180
unsigned int lbLBDMinimizingClause
Definition Solver.h:175
int64_t nbstopsrestartssame
Definition Solver.h:194
int64_t nbUn
Definition Solver.h:194
double cla_inc
Definition Solver.h:230
unsigned int MYFLAG
Definition Solver.h:277
long curRestart
Definition Solver.h:198
int strcmp()
Here is the call graph for this function:

◆ ~Solver()

Solver::~Solver ( )
virtual

Definition at line 173 of file Glucose.cpp.

174{
175}

Member Function Documentation

◆ abstractLevel()

uint32_t Gluco::Solver::abstractLevel ( Var x) const
inlineprotected

Definition at line 418 of file Solver.h.

418{ return 1 << (level(x) & 31); }
int level(Var x) const
Definition Solver.h:369
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addClause() [1/4]

bool Gluco::Solver::addClause ( const vec< Lit > & ps)
inline

Definition at line 402 of file Solver.h.

402{ ps.copyTo(add_tmp); return addClause_(add_tmp); }
bool addClause_(vec< Lit > &ps)
Definition Glucose.cpp:224
vec< Lit > add_tmp
Definition Solver.h:276
Here is the call graph for this function:

◆ addClause() [2/4]

bool Gluco::Solver::addClause ( Lit p)
inline

Definition at line 404 of file Solver.h.

404{ add_tmp.clear(); add_tmp.push(p); return addClause_(add_tmp); }
Cube * p
Definition exorList.c:222
Here is the call graph for this function:

◆ addClause() [3/4]

bool Gluco::Solver::addClause ( Lit p,
Lit q )
inline

Definition at line 405 of file Solver.h.

405{ add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ addClause() [4/4]

bool Gluco::Solver::addClause ( Lit p,
Lit q,
Lit r )
inline

Definition at line 406 of file Solver.h.

406{ add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ addClause_()

bool Solver::addClause_ ( vec< Lit > & ps)

Definition at line 224 of file Glucose.cpp.

225{
226 assert(decisionLevel() == 0);
227 if (!ok) return false;
228
229 if ( 0 ) {
230 for ( int i = 0; i < ps.size(); i++ )
231 printf( "%s%d ", (toInt(ps[i]) & 1) ? "-":"", toInt(ps[i]) >> 1 );
232 printf( "\n" );
233 }
234
235 // Check if clause is satisfied and remove false/duplicate literals:
236 sort(ps);
237
238 vec<Lit> oc;
239 oc.clear();
240
241 Lit p; int i, j, flag = 0;
242 if(certifiedUNSAT) {
243 for (i = j = 0, p = lit_Undef; i < ps.size(); i++) {
244 oc.push(ps[i]);
245 if (value(ps[i]) == l_True || ps[i] == ~p || value(ps[i]) == l_False)
246 flag = 1;
247 }
248 }
249
250 for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
251 if (value(ps[i]) == l_True || ps[i] == ~p)
252 return true;
253 else if (value(ps[i]) != l_False && ps[i] != p)
254 ps[j++] = p = ps[i];
255 ps.shrink(i - j);
256
257 if ( 0 ) {
258 for ( int i = 0; i < ps.size(); i++ )
259 printf( "%s%d ", (toInt(ps[i]) & 1) ? "-":"", toInt(ps[i]) >> 1 );
260 printf( "\n" );
261 }
262
263 if (flag && (certifiedUNSAT)) {
264 for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
265 fprintf(certifiedOutput, "%i ", (var(ps[i]) + 1) * (-2 * sign(ps[i]) + 1));
266 fprintf(certifiedOutput, "0\n");
267
268 fprintf(certifiedOutput, "d ");
269 for (i = j = 0, p = lit_Undef; i < oc.size(); i++)
270 fprintf(certifiedOutput, "%i ", (var(oc[i]) + 1) * (-2 * sign(oc[i]) + 1));
271 fprintf(certifiedOutput, "0\n");
272 }
273
274 if (ps.size() == 0)
275 return ok = false;
276 else if (ps.size() == 1){
277 uncheckedEnqueue(ps[0]);
278 return ok = (propagate() == CRef_Undef);
279 }else{
280 CRef cr = ca.alloc(ps, false);
281 clauses.push(cr);
282 attachClause(cr);
283 }
284
285 return true;
286}
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
ABC_NAMESPACE_IMPL_START typedef signed char value
int decisionLevel() const
Definition Solver.h:417
CRef propagate()
Definition Glucose.cpp:803
vec< CRef > clauses
Definition Solver.h:237
void attachClause(CRef cr)
Definition Glucose.cpp:289
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition Glucose.cpp:783
int size(void) const
Definition Vec.h:65
void shrink(int nelems)
Definition Vec.h:66
void clear(bool dealloc=false)
Definition Vec.h:124
void push(void)
Definition Vec.h:75
void sort(T *array, int size, LessThan lt)
Definition Sort.h:58
int toInt(Var v)
Definition SolverTypes.h:74
RegionAllocator< uint32_t >::Ref CRef
const Lit lit_Undef
Definition SolverTypes.h:81
int var(Lit p)
Definition SolverTypes.h:71
bool sign(Lit p)
Definition SolverTypes.h:70
const CRef CRef_Undef
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addEmptyClause()

bool Gluco::Solver::addEmptyClause ( )
inline

Definition at line 403 of file Solver.h.

403{ add_tmp.clear(); return addClause_(add_tmp); }
Here is the call graph for this function:

◆ addVar()

void Gluco::Solver::addVar ( Var v)
inline

Definition at line 464 of file Solver.h.

464{ while (v >= nVars()) newVar(); }
int nVars() const
Definition Solver.h:426
Var newVar(bool polarity=true, bool dvar=true)
Definition Glucose.cpp:202
Here is the call graph for this function:

◆ analyze()

void Solver::analyze ( CRef confl,
vec< Lit > & out_learnt,
vec< Lit > & selectors,
int & out_btlevel,
unsigned int & nblevels,
unsigned int & szWithoutSelectors )
protected

Definition at line 529 of file Glucose.cpp.

530{
531 int pathC = 0;
532 Lit p = lit_Undef;
533
534 // Generate conflict clause:
535 //
536 out_learnt.push(); // (leave room for the asserting literal)
537 int index = trail.size() - 1;
538
539 do{
540 assert(confl != CRef_Undef); // (otherwise should be UIP)
541 Clause& c = ca[confl];
542
543 // Special case for binary clauses
544 // The first one has to be SAT
545 if( p != lit_Undef && c.size()==2 && value(c[0])==l_False) {
546
547 assert(value(c[1])==l_True);
548 Lit tmp = c[0];
549 c[0] = c[1], c[1] = tmp;
550 }
551
552 if (c.learnt())
554
555#ifdef DYNAMICNBLEVEL
556 // DYNAMIC NBLEVEL trick (see competition'09 companion paper)
557 if(c.learnt() && c.lbd()>2) {
558 unsigned int nblevels = computeLBD(c);
559 if(nblevels+1<c.lbd() ) { // improve the LBD
560 if(c.lbd()<=lbLBDFrozenClause) {
561 c.setCanBeDel(false);
562 }
563 // seems to be interesting : keep it for the next round
564 c.setLBD(nblevels); // Update it
565 }
566 }
567#endif
568
569
570 for (int j = (p == lit_Undef) ? 0 : 1; j < c.size(); j++){
571 Lit q = c[j];
572
573 if (!seen[var(q)] && level(var(q)) > 0){
574 if(!isSelector(var(q)))
576 seen[var(q)] = 1;
577 if (level(var(q)) >= decisionLevel()) {
578 pathC++;
579#ifdef UPDATEVARACTIVITY
580 // UPDATEVARACTIVITY trick (see competition'09 companion paper)
581 if(!isSelector(var(q)) && (reason(var(q))!= CRef_Undef) && ca[reason(var(q))].learnt())
582 lastDecisionLevel.push(q);
583#endif
584
585 } else {
586 if(isSelector(var(q))) {
587 assert(value(q) == l_False);
588 selectors.push(q);
589 } else
590 out_learnt.push(q);
591 }
592 }
593 }
594
595 // Select next clause to look at:
596 while (!seen[var(trail[index--])]);
597 p = trail[index+1];
598 confl = reason(var(p));
599 seen[var(p)] = 0;
600 pathC--;
601
602 }while (pathC > 0);
603 out_learnt[0] = ~p;
604
605 // Simplify conflict clause:
606 //
607 int i, j;
608
609 for(i = 0;i<selectors.size();i++)
610 out_learnt.push(selectors[i]);
611
612 out_learnt.copyTo_(analyze_toclear);
613 if (ccmin_mode == 2){
614 uint32_t abstract_level = 0;
615 for (i = 1; i < out_learnt.size(); i++)
616 abstract_level |= abstractLevel(var(out_learnt[i])); // (maintain an abstraction of levels involved in conflict)
617
618 for (i = j = 1; i < out_learnt.size(); i++)
619 if (reason(var(out_learnt[i])) == CRef_Undef || !litRedundant(out_learnt[i], abstract_level))
620 out_learnt[j++] = out_learnt[i];
621
622 }else if (ccmin_mode == 1){
623 for (i = j = 1; i < out_learnt.size(); i++){
624 Var x = var(out_learnt[i]);
625
626 if (reason(x) == CRef_Undef)
627 out_learnt[j++] = out_learnt[i];
628 else{
629 Clause& c = ca[reason(var(out_learnt[i]))];
630 // Thanks to Siert Wieringa for this bug fix!
631 for (int k = ((c.size()==2) ? 0:1); k < c.size(); k++)
632 if (!seen[var(c[k])] && level(var(c[k])) > 0){
633 out_learnt[j++] = out_learnt[i];
634 break; }
635 }
636 }
637 }else
638 i = j = out_learnt.size();
639
640 max_literals += out_learnt.size();
641 out_learnt.shrink(i - j);
642 tot_literals += out_learnt.size();
643
644
645 /* ***************************************
646 Minimisation with binary clauses of the asserting clause
647 First of all : we look for small clauses
648 Then, we reduce clauses with small LBD.
649 Otherwise, this can be useless
650 */
651 if(!incremental && out_learnt.size()<=lbSizeMinimizingClause) {
653 }
654 // Find correct backtrack level:
655 //
656 if (out_learnt.size() == 1)
657 out_btlevel = 0;
658 else{
659 int max_i = 1;
660 // Find the first literal assigned at the next-highest level:
661 for (int i = 2; i < out_learnt.size(); i++)
662 if (level(var(out_learnt[i])) > level(var(out_learnt[max_i])))
663 max_i = i;
664 // Swap-in this literal at index 1:
665 Lit p = out_learnt[max_i];
666 out_learnt[max_i] = out_learnt[1];
667 out_learnt[1] = p;
668 out_btlevel = level(var(p));
669 }
670
671
672 // Compute the size of the clause without selectors (incremental mode)
673 if(incremental) {
674 szWithoutSelectors = 0;
675 for(int i=0;i<out_learnt.size();i++) {
676 if(!isSelector(var((out_learnt[i])))) szWithoutSelectors++;
677 else if(i>0) break;
678 }
679 } else
680 szWithoutSelectors = out_learnt.size();
681
682 // Compute LBD
683 lbd = computeLBD(out_learnt,out_learnt.size()-selectors.size());
684
685
686#ifdef UPDATEVARACTIVITY
687 // UPDATEVARACTIVITY trick (see competition'09 companion paper)
688 if(lastDecisionLevel.size()>0) {
689 for(int i = 0;i<lastDecisionLevel.size();i++) {
690 if(ca[reason(var(lastDecisionLevel[i]))].lbd()<lbd)
691 varBumpActivity(var(lastDecisionLevel[i]));
692 }
693 lastDecisionLevel.clear();
694 }
695#endif
696
697
698
699 for (j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0; // ('seen[]' is now cleared)
700 for(j = 0 ; j<selectors.size() ; j++) seen[var(selectors[j])] = 0;
701}
unsigned int uint32_t
Definition Fxch.h:32
unsigned size
unsigned learnt
void setLBD(int i)
void setCanBeDel(bool b)
bool isSelector(Var v)
Definition Solver.h:347
unsigned int computeLBD(const vec< Lit > &lits, int end=-1)
Definition Glucose.cpp:367
bool litRedundant(Lit p, uint32_t abstract_levels)
Definition Glucose.cpp:706
lbool value(Var x) const
Definition Solver.h:419
vec< Lit > trail
Definition Solver.h:243
void minimisationWithBinaryResolution(vec< Lit > &out_learnt)
Definition Glucose.cpp:429
uint32_t abstractLevel(Var x) const
Definition Solver.h:418
void claBumpActivity(Clause &c)
Definition Solver.h:388
void varBumpActivity(Var v, double inc)
Definition Solver.h:376
vec< char > seen
Definition Solver.h:273
CRef reason(Var x) const
Definition Solver.h:368
vec< Lit > analyze_toclear
Definition Solver.h:275
void copyTo_(vec< T > &copy) const
Definition Vec.h:93
int Var
Definition SolverTypes.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ analyzeFinal()

void Solver::analyzeFinal ( Lit p,
vec< Lit > & out_conflict )
protected

Definition at line 749 of file Glucose.cpp.

750{
751 out_conflict.clear();
752 out_conflict.push(p);
753
754 if (decisionLevel() == 0)
755 return;
756
757 seen[var(p)] = 1;
758
759 for (int i = trail.size()-1; i >= trail_lim[0]; i--){
760 Var x = var(trail[i]);
761 if (seen[x]){
762 if (reason(x) == CRef_Undef){
763 assert(level(x) > 0);
764 out_conflict.push(~trail[i]);
765 }else{
766 Clause& c = ca[reason(x)];
767 // for (int j = 1; j < c.size(); j++) Minisat (glucose 2.0) loop
768 // Bug in case of assumptions due to special data structures for Binary.
769 // Many thanks to Sam Bayless (sbayless@cs.ubc.ca) for discover this bug.
770 for (int j = ((c.size()==2) ? 0:1); j < c.size(); j++)
771 if (level(var(c[j])) > 0)
772 seen[var(c[j])] = 1;
773 }
774
775 seen[x] = 0;
776 }
777 }
778
779 seen[var(p)] = 0;
780}
vec< int > trail_lim
Definition Solver.h:245
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attachClause()

void Solver::attachClause ( CRef cr)
protected

Definition at line 289 of file Glucose.cpp.

289 {
290 const Clause& c = ca[cr];
291
292 assert(c.size() > 1);
293 if(c.size()==2) {
294 watchesBin[~c[0]].push(Watcher(cr, c[1]));
295 watchesBin[~c[1]].push(Watcher(cr, c[0]));
296 } else {
297 watches[~c[0]].push(Watcher(cr, c[1]));
298 watches[~c[1]].push(Watcher(cr, c[0]));
299 }
300 if (c.learnt()) learnts_literals += c.size();
301 else clauses_literals += c.size(); }
Here is the caller graph for this function:

◆ budgetOff()

void Gluco::Solver::budgetOff ( )
inline

Definition at line 442 of file Solver.h.

Here is the caller graph for this function:

◆ cancelUntil()

void Solver::cancelUntil ( int level)
protected

Definition at line 471 of file Glucose.cpp.

471 {
472 if (decisionLevel() > level){
473 for (int c = trail.size()-1; c >= trail_lim[level]; c--){
474 Var x = var(trail[c]);
475 assigns [x] = l_Undef;
476 if (phase_saving > 1 || ((phase_saving == 1) && c > trail_lim.last()))
477 polarity[x] = sign(trail[c]);
478 insertVarOrder(x); }
480 trail.shrink(trail.size() - trail_lim[level]);
481 trail_lim.shrink(trail_lim.size() - level);
482 }
483}
#define l_Undef
Definition bmcBmcS.c:34
vec< lbool > assigns
Definition Solver.h:240
vec< char > polarity
Definition Solver.h:241
void insertVarOrder(Var x)
Definition Solver.h:371
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkGarbage() [1/2]

void Gluco::Solver::checkGarbage ( void )
inline

Definition at line 395 of file Solver.h.

void checkGarbage()
Definition Solver.h:395
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkGarbage() [2/2]

void Gluco::Solver::checkGarbage ( double gf)
inline

Definition at line 396 of file Solver.h.

396 {
397 if (ca.wasted() > ca.size() * gf)
virtual void garbageCollect()
Definition Glucose.cpp:1427
Here is the call graph for this function:

◆ claBumpActivity()

void Gluco::Solver::claBumpActivity ( Clause & c)
inlineprotected

Definition at line 388 of file Solver.h.

388 {
389 if ( (c.activity() += cla_inc) > 1e20 ) {
390 // Rescale:
391 for (int i = 0; i < learnts.size(); i++)
392 ca[learnts[i]].activity() *= (float)1e-20;
393 cla_inc *= 1e-20; } }
vec< CRef > learnts
Definition Solver.h:238
Here is the call graph for this function:
Here is the caller graph for this function:

◆ claDecayActivity()

void Gluco::Solver::claDecayActivity ( )
inlineprotected

Definition at line 387 of file Solver.h.

387{ cla_inc *= (1 / clause_decay); }
Here is the caller graph for this function:

◆ clearInterrupt()

void Gluco::Solver::clearInterrupt ( )
inline

Definition at line 441 of file Solver.h.

441{ asynch_interrupt = false; }

◆ computeLBD() [1/2]

unsigned int Solver::computeLBD ( const Clause & c)
inlineprotected

Definition at line 397 of file Glucose.cpp.

397 {
398 int nblevels = 0;
399 MYFLAG++;
400
401 if(incremental) { // ----------------- INCREMENTAL MODE
402 int nbDone = 0;
403 for(int i=0;i<c.size();i++) {
404 if(nbDone>=c.sizeWithoutSelectors()) break;
405 if(isSelector(var(c[i]))) continue;
406 nbDone++;
407 int l = level(var(c[i]));
408 if (permDiff[l] != MYFLAG) {
409 permDiff[l] = MYFLAG;
410 nblevels++;
411 }
412 }
413 } else { // -------- DEFAULT MODE. NOT A LOT OF DIFFERENCES... BUT EASIER TO READ
414 for(int i=0;i<c.size();i++) {
415 int l = level(var(c[i]));
416 if (permDiff[l] != MYFLAG) {
417 permDiff[l] = MYFLAG;
418 nblevels++;
419 }
420 }
421 }
422 return nblevels;
423}
unsigned int sizeWithoutSelectors() const
vec< unsigned int > permDiff
Definition Solver.h:254
Here is the call graph for this function:

◆ computeLBD() [2/2]

unsigned int Solver::computeLBD ( const vec< Lit > & lits,
int end = -1 )
inlineprotected

Definition at line 367 of file Glucose.cpp.

367 {
368 int nblevels = 0;
369 MYFLAG++;
370
371 if(incremental) { // ----------------- INCREMENTAL MODE
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;
376 if(isSelector(var(lits[i]))) continue;
377 nbDone++;
378 int l = level(var(lits[i]));
379 if (permDiff[l] != MYFLAG) {
380 permDiff[l] = MYFLAG;
381 nblevels++;
382 }
383 }
384 } else { // -------- DEFAULT MODE. NOT A LOT OF DIFFERENCES... BUT EASIER TO READ
385 for(int i=0;i<lits.size();i++) {
386 int l = level(var(lits[i]));
387 if (permDiff[l] != MYFLAG) {
388 permDiff[l] = MYFLAG;
389 nblevels++;
390 }
391 }
392 }
393
394 return nblevels;
395}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decisionLevel()

int Gluco::Solver::decisionLevel ( ) const
inlineprotected

Definition at line 417 of file Solver.h.

417{ return trail_lim.size(); }
Here is the caller graph for this function:

◆ detachClause()

void Solver::detachClause ( CRef cr,
bool strict = false )
protected

Definition at line 306 of file Glucose.cpp.

306 {
307 const Clause& c = ca[cr];
308
309 assert(c.size() > 1);
310 if(c.size()==2) {
311 if (strict){
312 remove(watchesBin[~c[0]], Watcher(cr, c[1]));
313 remove(watchesBin[~c[1]], Watcher(cr, c[0]));
314 }else{
315 // Lazy detaching: (NOTE! Must clean all watcher lists before garbage collecting this clause)
316 watchesBin.smudge(~c[0]);
317 watchesBin.smudge(~c[1]);
318 }
319 } else {
320 if (strict){
321 remove(watches[~c[0]], Watcher(cr, c[1]));
322 remove(watches[~c[1]], Watcher(cr, c[0]));
323 }else{
324 // Lazy detaching: (NOTE! Must clean all watcher lists before garbage collecting this clause)
325 watches.smudge(~c[0]);
326 watches.smudge(~c[1]);
327 }
328 }
329 if (c.learnt()) learnts_literals -= c.size();
330 else clauses_literals -= c.size(); }
Here is the caller graph for this function:

◆ drand()

static double Gluco::Solver::drand ( double & seed)
inlinestaticprotected

Definition at line 353 of file Solver.h.

353 {
354 seed *= 1389796;
355 int q = (int)(seed / 2147483647);
356 seed -= (double)q * 2147483647;
357 return seed / 2147483647; }
Here is the caller graph for this function:

◆ enqueue()

bool Gluco::Solver::enqueue ( Lit p,
CRef from = CRef_Undef )
inlineprotected

Definition at line 401 of file Solver.h.

401{ return value(p) != l_Undef ? value(p) != l_False : (uncheckedEnqueue(p, from), true); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ garbageCollect()

void Solver::garbageCollect ( )
virtual

Reimplemented in Gluco::SimpSolver.

Definition at line 1427 of file Glucose.cpp.

1428{
1429 // Initialize the next region to a size corresponding to the estimated utilization degree. This
1430 // is not precise but should avoid some unnecessary reallocations for the new region:
1431 ClauseAllocator to(ca.size() - ca.wasted());
1432
1433 relocAll(to);
1434 if (verbosity >= 2)
1435 printf("| Garbage collection: %12d bytes => %12d bytes |\n",
1437 to.moveTo(ca);
1438}
void relocAll(ClauseAllocator &to)
Definition Glucose.cpp:1386
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCex()

int * Gluco::Solver::getCex ( ) const
inline

Definition at line 428 of file Solver.h.

428{ return NULL; }

◆ initNbInitialVars()

void Solver::initNbInitialVars ( int nb)

Definition at line 190 of file Glucose.cpp.

190 {
192}

◆ insertVarOrder()

void Gluco::Solver::insertVarOrder ( Var x)
inlineprotected

Definition at line 371 of file Solver.h.

371 {
372 if (!order_heap.inHeap(x) && decision[x]) order_heap.insert(x); }
vec< char > decision
Definition Solver.h:242
Here is the caller graph for this function:

◆ interrupt()

void Gluco::Solver::interrupt ( )
inline

Definition at line 440 of file Solver.h.

440{ asynch_interrupt = true; }

◆ irand()

static int Gluco::Solver::irand ( double & seed,
int size )
inlinestaticprotected

Definition at line 360 of file Solver.h.

360 {
361 return (int)(drand(seed) * size); }
static double drand(double &seed)
Definition Solver.h:353
unsigned long long size
Definition giaNewBdd.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSelector()

bool Gluco::Solver::isSelector ( Var v)
inlineprotected

Definition at line 347 of file Solver.h.

347{return (incremental && v>nbVarsInitialFormula);}
Here is the caller graph for this function:

◆ level()

int Gluco::Solver::level ( Var x) const
inlineprotected

Definition at line 369 of file Solver.h.

369{ return vardata[x].level; }
vec< VarData > vardata
Definition Solver.h:246
Here is the caller graph for this function:

◆ litRedundant()

bool Solver::litRedundant ( Lit p,
uint32_t abstract_levels )
protected

Definition at line 706 of file Glucose.cpp.

707{
708 analyze_stack.clear(); analyze_stack.push(p);
709 int top = analyze_toclear.size();
710 while (analyze_stack.size() > 0){
712 Clause& c = ca[reason(var(analyze_stack.last()))]; analyze_stack.pop();
713 if(c.size()==2 && value(c[0])==l_False) {
714 assert(value(c[1])==l_True);
715 Lit tmp = c[0];
716 c[0] = c[1], c[1] = tmp;
717 }
718
719 for (int i = 1; i < c.size(); i++){
720 Lit p = c[i];
721 if (!seen[var(p)] && level(var(p)) > 0){
722 if (reason(var(p)) != CRef_Undef && (abstractLevel(var(p)) & abstract_levels) != 0){
723 seen[var(p)] = 1;
724 analyze_stack.push(p);
725 analyze_toclear.push(p);
726 }else{
727 for (int j = top; j < analyze_toclear.size(); j++)
728 seen[var(analyze_toclear[j])] = 0;
729 analyze_toclear.shrink(analyze_toclear.size() - top);
730 return false;
731 }
732 }
733 }
734 }
735
736 return true;
737}
vec< Lit > analyze_stack
Definition Solver.h:274
Here is the call graph for this function:
Here is the caller graph for this function:

◆ locked()

bool Gluco::Solver::locked ( const Clause & c) const
inlineprotected

Definition at line 407 of file Solver.h.

407 {
408 if(c.size()>2)
409 return value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c;
410 return
411 (value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c)
412 ||
413 (value(c[1]) == l_True && reason(var(c[1])) != CRef_Undef && ca.lea(reason(var(c[1]))) == &c);
414 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimisationWithBinaryResolution()

void Solver::minimisationWithBinaryResolution ( vec< Lit > & out_learnt)
protected

Definition at line 429 of file Glucose.cpp.

429 {
430
431 // Find the LBD measure
432 unsigned int lbd = computeLBD(out_learnt);
433 Lit p = ~out_learnt[0];
434
435 if(lbd<=lbLBDMinimizingClause){
436 MYFLAG++;
437
438 for(int i = 1;i<out_learnt.size();i++) {
439 permDiff[var(out_learnt[i])] = MYFLAG;
440 }
441
442 vec<Watcher>& wbin = watchesBin[p];
443 int nb = 0;
444 for(int k = 0;k<wbin.size();k++) {
445 Lit imp = wbin[k].blocker;
446 if(permDiff[var(imp)]==MYFLAG && value(imp)==l_True) {
447 nb++;
448 permDiff[var(imp)]= MYFLAG-1;
449 }
450 }
451 int l = out_learnt.size()-1;
452 if(nb>0) {
454 for(int i = 1;i<out_learnt.size()-nb;i++) {
455 if(permDiff[var(out_learnt[i])]!=MYFLAG) {
456 Lit p = out_learnt[l];
457 out_learnt[l] = out_learnt[i];
458 out_learnt[i] = p;
459 l--;i--;
460 }
461 }
462
463 out_learnt.shrink(nb);
464
465 }
466 }
467}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkVarData()

static VarData Gluco::Solver::mkVarData ( CRef cr,
int l )
inlinestaticprotected

Definition at line 202 of file Solver.h.

202{ VarData d = {cr, l}; return d; }
Here is the caller graph for this function:

◆ modelValue() [1/2]

lbool Gluco::Solver::modelValue ( Lit p) const
inline

Definition at line 422 of file Solver.h.

422{ return model[var(p)] ^ sign(p); }
vec< lbool > model
Definition Solver.h:152
Here is the call graph for this function:

◆ modelValue() [2/2]

lbool Gluco::Solver::modelValue ( Var x) const
inline

Definition at line 421 of file Solver.h.

421{ return model[x]; }
Here is the caller graph for this function:

◆ nAssigns()

int Gluco::Solver::nAssigns ( ) const
inline

Definition at line 423 of file Solver.h.

423{ return trail.size(); }
Here is the caller graph for this function:

◆ nClauses()

int Gluco::Solver::nClauses ( ) const
inline

Definition at line 424 of file Solver.h.

424{ return clauses.size(); }
Here is the caller graph for this function:

◆ newDecisionLevel()

void Gluco::Solver::newDecisionLevel ( )
inlineprotected

Definition at line 415 of file Solver.h.

415{ trail_lim.push(trail.size()); }
Here is the caller graph for this function:

◆ newVar()

Var Solver::newVar ( bool polarity = true,
bool dvar = true )

Definition at line 202 of file Glucose.cpp.

203{
204 int v = nVars();
205 watches .init(mkLit(v, false));
206 watches .init(mkLit(v, true ));
207 watchesBin .init(mkLit(v, false));
208 watchesBin .init(mkLit(v, true ));
209 assigns .push(l_Undef);
210 vardata .push(mkVarData(CRef_Undef, 0));
211 //activity .push(0);
212 activity .push(rnd_init_act ? drand(random_seed) * 0.00001 : 0);
213 seen .push(0);
214 permDiff .push(0);
215 polarity .push(sign);
216 decision .push();
217 trail .capacity(v+1);
218 setDecisionVar(v, dvar);
219 return v;
220}
static VarData mkVarData(CRef cr, int l)
Definition Solver.h:202
void setDecisionVar(Var v, bool b)
Definition Solver.h:430
Lit mkLit(Var var, bool sign=false)
Definition SolverTypes.h:67
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nFreeVars()

int Gluco::Solver::nFreeVars ( ) const
inline

Definition at line 427 of file Solver.h.

427{ return (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]); }

◆ nLearnts()

int Gluco::Solver::nLearnts ( ) const
inline

Definition at line 425 of file Solver.h.

425{ return learnts.size(); }
Here is the caller graph for this function:

◆ nVars()

int Gluco::Solver::nVars ( ) const
inline

Definition at line 426 of file Solver.h.

426{ return vardata.size(); }
Here is the caller graph for this function:

◆ okay()

bool Gluco::Solver::okay ( ) const
inline

Definition at line 457 of file Solver.h.

457{ return ok; }

◆ pickBranchLit()

Lit Solver::pickBranchLit ( )
protected

Definition at line 490 of file Glucose.cpp.

491{
492 Var next = var_Undef;
493
494 // Random decision:
495 if (drand(random_seed) < random_var_freq && !order_heap.empty()){
496 next = order_heap[irand(random_seed,order_heap.size())];
497 if (value(next) == l_Undef && decision[next])
498 rnd_decisions++; }
499
500 // Activity based decision:
501 while (next == var_Undef || value(next) != l_Undef || !decision[next])
502 if (order_heap.empty()){
503 next = var_Undef;
504 break;
505 }else
506 next = order_heap.removeMin();
507
508 return next == var_Undef ? lit_Undef : mkLit(next, rnd_pol ? drand(random_seed) < 0.5 : (polarity[next] != 0));
509}
#define var_Undef
Definition SolverTypes.h:45
static int irand(double &seed, int size)
Definition Solver.h:360
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printClause()

void Gluco::Solver::printClause ( CRef c)
inline

Definition at line 480 of file Solver.h.

481{
482 Clause &c = ca[cr];
483 for (int i = 0; i < c.size(); i++){
484 printLit(c[i]);
485 printf(" ");
486 }
487}
void printLit(Lit l)
Definition Solver.h:474
Here is the call graph for this function:

◆ printIncrementalStats()

void Solver::printIncrementalStats ( )

Definition at line 1186 of file Glucose.cpp.

1186 {
1187
1188 printf("c---------- Glucose Stats -------------------------\n");
1189 printf("c restarts : %ld\n", starts);
1190 printf("c nb ReduceDB : %ld\n", nbReduceDB);
1191 printf("c nb removed Clauses : %ld\n", nbRemovedClauses);
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);
1195
1196 printf("c conflicts : %ld\n", conflicts);
1197 printf("c decisions : %ld\n", decisions);
1198 printf("c propagations : %ld\n", propagations);
1199
1200 printf("c SAT Calls : %d in %g seconds\n", nbSatCalls, totalTime4Sat);
1201 printf("c UNSAT Calls : %d in %g seconds\n", nbUnsatCalls, totalTime4Unsat);
1202 printf("c--------------------------------------------------\n");
1203
1204
1205}

◆ printInitialClause()

void Gluco::Solver::printInitialClause ( CRef c)
inline

Definition at line 489 of file Solver.h.

490{
491 Clause &c = ca[cr];
492 for (int i = 0; i < c.size(); i++){
493 if(!isSelector(var(c[i]))) {
494 printLit(c[i]);
495 printf(" ");
496 }
497 }
498}
Here is the call graph for this function:

◆ printLit()

void Gluco::Solver::printLit ( Lit l)
inline

Definition at line 474 of file Solver.h.

475{
476 printf("%s%d:%c", sign(l) ? "-" : "", var(l)+1, value(l) == l_True ? '1' : (value(l) == l_False ? '0' : 'X'));
477}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ progressEstimate()

double Solver::progressEstimate ( ) const
protected

Definition at line 1172 of file Glucose.cpp.

1173{
1174 double progress = 0;
1175 double F = 1.0 / nVars();
1176
1177 for (int i = 0; i <= decisionLevel(); i++){
1178 int beg = i == 0 ? 0 : trail_lim[i - 1];
1179 int end = i == decisionLevel() ? trail.size() : trail_lim[i];
1180 progress += pow(F, i) * (end - beg);
1181 }
1182
1183 return progress / nVars();
1184}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ propagate()

CRef Solver::propagate ( )
protected

Definition at line 803 of file Glucose.cpp.

804{
805 CRef confl = CRef_Undef;
806 int num_props = 0;
807 watches.cleanAll();
808 watchesBin.cleanAll();
809 while (qhead < trail.size()){
810 Lit p = trail[qhead++]; // 'p' is enqueued fact to propagate.
811 vec<Watcher>& ws = watches[p];
812 Watcher *i, *j, *end;
813 num_props++;
814
815 // First, Propagate binary clauses
816 vec<Watcher>& wbin = watchesBin[p];
817 for(int k = 0;k<wbin.size();k++) {
818 Lit imp = wbin[k].blocker;
819 if(value(imp) == l_False) {
820 return wbin[k].cref;
821 }
822 if(value(imp) == l_Undef) {
823 uncheckedEnqueue(imp,wbin[k].cref);
824 }
825 }
826
827 for (i = j = (Watcher*)ws, end = i + ws.size(); i != end;){
828 // Try to avoid inspecting the clause:
829 Lit blocker = i->blocker;
830 if (value(blocker) == l_True){
831 *j++ = *i++; continue; }
832
833 // Make sure the false literal is data[1]:
834 CRef cr = i->cref;
835 Clause& c = ca[cr];
836 Lit false_lit = ~p;
837 if (c[0] == false_lit)
838 c[0] = c[1], c[1] = false_lit;
839 assert(c[1] == false_lit);
840 i++;
841
842 // If 0th watch is true, then clause is already satisfied.
843 Lit first = c[0];
844 Watcher w = Watcher(cr, first);
845 if (first != blocker && value(first) == l_True){
846 *j++ = w; continue; }
847
848 // Look for new watch:
849 if(incremental) { // ----------------- INCREMENTAL MODE
850 int choosenPos = -1;
851 for (int k = 2; k < c.size(); k++) {
852
853 if (value(c[k]) != l_False){
854 if(decisionLevel()>assumptions.size()) {
855 choosenPos = k;
856 break;
857 } else {
858 choosenPos = k;
859
860 if(value(c[k])==l_True || !isSelector(var(c[k]))) {
861 break;
862 }
863 }
864
865 }
866 }
867 if(choosenPos!=-1) {
868 c[1] = c[choosenPos]; c[choosenPos] = false_lit;
869 watches[~c[1]].push(w);
870 goto NextClause; }
871 } else { // ----------------- DEFAULT MODE (NOT INCREMENTAL)
872 for (int k = 2; k < c.size(); k++) {
873
874 if (value(c[k]) != l_False){
875 c[1] = c[k]; c[k] = false_lit;
876 watches[~c[1]].push(w);
877 goto NextClause; }
878 }
879 }
880
881 // Did not find watch -- clause is unit under assignment:
882 *j++ = w;
883 if (value(first) == l_False){
884 confl = cr;
885 qhead = trail.size();
886 // Copy the remaining watches:
887 while (i < end)
888 *j++ = *i++;
889 }else {
890 uncheckedEnqueue(first, cr);
891
892
893 }
894 NextClause:;
895 }
896 ws.shrink(i - j);
897 }
898 propagations += num_props;
899 simpDB_props -= num_props;
900
901 return confl;
902}
vec< Lit > assumptions
Definition Solver.h:250
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reason()

CRef Gluco::Solver::reason ( Var x) const
inlineprotected

Definition at line 368 of file Solver.h.

368{ return vardata[x].reason; }
Here is the caller graph for this function:

◆ rebuildOrderHeap()

void Solver::rebuildOrderHeap ( )
protected

Definition at line 981 of file Glucose.cpp.

982{
983 vec<Var> vs;
984 for (Var v = 0; v < nVars(); v++)
985 if (decision[v] && value(v) == l_Undef)
986 vs.push(v);
987 order_heap.build(vs);
988}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduceDB()

void Solver::reduceDB ( )
protected

Definition at line 935 of file Glucose.cpp.

936{
937 int i, j;
938 nbReduceDB++;
939 sort(learnts, reduceDB_lt(ca));
940
941 // We have a lot of "good" clauses, it is difficult to compare them. Keep more !
943 // Useless :-)
944 if(ca[learnts.last()].lbd()<=5) nbclausesbeforereduce +=specialIncReduceDB;
945
946 // Don't delete binary or locked clauses. From the rest, delete clauses from the first half
947 // Keep clauses which seem to be usefull (their lbd was reduce during this sequence)
948
949 int limit = learnts.size() / 2;
950 for (i = j = 0; i < learnts.size(); i++){
951 Clause& c = ca[learnts[i]];
952 if (c.lbd()>2 && c.size() > 2 && c.canBeDel() && !locked(c) && (i < limit)) {
955 }
956 else {
957 if(!c.canBeDel()) limit++; //we keep c, so we can delete an other clause
958 c.setCanBeDel(true); // At the next step, c can be delete
959 learnts[j++] = learnts[i];
960 }
961 }
962 learnts.shrink(i - j);
963 checkGarbage();
964}
bool locked(const Clause &c) const
Definition Solver.h:407
void removeClause(CRef cr)
Definition Glucose.cpp:333
#define RATIOREMOVECLAUSES
Definition Constants.h:27
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relocAll()

void Solver::relocAll ( ClauseAllocator & to)
protected

Definition at line 1386 of file Glucose.cpp.

1387{
1388 int v, s, i, j;
1389 // All watchers:
1390 //
1391 // for (int i = 0; i < watches.size(); i++)
1392 watches.cleanAll();
1393 watchesBin.cleanAll();
1394 for (v = 0; v < nVars(); v++)
1395 for (s = 0; s < 2; s++){
1396 Lit p = mkLit(v, s != 0);
1397 // printf(" >>> RELOCING: %s%d\n", sign(p)?"-":"", var(p)+1);
1398 vec<Watcher>& ws = watches[p];
1399 for (j = 0; j < ws.size(); j++)
1400 ca.reloc(ws[j].cref, to);
1401 vec<Watcher>& ws2 = watchesBin[p];
1402 for (j = 0; j < ws2.size(); j++)
1403 ca.reloc(ws2[j].cref, to);
1404 }
1405
1406 // All reasons:
1407 //
1408 for (i = 0; i < trail.size(); i++){
1409 Var v = var(trail[i]);
1410
1411 if (reason(v) != CRef_Undef && (ca[reason(v)].reloced() || locked(ca[reason(v)])))
1412 ca.reloc(vardata[v].reason, to);
1413 }
1414
1415 // All learnt:
1416 //
1417 for (i = 0; i < learnts.size(); i++)
1418 ca.reloc(learnts[i], to);
1419
1420 // All original:
1421 //
1422 for (i = 0; i < clauses.size(); i++)
1423 ca.reloc(clauses[i], to);
1424}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeClause()

void Solver::removeClause ( CRef cr)
protected

Definition at line 333 of file Glucose.cpp.

333 {
334
335 Clause& c = ca[cr];
336
337 if (certifiedUNSAT) {
338 fprintf(certifiedOutput, "d ");
339 for (int i = 0; i < c.size(); i++)
340 fprintf(certifiedOutput, "%i ", (var(c[i]) + 1) * (-2 * sign(c[i]) + 1));
341 fprintf(certifiedOutput, "0\n");
342 }
343
344 detachClause(cr);
345 // Don't leave pointers to free'd memory!
346 if (locked(c)) vardata[var(c[0])].reason = CRef_Undef;
347 c.mark(1);
348 ca.free_(cr);
349}
unsigned mark
void detachClause(CRef cr, bool strict=false)
Definition Glucose.cpp:306
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeSatisfied()

void Solver::removeSatisfied ( vec< CRef > & cs)
protected

Definition at line 967 of file Glucose.cpp.

968{
969 int i, j;
970 for (i = j = 0; i < cs.size(); i++){
971 Clause& c = ca[cs[i]];
972 if (satisfied(c))
973 removeClause(cs[i]);
974 else
975 cs[j++] = cs[i];
976 }
977 cs.shrink(i - j);
978}
bool satisfied(const Clause &c) const
Definition Glucose.cpp:352
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void Solver::reset ( )
virtual

Reimplemented in Gluco::SimpSolver.

Definition at line 1440 of file Glucose.cpp.

1441{
1442 // Reset everything
1443 ok = true;
1444 K = (double)opt_K;
1445 R = (double)opt_R;
1446 firstReduceDB = opt_first_reduce_db;
1447 var_decay = (double)opt_var_decay;
1448 //max_var_decay = opt_max_var_decay;
1450 curRestart = 1;
1451 cla_inc = var_inc = 1;
1452 watches.clear(false); // We don't free the memory, new calls should be of the same size order.
1453 watchesBin.clear(false);
1454 //unaryWatches.clear(false);
1455 qhead = 0;
1456 simpDB_assigns = -1;
1457 simpDB_props = 0;
1458 order_heap.clear(false);
1460 //lastLearntClause = CRef_Undef;
1461 conflict_budget = -1;
1462 propagation_budget = -1;
1464 totalTime4Sat = 0.;
1465 totalTime4Unsat = 0.;
1467 MYFLAG = 0;
1468 lbdQueue.clear(false);
1469 lbdQueue.initSize(sizeLBDQueue);
1470 trailQueue.clear(false);
1471 trailQueue.initSize(sizeTrailQueue);
1472 sumLBD = 0;
1474 //stats.clear();
1475 //stats.growTo(coreStatsSize, 0);
1476 clauses.clear(false);
1477 learnts.clear(false);
1478 //permanentLearnts.clear(false);
1479 //unaryWatchedClauses.clear(false);
1480 model.clear(false);
1481 conflict.clear(false);
1482 activity.clear(false);
1483 assigns.clear(false);
1484 polarity.clear(false);
1485 //forceUNSAT.clear(false);
1486 decision.clear(false);
1487 trail.clear(false);
1488 nbpos.clear(false);
1489 trail_lim.clear(false);
1490 vardata.clear(false);
1491 assumptions.clear(false);
1492 permDiff.clear(false);
1493 lastDecisionLevel.clear(false);
1494 ca.clear();
1495 seen.clear(false);
1496 analyze_stack.clear(false);
1497 analyze_toclear.clear(false);
1498 add_tmp.clear(false);
1499 assumptionPositions.clear(false);
1500 initialPositions.clear(false);
1501}
vec< int > assumptionPositions
Definition Solver.h:296
vec< Lit > conflict
Definition Solver.h:153
vec< int > nbpos
Definition Solver.h:244
vec< int > initialPositions
Definition Solver.h:296
Here is the caller graph for this function:

◆ sat_solver_mark_cone()

void Gluco::Solver::sat_solver_mark_cone ( int var)
inline

Definition at line 468 of file Solver.h.

468{}
Here is the call graph for this function:

◆ sat_solver_set_var_fanin_lit()

void Gluco::Solver::sat_solver_set_var_fanin_lit ( int var,
int lit0,
int lit1 )
inline

Definition at line 466 of file Solver.h.

466{}
Here is the call graph for this function:

◆ sat_solver_start_new_round()

void Gluco::Solver::sat_solver_start_new_round ( )
inline

Definition at line 467 of file Solver.h.

467{}

◆ satisfied()

bool Solver::satisfied ( const Clause & c) const
protected

Definition at line 352 of file Glucose.cpp.

352 {
353 if(incremental) // Check clauses with many selectors is too time consuming
354 return (value(c[0]) == l_True) || (value(c[1]) == l_True);
355
356 // Default mode.
357 for (int i = 0; i < c.size(); i++)
358 if (value(c[i]) == l_True)
359 return true;
360 return false;
361}
Here is the caller graph for this function:

◆ search()

lbool Solver::search ( int nof_conflicts)
protected

Definition at line 1038 of file Glucose.cpp.

1039{
1040 assert(ok);
1041 int backtrack_level;
1042 int conflictC = 0;
1043 vec<Lit> learnt_clause,selectors;
1044 unsigned int nblevels,szWoutSelectors;
1045 bool blocked=false;
1046 starts++;
1047 for (;;){
1048 CRef confl = propagate();
1049 if (confl != CRef_Undef){
1050 // CONFLICT
1051 conflicts++; conflictC++;conflictsRestarts++;
1052 if(conflicts%5000==0 && var_decay<0.95)
1053 var_decay += 0.01;
1054
1055 if (verbosity >= 1 && conflicts%verbEveryConflicts==0){
1056 printf("c | %8d %7d %5d | %7d %8d %8d | %5d %8d %6d %8d | %6.3f %% |\n",
1057 (int)starts,(int)nbstopsrestarts, (int)(conflicts/starts),
1058 (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), nClauses(), (int)clauses_literals,
1059 (int)nbReduceDB, nLearnts(), (int)nbDL2,(int)nbRemovedClauses, progressEstimate()*100);
1060 }
1061 if (decisionLevel() == 0) {
1062 return l_False;
1063
1064 }
1065
1066 trailQueue.push(trail.size());
1067 // BLOCK RESTART (CP 2012 paper)
1068 if( conflictsRestarts>LOWER_BOUND_FOR_BLOCKING_RESTART && lbdQueue.isvalid() && trail.size()>R*trailQueue.getavg()) {
1069 lbdQueue.fastclear();
1071 if(!blocked) {lastblockatrestart=starts;nbstopsrestartssame++;blocked=true;}
1072 }
1073
1074 learnt_clause.clear();
1075 selectors.clear();
1076 analyze(confl, learnt_clause, selectors,backtrack_level,nblevels,szWoutSelectors);
1077
1078 lbdQueue.push(nblevels);
1079 sumLBD += nblevels;
1080
1081 cancelUntil(backtrack_level);
1082
1083 if (certifiedUNSAT) {
1084 for (int i = 0; i < learnt_clause.size(); i++)
1085 fprintf(certifiedOutput, "%i " , (var(learnt_clause[i]) + 1) *
1086 (-2 * sign(learnt_clause[i]) + 1) );
1087 fprintf(certifiedOutput, "0\n");
1088 }
1089
1090 if (learnt_clause.size() == 1){
1091 uncheckedEnqueue(learnt_clause[0]);nbUn++;
1092 }else{
1093 CRef cr = ca.alloc(learnt_clause, true);
1094 ca[cr].setLBD(nblevels);
1095 ca[cr].setSizeWithoutSelectors(szWoutSelectors);
1096 if(nblevels<=2) nbDL2++; // stats
1097 if(ca[cr].size()==2) nbBin++; // stats
1098 learnts.push(cr);
1099 attachClause(cr);
1100
1101 claBumpActivity(ca[cr]);
1102 uncheckedEnqueue(learnt_clause[0], cr);
1103 }
1106
1107
1108 }else{
1109
1110 // Our dynamic restart, see the SAT09 competition compagnion paper
1111 if ( (conflictsRestarts && lbdQueue.isvalid() && lbdQueue.getavg()*K > sumLBD/conflictsRestarts) || (pstop && *pstop) ) {
1112 lbdQueue.fastclear();
1114 int bt = 0;
1115 if(incremental) { // DO NOT BACKTRACK UNTIL 0.. USELESS
1116 bt = (decisionLevel()<assumptions.size()) ? decisionLevel() : assumptions.size();
1117 }
1118 cancelUntil(bt);
1119 return l_Undef;
1120 }
1121
1122 // Simplify the set of problem clauses:
1123 if (decisionLevel() == 0 && !simplify()) {
1124 return l_False;
1125 }
1126 // Perform clause database reduction !
1128 {
1129
1130 assert(learnts.size()>0);
1132 reduceDB();
1134 }
1135
1136 Lit next = lit_Undef;
1137 while (decisionLevel() < assumptions.size()){
1138 // Perform user provided assumption:
1139 Lit p = assumptions[decisionLevel()];
1140 if (value(p) == l_True){
1141 // Dummy decision level:
1143 }else if (value(p) == l_False){
1145 return l_False;
1146 }else{
1147 next = p;
1148 break;
1149 }
1150 }
1151
1152 if (next == lit_Undef){
1153 // New variable decision:
1154 decisions++;
1155 next = pickBranchLit();
1156
1157 if (next == lit_Undef){
1158 //printf("c last restart ## conflicts : %d %d \n",conflictC,decisionLevel());
1159 // Model found:
1160 return l_True;
1161 }
1162 }
1163
1164 // Increase decision level and enqueue 'next'
1166 uncheckedEnqueue(next);
1167 }
1168 }
1169}
Lit pickBranchLit()
Definition Glucose.cpp:490
void cancelUntil(int level)
Definition Glucose.cpp:471
double progressEstimate() const
Definition Glucose.cpp:1172
void reduceDB()
Definition Glucose.cpp:935
void newDecisionLevel()
Definition Solver.h:415
void analyzeFinal(Lit p, vec< Lit > &out_conflict)
Definition Glucose.cpp:749
void claDecayActivity()
Definition Solver.h:387
void varDecayActivity()
Definition Solver.h:374
bool simplify()
Definition Glucose.cpp:999
void analyze(CRef confl, vec< Lit > &out_learnt, vec< Lit > &selectors, int &out_btlevel, unsigned int &nblevels, unsigned int &szWithoutSelectors)
Definition Glucose.cpp:529
int nClauses() const
Definition Solver.h:424
int nLearnts() const
Definition Solver.h:425
#define LOWER_BOUND_FOR_BLOCKING_RESTART
Definition Constants.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setConfBudget()

void Gluco::Solver::setConfBudget ( int64_t x)
inline

Definition at line 438 of file Solver.h.

438{ conflict_budget = conflicts + x; }

◆ setDecisionVar()

void Gluco::Solver::setDecisionVar ( Var v,
bool b )
inline

Definition at line 430 of file Solver.h.

431{
432 if ( b && !decision[v]) dec_vars++;
433 else if (!b && decision[v]) dec_vars--;
434
435 decision[v] = b;
437}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setIncrementalMode()

void Solver::setIncrementalMode ( )

Definition at line 185 of file Glucose.cpp.

185 {
186 incremental = true;
187}
Here is the caller graph for this function:

◆ setPolarity()

void Gluco::Solver::setPolarity ( Var v,
bool b )
inline

Definition at line 429 of file Solver.h.

429{ polarity[v] = b; }

◆ setPropBudget()

void Gluco::Solver::setPropBudget ( int64_t x)
inline

Definition at line 439 of file Solver.h.

◆ simplify()

bool Solver::simplify ( )

Definition at line 999 of file Glucose.cpp.

1000{
1001 assert(decisionLevel() == 0);
1002
1003 if (!ok || propagate() != CRef_Undef)
1004 return ok = false;
1005
1006 if (nAssigns() == simpDB_assigns || (simpDB_props > 0))
1007 return true;
1008
1009 // Remove satisfied clauses:
1011 if (remove_satisfied) // Can be turned off.
1013
1014 checkGarbage();
1015
1017
1019 simpDB_props = clauses_literals + learnts_literals; // (shouldn't depend on stats really, but it will do for now)
1020
1021 return true;
1022}
int nAssigns() const
Definition Solver.h:423
void rebuildOrderHeap()
Definition Glucose.cpp:981
void removeSatisfied(vec< CRef > &cs)
Definition Glucose.cpp:967
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve() [1/5]

bool Gluco::Solver::solve ( )
inline

Definition at line 451 of file Solver.h.

451{ budgetOff(); assumptions.clear(); return solve_() == l_True; }
lbool solve_()
Definition Glucose.cpp:1209
void budgetOff()
Definition Solver.h:442
Here is the call graph for this function:

◆ solve() [2/5]

bool Gluco::Solver::solve ( const vec< Lit > & assumps)
inline

Definition at line 455 of file Solver.h.

455{ budgetOff(); assumps.copyTo(assumptions); return solve_() == l_True; }
Here is the call graph for this function:

◆ solve() [3/5]

bool Gluco::Solver::solve ( Lit p)
inline

Definition at line 452 of file Solver.h.

452{ budgetOff(); assumptions.clear(); assumptions.push(p); return solve_() == l_True; }
Here is the call graph for this function:

◆ solve() [4/5]

bool Gluco::Solver::solve ( Lit p,
Lit q )
inline

Definition at line 453 of file Solver.h.

453{ budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_() == l_True; }
Here is the call graph for this function:

◆ solve() [5/5]

bool Gluco::Solver::solve ( Lit p,
Lit q,
Lit r )
inline

Definition at line 454 of file Solver.h.

454{ budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_() == l_True; }
Here is the call graph for this function:

◆ solve_()

lbool Solver::solve_ ( )
protected

Definition at line 1209 of file Glucose.cpp.

1210{
1211
1213 printf("Can not use incremental and certified unsat in the same time\n");
1214 exit(-1);
1215 }
1216 model.clear();
1217 conflict.clear();
1218 if (!ok) return l_False;
1219 double curTime = cpuTime();
1220
1221
1222 solves++;
1223
1224
1225
1226 lbool status = l_Undef;
1227 if(!incremental && verbosity>=1) {
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");
1234 printf("c | * LBD Queue : %6d | * First : %6d | * size < %3d |\n",lbdQueue.maxSize(),nbclausesbeforereduce,lbSizeMinimizingClause);
1235 printf("c | * Trail Queue : %6d | * Inc : %6d | * lbd < %3d |\n",trailQueue.maxSize(),incReduceDB,lbLBDMinimizingClause);
1236 printf("c | * K : %6.2f | * Special : %6d | |\n",K,specialIncReduceDB);
1237 printf("c | * R : %6.2f | * Protected : (lbd)< %2d | |\n",R,lbLBDFrozenClause);
1238 printf("c | | | |\n");
1239printf("c ==================================[ Search Statistics (every %6d conflicts) ]=========================\n",verbEveryConflicts);
1240 printf("c | |\n");
1241
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");
1245 }
1246
1247 // Search:
1248 int curr_restarts = 0;
1249 while (status == l_Undef){
1250 status = search(0); // the parameter is useless in glucose, kept to allow modifications
1251 if (!withinBudget() || terminate_search_early || (pstop && *pstop)) break;
1252 if (nRuntimeLimit && Abc_Clock() > nRuntimeLimit) break;
1253 curr_restarts++;
1254 }
1255
1256 if (!incremental && verbosity >= 1)
1257 printf("c =========================================================================================================\n");
1258
1259
1260 if (certifiedUNSAT){ // Want certified output
1261 if (status == l_False)
1262 fprintf(certifiedOutput, "0\n");
1263 fclose(certifiedOutput);
1264 }
1265
1266
1267 if (status == l_True){
1268 // Extend & copy model:
1269 model.growTo(nVars());
1270 for (int i = 0; i < nVars(); i++) model[i] = value(i);
1271 }else if (status == l_False && conflict.size() == 0)
1272 ok = false;
1273
1274 cancelUntil(0);
1275
1276 double finalTime = cpuTime();
1277 if(status==l_True) {
1278 nbSatCalls++;
1279 totalTime4Sat +=(finalTime-curTime);
1280 }
1281 if(status==l_False) {
1282 nbUnsatCalls++;
1283 totalTime4Unsat +=(finalTime-curTime);
1284 }
1285
1286 // ABC callback
1287 if (pCnfFunc && !terminate_search_early) {// hack to avoid calling callback twise if the solver was terminated early
1288 int * pCex = NULL;
1289 int message = (status == l_True ? 1 : status == l_False ? 0 : -1);
1290 if (status == l_True) {
1291 pCex = new int[nVars()];
1292 for (int i = 0; i < nVars(); i++)
1293 pCex[i] = (model[i] == l_True);
1294 }
1295
1296 int callback_result = pCnfFunc(pCnfMan, message, pCex);
1297 assert(callback_result == 0);
1298 }
1299 else if (pCnfFunc)
1300 terminate_search_early = false; // for next run
1301
1302 return status;
1303}
lbool search(int nof_conflicts)
Definition Glucose.cpp:1038
bool withinBudget() const
Definition Solver.h:443
void * pCnfMan
Definition Solver.h:58
signed char lbool
Definition satVec.h:135
VOID_HACK exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solveLimited()

lbool Gluco::Solver::solveLimited ( const vec< Lit > & assumps)
inline

Definition at line 456 of file Solver.h.

456{ assumps.copyTo(assumptions); return solve_(); }
Here is the call graph for this function:

◆ toDimacs() [1/7]

void Gluco::Solver::toDimacs ( const char * file)
inline

Definition at line 459 of file Solver.h.

459{ vec<Lit> as; toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
Definition Glucose.cpp:1341
struct file file
Definition file.h:21
Here is the call graph for this function:

◆ toDimacs() [2/7]

void Solver::toDimacs ( const char * file,
const vec< Lit > & assumps )

Definition at line 1331 of file Glucose.cpp.

1332{
1333 FILE* f = fopen(file, "wb");
1334 if (f == NULL)
1335 fprintf(stderr, "could not open file %s\n", file), exit(1);
1336 toDimacs(f, assumps);
1337 fclose(f);
1338}
Here is the call graph for this function:

◆ toDimacs() [3/7]

void Gluco::Solver::toDimacs ( const char * file,
Lit p )
inline

Definition at line 460 of file Solver.h.

460{ vec<Lit> as; as.push(p); toDimacs(file, as); }
Here is the call graph for this function:

◆ toDimacs() [4/7]

void Gluco::Solver::toDimacs ( const char * file,
Lit p,
Lit q )
inline

Definition at line 461 of file Solver.h.

461{ vec<Lit> as; as.push(p); as.push(q); toDimacs(file, as); }
Here is the call graph for this function:

◆ toDimacs() [5/7]

void Gluco::Solver::toDimacs ( const char * file,
Lit p,
Lit q,
Lit r )
inline

Definition at line 462 of file Solver.h.

462{ vec<Lit> as; as.push(p); as.push(q); as.push(r); toDimacs(file, as); }
Here is the call graph for this function:

◆ toDimacs() [6/7]

void Solver::toDimacs ( FILE * f,
Clause & c,
vec< Var > & map,
Var & max )

Definition at line 1320 of file Glucose.cpp.

1321{
1322 if (satisfied(c)) return;
1323
1324 for (int i = 0; i < c.size(); i++)
1325 if (value(c[i]) != l_False)
1326 fprintf(f, "%s%d ", sign(c[i]) ? "-" : "", mapVar(var(c[i]), map, max)+1);
1327 fprintf(f, "0\n");
1328}
void map()
Here is the call graph for this function:

◆ toDimacs() [7/7]

void Solver::toDimacs ( FILE * f,
const vec< Lit > & assumps )

Definition at line 1341 of file Glucose.cpp.

1342{
1343 // Handle case when solver is in contradictory state:
1344 if (!ok){
1345 fprintf(f, "p cnf 1 2\n1 0\n-1 0\n");
1346 return; }
1347
1348 vec<Var> map; Var max = 0;
1349
1350 // Cannot use removeClauses here because it is not safe
1351 // to deallocate them at this point. Could be improved.
1352 int i, cnt = 0;
1353 for (i = 0; i < clauses.size(); i++)
1354 if (!satisfied(ca[clauses[i]]))
1355 cnt++;
1356
1357 for (i = 0; i < clauses.size(); i++)
1358 if (!satisfied(ca[clauses[i]])){
1359 Clause& c = ca[clauses[i]];
1360 for (int j = 0; j < c.size(); j++)
1361 if (value(c[j]) != l_False)
1362 mapVar(var(c[j]), map, max);
1363 }
1364
1365 // Assumptions are added as unit clauses:
1366 cnt += assumptions.size();
1367
1368 fprintf(f, "p cnf %d %d\n", max, cnt);
1369
1370 for (i = 0; i < assumptions.size(); i++){
1372 fprintf(f, "%s%d 0\n", sign(assumptions[i]) ? "-" : "", mapVar(var(assumptions[i]), map, max)+1);
1373 }
1374
1375 for (i = 0; i < clauses.size(); i++)
1376 toDimacs(f, ca[clauses[i]], map, max);
1377
1378 if (verbosity > 0)
1379 printf("Wrote %d clauses with %d variables.\n", cnt, max);
1380}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uncheckedEnqueue()

void Solver::uncheckedEnqueue ( Lit p,
CRef from = CRef_Undef )
protected

Definition at line 783 of file Glucose.cpp.

784{
785 assert(value(p) == l_Undef);
786 assigns[var(p)] = lbool(!sign(p));
787 vardata[var(p)] = mkVarData(from, decisionLevel());
788 trail.push_(p);
789}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ value() [1/2]

lbool Gluco::Solver::value ( Lit p) const
inline

Definition at line 420 of file Solver.h.

420{ return assigns[var(p)] ^ sign(p); }
Here is the call graph for this function:

◆ value() [2/2]

lbool Gluco::Solver::value ( Var x) const
inline

Definition at line 419 of file Solver.h.

419{ return assigns[x]; }
Here is the caller graph for this function:

◆ varBumpActivity() [1/2]

void Gluco::Solver::varBumpActivity ( Var v)
inlineprotected

Definition at line 375 of file Solver.h.

Here is the call graph for this function:

◆ varBumpActivity() [2/2]

void Gluco::Solver::varBumpActivity ( Var v,
double inc )
inlineprotected

Definition at line 376 of file Solver.h.

376 {
377 if ( (activity[v] += inc) > 1e100 ) {
378 // Rescale:
379 for (int i = 0; i < nVars(); i++)
380 activity[i] *= 1e-100;
381 var_inc *= 1e-100; }
382
383 // Update order_heap with respect to new activity:
384 if (order_heap.inHeap(v))
385 order_heap.decrease(v); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ varDecayActivity()

void Gluco::Solver::varDecayActivity ( )
inlineprotected

Definition at line 374 of file Solver.h.

374{ var_inc *= (1 / var_decay); }
Here is the caller graph for this function:

◆ withinBudget()

bool Gluco::Solver::withinBudget ( ) const
inlineprotected

Definition at line 443 of file Solver.h.

443 {
444 return !asynch_interrupt &&
445 (conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
Here is the caller graph for this function:

Member Data Documentation

◆ activity

vec<double> Gluco::Solver::activity
protected

Definition at line 231 of file Solver.h.

◆ add_tmp

vec<Lit> Gluco::Solver::add_tmp
protected

Definition at line 276 of file Solver.h.

◆ analyze_stack

vec<Lit> Gluco::Solver::analyze_stack
protected

Definition at line 274 of file Solver.h.

◆ analyze_toclear

vec<Lit> Gluco::Solver::analyze_toclear
protected

Definition at line 275 of file Solver.h.

◆ assigns

vec<lbool> Gluco::Solver::assigns
protected

Definition at line 240 of file Solver.h.

◆ assumptionPositions

vec<int> Gluco::Solver::assumptionPositions
protected

Definition at line 296 of file Solver.h.

◆ assumptions

vec<Lit> Gluco::Solver::assumptions
protected

Definition at line 250 of file Solver.h.

◆ asynch_interrupt

bool Gluco::Solver::asynch_interrupt
protected

Definition at line 288 of file Solver.h.

◆ ca

ClauseAllocator Gluco::Solver::ca
protected

Definition at line 261 of file Solver.h.

◆ ccmin_mode

int Gluco::Solver::ccmin_mode

Definition at line 181 of file Solver.h.

◆ certifiedOutput

FILE* Gluco::Solver::certifiedOutput

Definition at line 188 of file Solver.h.

◆ certifiedUNSAT

bool Gluco::Solver::certifiedUNSAT

Definition at line 189 of file Solver.h.

◆ cla_inc

double Gluco::Solver::cla_inc
protected

Definition at line 230 of file Solver.h.

◆ clause_decay

double Gluco::Solver::clause_decay

Definition at line 178 of file Solver.h.

◆ clauses

vec<CRef> Gluco::Solver::clauses
protected

Definition at line 237 of file Solver.h.

◆ clauses_literals

int64_t Gluco::Solver::clauses_literals

Definition at line 195 of file Solver.h.

◆ conflict

vec<Lit> Gluco::Solver::conflict

Definition at line 153 of file Solver.h.

◆ conflict_budget

int64_t Gluco::Solver::conflict_budget
protected

Definition at line 286 of file Solver.h.

◆ conflicts

int64_t Gluco::Solver::conflicts

Definition at line 194 of file Solver.h.

◆ conflictsRestarts

int64_t Gluco::Solver::conflictsRestarts

Definition at line 194 of file Solver.h.

◆ curRestart

long Gluco::Solver::curRestart
protected

Definition at line 198 of file Solver.h.

◆ dec_vars

int64_t Gluco::Solver::dec_vars

Definition at line 195 of file Solver.h.

◆ decision

vec<char> Gluco::Solver::decision
protected

Definition at line 242 of file Solver.h.

◆ decisions

int64_t Gluco::Solver::decisions

Definition at line 194 of file Solver.h.

◆ firstReduceDB

int Gluco::Solver::firstReduceDB

Definition at line 168 of file Solver.h.

◆ garbage_frac

double Gluco::Solver::garbage_frac

Definition at line 185 of file Solver.h.

◆ incReduceDB

int Gluco::Solver::incReduceDB

Definition at line 169 of file Solver.h.

◆ incremental

int Gluco::Solver::incremental
protected

Definition at line 292 of file Solver.h.

◆ initialPositions

vec<int> Gluco::Solver::initialPositions
protected

Definition at line 296 of file Solver.h.

◆ jftr

int Gluco::Solver::jftr

Definition at line 68 of file Solver.h.

◆ K

double Gluco::Solver::K

Definition at line 162 of file Solver.h.

◆ lastblockatrestart

int64_t Gluco::Solver::lastblockatrestart

Definition at line 194 of file Solver.h.

◆ lastIndexRed

int Gluco::Solver::lastIndexRed
protected

Definition at line 228 of file Solver.h.

◆ lbdQueue

bqueue<unsigned int> Gluco::Solver::lbdQueue
protected

Definition at line 265 of file Solver.h.

◆ lbLBDFrozenClause

unsigned int Gluco::Solver::lbLBDFrozenClause

Definition at line 171 of file Solver.h.

◆ lbLBDMinimizingClause

unsigned int Gluco::Solver::lbLBDMinimizingClause

Definition at line 175 of file Solver.h.

◆ lbSizeMinimizingClause

int Gluco::Solver::lbSizeMinimizingClause

Definition at line 174 of file Solver.h.

◆ learnts

vec<CRef> Gluco::Solver::learnts
protected

Definition at line 238 of file Solver.h.

◆ learnts_literals

int64_t Gluco::Solver::learnts_literals

Definition at line 195 of file Solver.h.

◆ learntsize_adjust_cnt

int Gluco::Solver::learntsize_adjust_cnt
protected

Definition at line 282 of file Solver.h.

◆ learntsize_adjust_confl

double Gluco::Solver::learntsize_adjust_confl
protected

Definition at line 281 of file Solver.h.

◆ max_learnts

double Gluco::Solver::max_learnts
protected

Definition at line 280 of file Solver.h.

◆ max_literals

int64_t Gluco::Solver::max_literals

Definition at line 195 of file Solver.h.

◆ model

vec<lbool> Gluco::Solver::model

Definition at line 152 of file Solver.h.

◆ MYFLAG

unsigned int Gluco::Solver::MYFLAG
protected

Definition at line 277 of file Solver.h.

◆ nbBin

int64_t Gluco::Solver::nbBin

Definition at line 194 of file Solver.h.

◆ nbclausesbeforereduce

int Gluco::Solver::nbclausesbeforereduce
protected

Definition at line 263 of file Solver.h.

◆ nbDL2

int64_t Gluco::Solver::nbDL2

Definition at line 194 of file Solver.h.

◆ nbpos

vec<int> Gluco::Solver::nbpos
protected

Definition at line 244 of file Solver.h.

◆ nbReduceDB

int64_t Gluco::Solver::nbReduceDB

Definition at line 194 of file Solver.h.

◆ nbReducedClauses

int64_t Gluco::Solver::nbReducedClauses

Definition at line 194 of file Solver.h.

◆ nbRemovedClauses

int64_t Gluco::Solver::nbRemovedClauses

Definition at line 194 of file Solver.h.

◆ nbSatCalls

int Gluco::Solver::nbSatCalls
protected

Definition at line 295 of file Solver.h.

◆ nbstopsrestarts

int64_t Gluco::Solver::nbstopsrestarts

Definition at line 194 of file Solver.h.

◆ nbstopsrestartssame

int64_t Gluco::Solver::nbstopsrestartssame

Definition at line 194 of file Solver.h.

◆ nbUn

int64_t Gluco::Solver::nbUn

Definition at line 194 of file Solver.h.

◆ nbUnsatCalls

int Gluco::Solver::nbUnsatCalls
protected

Definition at line 295 of file Solver.h.

◆ nbVarsInitialFormula

int Gluco::Solver::nbVarsInitialFormula
protected

Definition at line 293 of file Solver.h.

◆ nCallConfl

int Gluco::Solver::nCallConfl

Definition at line 60 of file Solver.h.

◆ nRuntimeLimit

uint64_t Gluco::Solver::nRuntimeLimit

Definition at line 63 of file Solver.h.

◆ ok

bool Gluco::Solver::ok
protected

Definition at line 229 of file Solver.h.

◆ order_heap

Heap<VarOrderLt> Gluco::Solver::order_heap
protected

Definition at line 251 of file Solver.h.

◆ pCnfFunc

int(* Gluco::Solver::pCnfFunc) (void *p, int, int *)

Definition at line 59 of file Solver.h.

◆ pCnfMan

void* Gluco::Solver::pCnfMan

Definition at line 58 of file Solver.h.

◆ permDiff

vec<unsigned int> Gluco::Solver::permDiff
protected

Definition at line 254 of file Solver.h.

◆ phase_saving

int Gluco::Solver::phase_saving

Definition at line 182 of file Solver.h.

◆ polarity

vec<char> Gluco::Solver::polarity
protected

Definition at line 241 of file Solver.h.

◆ progress_estimate

double Gluco::Solver::progress_estimate
protected

Definition at line 252 of file Solver.h.

◆ propagation_budget

int64_t Gluco::Solver::propagation_budget
protected

Definition at line 287 of file Solver.h.

◆ propagations

int64_t Gluco::Solver::propagations

Definition at line 194 of file Solver.h.

◆ pstop

int* Gluco::Solver::pstop

Definition at line 62 of file Solver.h.

◆ qhead

int Gluco::Solver::qhead
protected

Definition at line 247 of file Solver.h.

◆ R

double Gluco::Solver::R

Definition at line 163 of file Solver.h.

◆ random_seed

double Gluco::Solver::random_seed

Definition at line 180 of file Solver.h.

◆ random_var_freq

double Gluco::Solver::random_var_freq

Definition at line 179 of file Solver.h.

◆ remove_satisfied

bool Gluco::Solver::remove_satisfied
protected

Definition at line 253 of file Solver.h.

◆ rnd_decisions

int64_t Gluco::Solver::rnd_decisions

Definition at line 194 of file Solver.h.

◆ rnd_init_act

bool Gluco::Solver::rnd_init_act

Definition at line 184 of file Solver.h.

◆ rnd_pol

bool Gluco::Solver::rnd_pol

Definition at line 183 of file Solver.h.

◆ seen

vec<char> Gluco::Solver::seen
protected

Definition at line 273 of file Solver.h.

◆ showModel

int Gluco::Solver::showModel

Definition at line 160 of file Solver.h.

◆ simpDB_assigns

int Gluco::Solver::simpDB_assigns
protected

Definition at line 248 of file Solver.h.

◆ simpDB_props

int64_t Gluco::Solver::simpDB_props
protected

Definition at line 249 of file Solver.h.

◆ sizeLBDQueue

double Gluco::Solver::sizeLBDQueue

Definition at line 164 of file Solver.h.

◆ sizeTrailQueue

double Gluco::Solver::sizeTrailQueue

Definition at line 165 of file Solver.h.

◆ SolverType

int Gluco::Solver::SolverType

Definition at line 50 of file Solver.h.

◆ solves

int64_t Gluco::Solver::solves

Definition at line 194 of file Solver.h.

◆ specialIncReduceDB

int Gluco::Solver::specialIncReduceDB

Definition at line 170 of file Solver.h.

◆ starts

int64_t Gluco::Solver::starts

Definition at line 194 of file Solver.h.

◆ sumAssumptions

int Gluco::Solver::sumAssumptions
protected

Definition at line 267 of file Solver.h.

◆ sumLBD

float Gluco::Solver::sumLBD
protected

Definition at line 266 of file Solver.h.

◆ terminate_search_early

bool Gluco::Solver::terminate_search_early

Definition at line 61 of file Solver.h.

◆ tot_literals

int64_t Gluco::Solver::tot_literals

Definition at line 195 of file Solver.h.

◆ totalTime4Sat

double Gluco::Solver::totalTime4Sat
protected

Definition at line 294 of file Solver.h.

◆ totalTime4Unsat

double Gluco::Solver::totalTime4Unsat
protected

Definition at line 294 of file Solver.h.

◆ trail

vec<Lit> Gluco::Solver::trail
protected

Definition at line 243 of file Solver.h.

◆ trail_lim

vec<int> Gluco::Solver::trail_lim
protected

Definition at line 245 of file Solver.h.

◆ trailQueue

bqueue<unsigned int> Gluco::Solver::trailQueue
protected

Definition at line 265 of file Solver.h.

◆ user_lits

vec<Lit> Gluco::Solver::user_lits

Definition at line 65 of file Solver.h.

◆ user_vec

vec<int> Gluco::Solver::user_vec

Definition at line 64 of file Solver.h.

◆ var_decay

double Gluco::Solver::var_decay

Definition at line 177 of file Solver.h.

◆ var_inc

double Gluco::Solver::var_inc
protected

Definition at line 232 of file Solver.h.

◆ vardata

vec<VarData> Gluco::Solver::vardata
protected

Definition at line 246 of file Solver.h.

◆ verbEveryConflicts

int Gluco::Solver::verbEveryConflicts

Definition at line 159 of file Solver.h.

◆ verbosity

int Gluco::Solver::verbosity

Definition at line 158 of file Solver.h.

◆ watches

OccLists<Lit, vec<Watcher>, WatcherDeleted> Gluco::Solver::watches
protected

Definition at line 234 of file Solver.h.

◆ watchesBin

OccLists<Lit, vec<Watcher>, WatcherDeleted> Gluco::Solver::watchesBin
protected

Definition at line 236 of file Solver.h.


The documentation for this class was generated from the following files: