abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
msatSolverApi.c File Reference
#include "msatInt.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Msat_SolverSetupTruthTables (unsigned uTruths[][2])
 DECLARATIONS ///. More...
 
int Msat_SolverReadVarNum (Msat_Solver_t *p)
 FUNCTION DEFINITIONS ///. More...
 
int Msat_SolverReadClauseNum (Msat_Solver_t *p)
 
int Msat_SolverReadVarAllocNum (Msat_Solver_t *p)
 
int Msat_SolverReadDecisionLevel (Msat_Solver_t *p)
 
int * Msat_SolverReadDecisionLevelArray (Msat_Solver_t *p)
 
Msat_Clause_t ** Msat_SolverReadReasonArray (Msat_Solver_t *p)
 
Msat_Type_t Msat_SolverReadVarValue (Msat_Solver_t *p, Msat_Var_t Var)
 
Msat_ClauseVec_tMsat_SolverReadLearned (Msat_Solver_t *p)
 
Msat_ClauseVec_t ** Msat_SolverReadWatchedArray (Msat_Solver_t *p)
 
int * Msat_SolverReadAssignsArray (Msat_Solver_t *p)
 
int * Msat_SolverReadModelArray (Msat_Solver_t *p)
 
int Msat_SolverReadBackTracks (Msat_Solver_t *p)
 
int Msat_SolverReadInspects (Msat_Solver_t *p)
 
Msat_MmStep_tMsat_SolverReadMem (Msat_Solver_t *p)
 
int * Msat_SolverReadSeenArray (Msat_Solver_t *p)
 
int Msat_SolverIncrementSeenId (Msat_Solver_t *p)
 
void Msat_SolverSetVerbosity (Msat_Solver_t *p, int fVerbose)
 
void Msat_SolverClausesIncrement (Msat_Solver_t *p)
 
void Msat_SolverClausesDecrement (Msat_Solver_t *p)
 
void Msat_SolverClausesIncrementL (Msat_Solver_t *p)
 
void Msat_SolverClausesDecrementL (Msat_Solver_t *p)
 
void Msat_SolverMarkLastClauseTypeA (Msat_Solver_t *p)
 
void Msat_SolverMarkClausesStart (Msat_Solver_t *p)
 
float * Msat_SolverReadFactors (Msat_Solver_t *p)
 
Msat_Clause_tMsat_SolverReadClause (Msat_Solver_t *p, int Num)
 
Msat_ClauseVec_tMsat_SolverReadAdjacents (Msat_Solver_t *p)
 
Msat_IntVec_tMsat_SolverReadConeVars (Msat_Solver_t *p)
 
Msat_IntVec_tMsat_SolverReadVarsUsed (Msat_Solver_t *p)
 
Msat_Solver_tMsat_SolverAlloc (int nVarsAlloc, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose)
 
void Msat_SolverResize (Msat_Solver_t *p, int nVarsAlloc)
 
void Msat_SolverClean (Msat_Solver_t *p, int nVars)
 
void Msat_SolverFree (Msat_Solver_t *p)
 
void Msat_SolverPrepare (Msat_Solver_t *p, Msat_IntVec_t *vVars)
 

Function Documentation

Msat_Solver_t* Msat_SolverAlloc ( int  nVarsAlloc,
double  dClaInc,
double  dClaDecay,
double  dVarInc,
double  dVarDecay,
int  fVerbose 
)

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

Synopsis [Allocates the solver.]

Description [After the solver is allocated, the procedure Msat_SolverClean() should be called to set the number of variables.]

SideEffects []

SeeAlso []

Definition at line 154 of file msatSolverApi.c.

