ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
msatSolverCore.c
Go to the documentation of this file.
1
20
21#include "msatInt.h"
22
24
25
29
33
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}
53
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}
76
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}
98
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}
120
138int Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTrackLimit, int nTimeLimit )
139{
140 Msat_SearchParams_t Params = { 0.95, 0.999 };
141 double nConflictsLimit, nLearnedLimit;
142 Msat_Type_t Status;
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;
170 Status = MSAT_UNKNOWN;
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}
208
212
213
215
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
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
#define MSAT_VAR_UNASSIGNED
Definition msatInt.h:68
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)
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition msatInt.h:57
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
void Msat_SolverPrintStats(Msat_Solver_t *p)
int Msat_SolverSolve(Msat_Solver_t *p, Msat_IntVec_t *vAssumps, int nBackTrackLimit, int nTimeLimit)
int Msat_SolverAddClause(Msat_Solver_t *p, Msat_IntVec_t *vLits)
double Msat_SolverProgressEstimate(Msat_Solver_t *p)
ABC_NAMESPACE_IMPL_START int Msat_SolverAddVar(Msat_Solver_t *p, int Level)
DECLARATIONS ///.
struct Msat_IntVec_t_ Msat_IntVec_t
Definition msat.h:45
typedefABC_NAMESPACE_HEADER_START struct Msat_Solver_t_ Msat_Solver_t
INCLUDES ///.
Definition msat.h:42
void Msat_SolverResize(Msat_Solver_t *pMan, int nVarsAlloc)
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