Commit fdf00d80 by Alan Mishchenko

Tuning SAT solver for QBF instances.

parent 3b838b95
...@@ -21829,7 +21829,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21829,7 +21829,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( argc == globalUtilOptind + 1 ) if ( argc == globalUtilOptind + 1 )
{ {
int * pModel = NULL; int * pModel = NULL;
extern int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fVerbose, int ** ppModel ); extern int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fVerbose, int ** ppModel, int nPis );
// get the input file name // get the input file name
char * pFileName = argv[globalUtilOptind]; char * pFileName = argv[globalUtilOptind];
FILE * pFile = fopen( pFileName, "rb" ); FILE * pFile = fopen( pFileName, "rb" );
...@@ -21839,14 +21839,14 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21839,14 +21839,14 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
} }
fclose( pFile ); fclose( pFile );
Cnf_DataSolveFromFile( pFileName, nConfLimit, nLearnedStart, nLearnedDelta, nLearnedPerce, fVerbose, &pModel ); Cnf_DataSolveFromFile( pFileName, nConfLimit, nLearnedStart, nLearnedDelta, nLearnedPerce, fVerbose, &pModel, Abc_NtkPiNum(pNtk) );
if ( pModel && pNtk ) if ( pModel && pNtk )
{ {
int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pModel ); int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pModel );
if ( pSimInfo[0] != 1 ) if ( pSimInfo[0] != 1 )
Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" ); Abc_Print( 1, "ERROR in mapping PIs into SAT vars: Generated CEX is invalid.\n" );
ABC_FREE( pSimInfo ); ABC_FREE( pSimInfo );
pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pNtk->pModel, 0, 0, 0 ); pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pModel, 0, 0, 0 );
} }
ABC_FREE( pModel ); ABC_FREE( pModel );
return 0; return 0;
...@@ -185,13 +185,15 @@ void Sat_Solver2WriteDimacs( sat_solver2 * p, char * pFileName, lit* assumpBegin ...@@ -185,13 +185,15 @@ void Sat_Solver2WriteDimacs( sat_solver2 * p, char * pFileName, lit* assumpBegin
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline double Sat_Wrd2Dbl( word w ) { return (double)(unsigned)(w&0x3FFFFFFF) + (double)(1<<30)*(unsigned)(w>>30); }
void Sat_SolverPrintStats( FILE * pFile, sat_solver * p ) void Sat_SolverPrintStats( FILE * pFile, sat_solver * p )
{ {
// printf( "calls : %10d (%d)\n", (int)p->nCalls, (int)p->nCalls2 ); // printf( "calls : %10d (%d)\n", (int)p->nCalls, (int)p->nCalls2 );
printf( "starts : %10d\n", (int)p->stats.starts ); printf( "starts : %16.0f\n", Sat_Wrd2Dbl(p->stats.starts) );
printf( "conflicts : %10d\n", (int)p->stats.conflicts ); printf( "conflicts : %16.0f\n", Sat_Wrd2Dbl(p->stats.conflicts) );
printf( "decisions : %10d\n", (int)p->stats.decisions ); printf( "decisions : %16.0f\n", Sat_Wrd2Dbl(p->stats.decisions) );
printf( "propagations : %10d\n", (int)p->stats.propagations ); printf( "propagations : %16.0f\n", Sat_Wrd2Dbl(p->stats.propagations) );
// printf( "inspects : %10d\n", (int)p->stats.inspects ); // printf( "inspects : %10d\n", (int)p->stats.inspects );
// printf( "inspects2 : %10d\n", (int)p->stats.inspects2 ); // printf( "inspects2 : %10d\n", (int)p->stats.inspects2 );
} }
......
...@@ -399,12 +399,12 @@ finish: ...@@ -399,12 +399,12 @@ finish:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fVerbose, int ** ppModel ) int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fVerbose, int ** ppModel, int nPis )
{ {
abctime clk = Abc_Clock(); abctime clk = Abc_Clock();
Cnf_Dat_t * pCnf = Cnf_DataReadFromFile( pFileName ); Cnf_Dat_t * pCnf = Cnf_DataReadFromFile( pFileName );
sat_solver * pSat; sat_solver * pSat;
int status, RetValue = -1; int i, status, RetValue = -1;
if ( pCnf == NULL ) if ( pCnf == NULL )
return -1; return -1;
if ( fVerbose ) if ( fVerbose )
...@@ -414,10 +414,10 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, ...@@ -414,10 +414,10 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart,
} }
// convert into SAT solver // convert into SAT solver
pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 ); pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
Cnf_DataFree( pCnf );
if ( pSat == NULL ) if ( pSat == NULL )
{ {
printf( "The problem is trivially UNSAT.\n" ); printf( "The problem is trivially UNSAT.\n" );
Cnf_DataFree( pCnf );
return 1; return 1;
} }
if ( nLearnedStart ) if ( nLearnedStart )
...@@ -440,7 +440,6 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, ...@@ -440,7 +440,6 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart,
assert( 0 ); assert( 0 );
if ( fVerbose ) if ( fVerbose )
Sat_SolverPrintStats( stdout, pSat ); Sat_SolverPrintStats( stdout, pSat );
sat_solver_delete( pSat );
if ( RetValue == -1 ) if ( RetValue == -1 )
Abc_Print( 1, "UNDECIDED " ); Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 ) else if ( RetValue == 0 )
...@@ -449,6 +448,15 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart, ...@@ -449,6 +448,15 @@ int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int nLearnedStart,
Abc_Print( 1, "UNSATISFIABLE " ); Abc_Print( 1, "UNSATISFIABLE " );
//Abc_Print( -1, "\n" ); //Abc_Print( -1, "\n" );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
// derive SAT assignment
if ( RetValue == 0 )
{
*ppModel = ABC_ALLOC( int, nPis );
for ( i = 0; i < nPis; i++ )
(*ppModel)[i] = sat_solver_var_value( pSat, pCnf->nVars - nPis + i );
}
Cnf_DataFree( pCnf );
sat_solver_delete( pSat );
return RetValue; return RetValue;
} }
......
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