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

#include <Solver.h>

Inheritance diagram for Gluco2::Solver:
Collaboration diagram for Gluco2::Solver:

Classes

struct  JustKey
 
struct  JustOrderLt2
 
struct  NodeData
 
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)
 
void sat_solver_set_jftr (int)
 
int sat_solver_jftr ()
 
void sat_solver_reset ()
 
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, bool use_oheap=true)
 
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
 
int level (Var x) 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 ()
 
void markTill (Var v0, int nlim)
 
void markApprox (Var v0, Var v1, int nlim)
 
void prelocate (int var_num)
 
void setVarFaninLits (Var v, Lit lit1, Lit lit2)
 
void setVarFaninLits (int v, int lit1, int lit2)
 
void setNewRound ()
 
void markCone (Var v)
 
void setJust (int njftr)
 
bool isRoundWatch (Var v) const
 
void justReset ()
 
double varActivity (int v) const
 
int varPolarity (int v)
 
int justUsage () const
 
int solveLimited (int *, int nlits)
 

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
 
vec< LitJustModel
 

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
 
double progressEstimate () const
 
bool withinBudget () const
 
bool isSelector (Var v)
 
void uncheckedEnqueue2 (Lit p, CRef from=CRef_Undef)
 
void addJwatch (Var host, Var member, int index)
 
void inplace_sort (Var v)
 
bool isTwoFanin (Var v) const
 
bool isAND (Var v) const
 
bool isJReason (Var v) const
 
Lit getFaninLit0 (Var v) const
 
Lit getFaninLit1 (Var v) const
 
bool getFaninC0 (Var v) const
 
bool getFaninC1 (Var v) const
 
Var getFaninVar0 (Var v) const
 
Var getFaninVar1 (Var v) const
 
Lit getFaninPlt0 (Var v) const
 
Lit getFaninPlt1 (Var v) const
 
Lit maxActiveLit (Lit lit0, Lit lit1) const
 
Lit gateJustFanin (Var v) const
 
void gateAddJwatch (Var v, int index)
 
CRef gatePropagateCheck (Var v, Var t)
 
CRef gatePropagateCheckThis (Var v)
 
CRef gatePropagateCheckFanout (Var v, Lit lfo)
 
void setItpcSize (int sz)
 
void updateJustActivity (Var v)
 
void ResetJustData (bool fCleanMemory)
 
Lit pickJustLit (int &index)
 
void justCheck ()
 
void pushJustQueue (Var v, int index)
 
void restoreJustQueue (int level)
 
void gateClearJwatch (Var v, int backtrack_level)
 
CRef gatePropagate (Lit p)
 
CRef interpret (Var v, Var t)
 
CRef castCRef (Lit p)
 
CRef getConfClause (CRef r)
 
CRef Var2CRef (Var v) const
 
Var CRef2Var (CRef cr) const
 
bool isGateCRef (CRef cr) const
 
void loadJust_rec (Var v)
 
void loadJust ()
 

Static Protected Member Functions

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

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
 
bool heap_rescale
 
vec< NodeDatavar2NodeData
 
vec< unsigned > var2TravId
 
vec< Litvar2Fanout0
 
vec< Litvar2FanoutN
 
CRef itpc
 
unsigned travId_prev
 
unsigned travId
 
int jhead
 
Heap2< JustOrderLt2, JustKeyjheap
 
vec< int > jlevel
 
vec< int > jnext
 
int nSkipMark
 
vec< VarvMarked
 

Detailed Description

Definition at line 49 of file Solver.h.

Constructor & Destructor Documentation

◆ Solver()

Solver::Solver ( )

Definition at line 91 of file Glucose2.cpp.

91 :
92
93 // Parameters (user settable):
94 //
95 SolverType(0)
96 , pCnfFunc(NULL)
97 , nCallConfl(1000)
99 , pstop(NULL)
100 , nRuntimeLimit(0)
101
102 , verbosity (0)
103 , verbEveryConflicts(10000)
104 , showModel (0)
105 , K (opt_K)
106 , R (opt_R)
107 , sizeLBDQueue (opt_size_lbd_queue)
108 , sizeTrailQueue (opt_size_trail_queue)
109 , firstReduceDB (opt_first_reduce_db)
110 , incReduceDB (opt_inc_reduce_db)
111 , specialIncReduceDB (opt_spec_inc_reduce_db)
112 , lbLBDFrozenClause (opt_lb_lbd_frozen_clause)
113 , lbSizeMinimizingClause (opt_lb_size_minimzing_clause)
114 , lbLBDMinimizingClause (opt_lb_lbd_minimzing_clause)
115 , var_decay (opt_var_decay)
116 , clause_decay (opt_clause_decay)
117 , random_var_freq (opt_random_var_freq)
118 , random_seed (opt_random_seed)
119 , ccmin_mode (opt_ccmin_mode)
120 , phase_saving (opt_phase_saving)
121 , rnd_pol (false)
122 , rnd_init_act (opt_rnd_init_act)
123 , garbage_frac (opt_garbage_frac)
124 , certifiedOutput (NULL)
126 // Statistics: (formerly in 'SolverStats')
127 //
131 , curRestart(1)
132
133 , ok (true)
134 , cla_inc (1)
135 , var_inc (1)
138 , qhead (0)
139 , simpDB_assigns (-1)
140 , simpDB_props (0)
143 , remove_satisfied (true)
144
145 // Resource constraints:
146 //
147 , conflict_budget (-1)
148 , propagation_budget (-1)
149 , asynch_interrupt (false)
150 , incremental(opt_incremental)
152
153 #ifdef CGLUCOSE_EXP
154 //, jheap (JustOrderLt(this))
155 , jheap (JustOrderLt2(this))
156 #endif
157{
158 MYFLAG=0;
159
160 // Initialize only first time. Useful for incremental solving, useless otherwise
161 lbdQueue.initSize(sizeLBDQueue);
162 trailQueue.initSize(sizeTrailQueue);
163 sumLBD = 0;
167
168
169 if(certifiedUNSAT) {
170 if(!strcmp(opt_certified_file_,"NULL")) {
171 certifiedOutput = fopen("/dev/stdout", "wb");
172 } else {
173 certifiedOutput = fopen(opt_certified_file_, "wb");
174 }
175 // fprintf(certifiedOutput,"o proof DRUP\n");
176 }
177
178 #ifdef CGLUCOSE_EXP
179 jhead= 0;
180 jftr = 0;
181 travId = 0;
182 travId_prev = 0;
183
184 // allocate space for clause interpretation
185 vec<Lit> tmp; tmp.growTo(3);
186 itpc = ca.alloc(tmp);
187 ca[itpc].shrink( ca[itpc].size() );
188
189 nSkipMark = 0;
190 #endif
191}
#define INT32_MAX
Definition pstdint.h:415
vec< double > activity
Definition Solver.h:237
OccLists< Lit, vec< Watcher >, WatcherDeleted > watchesBin
Definition Solver.h:242
int incReduceDB
Definition Solver.h:175
unsigned int MYFLAG
Definition Solver.h:283
int64_t decisions
Definition Solver.h:200
uint64_t nRuntimeLimit
Definition Solver.h:65
int64_t learnts_literals
Definition Solver.h:201
int64_t clauses_literals
Definition Solver.h:201
double var_inc
Definition Solver.h:238
double clause_decay
Definition Solver.h:184
int nbVarsInitialFormula
Definition Solver.h:299
long curRestart
Definition Solver.h:204
int nbclausesbeforereduce
Definition Solver.h:269
int64_t simpDB_props
Definition Solver.h:255
int64_t nbstopsrestarts
Definition Solver.h:200
unsigned int lbLBDFrozenClause
Definition Solver.h:177
double progress_estimate
Definition Solver.h:258
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
Definition Solver.h:240
ClauseAllocator ca
Definition Solver.h:267
unsigned travId_prev
Definition Solver.h:425
int64_t conflicts
Definition Solver.h:200
bool asynch_interrupt
Definition Solver.h:294
int64_t dec_vars
Definition Solver.h:201
int64_t nbUn
Definition Solver.h:200
int64_t lastblockatrestart
Definition Solver.h:200
int verbEveryConflicts
Definition Solver.h:165
int64_t conflictsRestarts
Definition Solver.h:200
int specialIncReduceDB
Definition Solver.h:176
float sumLBD
Definition Solver.h:272
bool rnd_init_act
Definition Solver.h:190
double totalTime4Unsat
Definition Solver.h:300
bool certifiedUNSAT
Definition Solver.h:195
int firstReduceDB
Definition Solver.h:174
FILE * certifiedOutput
Definition Solver.h:194
int64_t starts
Definition Solver.h:200
unsigned travId
Definition Solver.h:425
Heap2< JustOrderLt2, JustKey > jheap
Definition Solver.h:453
int64_t tot_literals
Definition Solver.h:201
bqueue< unsigned int > trailQueue
Definition Solver.h:271
int64_t max_literals
Definition Solver.h:201
int phase_saving
Definition Solver.h:188
double random_seed
Definition Solver.h:186
bool remove_satisfied
Definition Solver.h:259
int simpDB_assigns
Definition Solver.h:254
double sizeLBDQueue
Definition Solver.h:170
int SolverType
Definition Solver.h:52
Heap< VarOrderLt > order_heap
Definition Solver.h:257
int64_t nbReduceDB
Definition Solver.h:200
int64_t nbDL2
Definition Solver.h:200
double cla_inc
Definition Solver.h:236
int incremental
Definition Solver.h:298
bqueue< unsigned int > lbdQueue
Definition Solver.h:271
bool terminate_search_early
Definition Solver.h:63
int64_t solves
Definition Solver.h:200
double var_decay
Definition Solver.h:183
int * pstop
Definition Solver.h:64
int(* pCnfFunc)(void *p, int, int *)
Definition Solver.h:61
int64_t conflict_budget
Definition Solver.h:292
int64_t nbstopsrestartssame
Definition Solver.h:200
int64_t propagation_budget
Definition Solver.h:293
int64_t nbReducedClauses
Definition Solver.h:200
double sizeTrailQueue
Definition Solver.h:171
unsigned int lbLBDMinimizingClause
Definition Solver.h:181
int nbUnsatCalls
Definition Solver.h:301
int64_t propagations
Definition Solver.h:200
int nCallConfl
Definition Solver.h:62
int64_t nbBin
Definition Solver.h:200
int64_t rnd_decisions
Definition Solver.h:200
int lbSizeMinimizingClause
Definition Solver.h:180
double totalTime4Sat
Definition Solver.h:300
int64_t nbRemovedClauses
Definition Solver.h:200
double random_var_freq
Definition Solver.h:185
double garbage_frac
Definition Solver.h:191
void growTo(int size)
Definition Vec.h:126
StringOption opt_certified_file_(_certified, "certified-output", "Certified UNSAT output file", "NULL")
BoolOption opt_certified_(_certified, "certified", "Certified UNSAT using DRUP format", false)
unsigned long long size
Definition giaNewBdd.h:39
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Solver()

Solver::~Solver ( )
virtual

Definition at line 194 of file Glucose2.cpp.

195{
196}

Member Function Documentation

◆ abstractLevel()

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

Definition at line 561 of file Solver.h.

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

◆ addClause() [1/4]

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

Definition at line 532 of file Solver.h.

532{ ps.copyTo(add_tmp); return addClause_(add_tmp); }
bool addClause_(vec< Lit > &ps)
Definition Glucose2.cpp:268
vec< Lit > add_tmp
Definition Solver.h:282
Here is the call graph for this function:

◆ addClause() [2/4]

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

Definition at line 534 of file Solver.h.