158 {
159  Msat_Solver_t * p;
160  int i;
161 
162  assert(sizeof(Msat_Lit_t) == sizeof(unsigned));
163  assert(sizeof(float) == sizeof(unsigned));
164 
165  p = ABC_ALLOC( Msat_Solver_t, 1 );
166  memset( p, 0, sizeof(Msat_Solver_t) );
167 
168  p->nVarsAlloc = nVarsAlloc;
169  p->nVars = 0;
170 
171  p->nClauses = 0;
172  p->vClauses = Msat_ClauseVecAlloc( 512 );
173  p->vLearned = Msat_ClauseVecAlloc( 512 );
174 
175  p->dClaInc = dClaInc;
176  p->dClaDecay = dClaDecay;
177  p->dVarInc = dVarInc;
178  p->dVarDecay = dVarDecay;
179 
180  p->pdActivity = ABC_ALLOC( double, p->nVarsAlloc );
181  p->pFactors = ABC_ALLOC( float, p->nVarsAlloc );
182  for ( i = 0; i < p->nVarsAlloc; i++ )
183  {
184  p->pdActivity[i] = 0.0;
185  p->pFactors[i] = 1.0;
186  }
187 
188  p->pAssigns = ABC_ALLOC( int, p->nVarsAlloc );
189  p->pModel = ABC_ALLOC( int, p->nVarsAlloc );
190  for ( i = 0; i < p->nVarsAlloc; i++ )
191  p->pAssigns[i] = MSAT_VAR_UNASSIGNED;
192 // p->pOrder = Msat_OrderAlloc( p->pAssigns, p->pdActivity, p->nVarsAlloc );
193  p->pOrder = Msat_OrderAlloc( p );
194 
195  p->pvWatched = ABC_ALLOC( Msat_ClauseVec_t *, 2 * p->nVarsAlloc );
196  for ( i = 0; i < 2 * p->nVarsAlloc; i++ )
197  p->pvWatched[i] = Msat_ClauseVecAlloc( 16 );
198  p->pQueue = Msat_QueueAlloc( p->nVarsAlloc );
199 
200  p->vTrail = Msat_IntVecAlloc( p->nVarsAlloc );
201  p->vTrailLim = Msat_IntVecAlloc( p->nVarsAlloc );
202  p->pReasons = ABC_ALLOC( Msat_Clause_t *, p->nVarsAlloc );
203  memset( p->pReasons, 0, sizeof(Msat_Clause_t *) * p->nVarsAlloc );
204  p->pLevel = ABC_ALLOC( int, p->nVarsAlloc );
205  for ( i = 0; i < p->nVarsAlloc; i++ )
206  p->pLevel[i] = -1;
207  p->dRandSeed = 91648253;
208  p->fVerbose = fVerbose;
209  p->dProgress = 0.0;
210 // p->pModel = Msat_IntVecAlloc( p->nVarsAlloc );
211  p->pMem = Msat_MmStepStart( 10 );
212 
213  p->vConeVars = Msat_IntVecAlloc( p->nVarsAlloc );
214  p->vAdjacents = Msat_ClauseVecAlloc( p->nVarsAlloc );
215  for ( i = 0; i < p->nVarsAlloc; i++ )
216  Msat_ClauseVecPush( p->vAdjacents, (Msat_Clause_t *)Msat_IntVecAlloc(5) );
217  p->vVarsUsed = Msat_IntVecAlloc( p->nVarsAlloc );
218  Msat_IntVecFill( p->vVarsUsed, p->nVarsAlloc, 1 );
219 
220 
221  p->pSeen = ABC_ALLOC( int, p->nVarsAlloc );
222  memset( p->pSeen, 0, sizeof(int) * p->nVarsAlloc );
223  p->nSeenId = 1;
224  p->vReason = Msat_IntVecAlloc( p->nVarsAlloc );
225  p->vTemp = Msat_IntVecAlloc( p->nVarsAlloc );
226  return p;
227 }
char * memset()
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_Lit_t
Definition: msatInt.h:65
void Msat_ClauseVecPush(Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
void Msat_IntVecFill(Msat_IntVec_t *p, int nSize, int Entry)
Definition: msatVec.c:177
Msat_IntVec_t * Msat_IntVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: msatVec.c:48
Msat_Order_t * Msat_OrderAlloc(Msat_Solver_t *pSat)
FUNCTION DEFINITIONS ///.
Definition: msatOrderH.c:78
ABC_NAMESPACE_IMPL_START Msat_ClauseVec_t * Msat_ClauseVecAlloc(int nCap)
DECLARATIONS ///.
Definition: msatClauseVec.c:45
#define assert(ex)
Definition: util_old.h:213
Msat_Queue_t * Msat_QueueAlloc(int nVars)
FUNCTION DEFINITIONS ///.
Definition: msatQueue.c:53
Msat_MmStep_t * Msat_MmStepStart(int nSteps)
Definition: msatMem.c:423
typedefABC_NAMESPACE_HEADER_START struct Msat_Solver_t_ Msat_Solver_t
INCLUDES ///.
Definition: msat.h:42
void Msat_SolverClausesDecrement ( Msat_Solver_t p)

Definition at line 65 of file msatSolverApi.c.

65 { p->nClausesAlloc--; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverClausesDecrementL ( Msat_Solver_t p)

Definition at line 67 of file msatSolverApi.c.

67 { p->nClausesAllocL--; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverClausesIncrement ( Msat_Solver_t p)

Definition at line 64 of file msatSolverApi.c.

64 { p->nClausesAlloc++; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverClausesIncrementL ( Msat_Solver_t p)

Definition at line 66 of file msatSolverApi.c.

66 { p->nClausesAllocL++; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverClean ( Msat_Solver_t p,
int  nVars 
)

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

Synopsis [Prepares the solver.]

Description [Cleans the solver assuming that the problem will involve the given number of variables (nVars). This procedure is useful for many small (incremental) SAT problems, to prevent the solver from being reallocated each time.]

SideEffects []

SeeAlso []

Definition at line 307 of file msatSolverApi.c.

308 {
309  int i;
310  // free the clauses
311  int nClauses;
312  Msat_Clause_t ** pClauses;
313 
314  assert( p->nVarsAlloc >= nVars );
315  p->nVars = nVars;
316  p->nClauses = 0;
317 
318  nClauses = Msat_ClauseVecReadSize( p->vClauses );
319  pClauses = Msat_ClauseVecReadArray( p->vClauses );
320  for ( i = 0; i < nClauses; i++ )
321  Msat_ClauseFree( p, pClauses[i], 0 );
322 // Msat_ClauseVecFree( p->vClauses );
323  Msat_ClauseVecClear( p->vClauses );
324 
325  nClauses = Msat_ClauseVecReadSize( p->vLearned );
326  pClauses = Msat_ClauseVecReadArray( p->vLearned );
327  for ( i = 0; i < nClauses; i++ )
328  Msat_ClauseFree( p, pClauses[i], 0 );
329 // Msat_ClauseVecFree( p->vLearned );
330  Msat_ClauseVecClear( p->vLearned );
331 
332 // ABC_FREE( p->pdActivity );
333  for ( i = 0; i < p->nVars; i++ )
334  p->pdActivity[i] = 0;
335 
336 // Msat_OrderFree( p->pOrder );
337 // Msat_OrderClean( p->pOrder, p->nVars, NULL );
338  Msat_OrderSetBounds( p->pOrder, p->nVars );
339 
340  for ( i = 0; i < 2 * p->nVars; i++ )
341 // Msat_ClauseVecFree( p->pvWatched[i] );
342  Msat_ClauseVecClear( p->pvWatched[i] );
343 // ABC_FREE( p->pvWatched );
344 // Msat_QueueFree( p->pQueue );
345  Msat_QueueClear( p->pQueue );
346 
347 // ABC_FREE( p->pAssigns );
348  for ( i = 0; i < p->nVars; i++ )
349  p->pAssigns[i] = MSAT_VAR_UNASSIGNED;
350 // Msat_IntVecFree( p->vTrail );
351  Msat_IntVecClear( p->vTrail );
352 // Msat_IntVecFree( p->vTrailLim );
353  Msat_IntVecClear( p->vTrailLim );
354 // ABC_FREE( p->pReasons );
355  memset( p->pReasons, 0, sizeof(Msat_Clause_t *) * p->nVars );
356 // ABC_FREE( p->pLevel );
357  for ( i = 0; i < p->nVars; i++ )
358  p->pLevel[i] = -1;
359 // Msat_IntVecFree( p->pModel );
360 // Msat_MmStepStop( p->pMem, 0 );
361  p->dRandSeed = 91648253;
362  p->dProgress = 0.0;
363 
364 // ABC_FREE( p->pSeen );
365  memset( p->pSeen, 0, sizeof(int) * p->nVars );
366  p->nSeenId = 1;
367 // Msat_IntVecFree( p->vReason );
368  Msat_IntVecClear( p->vReason );
369 // Msat_IntVecFree( p->vTemp );
370  Msat_IntVecClear( p->vTemp );
371 // printf(" The number of clauses remaining = %d (%d).\n", p->nClausesAlloc, p->nClausesAllocL );
372 // ABC_FREE( p );
373 }
char * memset()
void Msat_ClauseFree(Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
Definition: msatClause.c:223
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_QueueClear(Msat_Queue_t *p)
Definition: msatQueue.c:149
void Msat_OrderSetBounds(Msat_Order_t *p, int nVarsMax)
Definition: msatOrderH.c:101
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition: msatVec.c:335
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
void Msat_ClauseVecClear(Msat_ClauseVec_t *p)
#define assert(ex)
Definition: util_old.h:213
int nVars
Definition: llb3Image.c:58
void Msat_SolverFree ( Msat_Solver_t p)

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

Synopsis [Frees the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file msatSolverApi.c.

387 {
388  int i;
389 
390  // free the clauses
391  int nClauses;
392  Msat_Clause_t ** pClauses;
393 //printf( "clauses = %d. learned = %d.\n", Msat_ClauseVecReadSize( p->vClauses ),
394 // Msat_ClauseVecReadSize( p->vLearned ) );
395 
396  nClauses = Msat_ClauseVecReadSize( p->vClauses );
397  pClauses = Msat_ClauseVecReadArray( p->vClauses );
398  for ( i = 0; i < nClauses; i++ )
399  Msat_ClauseFree( p, pClauses[i], 0 );
400  Msat_ClauseVecFree( p->vClauses );
401 
402  nClauses = Msat_ClauseVecReadSize( p->vLearned );
403  pClauses = Msat_ClauseVecReadArray( p->vLearned );
404  for ( i = 0; i < nClauses; i++ )
405  Msat_ClauseFree( p, pClauses[i], 0 );
406  Msat_ClauseVecFree( p->vLearned );
407 
408  ABC_FREE( p->pdActivity );
409  ABC_FREE( p->pFactors );
410  Msat_OrderFree( p->pOrder );
411 
412  for ( i = 0; i < 2 * p->nVarsAlloc; i++ )
413  Msat_ClauseVecFree( p->pvWatched[i] );
414  ABC_FREE( p->pvWatched );
415  Msat_QueueFree( p->pQueue );
416 
417  ABC_FREE( p->pAssigns );
418  ABC_FREE( p->pModel );
419  Msat_IntVecFree( p->vTrail );
420  Msat_IntVecFree( p->vTrailLim );
421  ABC_FREE( p->pReasons );
422  ABC_FREE( p->pLevel );
423 
424  Msat_MmStepStop( p->pMem, 0 );
425 
426  nClauses = Msat_ClauseVecReadSize( p->vAdjacents );
427  pClauses = Msat_ClauseVecReadArray( p->vAdjacents );
428  for ( i = 0; i < nClauses; i++ )
429  Msat_IntVecFree( (Msat_IntVec_t *)pClauses[i] );
430  Msat_ClauseVecFree( p->vAdjacents );
431  Msat_IntVecFree( p->vConeVars );
432  Msat_IntVecFree( p->vVarsUsed );
433 
434  ABC_FREE( p->pSeen );
435  Msat_IntVecFree( p->vReason );
436  Msat_IntVecFree( p->vTemp );
437  ABC_FREE( p );
438 }
void Msat_ClauseFree(Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
Definition: msatClause.c:223
void Msat_QueueFree(Msat_Queue_t *p)
Definition: msatQueue.c:74
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
void Msat_OrderFree(Msat_Order_t *p)
Definition: msatOrderH.c:163
void Msat_IntVecFree(Msat_IntVec_t *p)
Definition: msatVec.c:160
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Msat_MmStepStop(Msat_MmStep_t *p, int fVerbose)
Definition: msatMem.c:458
void Msat_ClauseVecFree(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:68
int Msat_SolverIncrementSeenId ( Msat_Solver_t p)

Definition at line 62 of file msatSolverApi.c.

62 { return ++p->nSeenId; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverMarkClausesStart ( Msat_Solver_t p)

Definition at line 69 of file msatSolverApi.c.

69 { p->nClausesStart = Msat_ClauseVecReadSize(p->vClauses); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
void Msat_SolverMarkLastClauseTypeA ( Msat_Solver_t p)

Definition at line 68 of file msatSolverApi.c.

68 { Msat_ClauseSetTypeA( Msat_ClauseVecReadEntry( p->vClauses, Msat_ClauseVecReadSize(p->vClauses)-1 ), 1 ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_ClauseSetTypeA(Msat_Clause_t *pC, int fTypeA)
Definition: msatClause.c:264
Msat_Clause_t * Msat_ClauseVecReadEntry(Msat_ClauseVec_t *p, int i)
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
void Msat_SolverPrepare ( Msat_Solver_t p,
Msat_IntVec_t vVars 
)

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

Synopsis [Prepares the solver to run on a subset of variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 451 of file msatSolverApi.c.

452 {
453 
454  int i;
455  // undo the previous data
456  for ( i = 0; i < p->nVarsAlloc; i++ )
457  {
458  p->pAssigns[i] = MSAT_VAR_UNASSIGNED;
459  p->pReasons[i] = NULL;
460  p->pLevel[i] = -1;
461  p->pdActivity[i] = 0.0;
462  }
463 
464  // set the new variable order
465  Msat_OrderClean( p->pOrder, vVars );
466 
467  Msat_QueueClear( p->pQueue );
468  Msat_IntVecClear( p->vTrail );
469  Msat_IntVecClear( p->vTrailLim );
470  p->dProgress = 0.0;
471 }
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_QueueClear(Msat_Queue_t *p)
Definition: msatQueue.c:149
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition: msatVec.c:335
void Msat_OrderClean(Msat_Order_t *p, Msat_IntVec_t *vCone)
Definition: msatOrderH.c:120
Msat_ClauseVec_t* Msat_SolverReadAdjacents ( Msat_Solver_t p)

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

Synopsis [Reads the clause with the given number.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file msatSolverApi.c.

105 {
106  return p->vAdjacents;
107 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int* Msat_SolverReadAssignsArray ( Msat_Solver_t p)

Definition at line 56 of file msatSolverApi.c.

56 { return p->pAssigns; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_SolverReadBackTracks ( Msat_Solver_t p)

Definition at line 58 of file msatSolverApi.c.

58 { return (int)p->Stats.nConflicts; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Clause_t* Msat_SolverReadClause ( Msat_Solver_t p,
int  Num 
)

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

Synopsis [Reads the clause with the given number.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file msatSolverApi.c.

84 {
85  int nClausesP;
86  assert( Num < p->nClauses );
87  nClausesP = Msat_ClauseVecReadSize( p->vClauses );
88  if ( Num < nClausesP )
89  return Msat_ClauseVecReadEntry( p->vClauses, Num );
90  return Msat_ClauseVecReadEntry( p->vLearned, Num - nClausesP );
91 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Clause_t * Msat_ClauseVecReadEntry(Msat_ClauseVec_t *p, int i)
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
#define assert(ex)
Definition: util_old.h:213
int Msat_SolverReadClauseNum ( Msat_Solver_t p)

Definition at line 48 of file msatSolverApi.c.

48 { return p->nClauses; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_IntVec_t* Msat_SolverReadConeVars ( Msat_Solver_t p)

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

Synopsis [Reads the clause with the given number.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file msatSolverApi.c.

121 {
122  return p->vConeVars;
123 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_SolverReadDecisionLevel ( Msat_Solver_t p)

Definition at line 50 of file msatSolverApi.c.

50 { return Msat_IntVecReadSize(p->vTrailLim); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
int* Msat_SolverReadDecisionLevelArray ( Msat_Solver_t p)

Definition at line 51 of file msatSolverApi.c.

51 { return p->pLevel; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float* Msat_SolverReadFactors ( Msat_Solver_t p)

Definition at line 70 of file msatSolverApi.c.

70 { return p->pFactors; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_SolverReadInspects ( Msat_Solver_t p)

Definition at line 59 of file msatSolverApi.c.

59 { return (int)p->Stats.nInspects; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_ClauseVec_t* Msat_SolverReadLearned ( Msat_Solver_t p)

Definition at line 54 of file msatSolverApi.c.

54 { return p->vLearned; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_MmStep_t* Msat_SolverReadMem ( Msat_Solver_t p)

Definition at line 60 of file msatSolverApi.c.

60 { return p->pMem; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int* Msat_SolverReadModelArray ( Msat_Solver_t p)

Definition at line 57 of file msatSolverApi.c.

57 { return p->pModel; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Clause_t** Msat_SolverReadReasonArray ( Msat_Solver_t p)

Definition at line 52 of file msatSolverApi.c.

52 { return p->pReasons; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int* Msat_SolverReadSeenArray ( Msat_Solver_t p)

Definition at line 61 of file msatSolverApi.c.

61 { return p->pSeen; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_SolverReadVarAllocNum ( Msat_Solver_t p)

Definition at line 49 of file msatSolverApi.c.

49 { return p->nVarsAlloc; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_SolverReadVarNum ( Msat_Solver_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Simple SAT solver APIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file msatSolverApi.c.

47 { return p->nVars; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVars
Definition: llb3Image.c:58
Msat_IntVec_t* Msat_SolverReadVarsUsed ( Msat_Solver_t p)

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

Synopsis [Reads the clause with the given number.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file msatSolverApi.c.

137 {
138  return p->vVarsUsed;
139 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Type_t Msat_SolverReadVarValue ( Msat_Solver_t p,
Msat_Var_t  Var 
)

Definition at line 53 of file msatSolverApi.c.

53 { return (Msat_Type_t)p->pAssigns[Var]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Type_t
Definition: msat.h:50
int Var
Definition: SolverTypes.h:42
Msat_ClauseVec_t** Msat_SolverReadWatchedArray ( Msat_Solver_t p)

Definition at line 55 of file msatSolverApi.c.

55 { return p->pvWatched; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverResize ( Msat_Solver_t p,
int  nVarsAlloc 
)

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

Synopsis [Resizes the solver.]

Description [Assumes that the solver contains some clauses, and that it is currently between the calls. Resizes the solver to accomodate more variables.]

SideEffects []

SeeAlso []

Definition at line 242 of file msatSolverApi.c.

243 {
244  int nVarsAllocOld, i;
245 
246  nVarsAllocOld = p->nVarsAlloc;
247  p->nVarsAlloc = nVarsAlloc;
248 
249  p->pdActivity = ABC_REALLOC( double, p->pdActivity, p->nVarsAlloc );
250  p->pFactors = ABC_REALLOC( float, p->pFactors, p->nVarsAlloc );
251  for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ )
252  {
253  p->pdActivity[i] = 0.0;
254  p->pFactors[i] = 1.0;
255  }
256 
257  p->pAssigns = ABC_REALLOC( int, p->pAssigns, p->nVarsAlloc );
258  p->pModel = ABC_REALLOC( int, p->pModel, p->nVarsAlloc );
259  for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ )
260  p->pAssigns[i] = MSAT_VAR_UNASSIGNED;
261 
262 // Msat_OrderRealloc( p->pOrder, p->pAssigns, p->pdActivity, p->nVarsAlloc );
263  Msat_OrderSetBounds( p->pOrder, p->nVarsAlloc );
264 
265  p->pvWatched = ABC_REALLOC( Msat_ClauseVec_t *, p->pvWatched, 2 * p->nVarsAlloc );
266  for ( i = 2 * nVarsAllocOld; i < 2 * p->nVarsAlloc; i++ )
267  p->pvWatched[i] = Msat_ClauseVecAlloc( 16 );
268 
269  Msat_QueueFree( p->pQueue );
270  p->pQueue = Msat_QueueAlloc( p->nVarsAlloc );
271 
272  p->pReasons = ABC_REALLOC( Msat_Clause_t *, p->pReasons, p->nVarsAlloc );
273  p->pLevel = ABC_REALLOC( int, p->pLevel, p->nVarsAlloc );
274  for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ )
275  {
276  p->pReasons[i] = NULL;
277  p->pLevel[i] = -1;
278  }
279 
280  p->pSeen = ABC_REALLOC( int, p->pSeen, p->nVarsAlloc );
281  for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ )
282  p->pSeen[i] = 0;
283 
284  Msat_IntVecGrow( p->vTrail, p->nVarsAlloc );
285  Msat_IntVecGrow( p->vTrailLim, p->nVarsAlloc );
286 
287  // make sure the array of adjucents has room to store the variable numbers
288  for ( i = Msat_ClauseVecReadSize(p->vAdjacents); i < p->nVarsAlloc; i++ )
289  Msat_ClauseVecPush( p->vAdjacents, (Msat_Clause_t *)Msat_IntVecAlloc(5) );
290  Msat_IntVecFill( p->vVarsUsed, p->nVarsAlloc, 1 );
291 }
void Msat_QueueFree(Msat_Queue_t *p)
Definition: msatQueue.c:74
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
void Msat_OrderSetBounds(Msat_Order_t *p, int nVarsMax)
Definition: msatOrderH.c:101
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
void Msat_ClauseVecPush(Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
void Msat_IntVecFill(Msat_IntVec_t *p, int nSize, int Entry)
Definition: msatVec.c:177
Msat_IntVec_t * Msat_IntVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: msatVec.c:48
ABC_NAMESPACE_IMPL_START Msat_ClauseVec_t * Msat_ClauseVecAlloc(int nCap)
DECLARATIONS ///.
Definition: msatClauseVec.c:45
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition: msatVec.c:299
Msat_Queue_t * Msat_QueueAlloc(int nVars)
FUNCTION DEFINITIONS ///.
Definition: msatQueue.c:53
void Msat_SolverSetupTruthTables ( unsigned  uTruths[][2])
static

DECLARATIONS ///.

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

FileName [msatSolverApi.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 [APIs of the SAT solver.]

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:
msatSolverApi.c,v 1.0 2004/01/01 1:00:00 alanmi Exp

]

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 484 of file msatSolverApi.c.

485 {
486  int m, v;
487  // set up the truth tables
488  for ( m = 0; m < 32; m++ )
489  for ( v = 0; v < 5; v++ )
490  if ( m & (1 << v) )
491  uTruths[v][0] |= (1 << m);
492  // make adjustments for the case of 6 variables
493  for ( v = 0; v < 5; v++ )
494  uTruths[v][1] = uTruths[v][0];
495  uTruths[5][0] = 0;
496  uTruths[5][1] = ~((unsigned)0);
497 }
void Msat_SolverSetVerbosity ( Msat_Solver_t p,
int  fVerbose 
)

Definition at line 63 of file msatSolverApi.c.

63 { p->fVerbose = fVerbose; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950