Commit fc4ab6bd by Alan Mishchenko

Started experiments with a new solver.

parent 0cfc97b9
...@@ -118,15 +118,6 @@ static inline lit clause_read_lit (clause* c) { return (lit)((ABC_PTRUINT_T) ...@@ -118,15 +118,6 @@ static inline lit clause_read_lit (clause* c) { return (lit)((ABC_PTRUINT_T)
static inline int sat_solver_dlevel(sat_solver* s) { return veci_size(&s->trail_lim); } static inline int sat_solver_dlevel(sat_solver* s) { return veci_size(&s->trail_lim); }
static inline vecp* sat_solver_read_wlist(sat_solver* s, lit l) { return &s->wlists[l]; } static inline vecp* sat_solver_read_wlist(sat_solver* s, lit l) { return &s->wlists[l]; }
static inline void vecp_remove(vecp* v, void* e)
{
void** ws = vecp_begin(v);
int j = 0;
for (; ws[j] != e ; j++);
assert(j < vecp_size(v));
for (; j < vecp_size(v)-1; j++) ws[j] = ws[j+1];
vecp_resize(v,vecp_size(v)-1);
}
//================================================================================================= //=================================================================================================
// Variable order functions: // Variable order functions:
......
...@@ -77,6 +77,9 @@ extern void * sat_solver2_store_release( sat_solver2 * s ); ...@@ -77,6 +77,9 @@ extern void * sat_solver2_store_release( sat_solver2 * s );
//struct clause_t; //struct clause_t;
//typedef struct clause_t clause; //typedef struct clause_t clause;
struct varinfo_t;
typedef struct varinfo_t varinfo;
struct sat_solver2_t struct sat_solver2_t
{ {
int size; // nof variables int size; // nof variables
...@@ -84,64 +87,51 @@ struct sat_solver2_t ...@@ -84,64 +87,51 @@ struct sat_solver2_t
int qhead; // Head index of queue. int qhead; // Head index of queue.
int qtail; // Tail index of queue. int qtail; // Tail index of queue.
int root_level; // Level of first proper decision.
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
int simpdb_props; // Number of propagations before next 'simplifyDB()'.
double random_seed;
double progress_estimate;
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
int fNotUseRandom; // do not allow random decisions with a fixed probability
// int fSkipSimplify; // set to one to skip simplification of the clause database
// clauses // clauses
vecp clauses; // List of problem constraints. (contains: clause*) int iLearnt; // the first learnt clause
vecp learnts; // List of learnt clauses. (contains: clause*) int iLast; // the last learnt clause
veci* wlists; // watcher lists (for each literal)
cla* pWatches; // watcher lists (for each literal)
// activities // clause memory
// double var_inc; // Amount to bump next variable with. int * pMemArray;
// double var_decay; // INVERSE decay factor for variable activity: stores 1/decay. int nMemAlloc;
int var_inc; int nMemSize;
// int var_decay;
// float cla_inc; // Amount to bump next clause with. // activities
int var_inc; // Amount to bump next variable with.
int cla_inc; // Amount to bump next clause with. int cla_inc; // Amount to bump next clause with.
// float cla_decay; // INVERSE decay factor for clause activity: stores 1/decay. unsigned* activity; // A heuristic measurement of the activity of a variable.
clause** pWatches; // watcher lists (for each literal) // internal state
vecp* wlists; // varinfo * vi; // variable information
// double* activity; // A heuristic measurement of the activity of a variable. cla* reasons;
unsigned*activity; // A heuristic measurement of the activity of a variable.
lbool* assigns; // Current values of variables.
int* orderpos; // Index in variable order.
clause** reasons; //
int* levels; //
lit* trail; lit* trail;
char* polarity; int* orderpos; // Index in variable order.
clause* binary; // A temporary binary clause
lbool* tags; //
veci tagged; // (contains: var) veci tagged; // (contains: var)
veci stack; // (contains: var) veci stack; // (contains: var)
veci order; // Variable order. (heap) (contains: var) veci order; // Variable order. (heap) (contains: var)
veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int) veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int)
veci temp_clause; // temporary storage for a CNF clause
veci model; // If problem is solved, this vector contains the model (contains: lbool). veci model; // If problem is solved, this vector contains the model (contains: lbool).
veci conf_final; // If problem is unsatisfiable (possibly under assumptions), veci conf_final; // If problem is unsatisfiable (possibly under assumptions),
// this vector represent the final conflict clause expressed in the assumptions. // this vector represent the final conflict clause expressed in the assumptions.
// statistics
int root_level; // Level of first proper decision.
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
int simpdb_props; // Number of propagations before next 'simplifyDB()'.
double random_seed;
double progress_estimate;
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
stats_t stats; stats_t stats;
ABC_INT64_T nConfLimit; // external limit on the number of conflicts ABC_INT64_T nConfLimit; // external limit on the number of conflicts
ABC_INT64_T nInsLimit; // external limit on the number of implications ABC_INT64_T nInsLimit; // external limit on the number of implications
int nRuntimeLimit; // external limit on runtime int nRuntimeLimit; // external limit on runtime
// clause memory
int * pMemArray;
int nMemAlloc;
int nMemSize;
// int fSkipSimplify; // set to one to skip simplification of the clause database
int fNotUseRandom; // do not allow random decisions with a fixed probability
veci temp_clause; // temporary storage for a CNF clause
}; };
static int sat_solver2_var_value( sat_solver2* s, int v ) static int sat_solver2_var_value( sat_solver2* s, int v )
......
...@@ -54,6 +54,15 @@ static inline void veci_push (veci* v, int e) ...@@ -54,6 +54,15 @@ static inline void veci_push (veci* v, int e)
v->cap = newsize; } v->cap = newsize; }
v->ptr[v->size++] = e; v->ptr[v->size++] = e;
} }
static inline void veci_remove(veci* v, int e)
{
int * ws = (int*)veci_begin(v);
int j = 0;
for (; ws[j] != e ; j++);
assert(j < veci_size(v));
for (; j < veci_size(v)-1; j++) ws[j] = ws[j+1];
veci_resize(v,veci_size(v)-1);
}
// vector of 32- or 64-bit pointers // vector of 32- or 64-bit pointers
...@@ -83,6 +92,15 @@ static inline void vecp_push (vecp* v, void* e) ...@@ -83,6 +92,15 @@ static inline void vecp_push (vecp* v, void* e)
v->cap = newsize; } v->cap = newsize; }
v->ptr[v->size++] = e; v->ptr[v->size++] = e;
} }
static inline void vecp_remove(vecp* v, void* e)
{
void** ws = vecp_begin(v);
int j = 0;
for (; ws[j] != e ; j++);
assert(j < vecp_size(v));
for (; j < vecp_size(v)-1; j++) ws[j] = ws[j+1];
vecp_resize(v,vecp_size(v)-1);
}
...@@ -99,6 +117,7 @@ static inline void vecp_push (vecp* v, void* e) ...@@ -99,6 +117,7 @@ static inline void vecp_push (vecp* v, void* e)
#endif #endif
typedef int lit; typedef int lit;
typedef int cla;
typedef char lbool; typedef char lbool;
static const int var_Undef = -1; static const int var_Undef = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment