ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
msatSolverCore.c File Reference
#include "msatInt.h"
Include dependency graph for msatSolverCore.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ Msat_SolverAddClause()

int 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 65 of file msatSolverCore.c.

66{
67 Msat_Clause_t * pC;
68 int Value;
69 Value = Msat_ClauseCreate( p, vLits, 0, &pC );
70 if ( pC != NULL )
71 Msat_ClauseVecPush( p->vClauses, pC );
72// else if ( p->fProof )
73// Msat_ClauseCreateFake( p, vLits );
74 return Value;
75}
Cube * p
Definition exorList.c:222
void Msat_ClauseVecPush(Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
int Msat_ClauseCreate(Msat_Solver_t *p, Msat_IntVec_t *vLits, int fLearned, Msat_Clause_t **pClause_out)
FUNCTION DEFINITIONS ///.
Definition msatClause.c:58
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition msatInt.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_SolverAddVar()

ABC_NAMESPACE_IMPL_START int Msat_SolverAddVar ( Msat_Solver_t * p,
int Level )

DECLARATIONS ///.

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 alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

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

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

Synopsis [Adds one variable to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file msatSolverCore.c.

46{
47 if ( p->nVars == p->nVarsAlloc )
48 Msat_SolverResize( p, 2 * p->nVarsAlloc );
49 p->pLevel[p->nVars] = Level;
50 p->nVars++;
51 return 1;
52}
void Msat_SolverResize(Msat_Solver_t *pMan, int nVarsAlloc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_SolverPrintStats()

void Msat_SolverPrintStats ( Msat_Solver_t * p)

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

Synopsis [Prints statistics about the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file msatSolverCore.c.

111{
112 printf("C solver (%d vars; %d clauses; %d learned):\n",
113 p->nVars, Msat_ClauseVecReadSize(p->vClauses), Msat_ClauseVecReadSize(p->vLearned) );
114 printf("starts : %d\n", (int)p->Stats.nStarts);
115 printf("conflicts : %d\n", (int)p->Stats.nConflicts);
116 printf("decisions : %d\n", (int)p->Stats.nDecisions);
117 printf("propagations : %d\n", (int)p->Stats.nPropagations);
118 printf("inspects : %d\n", (int)p->Stats.nInspects);
119}
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_SolverProgressEstimate()

double Msat_SolverProgressEstimate ( Msat_Solver_t * p)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file msatSolverCore.c.

89{
90 double dProgress = 0.0;
91 double dF = 1.0 / p->nVars;
92 int i;
93 for ( i = 0; i < p->nVars; i++ )
94 if ( p->pAssigns[i] != MSAT_VAR_UNASSIGNED )
95 dProgress += pow( dF, p->pLevel[i] );
96 return dProgress / p->nVars;
97}
#define MSAT_VAR_UNASSIGNED
Definition msatInt.h:68
Here is the caller graph for this function:

◆ Msat_SolverSolve()

int 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 138 of file msatSolverCore.c.

139{
140 Msat_SearchParams_t Params = { 0.95, 0.999 };
141 double nConflictsLimit, nLearnedLimit;
143 abctime timeStart = Abc_Clock();
144
145// p->pFreq = ABC_ALLOC( int, p->nVarsAlloc );
146// memset( p->pFreq, 0, sizeof(int) * p->nVarsAlloc );
147
148 if ( vAssumps )
149 {
150 int * pAssumps, nAssumps, i;
151
152 assert( Msat_IntVecReadSize(p->vTrailLim) == 0 );
153
154 nAssumps = Msat_IntVecReadSize( vAssumps );
155 pAssumps = Msat_IntVecReadArray( vAssumps );
156 for ( i = 0; i < nAssumps; i++ )
157 {
158 if ( !Msat_SolverAssume(p, pAssumps[i]) || Msat_SolverPropagate(p) )
159 {
160 Msat_QueueClear( p->pQueue );
162 return MSAT_FALSE;
163 }
164 }
165 }
166 p->nLevelRoot = Msat_SolverReadDecisionLevel(p);
167 p->nClausesInit = Msat_ClauseVecReadSize( p->vClauses );
168 nConflictsLimit = 100;
169 nLearnedLimit = Msat_ClauseVecReadSize(p->vClauses) / 3;
171 p->nBackTracks = (int)p->Stats.nConflicts;
172 while ( Status == MSAT_UNKNOWN )
173 {
174 if ( p->fVerbose )
175 printf("Solving -- conflicts=%d learnts=%d progress=%.4f %%\n",
176 (int)nConflictsLimit, (int)nLearnedLimit, p->dProgress*100);
177 Status = Msat_SolverSearch( p, (int)nConflictsLimit, (int)nLearnedLimit, nBackTrackLimit, &Params );
178 nConflictsLimit *= 1.5;
179 nLearnedLimit *= 1.1;
180 // if the limit on the number of backtracks is given, quit the restart loop
181 if ( nBackTrackLimit > 0 && (int)p->Stats.nConflicts - p->nBackTracks > nBackTrackLimit )
182 break;
183 // if the runtime limit is exceeded, quit the restart loop
184 if ( nTimeLimit > 0 && Abc_Clock() - timeStart >= nTimeLimit * CLOCKS_PER_SEC )
185 break;
186 }
188 p->nBackTracks = (int)p->Stats.nConflicts - p->nBackTracks;
189/*
190 ABC_PRT( "True solver runtime", Abc_Clock() - timeStart );
191 // print the statistics
192 {
193 int i, Counter = 0;
194 for ( i = 0; i < p->nVars; i++ )
195 if ( p->pFreq[i] > 0 )
196 {
197 printf( "%d ", p->pFreq[i] );
198 Counter++;
199 }
200 if ( Counter )
201 printf( "\n" );
202 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 );
203 ABC_PRT( "Time", Abc_Clock() - timeStart );
204 }
205*/
206 return Status;
207}
ABC_INT64_T abctime
Definition abc_global.h:332
int Msat_SolverAssume(Msat_Solver_t *p, Msat_Lit_t Lit)
FUNCTION DEFINITIONS ///.
void Msat_SolverCancelUntil(Msat_Solver_t *p, int Level)
void Msat_QueueClear(Msat_Queue_t *p)
Definition msatQueue.c:149
int Msat_SolverReadDecisionLevel(Msat_Solver_t *p)
Msat_Clause_t * Msat_SolverPropagate(Msat_Solver_t *p)
Msat_Type_t Msat_SolverSearch(Msat_Solver_t *p, int nConfLimit, int nLearnedLimit, int nBackTrackLimit, Msat_SearchParams_t *pPars)
struct Msat_SearchParams_t_ Msat_SearchParams_t
Definition msatInt.h:89
Msat_Type_t
Definition msat.h:50
@ MSAT_FALSE
Definition msat.h:50
@ MSAT_UNKNOWN
Definition msat.h:50
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function: