31 #define SAT_USE_PROOF_LOGGING
40 #define L_ind solver2_dlevel(s)*2+2,solver2_dlevel(s)
42 #define L_lit(p) lit_sign(p)?"~":"", (lit_var(p))
46 for (i = 0; i < end - begin; i++)
55 static inline double drand(
double* seed) {
58 q = (int)(*seed / 2147483647);
59 *seed -= (double)q * 2147483647;
60 return *seed / 2147483647; }
107 assert( tag > 0 && tag < 16 );
108 if ( s->
vi[v].
tag == 0 )
113 assert( tag > 0 && tag < 16 );
114 if ( s->
vi[v].
tag == 0 )
121 s->
vi[tagged[i]].
tag = 0;
156 #define clause_foreach_var( p, var, i, start ) \
157 for ( i = start; (i < (int)(p)->size) && ((var) = lit_var((p)->lits[i])); i++ )
179 assert( (ProofId >> 2) > 0 );
205 assert( (ProofId >> 2) > 0 );
241 int parent = (i - 1) / 2;
244 heap[i] = heap[parent];
245 orderpos[heap[i]] = i;
247 parent = (i - 1) / 2;
258 if (orderpos[v] == -1){
286 while (child < size){
287 if (child+1 < size && s->
activity[heap[child]] < s->
activity[heap[child+1]])
290 if (act >= s->
activity[heap[child]])
292 heap[i] = heap[child];
293 orderpos[heap[i]] = i;
295 child = 2 * child + 1;
298 orderpos[heap[i]] = i;
310 #ifdef USE_FLOAT_ACTIVITY2
315 for (i = 0; i < s->
size; i++)
316 activity[i] *= 1e-100;
325 act_clas[i] *= (
float)1e-20;
343 if (act_clas[c->Id] > (
float)1e20)
354 for (i = 0; i < s->
size; i++)
384 if (act_clas[Id] & 0x80000000)
397 int i, lev, minl = 0, lbd = 0;
398 for (i = 0; i < (int)c->
size; i++) {
400 if ( !(minl & (1 << (lev & 31))) ) {
401 minl |= 1 << (lev & 31);
411 int h,
size = end - begin;
412 assert(size < 1 || begin[0] >= 0);
413 assert(size < 2 || begin[1] >= 0);
501 for (c = s->
qtail-1; c >= bound; c--)
511 for (c = s->
qhead-1; c >= bound; c--)
525 for (c = s->
qtail-1; c >= NewBound; c--)
533 for (c = s->
qhead-1; c >= NewBound; c--)
559 double progress = 0.0, F = 1.0 / s->
size;
560 for (i = 0; i < s->
size; i++)
563 return progress / s->
size;
784 int x, ind = s->
qtail-1;
786 lit* lits,* vars, i, j, k;
834 for (i = j = 1; i <
veci_size(learnt); i++){
873 for (i = 0; i < s->
size; i++)
892 lits[1] = lits[max_i];
906 clause* c, * confl = NULL;
908 lit* lits, false_lit,
p, * stop, * k;
909 cla* begin,* end, *i, *j;
912 while (confl == 0 && s->
qtail - s->
qhead > 0){
920 for (i = j = begin; i < end; ){
926 if (lits[0] == false_lit){
930 assert(lits[1] == false_lit);
937 stop = lits + c->
size;
938 for (k = lits + 2; k < stop; k++){
1006 ABC_INT64_T conflictC = 0;
1044 if ( learnt_clause.
size == 1 )
1086 for (i = 0; i < s->
size; i++)
1113 #ifdef USE_FLOAT_ACTIVITY2
1116 s->var_decay = (float)(1 / 0.95 );
1117 s->cla_decay = (float)(1 / 0.999 );
1126 #ifdef SAT_USE_PROOF_LOGGING
1175 int old_cap = s->
cap;
1187 #ifdef USE_FLOAT_ACTIVITY2
1197 for (var = s->
size; var < n; var++){
1204 *((
int*)s->
vi + var) = 0;
1210 #ifdef USE_FLOAT_ACTIVITY2
1267 for (i = 0; i < s->
cap*2; i++)
1290 lit *i,*j,*iFree = NULL;
1291 int maxvar, count, temp;
1298 for ( i = begin; i < end; i++ )
1305 for (i = begin + 1; i < end; i++){
1308 for (j = i; j > begin && *(j-1) > l; j--)
1316 for (i = j = begin + 1; i < end; i++)
1328 for ( i = begin; i < end; i++ )
1340 assert( count < end-begin );
1353 if ( count+1 == end-begin )
1366 int x, k, proof_id, CidNew;
1387 for (size = 1, seq = 0; size < x+1; seq++, size = 2*size + 1);
1388 while (size-1 != x){
1389 size = (size-1) >> 1;
1393 return pow(y, (
double)seq);
1399 for ( i = 0; i < 20; i++ )
1413 int *
pPerm, * pSortValues, nCutoffValue, * pClaProofs;
1414 int i, j, k, Id, nSelected;
1417 static int Count = 0;
1441 CounterStart = nLearnedOld - (s->
nLearntMax / 20);
1445 pSortValues =
ABC_ALLOC(
int, nLearnedOld );
1449 pSortValues[Id] = (((7 -
Abc_MinInt(c->
lbd, 7)) << 28) | (act_clas[Id] >> 4));
1451 assert( pSortValues[Id] >= 0 );
1455 assert( pSortValues[pPerm[0]] <= pSortValues[pPerm[nLearnedOld-1]] );
1456 nCutoffValue = pSortValues[pPerm[nLearnedOld-nSelected]];
1470 if ( j >= nLearnedOld / 6 )
1473 if ( j < nLearnedOld / 6 )
1487 pSortValues[j] = pSortValues[
clause_id(c)];
1489 pClaProofs[j] = pClaProofs[
clause_id(c)];
1508 assert( Counter == nLearnedOld );
1518 for ( i = 0; i < s->
size; i++ )
1533 for ( i = 0; i < s->
size*2; i++ )
1539 pArray[j++] = pArray[k];
1541 pArray[j++] = pArray[k];
1555 for ( i = 0; i < s->
size; i++ )
1579 Abc_Print(1,
"reduceDB: Keeping %7d out of %7d clauses (%5.2f %%) ",
1590 static int Count = 0;
1621 pArray[j++] = pArray[k];
1656 #ifdef USE_FLOAT_ACTIVITY2
1659 s->var_decay = (float)(1 / 0.95 );
1660 s->cla_decay = (float)(1 / 0.999 );
1697 for (i = 0; i < s->
cap*2; i++)
1705 Mem += s->
cap *
sizeof(int);
1706 Mem += s->
cap *
sizeof(char);
1707 #ifdef USE_FLOAT_ACTIVITY2
1708 Mem += s->
cap *
sizeof(double);
1710 Mem += s->
cap *
sizeof(unsigned);
1712 Mem += s->
cap *
sizeof(unsigned);
1714 Mem += s->
cap *
sizeof(
lit);
1715 Mem += s->
cap *
sizeof(int);
1716 Mem += s->
cap *
sizeof(int);
1717 Mem += s->
cap *
sizeof(int);
1718 Mem += s->
cap *
sizeof(int);
1804 int claSat[2] = {0};
1806 for ( i = 0; i < s->
size*2; i++ )
1812 for ( j = 0; j < (int)c->
size; j++ )
1815 if ( j == (
int)c->
size )
1817 pArray[m++] = pArray[k];
1837 int restart_iter = 0;
1838 ABC_INT64_T nof_conflicts;
1895 for ( i = begin; i < end; i++ )
1941 Abc_Print(1,
"==================================[MINISAT]===================================\n");
1942 Abc_Print(1,
"| Conflicts | ORIGINAL | LEARNT | Progress |\n");
1943 Abc_Print(1,
"| | Clauses Literals | Limit Clauses Literals Lit/Cl | |\n");
1944 Abc_Print(1,
"==============================================================================\n");
1950 Abc_Print(1,
"| %9.0f | %7.0f %8.0f | %7.0f %7.0f %8.0f %7.1f | %6.3f %% |\n",
1967 nof_conflicts = (ABC_INT64_T)( 100 *
luby2(2, restart_iter++) );
1976 Abc_Print(1,
"==============================================================================\n");
static clause * var_unit_clause(sat_solver2 *s, int v)
ABC_INT64_T clauses_literals
static void var_set_polar(sat_solver2 *s, int v, int pol)
static double Sat_MemMemoryAll(Sat_Mem_t *p)
static void order_unassigned(sat_solver2 *s, int v)
static int solver2_lit_removable_rec(sat_solver2 *s, int v)
static void solver2_logging_order_rec(sat_solver2 *s, int x)
void * Sat_ProofCore(sat_solver2 *s)
static void Vec_SetFree(Vec_Set_t *p)
static clause * clause2_read(sat_solver2 *s, cla h)
static void solver2_record(sat_solver2 *s, veci *cls, int proof_id)
static void order_assigned(sat_solver2 *s, int v)
double sat_solver2_memory_proof(sat_solver2 *s)
#define ABC_REALLOC(type, obj, num)
int Int2_ManChainStart(Int2_Man_t *p, clause *c)
static int lit_var(lit l)
void * Proof_DeriveCore(Vec_Set_t *vProof, int hRoot)
void sat_solver2_delete(sat_solver2 *s)
static void veci_push(veci *v, int e)
static void act_clause2_rescale(sat_solver2 *s)
static void var_set_tag(sat_solver2 *s, int v, int tag)
static void Prf_ManChainResolve(Prf_Man_t *p, clause *c)
static lbool solver2_search(sat_solver2 *s, ABC_INT64_T nof_conflicts)
static void solver2_canceluntil_rollback(sat_solver2 *s, int NewBound)
static int Vec_SetHandCurrent(Vec_Set_t *p)
int sat_solver2_check_watched(sat_solver2 *s)
static void solver2_canceluntil(sat_solver2 *s, int level)
static int irand(double *seed, int size)
static void veci_delete(veci *v)
struct sat_solver2_t sat_solver2
#define ABC_ALLOC(type, num)
sat_solver2 * sat_solver2_new(void)
static veci * solver2_wlist(sat_solver2 *s, lit l)
static void var_set_unit_clause(sat_solver2 *s, int v, cla i)
#define LEARNT_MAX_START_DEFAULT
INCLUDES ///.
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
static void veci_resize(veci *v, int k)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static int Vec_SetAppend(Vec_Set_t *p, int *pArray, int nSize)
static void Sat_MemFree_(Sat_Mem_t *p)
static int clause_id(clause *c)
int var_is_assigned(sat_solver2 *s, int v)
void sat_solver2_setnvars(sat_solver2 *s, int n)
#define Sat_MemForEachLearned(p, c, i, k)
static void proof_chain_resolve(sat_solver2 *s, clause *cls, int Var)
static int var_lev_mark(sat_solver2 *s, int v)
static void Prf_ManChainStart(Prf_Man_t *p, clause *c)
static void var_set_value(sat_solver2 *s, int v, int val)
static void solver2_clear_tags(sat_solver2 *s, int start)
double sat_solver2_memory(sat_solver2 *s, int fAll)
ABC_INT64_T learnts_literals
static double Abc_MaxDouble(double a, double b)
static void clause2_set_id(sat_solver2 *s, int h, int id)
static lit lit_neg(lit l)
static void Prf_ManAddSaved(Prf_Man_t *p, int i, int iNew)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
int * Abc_MergeSortCost(int *pCosts, int nSize)
static int clause_size(clause *c)
#define clause_foreach_var(p, var, i, start)
static int Abc_MinInt(int a, int b)
static int solver2_analyze_final(sat_solver2 *s, clause *conf, int skip_first)
static int var_level(sat_solver2 *s, int v)
static void act_clause2_bump(sat_solver2 *s, clause *c)
void var_set_partA(sat_solver2 *s, int v, int partA)
static void Vec_SetShrink(Vec_Set_t *p, int h)
static void veci_new(veci *v)
void Proof_ClauseSetEnts(Vec_Set_t *p, int h, int nEnts)
int sat_solver2_simplify(sat_solver2 *s)
static int order_select(sat_solver2 *s, float random_var_freq)
static int solver2_dlevel(sat_solver2 *s)
void sat_solver2_rollback(sat_solver2 *s)
static double solver2_progress(sat_solver2 *s)
static int var_polar(sat_solver2 *s, int v)
static int clause_learnt_h(Sat_Mem_t *p, cla h)
static int solver2_assume(sat_solver2 *s, lit l)
static void act_var_bump(sat_solver2 *s, int v)
static int clause2_proofid(sat_solver2 *s, clause *c, int varA)
static int lit_reason(sat_solver2 *s, int l)
#define ABC_NAMESPACE_IMPL_END
static int solver2_enqueue(sat_solver2 *s, lit l, cla from)
static int veci_pop(veci *v)
static void Prf_ManCompact(Prf_Man_t *p, int iNew)
static int solver2_lit_removable(sat_solver2 *s, int x)
struct varinfo2_t varinfo2
static void Int2_ManStop(Int2_Man_t *p)
static int var_reason(sat_solver2 *s, int v)
static int solver2_lit_is_false(sat_solver2 *s, int Lit)
static void solver2_logging_order(sat_solver2 *s, int x)
static int solver2_analyze(sat_solver2 *s, clause *c, veci *learnt)
double luby2(double y, int x)
static void Abc_Print(int level, const char *format,...)
static int var_value(sat_solver2 *s, int v)
static void printlits(lit *begin, lit *end)
static Vec_Int_t * Prf_ManUnsatCore(Prf_Man_t *p)
static const lit lit_Undef
static void var_add_tag(sat_solver2 *s, int v, int tag)
static int var_tag(sat_solver2 *s, int v)
static void act_var_rescale(sat_solver2 *s)
#define ABC_NAMESPACE_IMPL_START
static double Prf_ManMemory(Prf_Man_t *p)
static int Prf_ManChainStop(Prf_Man_t *p)
static int clause_is_lit(cla h)
typedefABC_NAMESPACE_HEADER_START struct Vec_Set_t_ Vec_Set_t
INCLUDES ///.
static int lit_sign(lit l)
static int sat_clause_compute_lbd(sat_solver2 *s, clause *c)
static void Sat_MemRollBack(Sat_Mem_t *p)
static void Prf_ManStop(Prf_Man_t *p)
static void var_lev_set_mark(sat_solver2 *s, int v)
#define LEARNT_MAX_INCRE_DEFAULT
static void act_var_decay(sat_solver2 *s)
#define ABC_CALLOC(type, num)
static void Sat_MemAlloc_(Sat_Mem_t *p, int nPageSize)
int sat_solver2_solve(sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
int var_is_partA(sat_solver2 *s, int v)
static int Sat_MemAppend(Sat_Mem_t *p, int *pArray, int nSize, int lrn, int fPlus1)
static void var_set_level(sat_solver2 *s, int v, int lev)
static void act_clause2_decay(sat_solver2 *s)
static double drand(double *seed)
static void solver2_clear_marks(sat_solver2 *s)
static int proof_chain_stop(sat_solver2 *s)
int Int2_ManChainResolve(Int2_Man_t *p, clause *c, int iLit, int varA)
static int Sat_MemClauseUsed(Sat_Mem_t *p, cla h)
void sat_solver2_reducedb(sat_solver2 *s)
static int Sat_MemCompactLearned(Sat_Mem_t *p, int fDoMove)
int Sat_ProofReduce(Vec_Set_t *vProof, void *pRoots, int hProofPivot)
static int clause2_create_new(sat_solver2 *s, lit *begin, lit *end, int learnt, int proof_id)
static int * veci_begin(veci *v)
static double Vec_ReportMemory(Vec_Set_t *p)
static cla Sat_MemHand(Sat_Mem_t *p, int i, int k)
static int veci_size(veci *v)
#define LEARNT_MAX_RATIO_DEFAULT
static void order_update(sat_solver2 *s, int v)
clause * solver2_propagate(sat_solver2 *s)
static void proof_chain_start(sat_solver2 *s, clause *c)