src/sat/msat/msatSolverCore.c File Reference

#include "msatInt.h"
Include dependency graph for msatSolverCore.c:

Go to the source code of this file.

Functions

bool Msat_SolverAddVar (Msat_Solver_t *p, int Level)
bool Msat_SolverAddClause (Msat_Solver_t *p, Msat_IntVec_t *vLits)
double Msat_SolverProgressEstimate (Msat_Solver_t *p)
void Msat_SolverPrintStats (Msat_Solver_t *p)
bool Msat_SolverSolve (Msat_Solver_t *p, Msat_IntVec_t *vAssumps, int nBackTrackLimit, int nTimeLimit)

Function Documentation

bool Msat_SolverAddClause ( Msat_Solver_t p,
Msat_IntVec_t vLits 
)

Function*************************************************************

Synopsis [Adds one clause to the solver's clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file msatSolverCore.c.

00063 {
00064     Msat_Clause_t * pC; 
00065     bool Value;
00066     Value = Msat_ClauseCreate( p, vLits, 0, &pC );
00067     if ( pC != NULL )
00068         Msat_ClauseVecPush( p->vClauses, pC );
00069 //    else if ( p->fProof )
00070 //        Msat_ClauseCreateFake( p, vLits );
00071     return Value;
00072 }

bool Msat_SolverAddVar ( Msat_Solver_t p,
int  Level 
)

CFile****************************************************************

FileName [msatSolverCore.c]

PackageName [A C version of SAT solver MINISAT, originally developed in C++ by Niklas Een and Niklas Sorensson, Chalmers University of Technology, Sweden: http://www.cs.chalmers.se/~een/Satzoo.]

Synopsis [The SAT solver core procedures.]

Author [Alan Mishchenko <alanmi@eecs.berkeley.edu>]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 1, 2004.]

Revision [

Id
msatSolverCore.c,v 1.2 2004/05/12 03:37:40 satrajit Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Adds one variable to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file msatSolverCore.c.

00043 {
00044     if ( p->nVars == p->nVarsAlloc )
00045         Msat_SolverResize( p, 2 * p->nVarsAlloc );
00046     p->pLevel[p->nVars] = Level;
00047     p->nVars++;
00048     return 1;
00049 }

void Msat_SolverPrintStats ( Msat_Solver_t p  ) 

Function*************************************************************

Synopsis [Prints statistics about the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file msatSolverCore.c.

00108 {
00109     printf("C solver (%d vars; %d clauses; %d learned):\n", 
00110         p->nVars, Msat_ClauseVecReadSize(p->vClauses), Msat_ClauseVecReadSize(p->vLearned) );
00111     printf("starts        : %lld\n", p->Stats.nStarts);
00112     printf("conflicts     : %lld\n", p->Stats.nConflicts);
00113     printf("decisions     : %lld\n", p->Stats.nDecisions);
00114     printf("propagations  : %lld\n", p->Stats.nPropagations);
00115     printf("inspects      : %lld\n", p->Stats.nInspects);
00116 }

double Msat_SolverProgressEstimate ( Msat_Solver_t p  ) 

Function*************************************************************

Synopsis [Returns search-space coverage. Not extremely reliable.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file msatSolverCore.c.

00086 {
00087     double dProgress = 0.0;
00088     double dF = 1.0 / p->nVars;
00089     int i;
00090     for ( i = 0; i < p->nVars; i++ )
00091         if ( p->pAssigns[i] != MSAT_VAR_UNASSIGNED )
00092             dProgress += pow( dF, p->pLevel[i] );
00093     return dProgress / p->nVars;
00094 }

bool Msat_SolverSolve ( Msat_Solver_t p,
Msat_IntVec_t vAssumps,
int  nBackTrackLimit,
int  nTimeLimit 
)

Function*************************************************************

Synopsis [Top-level solve.]

Description [If using assumptions (non-empty 'assumps' vector), you must call 'simplifyDB()' first to see that no top-level conflict is present (which would put the solver in an undefined state. If the last argument is given (vProj), the solver enumerates through the satisfying solutions, which are projected on the variables listed in this array. Note that the variables in the array may be complemented, in which case the derived assignment for the variable is complemented.]

SideEffects []

SeeAlso []

Definition at line 135 of file msatSolverCore.c.

00136 {
00137     Msat_SearchParams_t Params = { 0.95, 0.999 };
00138     double nConflictsLimit, nLearnedLimit;
00139     Msat_Type_t Status;
00140     int timeStart = clock();
00141     int64 nConflictsOld = p->Stats.nConflicts;
00142     int64 nDecisionsOld = p->Stats.nDecisions;
00143 
00144 //    p->pFreq = ALLOC( int, p->nVarsAlloc );
00145 //    memset( p->pFreq, 0, sizeof(int) * p->nVarsAlloc );
00146  
00147     if ( vAssumps )
00148     {
00149         int * pAssumps, nAssumps, i;
00150 
00151         assert( Msat_IntVecReadSize(p->vTrailLim) == 0 );
00152 
00153         nAssumps = Msat_IntVecReadSize( vAssumps );
00154         pAssumps = Msat_IntVecReadArray( vAssumps );
00155         for ( i = 0; i < nAssumps; i++ )
00156         {
00157             if ( !Msat_SolverAssume(p, pAssumps[i]) || Msat_SolverPropagate(p) )
00158             {
00159                 Msat_QueueClear( p->pQueue );
00160                 Msat_SolverCancelUntil( p, 0 );
00161                 return MSAT_FALSE;
00162             }
00163         }
00164     }
00165     p->nLevelRoot   = Msat_SolverReadDecisionLevel(p);
00166     p->nClausesInit = Msat_ClauseVecReadSize( p->vClauses );    
00167     nConflictsLimit = 100;
00168     nLearnedLimit   = Msat_ClauseVecReadSize(p->vClauses) / 3;
00169     Status = MSAT_UNKNOWN;
00170     p->nBackTracks = (int)p->Stats.nConflicts;
00171     while ( Status == MSAT_UNKNOWN )
00172     {
00173         if ( p->fVerbose )
00174             printf("Solving -- conflicts=%d   learnts=%d   progress=%.4f %%\n", 
00175                 (int)nConflictsLimit, (int)nLearnedLimit, p->dProgress*100);
00176         Status = Msat_SolverSearch( p, (int)nConflictsLimit, (int)nLearnedLimit, nBackTrackLimit, &Params );
00177         nConflictsLimit *= 1.5;
00178         nLearnedLimit   *= 1.1;
00179         // if the limit on the number of backtracks is given, quit the restart loop
00180         if ( nBackTrackLimit > 0 && (int)p->Stats.nConflicts - p->nBackTracks > nBackTrackLimit )
00181             break;
00182         // if the runtime limit is exceeded, quit the restart loop
00183         if ( nTimeLimit > 0 && clock() - timeStart >= nTimeLimit * CLOCKS_PER_SEC )
00184             break;
00185     }
00186     Msat_SolverCancelUntil( p, 0 );
00187     p->nBackTracks = (int)p->Stats.nConflicts - p->nBackTracks;
00188 /*
00189     PRT( "True solver runtime", clock() - timeStart );
00190     // print the statistics
00191     {
00192         int i, Counter = 0;
00193         for ( i = 0; i < p->nVars; i++ )
00194             if ( p->pFreq[i] > 0 )
00195             {
00196                 printf( "%d ", p->pFreq[i] );
00197                 Counter++;
00198             }
00199         if ( Counter )
00200             printf( "\n" );
00201         printf( "Total = %d. Used = %d.  Decisions = %d. Imps = %d. Conflicts = %d. ", p->nVars, Counter, (int)p->Stats.nDecisions, (int)p->Stats.nPropagations, (int)p->Stats.nConflicts );
00202         PRT( "Time", clock() - timeStart );
00203     }
00204 */
00205     return Status;
00206 }


Generated on Tue Jan 5 12:19:40 2010 for abc70930 by  doxygen 1.6.1