534{ 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 Gluco2::Solver::addClause ( Lit p,
Lit q )
inline

Definition at line 535 of file Solver.h.

535{ 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 Gluco2::Solver::addClause ( Lit p,
Lit q,
Lit r )
inline

Definition at line 536 of file Solver.h.

536{ 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 268 of file Glucose2.cpp.

269{
270 assert(decisionLevel() == 0);
271 if (!ok) return false;
272
273 if ( 0 ) {
274 for ( int i = 0; i < ps.size(); i++ )
275 printf( "%s%d ", (toInt(ps[i]) & 1) ? "-":"", toInt(ps[i]) >> 1 );
276 printf( "\n" );
277 }
278
279 // Check if clause is satisfied and remove false/duplicate literals:
280 sort(ps);
281
282 vec<Lit> oc;
283 oc.clear();
284
285 Lit p; int i, j, flag = 0;
286 if(certifiedUNSAT) {
287 for (i = j = 0, p = lit_Undef; i < ps.size(); i++) {
288 oc.push(ps[i]);
289 if (value(ps[i]) == l_True || ps[i] == ~p || value(ps[i]) == l_False)
290 flag = 1;
291 }
292 }
293
294 for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
295 if (value(ps[i]) == l_True || ps[i] == ~p)
296 return true;
297 else if (value(ps[i]) != l_False && ps[i] != p)
298 ps[j++] = p = ps[i];
299 ps.shrink_(i - j);
300
301 if ( 0 ) {
302 for ( int i = 0; i < ps.size(); i++ )
303 printf( "%s%d ", (toInt(ps[i]) & 1) ? "-":"", toInt(ps[i]) >> 1 );
304 printf( "\n" );
305 }
306
307 if (flag && (certifiedUNSAT)) {
308 for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
309 fprintf(certifiedOutput, "%i ", (var(ps[i]) + 1) * (-2 * sign(ps[i]) + 1));
310 fprintf(certifiedOutput, "0\n");
311
312 fprintf(certifiedOutput, "d ");
313 for (i = j = 0, p = lit_Undef; i < oc.size(); i++)
314 fprintf(certifiedOutput, "%i ", (var(oc[i]) + 1) * (-2 * sign(oc[i]) + 1));
315 fprintf(certifiedOutput, "0\n");
316 }
317
318 if (ps.size() == 0)
319 return ok = false;
320 else if (ps.size() == 1){
321 uncheckedEnqueue(ps[0]);
322 return ok = (propagate() == CRef_Undef);
323 }else{
324 CRef cr = ca.alloc(ps, false);
325 clauses.push(cr);
326 attachClause(cr);
327 }
328
329 return true;
330}
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
ABC_NAMESPACE_IMPL_START typedef signed char value
vec< CRef > clauses
Definition Solver.h:243
int decisionLevel() const
Definition Solver.h:560
void attachClause(CRef cr)
Definition Glucose2.cpp:333
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition Glucose2.cpp:925
void shrink_(int nelems)
Definition Vec.h:67
void push(void)
Definition Vec.h:77
void clear(bool dealloc=false)
Definition Vec.h:141
int size(void) const
Definition Vec.h:65
bool sign(Lit p)
Definition SolverTypes.h:72
int var(Lit p)
Definition SolverTypes.h:73
const CRef CRef_Undef
void sort(T *array, int size, LessThan lt)
Definition Sort.h:58
const Lit lit_Undef
Definition SolverTypes.h:83
RegionAllocator< uint32_t >::Ref CRef
int toInt(Var v)
Definition SolverTypes.h:76
#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 Gluco2::Solver::addEmptyClause ( )
inline

Definition at line 533 of file Solver.h.

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

◆ addJwatch()

void Gluco2::Solver::addJwatch ( Var host,
Var member,
int index )
inlineprotected

Definition at line 159 of file CGlucoseCore.h.

159 {
160 assert(level(host) >= level(member));
161 jnext[index] = jlevel[level(host)];
162 jlevel[level(host)] = index;
163}
vec< int > jlevel
Definition Solver.h:454
vec< int > jnext
Definition Solver.h:455
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addVar()

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

Definition at line 607 of file Solver.h.

607{ while (v >= nVars()) newVar(); }
int nVars() const
Definition Solver.h:569
Var newVar(bool polarity=true, bool dvar=true)
Definition Glucose2.cpp:223
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 604 of file Glucose2.cpp.

605{
606 //double clk = Abc_Clock();
607 heap_rescale = 0;
608
609 int pathC = 0;
610 Lit p = lit_Undef;
611
612 // Generate conflict clause:
613 //
614 out_learnt.push(); // (leave room for the asserting literal)
615 int index = trail.size() - 1;
616
617 analyze_toclear.shrink_( analyze_toclear.size() );
618 do{
619 assert(confl != CRef_Undef); // (otherwise should be UIP)
620
621 #ifdef CGLUCOSE_EXP
622 Clause& c = ca[ lit_Undef != p ? castCRef(p): getConfClause(confl) ];
623 #else
624 Clause& c = ca[confl];
625 #endif
626
627 // Special case for binary clauses
628 // The first one has to be SAT
629 if( p != lit_Undef && c.size()==2 && value(c[0])==l_False) {
630
631 assert(value(c[1])==l_True);
632 Lit tmp = c[0];
633 c[0] = c[1], c[1] = tmp;
634 }
635
636 if (c.learnt())
638
639#ifdef DYNAMICNBLEVEL
640 // DYNAMIC NBLEVEL trick (see competition'09 companion paper)
641 if(c.learnt() && c.lbd()>2) {
642 unsigned int nblevels = computeLBD(c);
643 if(nblevels+1<c.lbd() ) { // improve the LBD
644 if(c.lbd()<=lbLBDFrozenClause) {
645 c.setCanBeDel(false);
646 }
647 // seems to be interesting : keep it for the next round
648 c.setLBD(nblevels); // Update it
649 }
650 }
651#endif
652
653
654 for (int j = (p == lit_Undef) ? 0 : 1; j < c.size(); j++){
655 Lit q = c[j];
656 bool fBump = 0;
657
658 if (!seen[var(q)] && level(var(q)) > 0){
659 if(!isSelector(var(q))){
660 fBump = 1;
662 }
663 seen[var(q)] = 1;
664 if (level(var(q)) >= decisionLevel()) {
665 if( fBump )
666 analyze_toclear.push(q);
667 pathC++;
668 #ifdef UPDATEVARACTIVITY
669 // UPDATEVARACTIVITY trick (see competition'09 companion paper)
670 #ifdef CGLUCOSE_EXP
671 if(!isSelector(var(q)) && (reason(var(q))!= CRef_Undef)
672 && ! isGateCRef(reason(var(q))) && ca[reason(var(q))].learnt())
673 lastDecisionLevel.push(q);
674 #else
675 if(!isSelector(var(q)) && (reason(var(q))!= CRef_Undef) && ca[reason(var(q))].learnt())
676 lastDecisionLevel.push(q);
677 #endif
678 #endif
679
680 } else {
681 if(isSelector(var(q))) {
682 assert(value(q) == l_False);
683 selectors.push(q);
684 } else
685 out_learnt.push(q);
686 }
687 }
688 }
689
690 // Select next clause to look at:
691 while (!seen[var(trail[index--])]);
692 p = trail[index+1];
693 confl = reason(var(p));
694 seen[var(p)] = 0;
695 pathC--;
696
697 }while (pathC > 0);
698 out_learnt[0] = ~p;
699
700 // Simplify conflict clause:
701 //
702 int i, j;
703
704 for(i = 0;i<selectors.size();i++) out_learnt.push(selectors[i]);
705
706
707 #ifdef CGLUCOSE_EXP
708 for(i = 0;i<out_learnt.size();i++)
709 analyze_toclear.push(out_learnt[i]);
710 #else
711 out_learnt.copyTo_(analyze_toclear);
712 #endif
713 if (ccmin_mode == 2){
714 uint32_t abstract_level = 0;
715 for (i = 1; i < out_learnt.size(); i++)
716 abstract_level |= abstractLevel(var(out_learnt[i])); // (maintain an abstraction of levels involved in conflict)
717
718 for (i = j = 1; i < out_learnt.size(); i++)
719 if (reason(var(out_learnt[i])) == CRef_Undef || !litRedundant(out_learnt[i], abstract_level))
720 out_learnt[j++] = out_learnt[i];
721
722 }else if (ccmin_mode == 1){
723 for (i = j = 1; i < out_learnt.size(); i++){
724 Var x = var(out_learnt[i]);
725
726 if (reason(x) == CRef_Undef)
727 out_learnt[j++] = out_learnt[i];
728 else{
729 #ifdef CGLUCOSE_EXP
730 Clause& c = ca[castCRef(out_learnt[i])];
731 #else
732 Clause& c = ca[reason(var(out_learnt[i]))];
733 #endif
734 // Thanks to Siert Wieringa for this bug fix!
735 for (int k = ((c.size()==2) ? 0:1); k < c.size(); k++)
736 if (!seen[var(c[k])] && level(var(c[k])) > 0){
737 out_learnt[j++] = out_learnt[i];
738 break; }
739 }
740 }
741 }else
742 i = j = out_learnt.size();
743
744 max_literals += out_learnt.size();
745 out_learnt.shrink_(i - j);
746 tot_literals += out_learnt.size();
747
748
749 /* ***************************************
750 Minimisation with binary clauses of the asserting clause
751 First of all : we look for small clauses
752 Then, we reduce clauses with small LBD.
753 Otherwise, this can be useless
754 */
755 if(!incremental && out_learnt.size()<=lbSizeMinimizingClause) {
757 }
758 // Find correct backtrack level:
759 //
760 if (out_learnt.size() == 1)
761 out_btlevel = 0;
762 else{
763 int max_i = 1;
764 // Find the first literal assigned at the next-highest level:
765 for (int i = 2; i < out_learnt.size(); i++)
766 if (level(var(out_learnt[i])) > level(var(out_learnt[max_i])))
767 max_i = i;
768 // Swap-in this literal at index 1:
769 Lit p = out_learnt[max_i];
770 out_learnt[max_i] = out_learnt[1];
771 out_learnt[1] = p;
772 out_btlevel = level(var(p));
773 }
774
775
776 // Compute the size of the clause without selectors (incremental mode)
777 if(incremental) {
778 szWithoutSelectors = 0;
779 for(int i=0;i<out_learnt.size();i++) {
780 if(!isSelector(var((out_learnt[i])))) szWithoutSelectors++;
781 else if(i>0) break;
782 }
783 } else
784 szWithoutSelectors = out_learnt.size();
785
786 // Compute LBD
787 lbd = computeLBD(out_learnt,out_learnt.size()-selectors.size());
788
789
790#ifdef UPDATEVARACTIVITY
791 // UPDATEVARACTIVITY trick (see competition'09 companion paper)
792 if(lastDecisionLevel.size()>0) {
793 for(int i = 0;i<lastDecisionLevel.size();i++) {
794 Lit t = lastDecisionLevel[i];
795 //assert( ca[reason(var(t))].learnt() );
796 if(ca[reason(var(t))].lbd()<lbd)
798 }
799 lastDecisionLevel.shrink_( lastDecisionLevel.size() );
800 }
801#endif
802
803
804 if( justUsage() ){
805 if( heap_rescale )
806 {
807 for (j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0;
808
809 analyze_toclear.shrink_( analyze_toclear.size() );
810 for (j = 0; j < jheap.size(); j++){
811 Var x = jheap[j];
812 if( var2NodeData[x].now )
813 analyze_toclear.push(mkLit(x));
814 }
815 for (j = 0; j < analyze_toclear.size(); j++){
816 Var x = var(analyze_toclear[j]);
817// jdata[x].act_fanin = activity[getFaninVar0(x)] > activity[getFaninVar1(x)]? activity[getFaninVar0(x)]: activity[getFaninVar1(x)];
818// jheap.update(x);
820 jheap.update( JustKey( activity[getFaninVar1(x)], x, jheap.data_attr(x) ) );
821 else
822 jheap.update( JustKey( activity[getFaninVar0(x)], x, jheap.data_attr(x) ) );
823 }
824
825 } else {
826
827 for (j = 0; j < analyze_toclear.size(); j++)
828 {
829 seen[var(analyze_toclear[j])] = 0;
831 }
832 }
833 } else
834 for (j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0; // ('seen[]' is now cleared)
835 for(j = 0 ; j<selectors.size() ; j++) seen[var(selectors[j])] = 0;
836}
unsigned int uint32_t
Definition Fxch.h:32
unsigned learnt
void setCanBeDel(bool b)
void setLBD(int i)
bool isGateCRef(CRef cr) const
Definition Solver.h:423
vec< Lit > trail
Definition Solver.h:249
uint32_t abstractLevel(Var x) const
Definition Solver.h:561
unsigned int computeLBD(const vec< Lit > &lits, int end=-1)
Definition Glucose2.cpp:411
bool litRedundant(Lit p, uint32_t abstract_levels)
Definition Glucose2.cpp:841
Var getFaninVar1(Var v) const
Definition Solver.h:394
int justUsage() const
CRef getConfClause(CRef r)
vec< Lit > analyze_toclear
Definition Solver.h:281
void minimisationWithBinaryResolution(vec< Lit > &out_learnt)
Definition Glucose2.cpp:473
Var getFaninVar0(Var v) const
Definition Solver.h:393
void varBumpActivity(Var v, double inc)
Definition Solver.h:504
CRef castCRef(Lit p)
CRef reason(Var x) const
Definition Solver.h:491
vec< char > seen
Definition Solver.h:279
void claBumpActivity(Clause &c)
Definition Solver.h:518
bool isSelector(Var v)
Definition Solver.h:352
vec< NodeData > var2NodeData
Definition Solver.h:379
void updateJustActivity(Var v)
lbool value(Var x) const
Definition Solver.h:562
bool heap_rescale
Definition Solver.h:372
void copyTo_(vec< T > &copy) const
Definition Vec.h:95
Lit mkLit(Var var, bool sign=false)
Definition SolverTypes.h:69
int Var
Definition SolverTypes.h:54
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 888 of file Glucose2.cpp.

889{
890 out_conflict.shrink_( out_conflict.size() );
891 out_conflict.push(p);
892
893 if (decisionLevel() == 0)
894 return;
895
896 seen[var(p)] = 1;
897
898 for (int i = trail.size()-1; i >= trail_lim[0]; i--){
899 Var x = var(trail[i]);
900 if (seen[x]){
901 if (reason(x) == CRef_Undef){
902 assert(level(x) > 0);
903 out_conflict.push(~trail[i]);
904 }else{
905 #ifdef CGLUCOSE_EXP
906 Clause& c = ca[castCRef(trail[i])];
907 #else
908 Clause& c = ca[reason(x)];
909 #endif
910 // for (int j = 1; j < c.size(); j++) Minisat (glucose 2.0) loop
911 // Bug in case of assumptions due to special data structures for Binary.
912 // Many thanks to Sam Bayless (sbayless@cs.ubc.ca) for discover this bug.
913 for (int j = ((c.size()==2) ? 0:1); j < c.size(); j++)
914 if (level(var(c[j])) > 0)
915 seen[var(c[j])] = 1;
916 }
917
918 seen[x] = 0;
919 }
920 }
921
922 seen[var(p)] = 0;
923}
vec< int > trail_lim
Definition Solver.h:251
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 333 of file Glucose2.cpp.

333 {
334 const Clause& c = ca[cr];
335
336 assert(c.size() > 1);
337 if(c.size()==2) {
338 watchesBin[~c[0]].push(Watcher(cr, c[1]));
339 watchesBin[~c[1]].push(Watcher(cr, c[0]));
340 } else {
341 watches[~c[0]].push(Watcher(cr, c[1]));
342 watches[~c[1]].push(Watcher(cr, c[0]));
343 }
344 if (c.learnt()) learnts_literals += c.size();
345 else clauses_literals += c.size(); }
Here is the caller graph for this function:

◆ budgetOff()

void Gluco2::Solver::budgetOff ( )
inline

Definition at line 585 of file Solver.h.

Here is the caller graph for this function:

◆ cancelUntil()

void Solver::cancelUntil ( int level)
protected

Definition at line 515 of file Glucose2.cpp.

515 {
516 if (decisionLevel() > level){
517
518 #ifdef CGLUCOSE_EXP
519 if( 0 < justUsage() ){
520
521 for (int c = trail.size()-1; c >= trail_lim[level]; c--){
522 Var x = var(trail[c]);
523 assigns [x] = l_Undef;
524 if (phase_saving > 1 || ((phase_saving == 1) && c > trail_lim.last()))
525 polarity[x] = sign(trail[c]);
526 //gateClearJwatch(x, level);
527
528 var2NodeData[x].now = false;
529 }
530 for (int l = decisionLevel(); l > level; l -- ){
531 int q = jlevel[l], k;
532 jlevel[l] = -1;
533 while( -1 != q ){
534 k = jnext[q];
535 jnext[q] = -1;
536 Var v = var(trail[q]);
537 if( Solver::level(v) <= level ){
538 pushJustQueue(v,q);
539 }
540 q = k;
541 }
542 }
543 } else
544 #endif
545 for (int c = trail.size()-1; c >= trail_lim[level]; c--){
546 Var x = var(trail[c]);
547 assigns [x] = l_Undef;
548 if (phase_saving > 1 || ((phase_saving == 1) && c > trail_lim.last()))
549 polarity[x] = sign(trail[c]);
551 }
552
554
555 trail.shrink_(trail.size() - trail_lim[level]);
556 trail_lim.shrink_(trail_lim.size() - level);
557 }
558}
#define l_Undef
Definition bmcBmcS.c:34
void insertVarOrder(Var x)
Definition Solver.h:494
vec< char > polarity
Definition Solver.h:247
vec< lbool > assigns
Definition Solver.h:246
void pushJustQueue(Var v, int index)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ castCRef()

CRef Gluco2::Solver::castCRef ( Lit p)
inlineprotected

Definition at line 541 of file CGlucoseCore.h.

541 {
542 CRef cr = reason( var(p) );
543 if( CRef_Undef == cr )
544 return cr;
545 if( ! isGateCRef(cr) )
546 return cr;
547 Var v = CRef2Var(cr);
548 return interpret(v,var(p));
549}
CRef interpret(Var v, Var t)
Var CRef2Var(CRef cr) const
Definition Solver.h:422
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkGarbage() [1/2]

void Gluco2::Solver::checkGarbage ( void )
inline

Definition at line 525 of file Solver.h.

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

◆ checkGarbage() [2/2]

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

Definition at line 526 of file Solver.h.

526 {
527 if (ca.wasted() > ca.size() * gf)
virtual void garbageCollect()
Here is the call graph for this function:

◆ claBumpActivity()

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

Definition at line 518 of file Solver.h.

518 {
519 if ( (c.activity() += cla_inc) > 1e20 ) {
520 // Rescale:
521 for (int i = 0; i < learnts.size(); i++)
522 ca[learnts[i]].activity() *= (float)1e-20;
523 cla_inc *= 1e-20; } }
vec< CRef > learnts
Definition Solver.h:244
Here is the call graph for this function:
Here is the caller graph for this function:

◆ claDecayActivity()

void Gluco2::Solver::claDecayActivity ( )
inlineprotected

Definition at line 517 of file Solver.h.

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

◆ clearInterrupt()

void Gluco2::Solver::clearInterrupt ( )
inline

Definition at line 584 of file Solver.h.

584{ asynch_interrupt = false; }

◆ computeLBD() [1/2]

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

Definition at line 441 of file Glucose2.cpp.

441 {
442 int nblevels = 0;
443 MYFLAG++;
444
445 if(incremental) { // ----------------- INCREMENTAL MODE
446 int nbDone = 0;
447 for(int i=0;i<c.size();i++) {
448 if(nbDone>=c.sizeWithoutSelectors()) break;
449 if(isSelector(var(c[i]))) continue;
450 nbDone++;
451 int l = level(var(c[i]));
452 if (permDiff[l] != MYFLAG) {
453 permDiff[l] = MYFLAG;
454 nblevels++;
455 }
456 }
457 } else { // -------- DEFAULT MODE. NOT A LOT OF DIFFERENCES... BUT EASIER TO READ
458 for(int i=0;i<c.size();i++) {
459 int l = level(var(c[i]));
460 if (permDiff[l] != MYFLAG) {
461 permDiff[l] = MYFLAG;
462 nblevels++;
463 }
464 }
465 }
466 return nblevels;
467}
unsigned int sizeWithoutSelectors() const
vec< unsigned int > permDiff
Definition Solver.h:260
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 411 of file Glucose2.cpp.

411 {
412 int nblevels = 0;
413 MYFLAG++;
414
415 if(incremental) { // ----------------- INCREMENTAL MODE
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;
420 if(isSelector(var(lits[i]))) continue;
421 nbDone++;
422 int l = level(var(lits[i]));
423 if (permDiff[l] != MYFLAG) {
424 permDiff[l] = MYFLAG;
425 nblevels++;
426 }
427 }
428 } else { // -------- DEFAULT MODE. NOT A LOT OF DIFFERENCES... BUT EASIER TO READ
429 for(int i=0;i<lits.size();i++) {
430 int l = level(var(lits[i]));
431 if (permDiff[l] != MYFLAG) {
432 permDiff[l] = MYFLAG;
433 nblevels++;
434 }
435 }
436 }
437
438 return nblevels;
439}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CRef2Var()

Var Gluco2::Solver::CRef2Var ( CRef cr) const
inlineprotected

Definition at line 422 of file Solver.h.

422{ return cr & ~(1<<(sizeof(CRef)*8-1)); }
Here is the caller graph for this function:

◆ decisionLevel()

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

Definition at line 560 of file Solver.h.

560{ 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 350 of file Glucose2.cpp.

350 {
351 const Clause& c = ca[cr];
352
353 assert(c.size() > 1);
354 if(c.size()==2) {
355 if (strict){
356 remove(watchesBin[~c[0]], Watcher(cr, c[1]));
357 remove(watchesBin[~c[1]], Watcher(cr, c[0]));
358 }else{
359 // Lazy detaching: (NOTE! Must clean all watcher lists before garbage collecting this clause)
360 watchesBin.smudge(~c[0]);
361 watchesBin.smudge(~c[1]);
362 }
363 } else {
364 if (strict){
365 remove(watches[~c[0]], Watcher(cr, c[1]));
366 remove(watches[~c[1]], Watcher(cr, c[0]));
367 }else{
368 // Lazy detaching: (NOTE! Must clean all watcher lists before garbage collecting this clause)
369 watches.smudge(~c[0]);
370 watches.smudge(~c[1]);
371 }
372 }
373 if (c.learnt()) learnts_literals -= c.size();
374 else clauses_literals -= c.size(); }
Here is the caller graph for this function:

◆ drand()

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

Definition at line 358 of file Solver.h.

358 {
359 seed *= 1389796;
360 int q = (int)(seed / 2147483647);
361 seed -= (double)q * 2147483647;
362 return seed / 2147483647; }
Here is the caller graph for this function:

◆ enqueue()

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

Definition at line 531 of file Solver.h.

531{ 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 Gluco2::SimpSolver.

Definition at line 1648 of file Glucose2.cpp.

1649{
1650 // Initialize the next region to a size corresponding to the estimated utilization degree. This
1651 // is not precise but should avoid some unnecessary reallocations for the new region:
1652 ClauseAllocator to(ca.size() - ca.wasted());
1653
1654 relocAll(to);
1655 if (verbosity >= 2)
1656 printf("| Garbage collection: %12d bytes => %12d bytes |\n",
1658 to.moveTo(ca);
1659}
void relocAll(ClauseAllocator &to)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gateAddJwatch()

void Gluco2::Solver::gateAddJwatch ( Var v,
int index )
inlineprotected

Definition at line 118 of file CGlucoseCore.h.

118 {
119 assert(v < nVars());
120 assert(isJReason(v));
121
122 lbool val0, val1;
123 Var var0, var1;
124 var0 = getFaninVar0(v);
125 var1 = getFaninVar1(v);
126 val0 = value(getFaninLit0(v));
127 val1 = value(getFaninLit1(v));
128
129 assert( !isAND(v) || l_False == val0 || l_False == val1 );
130 assert( isAND(v) || (l_Undef != val0 && l_Undef != val1) );
131
132 if( (val0 == l_False && val1 == l_False) || !isAND(v) ){
133 addJwatch(vardata[var0].level < vardata[var1].level? var0: var1, v, index);
134 return;
135 }
136
137 addJwatch(l_False == val0? var0: var1, v, index);
138
139 return;
140}
void addJwatch(Var host, Var member, int index)
vec< VarData > vardata
Definition Solver.h:252
bool isJReason(Var v) const
Definition Solver.h:388
bool isAND(Var v) const
Definition Solver.h:387
Lit getFaninLit1(Var v) const
Definition Solver.h:390
Lit getFaninLit0(Var v) const
Definition Solver.h:389
signed char lbool
Definition satVec.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gateClearJwatch()

void Gluco2::Solver::gateClearJwatch ( Var v,
int backtrack_level )
protected

◆ gateJustFanin()

Lit Gluco2::Solver::gateJustFanin ( Var v) const
inlineprotected

Definition at line 18 of file CGlucoseCore.h.

18 {
19 assert(v < nVars());
20 assert(isJReason(v));
21
22
23 lbool val0, val1;
24 val0 = value(getFaninLit0(v));
25 val1 = value(getFaninLit1(v));
26
27 if(isAND(v)){
28 // should be handled by conflict analysis before entering here
29 assert( value(v) != l_False || l_True != val0 || l_True != val1 );
30
31 if(val0 == l_False || val1 == l_False)
32 return lit_Undef;
33
34 // branch
35 if(val0 == l_True)
36 return ~getFaninLit1(v);
37 if(val1 == l_True)
38 return ~getFaninLit0(v);
39
40 //assert( jdata[v].act_fanin == activity[getFaninVar0(v)] || jdata[v].act_fanin == activity[getFaninVar1(v)] );
41 //assert( jdata[v].act_fanin == (jdata[v].adir? activity[getFaninVar1(v)]: activity[getFaninVar0(v)]) );
42 return maxActiveLit( ~getFaninLit0(v), ~getFaninLit1(v) );
43 //return jdata[v].adir? ~getFaninLit1(v): ~getFaninLit0(v);
44 } else { // xor scope
45 // should be handled by conflict analysis before entering here
46 assert( value(v) == l_Undef || value(v) != l_False || val0 == val1 );
47
48 // both are assigned
49 if( l_Undef != val0 && l_Undef != val1 )
50 return lit_Undef;
51
52 // should be handled by propagation before entering here
53 assert( l_Undef == val0 && l_Undef == val1 );
54 return maxActiveLit( getFaninPlt0(v), getFaninPlt1(v) );
55 }
56}
Lit maxActiveLit(Lit lit0, Lit lit1) const
Definition Solver.h:397
Lit getFaninPlt0(Var v) const
Definition Solver.h:395
Lit getFaninPlt1(Var v) const
Definition Solver.h:396
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gatePropagate()

CRef Gluco2::Solver::gatePropagate ( Lit p)
inlineprotected

Definition at line 279 of file CGlucoseCore.h.

279 {
280 CRef confl = CRef_Undef, stats;
281 if( justUsage() < 2 )
282 return CRef_Undef;
283
284 if( ! isRoundWatch(var(p)) )
285 return CRef_Undef;
286
287 if( ! isTwoFanin( var(p) ) )
288 goto check_fanout;
289
290
291 // check fanin consistency
292 if( CRef_Undef != (stats = gatePropagateCheckThis( var(p) )) ){
293 confl = stats;
294 if( l_True == value(var(p)) )
295 return confl;
296 }
297
298 // check fanout consistency
299check_fanout:
300 assert( var(p) < var2Fanout0.size() );
301
302 if( ! var2NodeData[var(p)].sort )
304
305 int nFanout = 0;
306 for( Lit lfo = var2Fanout0[ var(p) ]; nFanout < var2NodeData[var(p)].sort; lfo = var2FanoutN[ toInt(lfo) ], nFanout ++ )
307 {
308 if( CRef_Undef != (stats = gatePropagateCheckFanout( var(p), lfo )) ){
309 confl = stats;
310 if( l_True == value(var(lfo)) )
311 return confl;
312 }
313 }
314
315 return confl;
316}
CRef gatePropagateCheckFanout(Var v, Lit lfo)
void inplace_sort(Var v)
vec< Lit > var2FanoutN
Definition Solver.h:382
CRef gatePropagateCheckThis(Var v)
vec< Lit > var2Fanout0
Definition Solver.h:382
bool isTwoFanin(Var v) const
bool isRoundWatch(Var v) const
Definition Solver.h:473
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gatePropagateCheck()

CRef Gluco2::Solver::gatePropagateCheck ( Var v,
Var t )
protected

◆ gatePropagateCheckFanout()

CRef Gluco2::Solver::gatePropagateCheckFanout ( Var v,
Lit lfo )
inlineprotected

Definition at line 318 of file CGlucoseCore.h.

318 {
319 Lit faninLit = sign(lfo)? getFaninLit1(var(lfo)): getFaninLit0(var(lfo));
320 assert( var(faninLit) == v );
321 if( isAND(var(lfo)) ){
322 if( l_False == value(faninLit) )
323 {
324 if( l_False == value(var(lfo)) )
325 return CRef_Undef;
326
327 if( l_True == value(var(lfo)) )
328 return Var2CRef(var(lfo));
329
330 var2NodeData[var(lfo)].dir = sign(lfo);
331 uncheckedEnqueue2(~mkLit(var(lfo)), Var2CRef( var(lfo) ) );
332 } else {
333 assert( l_True == value(faninLit) );
334
335 if( l_True == value(var(lfo)) )
336 return CRef_Undef;
337
338 // check value of the other fanin
339 Lit faninLitP = sign(lfo)? getFaninLit0(var(lfo)): getFaninLit1(var(lfo));
340 if( l_False == value(var(lfo)) ){
341
342 if( l_False == value(faninLitP) )
343 return CRef_Undef;
344
345 if( l_True == value(faninLitP) )
346 return Var2CRef(var(lfo));
347
348 uncheckedEnqueue2( ~faninLitP, Var2CRef( var(lfo) ) );
349 }
350 else
351 if( l_True == value(faninLitP) )
352 uncheckedEnqueue2( mkLit(var(lfo)), Var2CRef( var(lfo) ) );
353 }
354 } else { // xor scope
355 // check value of the other fanin
356 Lit faninLitP = sign(lfo)? getFaninLit0(var(lfo)): getFaninLit1(var(lfo));
357
358 lbool val0, val1, valo;
359 val0 = value(faninLit );
360 val1 = value(faninLitP);
361 valo = value(var(lfo));
362
363 if( l_Undef == val1 && l_Undef == valo )
364 return CRef_Undef;
365 else
366 if( l_Undef == val1 )
367 uncheckedEnqueue2( ~faninLitP ^ ( (l_True == val0) ^ (l_True == valo) ), Var2CRef( var(lfo) ) );
368 else
369 if( l_Undef == valo )
370 uncheckedEnqueue2( ~mkLit( var(lfo), (l_True == val0) ^ (l_True == val1) ), Var2CRef( var(lfo) ) );
371 else
372 if( l_False == (valo ^ (val0 == val1)) )
373 return Var2CRef(var(lfo));
374
375 }
376
377 return CRef_Undef;
378}
CRef Var2CRef(Var v) const
Definition Solver.h:421
void uncheckedEnqueue2(Lit p, CRef from=CRef_Undef)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gatePropagateCheckThis()

CRef Gluco2::Solver::gatePropagateCheckThis ( Var v)
inlineprotected

Definition at line 380 of file CGlucoseCore.h.

380 {
381 CRef confl = CRef_Undef;
382 if( isAND(v) ){
383 if( l_False == value(v) ){
384 if( l_True == value(getFaninLit0(v)) && l_True == value(getFaninLit1(v)) )
385 return Var2CRef(v);
386
387 if( l_False == value(getFaninLit0(v)) || l_False == value(getFaninLit1(v)) )
388 return CRef_Undef;
389
390 if( l_True == value(getFaninLit0(v)) )
392 if( l_True == value(getFaninLit1(v)) )
394 } else {
395 assert( l_True == value(v) );
396 if( l_False == value(getFaninLit0(v)) || l_False == value(getFaninLit1(v)) )
397 confl = Var2CRef(v);
398
399 if( l_Undef == value( getFaninLit0( v )) )
401
402 if( l_Undef == value( getFaninLit1( v )) )
404
405 }
406 } else { // xor scope
407 lbool val0, val1, valo;
408 val0 = value(getFaninLit0(v));
409 val1 = value(getFaninLit1(v));
410 valo = value(v);
411 if( l_Undef == val0 && l_Undef == val1 )
412 return CRef_Undef;
413 if( l_Undef == val0 )
414 uncheckedEnqueue2(~getFaninLit0( v ) ^ ( (l_True == val1) ^ (l_True == valo) ), Var2CRef( v ) );
415 else
416 if( l_Undef == val1 )
417 uncheckedEnqueue2(~getFaninLit1( v ) ^ ( (l_True == val0) ^ (l_True == valo) ), Var2CRef( v ) );
418 else
419 if( l_False == (valo ^ (val0 == val1)) )
420 return Var2CRef(v);
421 }
422
423 return confl;
424}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCex()

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

Definition at line 571 of file Solver.h.

571{ return (int*) &JustModel[0]; }
vec< Lit > JustModel
Definition Solver.h:481

◆ getConfClause()

CRef Gluco2::Solver::getConfClause ( CRef r)
inlineprotected

Definition at line 426 of file CGlucoseCore.h.

426 {
427 if( !isGateCRef(r) )
428 return r;
429 Var v = CRef2Var(r);
430 assert( isTwoFanin(v) );
431
432 if(isAND(v)){
433 if( l_False == value(v) ){
434 setItpcSize(3);
435 Clause& c = ca[itpc];
436 c[0] = mkLit(v);
437 c[1] = ~getFaninLit0( v );
438 c[2] = ~getFaninLit1( v );
439 } else {
440 setItpcSize(2);
441 Clause& c = ca[itpc];
442 c[0] = ~mkLit(v);
443
444 lbool val0 = value(getFaninLit0(v));
445 lbool val1 = value(getFaninLit1(v));
446
447 if( l_False == val0 && l_False == val1 )
448 c[1] = level(getFaninVar0(v)) < level(getFaninVar1(v))? getFaninLit0( v ): getFaninLit1( v );
449 else
450 if( l_False == val0 )
451 c[1] = getFaninLit0( v );
452 else
453 c[1] = getFaninLit1( v );
454 }
455 } else { // xor scope
456 setItpcSize(3);
457 Clause& c = ca[itpc];
458 c[0] = mkLit(v, l_True == value(v));
459 c[1] = mkLit(getFaninVar0(v), l_True == value(getFaninVar0(v)));
460 c[2] = mkLit(getFaninVar1(v), l_True == value(getFaninVar1(v)));
461 }
462
463
464 return itpc;
465}
void setItpcSize(int sz)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninC0()

bool Gluco2::Solver::getFaninC0 ( Var v) const
inlineprotected

Definition at line 391 of file Solver.h.

391{ return sign(getFaninLit0(v)); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninC1()

bool Gluco2::Solver::getFaninC1 ( Var v) const
inlineprotected

Definition at line 392 of file Solver.h.

392{ return sign(getFaninLit1(v)); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninLit0()

Lit Gluco2::Solver::getFaninLit0 ( Var v) const
inlineprotected

Definition at line 389 of file Solver.h.

389{ return var2NodeData[ v ].lit0; }
Here is the caller graph for this function:

◆ getFaninLit1()

Lit Gluco2::Solver::getFaninLit1 ( Var v) const
inlineprotected

Definition at line 390 of file Solver.h.

390{ return var2NodeData[ v ].lit1; }
Here is the caller graph for this function:

◆ getFaninPlt0()

Lit Gluco2::Solver::getFaninPlt0 ( Var v) const
inlineprotected

Definition at line 395 of file Solver.h.

395{ return mkLit(getFaninVar0(v), 1 == polarity[getFaninVar0(v)]); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninPlt1()

Lit Gluco2::Solver::getFaninPlt1 ( Var v) const
inlineprotected

Definition at line 396 of file Solver.h.

396{ return mkLit(getFaninVar1(v), 1 == polarity[getFaninVar1(v)]); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninVar0()

Var Gluco2::Solver::getFaninVar0 ( Var v) const
inlineprotected

Definition at line 393 of file Solver.h.

393{ return var(getFaninLit0(v)); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaninVar1()

Var Gluco2::Solver::getFaninVar1 ( Var v) const
inlineprotected

Definition at line 394 of file Solver.h.

394{ return var(getFaninLit1(v)); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initNbInitialVars()

void Solver::initNbInitialVars ( int nb)

Definition at line 211 of file Glucose2.cpp.

211 {
213}

◆ inplace_sort()

void Gluco2::Solver::inplace_sort ( Var v)
inlineprotected

Definition at line 565 of file CGlucoseCore.h.

565 {
566 Lit w, next, prev;
567 prev= var2Fanout0[v];
568
569 if( toLit(~0) == prev ) return;
570
571 if( isRoundWatch(var(prev)) )
572 var2NodeData[v].sort ++ ;
573
574 if( toLit(~0) == (w = var2FanoutN[toInt(prev)]) )
575 return;
576
577 while( toLit(~0) != w ){
578 next = var2FanoutN[toInt(w)];
579 if( isRoundWatch(var(w)) )
580 var2NodeData[v].sort ++ ;
581 if( isRoundWatch(var(w)) && !isRoundWatch(var(prev)) ){
583 var2Fanout0[v] = w;
584 var2FanoutN[toInt(prev)] = next;
585 } else
586 prev = w;
587 w = next;
588 }
589}
Lit toLit(int i)
Definition SolverTypes.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertVarOrder()

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

Definition at line 494 of file Solver.h.

494 {
495 #ifdef CGLUCOSE_EXP
496 if (!justUsage() && !order_heap.inHeap(x) && decision[x]) order_heap.insert(x);
497 #else
498 if (!order_heap.inHeap(x) && decision[x]) order_heap.insert(x);
499 #endif
500}
vec< char > decision
Definition Solver.h:248
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpret()

CRef Gluco2::Solver::interpret ( Var v,
Var t )
inlineprotected

Definition at line 473 of file CGlucoseCore.h.

474{ // get gate-clause on implication graph
475 assert( isTwoFanin(v) );
476
477 lbool val0, val1, valo;
478 Var var0, var1;
479 var0 = getFaninVar0( v );
480 var1 = getFaninVar1( v );
481 val0 = value(var0);
482 val1 = value(var1);
483 valo = value( v );
484
485 // phased values
486 if(l_Undef != val0) val0 = val0 ^ getFaninC0( v );
487 if(l_Undef != val1) val1 = val1 ^ getFaninC1( v );
488
489
490 if( isAND(v) ){
491 if( v == t ){ // tracing output
492 if( l_False == valo ){
493 setItpcSize(2);
494 Clause& c = ca[itpc];
495 c[0] = ~mkLit(v);
496
497 c[1] = var2NodeData[v].dir ? getFaninLit1( v ): getFaninLit0( v );
498 } else {
499 setItpcSize(3);
500 Clause& c = ca[itpc];
501 c[0] = mkLit(v);
502 c[1] = ~getFaninLit0( v );
503 c[2] = ~getFaninLit1( v );
504 }
505 } else {
506 assert( t == var0 || t == var1 );
507 if( l_False == valo ){
508 setItpcSize(3);
509 Clause& c = ca[itpc];
510 c[0] = ~getFaninLit0( v );
511 c[1] = ~getFaninLit1( v );
512 c[2] = mkLit(v);
513 if( t == var1 )
514 c[1].x ^= c[0].x, c[0].x ^= c[1].x, c[1].x ^= c[0].x;
515 } else {
516 setItpcSize(2);
517 Clause& c = ca[itpc];
518 c[0] = t == var0? getFaninLit0( v ): getFaninLit1( v );
519 c[1] = ~mkLit(v);
520 }
521 }
522 } else { // xor scope
523 setItpcSize(3);
524 Clause& c = ca[itpc];
525 if( v == t ){
526 c[0] = mkLit(v, l_False == value(v));
527 c[1] = mkLit(var0, l_True == value(var0));
528 c[2] = mkLit(var1, l_True == value(var1));
529 } else {
530 if( t == var0)
531 c[0] = mkLit(var0, l_False == value(var0)), c[1] = mkLit(var1, l_True == value(var1));
532 else
533 c[1] = mkLit(var0, l_True == value(var0)), c[0] = mkLit(var1, l_False == value(var1));
534 c[2] = mkLit(v, l_True == value(v));
535 }
536 }
537
538 return itpc;
539}
bool getFaninC1(Var v) const
Definition Solver.h:392
bool getFaninC0(Var v) const
Definition Solver.h:391
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interrupt()

void Gluco2::Solver::interrupt ( )
inline

Definition at line 583 of file Solver.h.

583{ asynch_interrupt = true; }

◆ irand()

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

Definition at line 365 of file Solver.h.

365 {
366 return (int)(drand(seed) * size); }
static double drand(double &seed)
Definition Solver.h:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAND()

bool Gluco2::Solver::isAND ( Var v) const
inlineprotected

Definition at line 387 of file Solver.h.

387{ return getFaninVar0(v) < getFaninVar1(v); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isGateCRef()

bool Gluco2::Solver::isGateCRef ( CRef cr) const
inlineprotected

Definition at line 423 of file Solver.h.

423{ return CRef_Undef != cr && 0 != (cr & (1<<(sizeof(CRef)*8-1))); }
Here is the caller graph for this function:

◆ isJReason()

bool Gluco2::Solver::isJReason ( Var v) const
inlineprotected

Definition at line 388 of file Solver.h.

388{ return isTwoFanin(v) && ( l_False == value(v) || (!isAND(v) && l_Undef != value(v)) ); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRoundWatch()

bool Gluco2::Solver::isRoundWatch ( Var v) const
inline

Definition at line 473 of file Solver.h.

473{ return travId==var2TravId[v]; }
vec< unsigned > var2TravId
Definition Solver.h:381
Here is the caller graph for this function:

◆ isSelector()

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

Definition at line 352 of file Solver.h.

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

◆ isTwoFanin()

bool Gluco2::Solver::isTwoFanin ( Var v) const
inlineprotected

Definition at line 268 of file CGlucoseCore.h.

268 {
269 Lit lit0 = var2NodeData[ v ].lit0;
270 Lit lit1 = var2NodeData[ v ].lit1;
271 assert( toLit(~0) == lit0 || var(lit0) < nVars() );
272 assert( toLit(~0) == lit1 || var(lit1) < nVars() );
273 lit0.x = lit1.x = 0; // suppress the warning - alanmi
274 return toLit(~0) != var2NodeData[ v ].lit0 && toLit(~0) != var2NodeData[ v ].lit1;
275}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ justCheck()

void Gluco2::Solver::justCheck ( )
inlineprotected

Definition at line 169 of file CGlucoseCore.h.

169 {
170 Lit lit;
171 int i, nJustFail = 0;
172 for(i=0; i<trail.size(); i++){
173 Var x = var(trail[i]);
174 if( ! isRoundWatch(x) )
175 continue;
176 if( !isJReason(x) )
177 continue;
178 if( lit_Undef != (lit = gateJustFanin(x)) ){
179 printf("\t%8d is not justified (value=%d, level=%3d)\n", x, l_True == value(x)? 1: 0, vardata[x].level), nJustFail ++ ;
180
181 assert(false);
182 }
183 }
184 if( nJustFail )
185 printf("%d just-fails\n", nJustFail);
186}
Lit gateJustFanin(Var v) const
int lit
Definition satVec.h:130
Here is the call graph for this function:

◆ justReset()

void Gluco2::Solver::justReset ( )
inline

Definition at line 474 of file Solver.h.

474{ jftr = 0; reset(); }
virtual void reset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ justUsage()

int Gluco2::Solver::justUsage ( ) const
inline

Definition at line 16 of file CGlucoseCore.h.

16{ return jftr; }
Here is the caller graph for this function:

◆ level()

int Gluco2::Solver::level ( Var x) const
inline

Definition at line 492 of file Solver.h.

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

◆ litRedundant()

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

Definition at line 841 of file Glucose2.cpp.

842{
843 analyze_stack.shrink_( analyze_stack.size() ); analyze_stack.push(p);
844 int top = analyze_toclear.size();
845 while (analyze_stack.size() > 0){
847 #ifdef CGLUCOSE_EXP
848 Clause& c = ca[castCRef(analyze_stack.last())]; analyze_stack.pop();
849 #else
850 Clause& c = ca[reason(var(analyze_stack.last()))]; analyze_stack.pop();
851 #endif
852 if(c.size()==2 && value(c[0])==l_False) {
853 assert(value(c[1])==l_True);
854 Lit tmp = c[0];
855 c[0] = c[1], c[1] = tmp;
856 }
857
858 for (int i = 1; i < c.size(); i++){
859 Lit p = c[i];
860 if (!seen[var(p)] && level(var(p)) > 0){
861 if (reason(var(p)) != CRef_Undef && (abstractLevel(var(p)) & abstract_levels) != 0){
862 seen[var(p)] = 1;
863 analyze_stack.push(p);
864 analyze_toclear.push(p);
865 }else{
866 for (int j = top; j < analyze_toclear.size(); j++)
867 seen[var(analyze_toclear[j])] = 0;
868 analyze_toclear.shrink_(analyze_toclear.size() - top);
869 return false;
870 }
871 }
872 }
873 }
874
875 return true;
876}
vec< Lit > analyze_stack
Definition Solver.h:280
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadJust()

void Gluco2::Solver::loadJust ( )
inlineprotected

Definition at line 681 of file CGlucoseCore.h.

681 {
682 int i;
683 travId ++ ;
684 JustModel.shrink_(JustModel.size());
685 vMarked.shrink_(vMarked.size());
686 JustModel.push(toLit(0));
687 for(i = 0; i < assumptions.size(); i ++)
689 JustModel[0] = toLit( JustModel.size()-1 );
690 travId -- ;
691 for(i = 0; i < vMarked.size(); i ++)
692 var2TravId[ vMarked[i] ] = travId;
693}
vec< Var > vMarked
Definition Solver.h:460
void loadJust_rec(Var v)
vec< Lit > assumptions
Definition Solver.h:256
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadJust_rec()

void Gluco2::Solver::loadJust_rec ( Var v)
inlineprotected

Definition at line 666 of file CGlucoseCore.h.

666 {
667 //assert( value(v) != l_Undef );
668 if( var2TravId[v] == travId || value(v) == l_Undef )
669 return;
670 assert( var2TravId[v] == travId-1 );
671 var2TravId[v] = travId;
672 vMarked.push(v);
673
674 if( !isTwoFanin(v) ){
675 JustModel.push( mkLit( v, value(v) == l_False ) );
676 return;
677 }
680}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ locked()

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

Definition at line 537 of file Solver.h.

537 {
538 #ifdef CGLUCOSE_EXP
539
540 if(c.size()>2)
541 return value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && !isGateCRef(reason(var(c[0]))) && ca.lea(reason(var(c[0]))) == &c;
542 return
543 (value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && !isGateCRef(reason(var(c[0]))) && ca.lea(reason(var(c[0]))) == &c)
544 ||
545 (value(c[1]) == l_True && reason(var(c[1])) != CRef_Undef && !isGateCRef(reason(var(c[1]))) && ca.lea(reason(var(c[1]))) == &c);
546
547 #else
548
549 if(c.size()>2)
550 return value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c;
551 return
552 (value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c)
553 ||
554 (value(c[1]) == l_True && reason(var(c[1])) != CRef_Undef && ca.lea(reason(var(c[1]))) == &c);
555
556 #endif
557 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ markApprox()

void Gluco2::Solver::markApprox ( Var v0,
Var v1,
int nlim )
inline

Definition at line 634 of file CGlucoseCore.h.

634 {
635 int i;
636 if( travId <= 1 || nSkipMark>=4 || 0 == nlim )
637 goto finalize;
638
639 vMarked.shrink_( vMarked.size() );
640 travId ++ ; // travId = t+1
641 assert(travId>1);
642
643 markTill(v0, nlim);
644 if( vMarked.size() >= nlim )
645 goto finalize;
646
647 markTill(v1, nlim);
648 if( vMarked.size() >= nlim )
649 goto finalize;
650
651 travId -- ; // travId = t
652 for(i = 0; i < vMarked.size(); i ++){
653 var2TravId [ vMarked[i] ] = travId; // set new nodes to time t
654 var2NodeData[ vMarked[i] ].sort = 0;
655 }
656 nSkipMark ++ ;
657 return;
658finalize:
659
660 travId ++ ;
661 nSkipMark = 0;
662 markCone(v0);
663 markCone(v1);
664}
void markTill(Var v0, int nlim)
void markCone(Var v)
Here is the call graph for this function:

◆ markCone()

void Gluco2::Solver::markCone ( Var v)
inline

Definition at line 551 of file CGlucoseCore.h.

551 {
552 if( var2TravId[v] >= travId )
553 return;
554 var2TravId[v] = travId;
555 var2NodeData[v].sort = 0;
556 Var var0, var1;
557 var0 = getFaninVar0(v);
558 var1 = getFaninVar1(v);
559 if( !isTwoFanin(v) )
560 return;
561 markCone( var0 );
562 markCone( var1 );
563}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ markTill()

void Gluco2::Solver::markTill ( Var v0,
int nlim )
inline

Definition at line 617 of file CGlucoseCore.h.

617 {
618 if( var2TravId[v] == travId )
619 return;
620
621 vMarked.push(v);
622
623 if( vMarked.size() >= nlim )
624 return;
625 if( var2TravId[v] == travId-1 || !isTwoFanin(v) )
626 goto finalize;
627
628 markTill( getFaninVar0(v), nlim );
629 markTill( getFaninVar1(v), nlim );
630finalize:
631 var2TravId[v] = travId;
632}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxActiveLit()

Lit Gluco2::Solver::maxActiveLit ( Lit lit0,
Lit lit1 ) const
inlineprotected

Definition at line 397 of file Solver.h.

397{ return activity[var(lit0)] < activity[var(lit1)]? lit1: lit0; }
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 473 of file Glucose2.cpp.

473 {
474
475 // Find the LBD measure
476 unsigned int lbd = computeLBD(out_learnt);
477 Lit p = ~out_learnt[0];
478
479 if(lbd<=lbLBDMinimizingClause){
480 MYFLAG++;
481
482 for(int i = 1;i<out_learnt.size();i++) {
483 permDiff[var(out_learnt[i])] = MYFLAG;
484 }
485
486 vec<Watcher>& wbin = watchesBin[p];
487 int nb = 0;
488 for(int k = 0;k<wbin.size();k++) {
489 Lit imp = wbin[k].blocker;
490 if(permDiff[var(imp)]==MYFLAG && value(imp)==l_True) {
491 nb++;
492 permDiff[var(imp)]= MYFLAG-1;
493 }
494 }
495 int l = out_learnt.size()-1;
496 if(nb>0) {
498 for(int i = 1;i<out_learnt.size()-nb;i++) {
499 if(permDiff[var(out_learnt[i])]!=MYFLAG) {
500 Lit p = out_learnt[l];
501 out_learnt[l] = out_learnt[i];
502 out_learnt[i] = p;
503 l--;i--;
504 }
505 }
506
507 out_learnt.shrink_(nb);
508
509 }
510 }
511}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkNodeData()

static NodeData Gluco2::Solver::mkNodeData ( )
inlinestaticprotected

Definition at line 378 of file Solver.h.

378{ NodeData w; w.lit0 = toLit(~0); w.lit1 = toLit(~0); w.sort = 0; w.dir = 0; w.now = 0; return w; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkVarData()

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

Definition at line 208 of file Solver.h.

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

◆ modelValue() [1/2]

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

Definition at line 565 of file Solver.h.

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

◆ modelValue() [2/2]

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

Definition at line 564 of file Solver.h.

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

◆ nAssigns()

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

Definition at line 566 of file Solver.h.

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

◆ nClauses()

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

Definition at line 567 of file Solver.h.

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

◆ newDecisionLevel()

void Gluco2::Solver::newDecisionLevel ( )
inlineprotected

Definition at line 558 of file Solver.h.

558{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 223 of file Glucose2.cpp.

224{
225 int v = nVars();
226 watches .init(mkLit(v, false));
227 watches .init(mkLit(v, true ));
228 watchesBin .init(mkLit(v, false));
229 watchesBin .init(mkLit(v, true ));
230 assigns .push(l_Undef);
231 vardata .push(mkVarData(CRef_Undef, 0));
232 //activity .push(0);
233 activity .push(rnd_init_act ? drand(random_seed) * 0.00001 : 0);
234 seen .push(0);
235 permDiff .push(0);
236 polarity .push(sign);
237 decision .push();
238 trail .capacity(v+1);
239
240
241 #ifdef CGLUCOSE_EXP
242 //jreason .capacity(v+1);
243 if( justUsage() ){
244 //jdata .push(mkJustData(false));
245 //jwatch .push(mkJustWatch());
246
247 jlevel .push(-1);
248 jnext .push(-1);
249
250 var2FanoutN.growTo( nVars()<<1, toLit(~0));
251 //var2FanoutP.growTo( nVars()<<1, toLit(~0));
252 var2Fanout0.growTo( nVars(), toLit(~0));
253 var2NodeData.growTo( nVars(), mkNodeData());
254 var2TravId .growTo( nVars(), 0);
255
256 setDecisionVar(v, dvar, false);
257 } else
258 setDecisionVar(v, dvar);
259 #else
260 setDecisionVar(v, dvar);
261 #endif
262
263 return v;
264}
static VarData mkVarData(CRef cr, int l)
Definition Solver.h:208
void setDecisionVar(Var v, bool b, bool use_oheap=true)
Definition Solver.h:573
static NodeData mkNodeData()
Definition Solver.h:378
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nFreeVars()

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

Definition at line 570 of file Solver.h.

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

◆ nLearnts()

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

Definition at line 568 of file Solver.h.

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

◆ nVars()

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

Definition at line 569 of file Solver.h.

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

◆ okay()

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

Definition at line 600 of file Solver.h.

600{ return ok; }

◆ pickBranchLit()

Lit Solver::pickBranchLit ( )
protected

Definition at line 565 of file Glucose2.cpp.

566{
567 Var next = var_Undef;
568
569 // Random decision:
570 if (drand(random_seed) < random_var_freq && !order_heap.empty()){
571 next = order_heap[irand(random_seed,order_heap.size())];
572 if (value(next) == l_Undef && decision[next])
573 rnd_decisions++; }
574
575 // Activity based decision:
576 while (next == var_Undef || value(next) != l_Undef || !decision[next])
577 if (order_heap.empty()){
578 next = var_Undef;
579 break;
580 }else
581 next = order_heap.removeMin();
582
583 return next == var_Undef ? lit_Undef : mkLit(next, rnd_pol ? drand(random_seed) < 0.5 : (polarity[next] != 0));
584}
#define var_Undef
Definition SolverTypes.h:45
static int irand(double &seed, int size)
Definition Solver.h:365
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pickJustLit()

Lit Gluco2::Solver::pickJustLit ( int & index)
inlineprotected

Definition at line 90 of file CGlucoseCore.h.

90 {
91 Var next = var_Undef;
92 Lit jlit = lit_Undef;
93
94 for( ; jhead < trail.size() ; jhead++ ){
95 Var x = var(trail[jhead]);
96 if( !decisionLevel() && !isRoundWatch(x) ) continue;
97 if( isJReason(x) && l_Undef == value( getFaninVar0(x) ) && l_Undef == value( getFaninVar1(x) ) )
99 }
100
101 while( ! jheap.empty() ){
102 next = jheap.removeMin(index);
103 if( ! var2NodeData[next].now )
104 continue;
105
106 assert(isJReason(next));
107 if( lit_Undef != (jlit = gateJustFanin(next)) ){
108 //assert( jheap.prev.key() == activity[getFaninVar0(next)] || jheap.prev.key() == activity[getFaninVar1(next)] );
109 break;
110 }
111 gateAddJwatch(next,index);
112 }
113
114 return jlit;
115}
void gateAddJwatch(Var v, int index)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prelocate()

void Gluco2::Solver::prelocate ( int var_num)
inline

Definition at line 591 of file CGlucoseCore.h.

591 {
592 if( justUsage() ){
593 var2FanoutN .prelocate( base_var_num << 1 );
594 var2Fanout0 .prelocate( base_var_num );
595 var2NodeData.prelocate( base_var_num );
596 var2TravId .prelocate( base_var_num );
597 jheap .prelocate( base_var_num );
598 jlevel .prelocate( base_var_num );
599 jnext .prelocate( base_var_num );
600 }
601 watches .prelocate( base_var_num << 1 );
602 watchesBin .prelocate( base_var_num << 1 );
603
604 decision .prelocate( base_var_num );
605 trail .prelocate( base_var_num );
606 assigns .prelocate( base_var_num );
607 vardata .prelocate( base_var_num );
608 activity .prelocate( base_var_num );
609
610
611 seen .prelocate( base_var_num );
612 permDiff .prelocate( base_var_num );
613 polarity .prelocate( base_var_num );
614}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printClause()

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

Definition at line 632 of file Solver.h.

633{
634 Clause &c = ca[cr];
635 for (int i = 0; i < c.size(); i++){
636 printLit(c[i]);
637 printf(" ");
638 }
639}
void printLit(Lit l)
Definition Solver.h:626
Here is the call graph for this function:

◆ printIncrementalStats()

void Solver::printIncrementalStats ( )

Definition at line 1368 of file Glucose2.cpp.

1368 {
1369
1370 printf("c---------- Glucose Stats -------------------------\n");
1371 printf("c restarts : %ld\n", starts);
1372 printf("c nb ReduceDB : %ld\n", nbReduceDB);
1373 printf("c nb removed Clauses : %ld\n", nbRemovedClauses);
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);
1377
1378 printf("c conflicts : %ld\n", conflicts);
1379 printf("c decisions : %ld\n", decisions);
1380 printf("c propagations : %ld\n", propagations);
1381
1382 printf("c SAT Calls : %d in %g seconds\n", nbSatCalls, totalTime4Sat);
1383 printf("c UNSAT Calls : %d in %g seconds\n", nbUnsatCalls, totalTime4Unsat);
1384 printf("c--------------------------------------------------\n");
1385
1386
1387}

◆ printInitialClause()

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

Definition at line 641 of file Solver.h.

642{
643 Clause &c = ca[cr];
644 for (int i = 0; i < c.size(); i++){
645 if(!isSelector(var(c[i]))) {
646 printLit(c[i]);
647 printf(" ");
648 }
649 }
650}
Here is the call graph for this function:

◆ printLit()

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

Definition at line 626 of file Solver.h.

627{
628 printf("%s%d:%c", sign(l) ? "-" : "", var(l)+1, value(l) == l_True ? '1' : (value(l) == l_False ? '0' : 'X'));
629}
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 1354 of file Glucose2.cpp.

1355{
1356 double progress = 0;
1357 double F = 1.0 / nVars();
1358
1359 for (int i = 0; i <= decisionLevel(); i++){
1360 int beg = i == 0 ? 0 : trail_lim[i - 1];
1361 int end = i == decisionLevel() ? trail.size() : trail_lim[i];
1362 progress += pow(F, i) * (end - beg);
1363 }
1364
1365 return progress / nVars();
1366}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ propagate()

CRef Solver::propagate ( )
protected

Definition at line 947 of file Glucose2.cpp.

948{
949 CRef confl = CRef_Undef;
950 int num_props = 0;
951 watches.cleanAll();
952 watchesBin.cleanAll();
953 while (qhead < trail.size()){
954 Lit p = trail[qhead++]; // 'p' is enqueued fact to propagate.
955 vec<Watcher>& ws = watches[p];
956 Watcher *i, *j, *end;
957 num_props++;
958
959 #ifdef CGLUCOSE_EXP
960 if( 2 <= justUsage() ){
961 CRef stats;
962 if( CRef_Undef != (stats = gatePropagate(p)) ){
963 confl = stats;
964 if( l_True == value(var(p)) ) return confl;
965 }
966 }
967 #endif
968
969 // First, Propagate binary clauses
970 vec<Watcher>& wbin = watchesBin[p];
971 for(int k = 0;k<wbin.size();k++) {
972 Lit imp = wbin[k].blocker;
973 if(value(imp) == l_False) {
974 return wbin[k].cref;
975 }
976 if(value(imp) == l_Undef) {
977 uncheckedEnqueue(imp,wbin[k].cref);
978 }
979 }
980
981
982
983 for (i = j = (Watcher*)ws, end = i + ws.size(); i != end;){
984 // Try to avoid inspecting the clause:
985 Lit blocker = i->blocker;
986 if (value(blocker) == l_True){
987 *j++ = *i++; continue; }
988
989 // Make sure the false literal is data[1]:
990 CRef cr = i->cref;
991 Clause& c = ca[cr];
992 Lit false_lit = ~p;
993 if (c[0] == false_lit)
994 c[0] = c[1], c[1] = false_lit;
995 assert(c[1] == false_lit);
996 i++;
997
998 // If 0th watch is true, then clause is already satisfied.
999 Lit first = c[0];
1000 Watcher w = Watcher(cr, first);
1001 if (first != blocker && value(first) == l_True){
1002 *j++ = w; continue; }
1003
1004 // Look for new watch:
1005 if(incremental) { // ----------------- INCREMENTAL MODE
1006 int choosenPos = -1;
1007 for (int k = 2; k < c.size(); k++) {
1008
1009 if (value(c[k]) != l_False){
1010 if(decisionLevel()>assumptions.size()) {
1011 choosenPos = k;
1012 break;
1013 } else {
1014 choosenPos = k;
1015
1016 if(value(c[k])==l_True || !isSelector(var(c[k]))) {
1017 break;
1018 }
1019 }
1020
1021 }
1022 }
1023 if(choosenPos!=-1) {
1024 c[1] = c[choosenPos]; c[choosenPos] = false_lit;
1025 watches[~c[1]].push(w);
1026 goto NextClause; }
1027 } else { // ----------------- DEFAULT MODE (NOT INCREMENTAL)
1028 for (int k = 2; k < c.size(); k++) {
1029
1030 if (value(c[k]) != l_False){
1031 c[1] = c[k]; c[k] = false_lit;
1032 watches[~c[1]].push(w);
1033 goto NextClause; }
1034 }
1035 }
1036
1037 // Did not find watch -- clause is unit under assignment:
1038 *j++ = w;
1039 if (value(first) == l_False){
1040 confl = cr;
1041 qhead = trail.size();
1042 // Copy the remaining watches:
1043 while (i < end)
1044 *j++ = *i++;
1045 }else {
1046 uncheckedEnqueue(first, cr);
1047
1048
1049 }
1050 NextClause:;
1051 }
1052 ws.shrink_(i - j);
1053 }
1054 propagations += num_props;
1055 simpDB_props -= num_props;
1056
1057 return confl;
1058}
CRef gatePropagate(Lit p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushJustQueue()

void Gluco2::Solver::pushJustQueue ( Var v,
int index )
inlineprotected

Definition at line 60 of file CGlucoseCore.h.

60 {
61 assert(v < nVars());
62 assert(isJReason(v));
63
64 if( ! isRoundWatch(v) )\
65 return;
66
67 var2NodeData[v].now = true;
68
69
71 jheap.update( JustKey( activity[getFaninVar1(v)], v, index ) );
72 else
73 jheap.update( JustKey( activity[getFaninVar0(v)], v, index ) );
74}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reason()

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

Definition at line 491 of file Solver.h.

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

◆ rebuildOrderHeap()

void Solver::rebuildOrderHeap ( )
protected

Definition at line 1141 of file Glucose2.cpp.

1142{
1143 vec<Var> vs;
1144 for (Var v = 0; v < nVars(); v++)
1145 if (decision[v] && value(v) == l_Undef)
1146 vs.push(v);
1147 order_heap.build(vs);
1148}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduceDB()

void Solver::reduceDB ( )
protected

Definition at line 1095 of file Glucose2.cpp.

1096{
1097 int i, j;
1098 nbReduceDB++;
1099 sort(learnts, reduceDB_lt(ca));
1100
1101 // We have a lot of "good" clauses, it is difficult to compare them. Keep more !
1103 // Useless :-)
1104 if(ca[learnts.last()].lbd()<=5) nbclausesbeforereduce +=specialIncReduceDB;
1105
1106 // Don't delete binary or locked clauses. From the rest, delete clauses from the first half
1107 // Keep clauses which seem to be usefull (their lbd was reduce during this sequence)
1108
1109 int limit = learnts.size() / 2;
1110 for (i = j = 0; i < learnts.size(); i++){
1111 Clause& c = ca[learnts[i]];
1112 if (c.lbd()>2 && c.size() > 2 && c.canBeDel() && !locked(c) && (i < limit)) {
1115 }
1116 else {
1117 if(!c.canBeDel()) limit++; //we keep c, so we can delete an other clause
1118 c.setCanBeDel(true); // At the next step, c can be delete
1119 learnts[j++] = learnts[i];
1120 }
1121 }
1122 learnts.shrink_(i - j);
1123 checkGarbage();
1124}
bool locked(const Clause &c) const
Definition Solver.h:537
void removeClause(CRef cr)
Definition Glucose2.cpp:377
#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 1597 of file Glucose2.cpp.

1598{
1599 #ifdef CGLUCOSE_EXP
1600 if( CRef_Undef != itpc ){
1601 setItpcSize(3);
1602 ca.reloc(itpc, to);
1603 }
1604 #endif
1605 int v, s, i, j;
1606 // All watchers:
1607 //
1608 // for (int i = 0; i < watches.size(); i++)
1609 watches.cleanAll();
1610 watchesBin.cleanAll();
1611 for (v = 0; v < nVars(); v++)
1612 for (s = 0; s < 2; s++){
1613 Lit p = mkLit(v, s != 0);
1614 // printf(" >>> RELOCING: %s%d\n", sign(p)?"-":"", var(p)+1);
1615 vec<Watcher>& ws = watches[p];
1616 for (j = 0; j < ws.size(); j++)
1617 ca.reloc(ws[j].cref, to);
1618 vec<Watcher>& ws2 = watchesBin[p];
1619 for (j = 0; j < ws2.size(); j++)
1620 ca.reloc(ws2[j].cref, to);
1621 }
1622
1623 // All reasons:
1624 //
1625 for (i = 0; i < trail.size(); i++){
1626 Var v = var(trail[i]);
1627
1628 #ifdef CGLUCOSE_EXP
1629 if( isGateCRef(reason(v)) )
1630 continue;
1631 #endif
1632 if (reason(v) != CRef_Undef && (ca[reason(v)].reloced() || locked(ca[reason(v)])))
1633 ca.reloc(vardata[v].reason, to);
1634 }
1635
1636 // All learnt:
1637 //
1638 for (i = 0; i < learnts.size(); i++)
1639 ca.reloc(learnts[i], to);
1640
1641 // All original:
1642 //
1643 for (i = 0; i < clauses.size(); i++)
1644 ca.reloc(clauses[i], to);
1645}
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 377 of file Glucose2.cpp.

377 {
378
379 Clause& c = ca[cr];
380
381 if (certifiedUNSAT) {
382 fprintf(certifiedOutput, "d ");
383 for (int i = 0; i < c.size(); i++)
384 fprintf(certifiedOutput, "%i ", (var(c[i]) + 1) * (-2 * sign(c[i]) + 1));
385 fprintf(certifiedOutput, "0\n");
386 }
387
388 detachClause(cr);
389 // Don't leave pointers to free'd memory!
390 if (locked(c)) vardata[var(c[0])].reason = CRef_Undef;
391 c.mark(1);
392 ca.free_(cr);
393}
void detachClause(CRef cr, bool strict=false)
Definition Glucose2.cpp:350
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 1127 of file Glucose2.cpp.

1128{
1129 int i, j;
1130 for (i = j = 0; i < cs.size(); i++){
1131 Clause& c = ca[cs[i]];
1132 if (satisfied(c))
1133 removeClause(cs[i]);
1134 else
1135 cs[j++] = cs[i];
1136 }
1137 cs.shrink_(i - j);
1138}
bool satisfied(const Clause &c) const
Definition Glucose2.cpp:396
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void Solver::reset ( )
virtual

Reimplemented in Gluco2::SimpSolver.

Definition at line 1661 of file Glucose2.cpp.

1662{
1663 // Reset everything
1664 ok = true;
1665 K = (double)opt_K;
1666 R = (double)opt_R;
1667 firstReduceDB = opt_first_reduce_db;
1668 var_decay = (double)opt_var_decay;
1669 //max_var_decay = opt_max_var_decay;
1671 curRestart = 1;
1672 cla_inc = var_inc = 1;
1673 watches.clear(false); // We don't free the memory, new calls should be of the same size order.
1674 watchesBin.clear(false);
1675 //unaryWatches.clear(false);
1676 qhead = 0;
1677 simpDB_assigns = -1;
1678 simpDB_props = 0;
1679 order_heap.clear(false);
1681 //lastLearntClause = CRef_Undef;
1682 conflict_budget = -1;
1683 propagation_budget = -1;
1685 totalTime4Sat = 0.;
1686 totalTime4Unsat = 0.;
1688 MYFLAG = 0;
1689 lbdQueue.clear(false);
1690 lbdQueue.initSize(sizeLBDQueue);
1691 trailQueue.clear(false);
1692 trailQueue.initSize(sizeTrailQueue);
1693 sumLBD = 0;
1695 //stats.clear();
1696 //stats.growTo(coreStatsSize, 0);
1697 clauses.clear(false);
1698 learnts.clear(false);
1699 //permanentLearnts.clear(false);
1700 //unaryWatchedClauses.clear(false);
1701 model .shrink_(model .size());
1702 conflict.shrink_(conflict.size());
1703 activity.shrink_(activity.size());
1704 assigns .shrink_(assigns .size());
1705 polarity.shrink_(polarity.size());
1706 //forceUNSAT.clear(false);
1707 decision .shrink_(decision .size());
1708 trail .shrink_(trail .size());
1709 trail_lim .shrink_(trail_lim .size());
1710 vardata .shrink_(vardata .size());
1711 assumptions.shrink_(assumptions.size());
1712 nbpos .shrink_(nbpos .size());
1713 permDiff .shrink_(permDiff .size());
1714 #ifdef UPDATEVARACTIVITY
1715 lastDecisionLevel.shrink_(lastDecisionLevel.size());
1716 #endif
1717 ca.clear();
1718 seen .shrink_(seen.size());
1719 analyze_stack .shrink_(analyze_stack .size());
1720 analyze_toclear.shrink_(analyze_toclear.size());
1721 add_tmp.clear(false);
1722 assumptionPositions.clear(false);
1723 initialPositions.clear(false);
1724
1725 #ifdef CGLUCOSE_EXP
1726
1727 ResetJustData(false);
1728
1729 //jwatch.shrink_(jwatch.size());
1730 //jdata .shrink_(jdata .size());
1731
1732 jhead = 0;
1733 travId = 0;
1734 travId_prev = 0;
1735 var2TravId .shrink_(var2TravId.size());
1736 JustModel .shrink_(JustModel .size());
1737 jlevel .shrink_(jlevel.size());
1738 jnext .shrink_(jnext.size());
1739
1740 //var2FaninLits.shrink_(var2FaninLits.size());
1741 var2NodeData .shrink_(var2NodeData .size());
1742 var2Fanout0 .shrink_(var2Fanout0 .size());
1743 var2FanoutN .shrink_(var2FanoutN .size());
1744 //var2FanoutP.clear(false);
1745 if( CRef_Undef != itpc ){
1746 itpc = CRef_Undef; // clause allocator has been cleared, do not worry
1747 // allocate space for clause interpretation
1748 vec<Lit> tmp; tmp.growTo(3);
1749 itpc = ca.alloc(tmp);
1750 ca[itpc].shrink( ca[itpc].size() );
1751 }
1752
1753 vMarked.shrink_( vMarked.size() );
1754 nSkipMark = 0;
1755 #endif
1756}
vec< int > initialPositions
Definition Solver.h:302
vec< int > nbpos
Definition Solver.h:250
vec< int > assumptionPositions
Definition Solver.h:302
vec< Lit > conflict
Definition Solver.h:159
void ResetJustData(bool fCleanMemory)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetJustData()

void Gluco2::Solver::ResetJustData ( bool fCleanMemory)
inlineprotected

Definition at line 85 of file CGlucoseCore.h.

85 {
86 jhead = 0;
87 jheap .clear_( fCleanMemory );
88}
Here is the caller graph for this function:

◆ restoreJustQueue()

void Gluco2::Solver::restoreJustQueue ( int level)
protected
Here is the call graph for this function:

◆ sat_solver_jftr()

int Gluco2::Solver::sat_solver_jftr ( )
inline

Definition at line 613 of file Solver.h.

613{ return jftr; }

◆ sat_solver_mark_cone()

void Gluco2::Solver::sat_solver_mark_cone ( int v)
inline

Definition at line 611 of file Solver.h.

611{ markCone(v); }
Here is the call graph for this function:

◆ sat_solver_reset()

void Gluco2::Solver::sat_solver_reset ( )
inline

Definition at line 614 of file Solver.h.

614{ justReset(); }
void justReset()
Definition Solver.h:474
Here is the call graph for this function:

◆ sat_solver_set_jftr()

void Gluco2::Solver::sat_solver_set_jftr ( int njftr)
inline

Definition at line 612 of file Solver.h.

612{ setJust(njftr); }
void setJust(int njftr)
Definition Solver.h:472
Here is the call graph for this function:

◆ sat_solver_set_var_fanin_lit()

void Gluco2::Solver::sat_solver_set_var_fanin_lit ( int v,
int lit0,
int lit1 )
inline

Definition at line 609 of file Solver.h.

609{ setVarFaninLits( Var(v), toLit(lit0), toLit(lit1) ); }
void setVarFaninLits(Var v, Lit lit1, Lit lit2)
Here is the call graph for this function:

◆ sat_solver_start_new_round()

void Gluco2::Solver::sat_solver_start_new_round ( )
inline

Definition at line 610 of file Solver.h.

610{ setNewRound(); }
void setNewRound()
Definition Solver.h:470
Here is the call graph for this function:

◆ satisfied()

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

Definition at line 396 of file Glucose2.cpp.

396 {
397 if(incremental) // Check clauses with many selectors is too time consuming
398 return (value(c[0]) == l_True) || (value(c[1]) == l_True);
399
400 // Default mode.
401 for (int i = 0; i < c.size(); i++)
402 if (value(c[i]) == l_True)
403 return true;
404 return false;
405}
Here is the caller graph for this function:

◆ search()

lbool Solver::search ( int nof_conflicts)
protected

Definition at line 1201 of file Glucose2.cpp.

1202{
1203 assert(ok);
1204 int backtrack_level;
1205 int conflictC = 0;
1206 vec<Lit> learnt_clause,selectors;
1207 unsigned int nblevels,szWoutSelectors;
1208 bool blocked=false;
1209 starts++;
1210
1211 for (;;){
1212 CRef confl = propagate();
1213
1214 // exact conflict limit
1215 if ( !withinBudget() && confl != CRef_Undef ) {
1216 lbdQueue.fastclear();
1217 cancelUntil(0);
1218 return l_Undef; }
1219
1220 if (confl != CRef_Undef){
1221
1222 // CONFLICT
1223 conflicts++; conflictC++;conflictsRestarts++;
1224 if(conflicts%5000==0 && var_decay<0.95)
1225 var_decay += 0.01;
1226
1227 if (verbosity >= 1 && conflicts%verbEveryConflicts==0){
1228 printf("c | %8d %7d %5d | %7d %8d %8d | %5d %8d %6d %8d | %6.3f %% \n",
1229 (int)starts,(int)nbstopsrestarts, (int)(conflicts/starts),
1230 (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), nClauses(), (int)clauses_literals,
1231 (int)nbReduceDB, nLearnts(), (int)nbDL2,(int)nbRemovedClauses, progressEstimate()*100);
1232 }
1233 if (decisionLevel() == 0)
1234 return l_False;
1235
1236
1237 trailQueue.push(trail.size());
1238 // BLOCK RESTART (CP 2012 paper)
1239 if( conflictsRestarts>LOWER_BOUND_FOR_BLOCKING_RESTART && lbdQueue.isvalid() && trail.size()>R*trailQueue.getavg()) {
1240 lbdQueue.fastclear();
1242 if(!blocked) {lastblockatrestart=starts;nbstopsrestartssame++;blocked=true;}
1243 }
1244
1245 learnt_clause.shrink_( learnt_clause.size() );
1246 selectors .shrink_( selectors.size() );
1247 analyze(confl, learnt_clause, selectors,backtrack_level,nblevels,szWoutSelectors);
1248
1249 lbdQueue.push(nblevels);
1250 sumLBD += nblevels;
1251 cancelUntil(backtrack_level);
1252 if (certifiedUNSAT) {
1253 for (int i = 0; i < learnt_clause.size(); i++)
1254 fprintf(certifiedOutput, "%i " , (var(learnt_clause[i]) + 1) *
1255 (-2 * sign(learnt_clause[i]) + 1) );
1256 fprintf(certifiedOutput, "0\n");
1257 }
1258
1259 if (learnt_clause.size() == 1){
1260 uncheckedEnqueue(learnt_clause[0]);nbUn++;
1261 }else{
1262 CRef cr = ca.alloc(learnt_clause, true);
1263 ca[cr].setLBD(nblevels);
1264 ca[cr].setSizeWithoutSelectors(szWoutSelectors);
1265 if(nblevels<=2) nbDL2++; // stats
1266 if(ca[cr].size()==2) nbBin++; // stats
1267 learnts.push(cr);
1268 attachClause(cr);
1269
1270 claBumpActivity(ca[cr]);
1271 uncheckedEnqueue(learnt_clause[0], cr);
1272 }
1275
1276 }else{
1277 // Our dynamic restart, see the SAT09 competition compagnion paper
1278 if ( (conflictsRestarts && lbdQueue.isvalid() && lbdQueue.getavg()*K > sumLBD/conflictsRestarts) || (pstop && *pstop) ) {
1279 lbdQueue.fastclear();
1281 int bt = 0;
1282 if(incremental) { // DO NOT BACKTRACK UNTIL 0.. USELESS
1283 bt = (decisionLevel()<assumptions.size()) ? decisionLevel() : assumptions.size();
1284 }
1285 cancelUntil(bt);
1286 return l_Undef;
1287 }
1288
1289 // Simplify the set of problem clauses:
1290 if (decisionLevel() == 0 && !simplify()) {
1291 return l_False;
1292 }
1293 // Perform clause database reduction !
1295 {
1296 assert(learnts.size()>0);
1298 reduceDB();
1300 }
1301
1302 Lit next = lit_Undef;
1303 while (decisionLevel() < assumptions.size()){
1304 // Perform user provided assumption:
1305 Lit p = assumptions[decisionLevel()];
1306 if (value(p) == l_True){
1307 // Dummy decision level:
1309 } else if (value(p) == l_False){
1311 return l_False;
1312 } else {
1313 next = p;
1314 break;
1315 }
1316 }
1317
1318 #ifdef CGLUCOSE_EXP
1319 // pick from JustQueue
1320
1321 if (0 < justUsage())
1322 if ( next == lit_Undef ){
1323 int index = -1;
1324 decisions++;
1325 next = pickJustLit( index );
1326 if(next == lit_Undef)
1327 return l_True;
1328 //addJwatch(var(next), j_reason);
1329 jnext[index] = jlevel[decisionLevel()+1];
1330 jlevel[decisionLevel()+1] = index;
1331 }
1332 #endif
1333
1334 if (next == lit_Undef){
1335 // New variable decision:
1336 decisions++;
1337 next = pickBranchLit();
1338
1339 if (next == lit_Undef){
1340 // Model found:
1341 return l_True;
1342 }
1343 }
1344
1345 // Increase decision level and enqueue 'next'
1347 uncheckedEnqueue(next);
1348 }
1349 }
1350}
void varDecayActivity()
Definition Solver.h:502
Lit pickJustLit(int &index)
Lit pickBranchLit()
Definition Glucose2.cpp:565
bool withinBudget() const
Definition Solver.h:586
void claDecayActivity()
Definition Solver.h:517
void cancelUntil(int level)
Definition Glucose2.cpp:515
double progressEstimate() const
int nClauses() const
Definition Solver.h:567
void analyzeFinal(Lit p, vec< Lit > &out_conflict)
Definition Glucose2.cpp:888
void newDecisionLevel()
Definition Solver.h:558
void analyze(CRef confl, vec< Lit > &out_learnt, vec< Lit > &selectors, int &out_btlevel, unsigned int &nblevels, unsigned int &szWithoutSelectors)
Definition Glucose2.cpp:604
int nLearnts() const
Definition Solver.h:568
#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 Gluco2::Solver::setConfBudget ( int64_t x)
inline

Definition at line 581 of file Solver.h.

581{ conflict_budget = conflicts + x; }

◆ setDecisionVar()

void Gluco2::Solver::setDecisionVar ( Var v,
bool b,
bool use_oheap = true )
inline

Definition at line 573 of file Solver.h.

574{
575 if ( b && !decision[v]) dec_vars++;
576 else if (!b && decision[v]) dec_vars--;
577
578 decision[v] = b;
579 if( use_oheap ) insertVarOrder(v);
580}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setIncrementalMode()

void Solver::setIncrementalMode ( )

Definition at line 206 of file Glucose2.cpp.

206 {
207 incremental = true;
208}
Here is the caller graph for this function:

◆ setItpcSize()

void Gluco2::Solver::setItpcSize ( int sz)
inlineprotected

Definition at line 467 of file CGlucoseCore.h.

467 {
468 assert( 3 >= sz );
469 assert( CRef_Undef != itpc );
470 ca[itpc].header.size = sz;
471}
Here is the caller graph for this function:

◆ setJust()

void Gluco2::Solver::setJust ( int njftr)
inline

Definition at line 472 of file Solver.h.

472{ jftr = njftr; }
Here is the caller graph for this function:

◆ setNewRound()

void Gluco2::Solver::setNewRound ( )
inline

Definition at line 470 of file Solver.h.

470{ travId ++ ; }
Here is the caller graph for this function:

◆ setPolarity()

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

Definition at line 572 of file Solver.h.

572{ polarity[v] = b; }

◆ setPropBudget()

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

Definition at line 582 of file Solver.h.

◆ setVarFaninLits() [1/2]

void Gluco2::Solver::setVarFaninLits ( int v,
int lit1,
int lit2 )
inline

Definition at line 467 of file Solver.h.

467{ setVarFaninLits( Var(v), toLit(lit1), toLit(lit2) ); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVarFaninLits() [2/2]

void Gluco2::Solver::setVarFaninLits ( Var v,
Lit lit1,
Lit lit2 )
inline

inline void Solver::delVarFaninLits( Var v ){ if( toLit(~0) != getFaninLit0(v) ){ if( toLit(~0) == var2FanoutP[ (v<<1) + 0 ] ){ head of linked-list Lit root = mkLit(getFaninVar0(v)); Lit next = var2FanoutN[ (v<<1) + 0 ]; if( toLit(~0) != next ){ assert( var2Fanout0[ toInt(root) ] == toLit((v<<1) + 0) ); assert( var2FanoutP[ toInt(next) ] == toLit((v<<1) + 0) ); var2Fanout0[ getFaninVar0(v) ] = next; var2FanoutP[ toInt(next) ] = toLit(~0); } } else { Lit prev = var2FanoutP[ (v<<1) + 0 ]; Lit next = var2FanoutN[ (v<<1) + 0 ]; if( toLit(~0) != next ){ assert( var2FanoutN[ toInt(prev) ] == toLit((v<<1) + 0) ); assert( var2FanoutP[ toInt(next) ] == toLit((v<<1) + 0) ); var2FanoutN[ toInt(prev) ] = next; var2FanoutP[ toInt(next) ] = prev; } } }

if( toLit(~0) != getFaninLit1(v) ){
    if( toLit(~0) == var2FanoutP[ (v<<1) + 1 ] ){

head of linked-list Lit root = mkLit(getFaninVar1(v)); Lit next = var2FanoutN[ (v<<1) + 1 ]; if( toLit(~0) != next ){ assert( var2Fanout0[ toInt(root) ] == toLit((v<<1) + 1) ); assert( var2FanoutP[ toInt(next) ] == toLit((v<<1) + 1) ); var2Fanout0[ getFaninVar1(v) ] = next; var2FanoutP[ toInt(next) ] = toLit(~0); } } else { Lit prev = var2FanoutP[ (v<<1) + 1 ]; Lit next = var2FanoutN[ (v<<1) + 1 ]; if( toLit(~0) != next ){ assert( var2FanoutN[ toInt(prev) ] == toLit((v<<1) + 1) ); assert( var2FanoutP[ toInt(next) ] == toLit((v<<1) + 1) ); var2FanoutN[ toInt(prev) ] = next; var2FanoutP[ toInt(next) ] = prev; } } }

var2FanoutP [ (v<<1) + 0 ] = toLit(~0); var2FanoutP [ (v<<1) + 1 ] = toLit(~0); var2FanoutN [ (v<<1) + 0 ] = toLit(~0); var2FanoutN [ (v<<1) + 1 ] = toLit(~0); var2FaninLits[ (v<<1) + 0 ] = toLit(~0); var2FaninLits[ (v<<1) + 1 ] = toLit(~0); }

Definition at line 244 of file CGlucoseCore.h.

244 {
245 assert( var(lit1) != var(lit2) );
246 int mincap = var(lit1) < var(lit2)? var(lit2): var(lit1);
247 mincap = (v < mincap? mincap: v) + 1;
248
249 var2NodeData[ v ].lit0 = lit1;
250 var2NodeData[ v ].lit1 = lit2;
251
252
253 assert( toLit(~0) != lit1 && toLit(~0) != lit2 );
254
255 var2FanoutN[ (v<<1) + 0 ] = var2Fanout0[ var(lit1) ];
256 var2FanoutN[ (v<<1) + 1 ] = var2Fanout0[ var(lit2) ];
257 var2Fanout0[ var(lit1) ] = toLit( (v<<1) + 0 );
258 var2Fanout0[ var(lit2) ] = toLit( (v<<1) + 1 );
259
260 //if( toLit(~0) != var2FanoutN[ (v<<1) + 0 ] )
261 // var2FanoutP[ toInt(var2FanoutN[ (v<<1) + 0 ]) ] = toLit((v<<1) + 0);
262
263 //if( toLit(~0) != var2FanoutN[ (v<<1) + 1 ] )
264 // var2FanoutP[ toInt(var2FanoutN[ (v<<1) + 1 ]) ] = toLit((v<<1) + 1);
265}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simplify()

bool Solver::simplify ( )

Definition at line 1159 of file Glucose2.cpp.

1160{
1161 assert(decisionLevel() == 0);
1162
1163 if (!ok || propagate() != CRef_Undef)
1164 return ok = false;
1165
1166 if (nAssigns() == simpDB_assigns || (simpDB_props > 0))
1167 return true;
1168
1169 // Remove satisfied clauses:
1171 if (remove_satisfied) // Can be turned off.
1173
1174 checkGarbage();
1175
1176 #ifdef CGLUCOSE_EXP
1177 if( !justUsage() )
1178 #endif
1180
1182 simpDB_props = clauses_literals + learnts_literals; // (shouldn't depend on stats really, but it will do for now)
1183
1184 return true;
1185}
void rebuildOrderHeap()
void removeSatisfied(vec< CRef > &cs)
int nAssigns() const
Definition Solver.h:566
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve() [1/5]

bool Gluco2::Solver::solve ( )
inline

Definition at line 594 of file Solver.h.

594{ budgetOff(); assumptions.clear(); return solve_() == l_True; }
void budgetOff()
Definition Solver.h:585
Here is the call graph for this function:

◆ solve() [2/5]

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

Definition at line 598 of file Solver.h.

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

◆ solve() [3/5]

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

Definition at line 595 of file Solver.h.

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

◆ solve() [4/5]

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

Definition at line 596 of file Solver.h.

596{ 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 Gluco2::Solver::solve ( Lit p,
Lit q,
Lit r )
inline

Definition at line 597 of file Solver.h.

597{ 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 1391 of file Glucose2.cpp.

1392{
1393
1394 #ifdef CGLUCOSE_EXP
1395 ResetJustData(false);
1396 #endif
1397
1399 printf("Can not use incremental and certified unsat in the same time\n");
1400 exit(-1);
1401 }
1402
1403 conflict.shrink_(conflict.size());
1404 if (!ok){
1406 return l_False;
1407 }
1408 double curTime = cpuTime();
1409
1410 solves++;
1411
1412 lbool status = l_Undef;
1413 if(!incremental && verbosity>=1) {
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");
1420 printf("c | * LBD Queue : %6d | * First : %6d | * size < %3d |\n",lbdQueue.maxSize(),nbclausesbeforereduce,lbSizeMinimizingClause);
1421 printf("c | * Trail Queue : %6d | * Inc : %6d | * lbd < %3d |\n",trailQueue.maxSize(),incReduceDB,lbLBDMinimizingClause);
1422 printf("c | * K : %6.2f | * Special : %6d | |\n",K,specialIncReduceDB);
1423 printf("c | * R : %6.2f | * Protected : (lbd)< %2d | |\n",R,lbLBDFrozenClause);
1424 printf("c | | | |\n");
1425printf("c ==================================[ Search Statistics (every %6d conflicts) ]=========================\n",verbEveryConflicts);
1426 printf("c | |\n");
1427
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");
1431 }
1432
1433 // Search:
1434 int curr_restarts = 0;
1435 while (status == l_Undef){
1436 status = search(0); // the parameter is useless in glucose, kept to allow modifications
1437 if (!withinBudget() || terminate_search_early || (pstop && *pstop)) break;
1438 if (nRuntimeLimit && Abc_Clock() > nRuntimeLimit) break;
1439 curr_restarts++;
1440 }
1441
1442 if (!incremental && verbosity >= 1)
1443 printf("c =========================================================================================================\n");
1444
1445
1446 if (certifiedUNSAT){ // Want certified output
1447 if (status == l_False)
1448 fprintf(certifiedOutput, "0\n");
1449 fclose(certifiedOutput);
1450 }
1451
1452
1453 if (status == l_True){
1454
1455 if( justUsage() ){
1456 if( nSkipMark ){
1457 loadJust();
1458 } else {
1459 JustModel.shrink_(JustModel.size());
1460 assert(jheap.empty());
1461 //JustModel.growTo(nVars());
1462 int i = 0, j = 0;
1463 JustModel.push(toLit(0));
1464 for (; i < trail.size(); i++)
1465 if( isRoundWatch(var(trail[i])) && !isTwoFanin(var(trail[i])) )
1466 JustModel.push(trail[i]), j++;
1467 JustModel[0] = toLit(j);
1468 }
1469
1470 } else {
1471 // Extend & copy model:
1472 model.shrink_(model.size());
1473 model.growTo(nVars());
1474 for (int i = 0; i < trail.size(); i++) model[ var(trail[i]) ] = value(var(trail[i]));
1475 }
1476 }else if (status == l_False && conflict.size() == 0)
1477 ok = false;
1478
1479 //#ifdef CGLUCOSE_EXP
1480 //if(status == l_True && 0 < justUsage())
1481 // justCheck();
1482 //#endif
1483
1484 cancelUntil(0);
1485
1486 double finalTime = cpuTime();
1487 if(status==l_True) {
1488 nbSatCalls++;
1489 totalTime4Sat +=(finalTime-curTime);
1490 }
1491 if(status==l_False) {
1492 nbUnsatCalls++;
1493 totalTime4Unsat +=(finalTime-curTime);
1494 }
1495
1496 // ABC callback
1497 if (pCnfFunc && !terminate_search_early) {// hack to avoid calling callback twise if the solver was terminated early
1498 int * pCex = NULL;
1499 int message = (status == l_True ? 1 : status == l_False ? 0 : -1);
1500 if (status == l_True) {
1501 pCex = new int[nVars()];
1502 for (int i = 0; i < nVars(); i++)
1503 pCex[i] = (model[i] == l_True);
1504 }
1505
1506 int callback_result = pCnfFunc(pCnfMan, message, pCex);
1507 assert(callback_result == 0);
1508 }
1509 else if (pCnfFunc)
1510 terminate_search_early = false; // for next run
1511
1513 return status;
1514}
lbool search(int nof_conflicts)
void * pCnfMan
Definition Solver.h:60
VOID_HACK exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solveLimited() [1/2]

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

Definition at line 599 of file Solver.h.

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

◆ solveLimited() [2/2]

int Gluco2::Solver::solveLimited ( int * lit0,
int nlits )
inline

Definition at line 615 of file Solver.h.

615 {
616 assumptions.clear();
617 for(int i = 0; i < nlits; i ++)
618 assumptions.push(toLit(lit0[i]));
619 lbool res = solve_();
620 return res == l_True ? 1 : (res == l_False ? -1 : 0);
621}
Here is the call graph for this function:

◆ toDimacs() [1/7]

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

Definition at line 602 of file Solver.h.

602{ vec<Lit> as; toDimacs(file, as); }
void toDimacs(FILE *f, const vec< Lit > &assumps)
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 1542 of file Glucose2.cpp.

1543{
1544 FILE* f = fopen(file, "wb");
1545 if (f == NULL)
1546 fprintf(stderr, "could not open file %s\n", file), exit(1);
1547 toDimacs(f, assumps);
1548 fclose(f);
1549}
Here is the call graph for this function:

◆ toDimacs() [3/7]

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

Definition at line 603 of file Solver.h.

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

◆ toDimacs() [4/7]

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

Definition at line 604 of file Solver.h.

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

◆ toDimacs() [5/7]

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

Definition at line 605 of file Solver.h.

605{ 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 1531 of file Glucose2.cpp.

1532{
1533 if (satisfied(c)) return;
1534
1535 for (int i = 0; i < c.size(); i++)
1536 if (value(c[i]) != l_False)
1537 fprintf(f, "%s%d ", sign(c[i]) ? "-" : "", mapVar(var(c[i]), map, max)+1);
1538 fprintf(f, "0\n");
1539}
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 1552 of file Glucose2.cpp.

1553{
1554 // Handle case when solver is in contradictory state:
1555 if (!ok){
1556 fprintf(f, "p cnf 1 2\n1 0\n-1 0\n");
1557 return; }
1558
1559 vec<Var> map; Var max = 0;
1560
1561 // Cannot use removeClauses here because it is not safe
1562 // to deallocate them at this point. Could be improved.
1563 int i, cnt = 0;
1564 for (i = 0; i < clauses.size(); i++)
1565 if (!satisfied(ca[clauses[i]]))
1566 cnt++;
1567
1568 for (i = 0; i < clauses.size(); i++)
1569 if (!satisfied(ca[clauses[i]])){
1570 Clause& c = ca[clauses[i]];
1571 for (int j = 0; j < c.size(); j++)
1572 if (value(c[j]) != l_False)
1573 mapVar(var(c[j]), map, max);
1574 }
1575
1576 // Assumptions are added as unit clauses:
1577 cnt += assumptions.size();
1578
1579 fprintf(f, "p cnf %d %d\n", max, cnt);
1580
1581 for (i = 0; i < assumptions.size(); i++){
1583 fprintf(f, "%s%d 0\n", sign(assumptions[i]) ? "-" : "", mapVar(var(assumptions[i]), map, max)+1);
1584 }
1585
1586 for (i = 0; i < clauses.size(); i++)
1587 toDimacs(f, ca[clauses[i]], map, max);
1588
1589 if (verbosity > 0)
1590 printf("Wrote %d clauses with %d variables.\n", cnt, max);
1591}
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 925 of file Glucose2.cpp.

926{
927 if( justUsage() && !isRoundWatch(var(p)) )
928 return;
929 assert(value(p) == l_Undef);
930 assigns[var(p)] = lbool(!sign(p));
931 vardata[var(p)] = mkVarData(from, decisionLevel());
932 trail.push_(p);
933}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uncheckedEnqueue2()

void Gluco2::Solver::uncheckedEnqueue2 ( Lit p,
CRef from = CRef_Undef )
inlineprotected

Definition at line 76 of file CGlucoseCore.h.

77{
78 //assert( isRoundWatch(var(p)) ); // inplace sorting guarantee this
79 assert(value(p) == l_Undef);
80 assigns[var(p)] = lbool(!sign(p));
81 vardata[var(p)] = mkVarData(from, decisionLevel());
82 trail.push_(p);
83}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateJustActivity()

void Gluco2::Solver::updateJustActivity ( Var v)
inlineprotected

Definition at line 142 of file CGlucoseCore.h.

142 {
143 if( ! var2NodeData[v].sort )
144 inplace_sort(v);
145
146 int nFanout = 0;
147 for(Lit lfo = var2Fanout0[ v ]; nFanout < var2NodeData[v].sort; lfo = var2FanoutN[ toInt(lfo) ], nFanout ++ ){
148 Var x = var(lfo);
149 if( var2NodeData[x].now && jheap.inHeap(x) ){
151 jheap.update( JustKey( activity[getFaninVar1(x)], x, jheap.data_attr(x) ) );
152 else
153 jheap.update( JustKey( activity[getFaninVar0(x)], x, jheap.data_attr(x) ) );
154 }
155 }
156}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ value() [1/2]

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

Definition at line 563 of file Solver.h.

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

◆ value() [2/2]

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

Definition at line 562 of file Solver.h.

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

◆ Var2CRef()

CRef Gluco2::Solver::Var2CRef ( Var v) const
inlineprotected

Definition at line 421 of file Solver.h.

421{ return v | (1<<(sizeof(CRef)*8-1)); }
Here is the caller graph for this function:

◆ varActivity()

double Gluco2::Solver::varActivity ( int v) const
inline

Definition at line 478 of file Solver.h.

478{ return activity[v];}

◆ varBumpActivity() [1/2]

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

Definition at line 503 of file Solver.h.

Here is the call graph for this function:

◆ varBumpActivity() [2/2]

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

Definition at line 504 of file Solver.h.

504 {
505 if ( (activity[v] += inc) > 1e100 ) {
506 heap_rescale = 1;
507 // Rescale:
508 for (int i = 0; i < nVars(); i++)
509 activity[i] *= 1e-100;
510 var_inc *= 1e-100; }
511
512 // Update order_heap with respect to new activity:
513 if (!justUsage() && order_heap.inHeap(v))
514 order_heap.decrease(v);
515}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ varDecayActivity()

void Gluco2::Solver::varDecayActivity ( )
inlineprotected

Definition at line 502 of file Solver.h.

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

◆ varPolarity()

int Gluco2::Solver::varPolarity ( int v)
inline

Definition at line 480 of file Solver.h.

480{ return polarity[v]? 1: 0;}

◆ withinBudget()

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

Definition at line 586 of file Solver.h.

586 {
587 return !asynch_interrupt &&
588 (conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
Here is the caller graph for this function:

Member Data Documentation

◆ activity

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

Definition at line 237 of file Solver.h.

◆ add_tmp

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

Definition at line 282 of file Solver.h.

◆ analyze_stack

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

Definition at line 280 of file Solver.h.

◆ analyze_toclear

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

Definition at line 281 of file Solver.h.

◆ assigns

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

Definition at line 246 of file Solver.h.

◆ assumptionPositions

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

Definition at line 302 of file Solver.h.

◆ assumptions

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

Definition at line 256 of file Solver.h.

◆ asynch_interrupt

bool Gluco2::Solver::asynch_interrupt
protected

Definition at line 294 of file Solver.h.

◆ ca

ClauseAllocator Gluco2::Solver::ca
protected

Definition at line 267 of file Solver.h.

◆ ccmin_mode

int Gluco2::Solver::ccmin_mode

Definition at line 187 of file Solver.h.

◆ certifiedOutput

FILE* Gluco2::Solver::certifiedOutput

Definition at line 194 of file Solver.h.

◆ certifiedUNSAT

bool Gluco2::Solver::certifiedUNSAT

Definition at line 195 of file Solver.h.

◆ cla_inc

double Gluco2::Solver::cla_inc
protected

Definition at line 236 of file Solver.h.

◆ clause_decay

double Gluco2::Solver::clause_decay

Definition at line 184 of file Solver.h.

◆ clauses

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

Definition at line 243 of file Solver.h.

◆ clauses_literals

int64_t Gluco2::Solver::clauses_literals

Definition at line 201 of file Solver.h.

◆ conflict

vec<Lit> Gluco2::Solver::conflict

Definition at line 159 of file Solver.h.

◆ conflict_budget

int64_t Gluco2::Solver::conflict_budget
protected

Definition at line 292 of file Solver.h.

◆ conflicts

int64_t Gluco2::Solver::conflicts

Definition at line 200 of file Solver.h.

◆ conflictsRestarts

int64_t Gluco2::Solver::conflictsRestarts

Definition at line 200 of file Solver.h.

◆ curRestart

long Gluco2::Solver::curRestart
protected

Definition at line 204 of file Solver.h.

◆ dec_vars

int64_t Gluco2::Solver::dec_vars

Definition at line 201 of file Solver.h.

◆ decision

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

Definition at line 248 of file Solver.h.

◆ decisions

int64_t Gluco2::Solver::decisions

Definition at line 200 of file Solver.h.

◆ firstReduceDB

int Gluco2::Solver::firstReduceDB

Definition at line 174 of file Solver.h.

◆ garbage_frac

double Gluco2::Solver::garbage_frac

Definition at line 191 of file Solver.h.

◆ heap_rescale

bool Gluco2::Solver::heap_rescale
protected

Definition at line 372 of file Solver.h.

◆ incReduceDB

int Gluco2::Solver::incReduceDB

Definition at line 175 of file Solver.h.

◆ incremental

int Gluco2::Solver::incremental
protected

Definition at line 298 of file Solver.h.

◆ initialPositions

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

Definition at line 302 of file Solver.h.

◆ itpc

CRef Gluco2::Solver::itpc
protected

Definition at line 383 of file Solver.h.

◆ jftr

int Gluco2::Solver::jftr

Definition at line 70 of file Solver.h.

◆ jhead

int Gluco2::Solver::jhead
protected

Definition at line 428 of file Solver.h.

◆ jheap

Heap2<JustOrderLt2, JustKey> Gluco2::Solver::jheap
protected

Definition at line 453 of file Solver.h.

◆ jlevel

vec<int> Gluco2::Solver::jlevel
protected

Definition at line 454 of file Solver.h.

◆ jnext

vec<int> Gluco2::Solver::jnext
protected

Definition at line 455 of file Solver.h.

◆ JustModel

vec<Lit> Gluco2::Solver::JustModel

Definition at line 481 of file Solver.h.

◆ K

double Gluco2::Solver::K

Definition at line 168 of file Solver.h.

◆ lastblockatrestart

int64_t Gluco2::Solver::lastblockatrestart

Definition at line 200 of file Solver.h.

◆ lastIndexRed

int Gluco2::Solver::lastIndexRed
protected

Definition at line 234 of file Solver.h.

◆ lbdQueue

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

Definition at line 271 of file Solver.h.

◆ lbLBDFrozenClause

unsigned int Gluco2::Solver::lbLBDFrozenClause

Definition at line 177 of file Solver.h.

◆ lbLBDMinimizingClause

unsigned int Gluco2::Solver::lbLBDMinimizingClause

Definition at line 181 of file Solver.h.

◆ lbSizeMinimizingClause

int Gluco2::Solver::lbSizeMinimizingClause

Definition at line 180 of file Solver.h.

◆ learnts

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

Definition at line 244 of file Solver.h.

◆ learnts_literals

int64_t Gluco2::Solver::learnts_literals

Definition at line 201 of file Solver.h.

◆ learntsize_adjust_cnt

int Gluco2::Solver::learntsize_adjust_cnt
protected

Definition at line 288 of file Solver.h.

◆ learntsize_adjust_confl

double Gluco2::Solver::learntsize_adjust_confl
protected

Definition at line 287 of file Solver.h.

◆ max_learnts

double Gluco2::Solver::max_learnts
protected

Definition at line 286 of file Solver.h.

◆ max_literals

int64_t Gluco2::Solver::max_literals

Definition at line 201 of file Solver.h.

◆ model

vec<lbool> Gluco2::Solver::model

Definition at line 158 of file Solver.h.

◆ MYFLAG

unsigned int Gluco2::Solver::MYFLAG
protected

Definition at line 283 of file Solver.h.

◆ nbBin

int64_t Gluco2::Solver::nbBin

Definition at line 200 of file Solver.h.

◆ nbclausesbeforereduce

int Gluco2::Solver::nbclausesbeforereduce
protected

Definition at line 269 of file Solver.h.

◆ nbDL2

int64_t Gluco2::Solver::nbDL2

Definition at line 200 of file Solver.h.

◆ nbpos

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

Definition at line 250 of file Solver.h.

◆ nbReduceDB

int64_t Gluco2::Solver::nbReduceDB

Definition at line 200 of file Solver.h.

◆ nbReducedClauses

int64_t Gluco2::Solver::nbReducedClauses

Definition at line 200 of file Solver.h.

◆ nbRemovedClauses

int64_t Gluco2::Solver::nbRemovedClauses

Definition at line 200 of file Solver.h.

◆ nbSatCalls

int Gluco2::Solver::nbSatCalls
protected

Definition at line 301 of file Solver.h.

◆ nbstopsrestarts

int64_t Gluco2::Solver::nbstopsrestarts

Definition at line 200 of file Solver.h.

◆ nbstopsrestartssame

int64_t Gluco2::Solver::nbstopsrestartssame

Definition at line 200 of file Solver.h.

◆ nbUn

int64_t Gluco2::Solver::nbUn

Definition at line 200 of file Solver.h.

◆ nbUnsatCalls

int Gluco2::Solver::nbUnsatCalls
protected

Definition at line 301 of file Solver.h.

◆ nbVarsInitialFormula

int Gluco2::Solver::nbVarsInitialFormula
protected

Definition at line 299 of file Solver.h.

◆ nCallConfl

int Gluco2::Solver::nCallConfl

Definition at line 62 of file Solver.h.

◆ nRuntimeLimit

uint64_t Gluco2::Solver::nRuntimeLimit

Definition at line 65 of file Solver.h.

◆ nSkipMark

int Gluco2::Solver::nSkipMark
protected

Definition at line 457 of file Solver.h.

◆ ok

bool Gluco2::Solver::ok
protected

Definition at line 235 of file Solver.h.

◆ order_heap

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

Definition at line 257 of file Solver.h.

◆ pCnfFunc

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

Definition at line 61 of file Solver.h.

◆ pCnfMan

void* Gluco2::Solver::pCnfMan

Definition at line 60 of file Solver.h.

◆ permDiff

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

Definition at line 260 of file Solver.h.

◆ phase_saving

int Gluco2::Solver::phase_saving

Definition at line 188 of file Solver.h.

◆ polarity

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

Definition at line 247 of file Solver.h.

◆ progress_estimate

double Gluco2::Solver::progress_estimate
protected

Definition at line 258 of file Solver.h.

◆ propagation_budget

int64_t Gluco2::Solver::propagation_budget
protected

Definition at line 293 of file Solver.h.

◆ propagations

int64_t Gluco2::Solver::propagations

Definition at line 200 of file Solver.h.

◆ pstop

int* Gluco2::Solver::pstop

Definition at line 64 of file Solver.h.

◆ qhead

int Gluco2::Solver::qhead
protected

Definition at line 253 of file Solver.h.

◆ R

double Gluco2::Solver::R

Definition at line 169 of file Solver.h.

◆ random_seed

double Gluco2::Solver::random_seed

Definition at line 186 of file Solver.h.

◆ random_var_freq

double Gluco2::Solver::random_var_freq

Definition at line 185 of file Solver.h.

◆ remove_satisfied

bool Gluco2::Solver::remove_satisfied
protected

Definition at line 259 of file Solver.h.

◆ rnd_decisions

int64_t Gluco2::Solver::rnd_decisions

Definition at line 200 of file Solver.h.

◆ rnd_init_act

bool Gluco2::Solver::rnd_init_act

Definition at line 190 of file Solver.h.

◆ rnd_pol

bool Gluco2::Solver::rnd_pol

Definition at line 189 of file Solver.h.

◆ seen

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

Definition at line 279 of file Solver.h.

◆ showModel

int Gluco2::Solver::showModel

Definition at line 166 of file Solver.h.

◆ simpDB_assigns

int Gluco2::Solver::simpDB_assigns
protected

Definition at line 254 of file Solver.h.

◆ simpDB_props

int64_t Gluco2::Solver::simpDB_props
protected

Definition at line 255 of file Solver.h.

◆ sizeLBDQueue

double Gluco2::Solver::sizeLBDQueue

Definition at line 170 of file Solver.h.

◆ sizeTrailQueue

double Gluco2::Solver::sizeTrailQueue

Definition at line 171 of file Solver.h.

◆ SolverType

int Gluco2::Solver::SolverType

Definition at line 52 of file Solver.h.

◆ solves

int64_t Gluco2::Solver::solves

Definition at line 200 of file Solver.h.

◆ specialIncReduceDB

int Gluco2::Solver::specialIncReduceDB

Definition at line 176 of file Solver.h.

◆ starts

int64_t Gluco2::Solver::starts

Definition at line 200 of file Solver.h.

◆ sumAssumptions

int Gluco2::Solver::sumAssumptions
protected

Definition at line 273 of file Solver.h.

◆ sumLBD

float Gluco2::Solver::sumLBD
protected

Definition at line 272 of file Solver.h.

◆ terminate_search_early

bool Gluco2::Solver::terminate_search_early

Definition at line 63 of file Solver.h.

◆ tot_literals

int64_t Gluco2::Solver::tot_literals

Definition at line 201 of file Solver.h.

◆ totalTime4Sat

double Gluco2::Solver::totalTime4Sat
protected

Definition at line 300 of file Solver.h.

◆ totalTime4Unsat

double Gluco2::Solver::totalTime4Unsat
protected

Definition at line 300 of file Solver.h.

◆ trail

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

Definition at line 249 of file Solver.h.

◆ trail_lim

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

Definition at line 251 of file Solver.h.

◆ trailQueue

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

Definition at line 271 of file Solver.h.

◆ travId

unsigned Gluco2::Solver::travId
protected

Definition at line 425 of file Solver.h.

◆ travId_prev

unsigned Gluco2::Solver::travId_prev
protected

Definition at line 425 of file Solver.h.

◆ user_lits

vec<Lit> Gluco2::Solver::user_lits

Definition at line 67 of file Solver.h.

◆ user_vec

vec<int> Gluco2::Solver::user_vec

Definition at line 66 of file Solver.h.

◆ var2Fanout0

vec<Lit> Gluco2::Solver::var2Fanout0
protected

Definition at line 382 of file Solver.h.

◆ var2FanoutN

vec<Lit> Gluco2::Solver::var2FanoutN
protected

Definition at line 382 of file Solver.h.

◆ var2NodeData

vec<NodeData> Gluco2::Solver::var2NodeData
protected

Definition at line 379 of file Solver.h.

◆ var2TravId

vec<unsigned> Gluco2::Solver::var2TravId
protected

Definition at line 381 of file Solver.h.

◆ var_decay

double Gluco2::Solver::var_decay

Definition at line 183 of file Solver.h.

◆ var_inc

double Gluco2::Solver::var_inc
protected

Definition at line 238 of file Solver.h.

◆ vardata

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

Definition at line 252 of file Solver.h.

◆ verbEveryConflicts

int Gluco2::Solver::verbEveryConflicts

Definition at line 165 of file Solver.h.

◆ verbosity

int Gluco2::Solver::verbosity

Definition at line 164 of file Solver.h.

◆ vMarked

vec<Var> Gluco2::Solver::vMarked
protected

Definition at line 460 of file Solver.h.

◆ watches

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

Definition at line 240 of file Solver.h.

◆ watchesBin

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

Definition at line 242 of file Solver.h.


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