Commit f6193c0d by Alan Mishchenko

Updates to variable activity in the SAT solver.

parent 45f4d6c7
...@@ -30,14 +30,10 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA ...@@ -30,14 +30,10 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
#include "satVec.h" #include "satVec.h"
#include "satClause.h" #include "satClause.h"
#include "misc/util/utilFloat.h"
#include "misc/util/utilDouble.h" #include "misc/util/utilDouble.h"
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
//#define USE_FLOAT_ACTIVITY
//#define USE_FLOAT_ACTIVITY_NEW
//================================================================================================= //=================================================================================================
// Public interface: // Public interface:
...@@ -111,7 +107,6 @@ struct sat_solver_t ...@@ -111,7 +107,6 @@ struct sat_solver_t
int hBinary; // the special binary clause int hBinary; // the special binary clause
clause * binary; clause * binary;
veci* wlists; // watcher lists veci* wlists; // watcher lists
veci act_clas; // contain clause activities
// rollback // rollback
int iVarPivot; // the pivot for variables int iVarPivot; // the pivot for variables
...@@ -119,31 +114,17 @@ struct sat_solver_t ...@@ -119,31 +114,17 @@ struct sat_solver_t
int hProofPivot; // the pivot for proof records int hProofPivot; // the pivot for proof records
// activities // activities
#ifdef USE_FLOAT_ACTIVITY int VarActType;
#ifdef USE_FLOAT_ACTIVITY_NEW int ClaActType;
xFloat_t var_inc; // Amount to bump next variable with. word var_inc; // Amount to bump next variable with.
xFloat_t var_inc2; // Amount to bump next variable with. word var_inc2; // Amount to bump next variable with.
xFloat_t var_decay; // INVERSE decay factor for variable activity: stores 1/decay. word var_decay; // INVERSE decay factor for variable activity: stores 1/decay.
xFloat_t cla_inc; // Amount to bump next clause with. word* activity; // A heuristic measurement of the activity of a variable.
xFloat_t cla_decay; // INVERSE decay factor for clause activity: stores 1/decay. word* activity2; // backup variable activity
xFloat_t* activity; // A heuristic measurement of the activity of a variable. unsigned cla_inc; // Amount to bump next clause with.
xFloat_t* activity2; // backup variable activity unsigned cla_decay; // INVERSE decay factor for clause activity: stores 1/decay.
#else veci act_clas; // contain clause activities
double var_inc; // Amount to bump next variable with.
double var_inc2; // Amount to bump next variable with.
double var_decay; // INVERSE decay factor for variable activity: stores 1/decay.
float cla_inc; // Amount to bump next clause with.
float cla_decay; // INVERSE decay factor for clause activity: stores 1/decay.
double* activity; // A heuristic measurement of the activity of a variable.
double* activity2; // A heuristic measurement of the activity of a variable.
#endif
#else
int var_inc; // Amount to bump next variable with.
int var_inc2; // Amount to bump next variable with.
int cla_inc; // Amount to bump next clause with.
unsigned* activity; // A heuristic measurement of the activity of a variable.
unsigned* activity2; // backup variable activity
#endif
char * pFreqs; // how many times this variable was assigned a value char * pFreqs; // how many times this variable was assigned a value
int nVarUsed; int nVarUsed;
...@@ -233,21 +214,25 @@ static int sat_solver_var_literal( sat_solver* s, int v ) ...@@ -233,21 +214,25 @@ static int sat_solver_var_literal( sat_solver* s, int v )
static void sat_solver_act_var_clear(sat_solver* s) static void sat_solver_act_var_clear(sat_solver* s)
{ {
int i; int i;
#ifdef USE_FLOAT_ACTIVITY if ( s->VarActType == 0 )
#ifdef USE_FLOAT_ACTIVITY_NEW {
for (i = 0; i < s->size; i++) for (i = 0; i < s->size; i++)
s->activity[i] = xSat_FloatCreateConst1(); s->activity[i] = (1 << 10);
s->var_inc = xSat_FloatCreateConst1(); s->var_inc = (1 << 5);
#else }
for (i = 0; i < s->size; i++) else if ( s->VarActType == 1 )
s->activity[i] = 0; {
s->var_inc = 1; for (i = 0; i < s->size; i++)
#endif s->activity[i] = 0;
#else s->var_inc = 1;
for (i = 0; i < s->size; i++) }
s->activity[i] = 0; else if ( s->VarActType == 2 )
s->var_inc = (1 << 5); {
#endif for (i = 0; i < s->size; i++)
s->activity[i] = Xdbl_Const1();
s->var_inc = Xdbl_Const1();
}
else assert(0);
} }
static void sat_solver_compress(sat_solver* s) static void sat_solver_compress(sat_solver* s)
{ {
...@@ -313,18 +298,8 @@ static inline void sat_solver_bookmark(sat_solver* s) ...@@ -313,18 +298,8 @@ static inline void sat_solver_bookmark(sat_solver* s)
Sat_MemBookMark( &s->Mem ); Sat_MemBookMark( &s->Mem );
if ( s->activity2 ) if ( s->activity2 )
{ {
#ifdef USE_FLOAT_ACTIVITY
#ifdef USE_FLOAT_ACTIVITY_NEW
s->var_inc2 = s->var_inc; s->var_inc2 = s->var_inc;
memcpy( s->activity2, s->activity, sizeof(xFloat_t) * s->iVarPivot ); memcpy( s->activity2, s->activity, sizeof(word) * s->iVarPivot );
#else
s->var_inc2 = s->var_inc;
memcpy( s->activity2, s->activity, sizeof(double) * s->iVarPivot );
#endif
#else
s->var_inc2 = s->var_inc;
memcpy( s->activity2, s->activity, sizeof(unsigned) * s->iVarPivot );
#endif
} }
} }
static inline void sat_solver_set_pivot_variables( sat_solver* s, int * pPivots, int nPivots ) static inline void sat_solver_set_pivot_variables( sat_solver* s, int * pPivots, int nPivots )
......
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