abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
msat.h File Reference

Go to the source code of this file.

Macros

#define MSAT_VAR2LIT(v, s)   (2*(v)+(s))
 
#define MSAT_LITNOT(l)   ((l)^1)
 
#define MSAT_LITSIGN(l)   ((l)&1)
 
#define MSAT_LIT2VAR(l)   ((l)>>1)
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Msat_Solver_t_ 
Msat_Solver_t
 INCLUDES ///. More...
 
typedef struct Msat_IntVec_t_ Msat_IntVec_t
 
typedef struct Msat_ClauseVec_t_ Msat_ClauseVec_t
 
typedef struct Msat_VarHeap_t_ Msat_VarHeap_t
 

Enumerations

enum  Msat_Type_t { MSAT_FALSE = -1, MSAT_UNKNOWN = 0, MSAT_TRUE = 1 }
 

Functions

int Msat_SolverParseDimacs (FILE *pFile, Msat_Solver_t **p, int fVerbose)
 GLOBAL VARIABLES ///. More...
 
int Msat_SolverAddVar (Msat_Solver_t *p, int Level)
 DECLARATIONS ///. More...
 
int Msat_SolverAddClause (Msat_Solver_t *p, Msat_IntVec_t *pLits)
 
int Msat_SolverSimplifyDB (Msat_Solver_t *p)
 
int Msat_SolverSolve (Msat_Solver_t *p, Msat_IntVec_t *pVecAssumps, int nBackTrackLimit, int nTimeLimit)
 
void Msat_SolverPrintStats (Msat_Solver_t *p)
 
void Msat_SolverPrintAssignment (Msat_Solver_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Msat_SolverPrintClauses (Msat_Solver_t *p)
 
void Msat_SolverWriteDimacs (Msat_Solver_t *p, char *pFileName)
 
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_SolverReadAssignsArray (Msat_Solver_t *p)
 
int * Msat_SolverReadModelArray (Msat_Solver_t *p)
 
unsigned Msat_SolverReadTruth (Msat_Solver_t *p)
 
int Msat_SolverReadBackTracks (Msat_Solver_t *p)
 
int Msat_SolverReadInspects (Msat_Solver_t *p)
 
void Msat_SolverSetVerbosity (Msat_Solver_t *p, int fVerbose)
 
void Msat_SolverSetProofWriting (Msat_Solver_t *p, int fProof)
 
void Msat_SolverSetVarTypeA (Msat_Solver_t *p, int Var)
 
void Msat_SolverSetVarMap (Msat_Solver_t *p, Msat_IntVec_t *vVarMap)
 
void Msat_SolverMarkLastClauseTypeA (Msat_Solver_t *p)
 
void Msat_SolverMarkClausesStart (Msat_Solver_t *p)
 
float * Msat_SolverReadFactors (Msat_Solver_t *p)
 
int Msat_SolverReadSolutions (Msat_Solver_t *p)
 
int * Msat_SolverReadSolutionsArray (Msat_Solver_t *p)
 
Msat_ClauseVec_tMsat_SolverReadAdjacents (Msat_Solver_t *p)
 
Msat_IntVec_tMsat_SolverReadConeVars (Msat_Solver_t *p)
 
Msat_IntVec_tMsat_SolverReadVarsUsed (Msat_Solver_t *p)
 
void Msat_SolverRemoveLearned (Msat_Solver_t *p)
 
void Msat_SolverRemoveMarked (Msat_Solver_t *p)
 
Msat_Solver_tMsat_SolverAlloc (int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose)
 
void Msat_SolverResize (Msat_Solver_t *pMan, int nVarsAlloc)
 
void Msat_SolverClean (Msat_Solver_t *p, int nVars)
 
void Msat_SolverPrepare (Msat_Solver_t *pSat, Msat_IntVec_t *vVars)
 
void Msat_SolverFree (Msat_Solver_t *p)
 
Msat_IntVec_tMsat_IntVecAlloc (int nCap)
 FUNCTION DEFINITIONS ///. More...
 
Msat_IntVec_tMsat_IntVecAllocArray (int *pArray, int nSize)
 
Msat_IntVec_tMsat_IntVecAllocArrayCopy (int *pArray, int nSize)
 
Msat_IntVec_tMsat_IntVecDup (Msat_IntVec_t *pVec)
 
Msat_IntVec_tMsat_IntVecDupArray (Msat_IntVec_t *pVec)
 
void Msat_IntVecFree (Msat_IntVec_t *p)
 
void Msat_IntVecFill (Msat_IntVec_t *p, int nSize, int Entry)
 
int * Msat_IntVecReleaseArray (Msat_IntVec_t *p)
 
int * Msat_IntVecReadArray (Msat_IntVec_t *p)
 
int Msat_IntVecReadSize (Msat_IntVec_t *p)
 
int Msat_IntVecReadEntry (Msat_IntVec_t *p, int i)
 
int Msat_IntVecReadEntryLast (Msat_IntVec_t *p)
 
void Msat_IntVecWriteEntry (Msat_IntVec_t *p, int i, int Entry)
 
void Msat_IntVecGrow (Msat_IntVec_t *p, int nCapMin)
 
void Msat_IntVecShrink (Msat_IntVec_t *p, int nSizeNew)
 
void Msat_IntVecClear (Msat_IntVec_t *p)
 
void Msat_IntVecPush (Msat_IntVec_t *p, int Entry)
 
int Msat_IntVecPushUnique (Msat_IntVec_t *p, int Entry)
 
void Msat_IntVecPushUniqueOrder (Msat_IntVec_t *p, int Entry, int fIncrease)
 
int Msat_IntVecPop (Msat_IntVec_t *p)
 
void Msat_IntVecSort (Msat_IntVec_t *p, int fReverse)
 
Msat_VarHeap_tMsat_VarHeapAlloc ()
 
void Msat_VarHeapSetActivity (Msat_VarHeap_t *p, double *pActivity)
 
void Msat_VarHeapStart (Msat_VarHeap_t *p, int *pVars, int nVars, int nVarsAlloc)
 
void Msat_VarHeapGrow (Msat_VarHeap_t *p, int nSize)
 
void Msat_VarHeapStop (Msat_VarHeap_t *p)
 
void Msat_VarHeapPrint (FILE *pFile, Msat_VarHeap_t *p)
 
void Msat_VarHeapCheck (Msat_VarHeap_t *p)
 
void Msat_VarHeapCheckOne (Msat_VarHeap_t *p, int iVar)
 
int Msat_VarHeapContainsVar (Msat_VarHeap_t *p, int iVar)
 
void Msat_VarHeapInsert (Msat_VarHeap_t *p, int iVar)
 
void Msat_VarHeapUpdate (Msat_VarHeap_t *p, int iVar)
 
void Msat_VarHeapDelete (Msat_VarHeap_t *p, int iVar)
 
double Msat_VarHeapReadMaxWeight (Msat_VarHeap_t *p)
 
int Msat_VarHeapCountNodes (Msat_VarHeap_t *p, double WeightLimit)
 
int Msat_VarHeapReadMax (Msat_VarHeap_t *p)
 
int Msat_VarHeapGetMax (Msat_VarHeap_t *p)
 

Macro Definition Documentation

#define MSAT_LIT2VAR (   l)    ((l)>>1)

Definition at line 59 of file msat.h.

#define MSAT_LITNOT (   l)    ((l)^1)

Definition at line 57 of file msat.h.

#define MSAT_LITSIGN (   l)    ((l)&1)

Definition at line 58 of file msat.h.

#define MSAT_VAR2LIT (   v,
 
)    (2*(v)+(s))

Definition at line 56 of file msat.h.

Typedef Documentation

Definition at line 46 of file msat.h.

typedef struct Msat_IntVec_t_ Msat_IntVec_t

Definition at line 45 of file msat.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Msat_Solver_t_ Msat_Solver_t

INCLUDES ///.

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

FileName [msat.h]

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 [External definitions of the 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:
msat.h,v 1.6 2004/05/12 06:30:20 satrajit Exp

]PARAMETERS ///STRUCTURE DEFINITIONS ///

Definition at line 42 of file msat.h.

typedef struct Msat_VarHeap_t_ Msat_VarHeap_t

Definition at line 47 of file msat.h.

Enumeration Type Documentation

Enumerator
MSAT_FALSE 
MSAT_UNKNOWN 
MSAT_TRUE 

Definition at line 50 of file msat.h.

50 { MSAT_FALSE = -1, MSAT_UNKNOWN = 0, MSAT_TRUE = 1 } Msat_Type_t;
Msat_Type_t
Definition: msat.h:50
Definition: msat.h:50

Function Documentation

Msat_IntVec_t* Msat_IntVecAlloc ( int  nCap)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file msatVec.c.

49 {
50  Msat_IntVec_t * p;
51  p = ABC_ALLOC( Msat_IntVec_t, 1 );
52  if ( nCap > 0 && nCap < 16 )
53  nCap = 16;
54  p->nSize = 0;
55  p->nCap = nCap;
56  p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
57  return p;
58 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pArray
Definition: msatInt.h:164
Msat_IntVec_t* Msat_IntVecAllocArray ( int *  pArray,
int  nSize 
)

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

Synopsis [Creates the vector from an integer array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file msatVec.c.

72 {
73  Msat_IntVec_t * p;
74  p = ABC_ALLOC( Msat_IntVec_t, 1 );
75  p->nSize = nSize;
76  p->nCap = nSize;
77  p->pArray = pArray;
78  return p;
79 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pArray
Definition: msatInt.h:164
Msat_IntVec_t* Msat_IntVecAllocArrayCopy ( int *  pArray,
int  nSize 
)

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

Synopsis [Creates the vector from an integer array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file msatVec.c.

93 {
94  Msat_IntVec_t * p;
95  p = ABC_ALLOC( Msat_IntVec_t, 1 );
96  p->nSize = nSize;
97  p->nCap = nSize;
98  p->pArray = ABC_ALLOC( int, nSize );
99  memcpy( p->pArray, pArray, sizeof(int) * nSize );
100  return p;
101 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * memcpy()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pArray
Definition: msatInt.h:164
void Msat_IntVecClear ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file msatVec.c.

336 {
337  p->nSize = 0;
338 }
Msat_IntVec_t* Msat_IntVecDup ( Msat_IntVec_t pVec)

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

Synopsis [Duplicates the integer array.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file msatVec.c.

115 {
116  Msat_IntVec_t * p;
117  p = ABC_ALLOC( Msat_IntVec_t, 1 );
118  p->nSize = pVec->nSize;
119  p->nCap = pVec->nCap;
120  p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
121  memcpy( p->pArray, pVec->pArray, sizeof(int) * pVec->nSize );
122  return p;
123 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * memcpy()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pArray
Definition: msatInt.h:164
Msat_IntVec_t* Msat_IntVecDupArray ( Msat_IntVec_t pVec)

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

Synopsis [Transfers the array into another vector.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file msatVec.c.

137 {
138  Msat_IntVec_t * p;
139  p = ABC_ALLOC( Msat_IntVec_t, 1 );
140  p->nSize = pVec->nSize;
141  p->nCap = pVec->nCap;
142  p->pArray = pVec->pArray;
143  pVec->nSize = 0;
144  pVec->nCap = 0;
145  pVec->pArray = NULL;
146  return p;
147 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pArray
Definition: msatInt.h:164
void Msat_IntVecFill ( Msat_IntVec_t p,
int  nSize,
int  Entry 
)

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

Synopsis [Fills the vector with given number of entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file msatVec.c.

178 {
179  int i;
180  Msat_IntVecGrow( p, nSize );
181  p->nSize = nSize;
182  for ( i = 0; i < p->nSize; i++ )
183  p->pArray[i] = Entry;
184 }
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition: msatVec.c:299
int * pArray
Definition: msatInt.h:164
void Msat_IntVecFree ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file msatVec.c.

161 {
162  ABC_FREE( p->pArray );
163  ABC_FREE( p );
164 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * pArray
Definition: msatInt.h:164
void Msat_IntVecGrow ( Msat_IntVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file msatVec.c.

300 {
301  if ( p->nCap >= nCapMin )
302  return;
303  p->pArray = ABC_REALLOC( int, p->pArray, nCapMin );
304  p->nCap = nCapMin;
305 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int * pArray
Definition: msatInt.h:164
int Msat_IntVecPop ( Msat_IntVec_t p)

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

Synopsis [Returns the last entry and removes it from the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file msatVec.c.

426 {
427  assert( p->nSize > 0 );
428  return p->pArray[--p->nSize];
429 }
#define assert(ex)
Definition: util_old.h:213
int * pArray
Definition: msatInt.h:164
void Msat_IntVecPush ( Msat_IntVec_t p,
int  Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 351 of file msatVec.c.

352 {
353  if ( p->nSize == p->nCap )
354  {
355  if ( p->nCap < 16 )
356  Msat_IntVecGrow( p, 16 );
357  else
358  Msat_IntVecGrow( p, 2 * p->nCap );
359  }
360  p->pArray[p->nSize++] = Entry;
361 }
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition: msatVec.c:299
int * pArray
Definition: msatInt.h:164
int Msat_IntVecPushUnique ( Msat_IntVec_t p,
int  Entry 
)

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

Synopsis [Add the element while ensuring uniqueness.]

Description [Returns 1 if the element was found, and 0 if it was new. ]

SideEffects []

SeeAlso []

Definition at line 374 of file msatVec.c.

375 {
376  int i;
377  for ( i = 0; i < p->nSize; i++ )
378  if ( p->pArray[i] == Entry )
379  return 1;
380  Msat_IntVecPush( p, Entry );
381  return 0;
382 }
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:351
int * pArray
Definition: msatInt.h:164
void Msat_IntVecPushUniqueOrder ( Msat_IntVec_t p,
int  Entry,
int  fIncrease 
)

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

Synopsis [Inserts the element while sorting in the increasing order.]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file msatVec.c.

396 {
397  int Entry1, Entry2;
398  int i;
399  Msat_IntVecPushUnique( p, Entry );
400  // find the p of the node
401  for ( i = p->nSize-1; i > 0; i-- )
402  {
403  Entry1 = p->pArray[i ];
404  Entry2 = p->pArray[i-1];
405  if (( fIncrease && Entry1 >= Entry2) ||
406  (!fIncrease && Entry1 <= Entry2) )
407  break;
408  p->pArray[i ] = Entry2;
409  p->pArray[i-1] = Entry1;
410  }
411 }
int * pArray
Definition: msatInt.h:164
int Msat_IntVecPushUnique(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:374
int* Msat_IntVecReadArray ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file msatVec.c.

218 {
219  return p->pArray;
220 }
int * pArray
Definition: msatInt.h:164
int Msat_IntVecReadEntry ( Msat_IntVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file msatVec.c.

250 {
251  assert( i >= 0 && i < p->nSize );
252  return p->pArray[i];
253 }
#define assert(ex)
Definition: util_old.h:213
int * pArray
Definition: msatInt.h:164
int Msat_IntVecReadEntryLast ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file msatVec.c.

284 {
285  return p->pArray[p->nSize-1];
286 }
int * pArray
Definition: msatInt.h:164
int Msat_IntVecReadSize ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 233 of file msatVec.c.

234 {
235  return p->nSize;
236 }
int* Msat_IntVecReleaseArray ( Msat_IntVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file msatVec.c.

198 {
199  int * pArray = p->pArray;
200  p->nCap = 0;
201  p->nSize = 0;
202  p->pArray = NULL;
203  return pArray;
204 }
int * pArray
Definition: msatInt.h:164
void Msat_IntVecShrink ( Msat_IntVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 318 of file msatVec.c.

319 {
320  assert( p->nSize >= nSizeNew );
321  p->nSize = nSizeNew;
322 }
#define assert(ex)
Definition: util_old.h:213
void Msat_IntVecSort ( Msat_IntVec_t p,
int  fReverse 
)

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file msatVec.c.

443 {
444  if ( fReverse )
445  qsort( (void *)p->pArray, p->nSize, sizeof(int),
446  (int (*)(const void *, const void *)) Msat_IntVecSortCompare2 );
447  else
448  qsort( (void *)p->pArray, p->nSize, sizeof(int),
449  (int (*)(const void *, const void *)) Msat_IntVecSortCompare1 );
450 }
static int Msat_IntVecSortCompare2(int *pp1, int *pp2)
Definition: msatVec.c:484
int * pArray
Definition: msatInt.h:164
static ABC_NAMESPACE_IMPL_START int Msat_IntVecSortCompare1(int *pp1, int *pp2)
DECLARATIONS ///.
Definition: msatVec.c:463
void Msat_IntVecWriteEntry ( Msat_IntVec_t p,
int  i,
int  Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file msatVec.c.

267 {
268  assert( i >= 0 && i < p->nSize );
269  p->pArray[i] = Entry;
270 }
#define assert(ex)
Definition: util_old.h:213
int * pArray
Definition: msatInt.h:164
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 }
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
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
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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverResize(Msat_Solver_t *pMan, int nVarsAlloc)
int nVars
Definition: llb3Image.c:58
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_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
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)
int Msat_SolverParseDimacs ( FILE *  pFile,
Msat_Solver_t **  p,
int  fVerbose 
)

GLOBAL VARIABLES ///.

MACRO DEFINITIONS ///FUNCTION DECLARATIONS ///

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

Synopsis [Starts the solver and reads the DIMAC file.]

Description [Returns FALSE upon immediate conflict.]

SideEffects []

SeeAlso []

Definition at line 258 of file msatRead.c.

259 {
260  char * pText;
261  int Value;
262  pText = Msat_FileRead( pFile );
263  Value = Msat_ReadDimacs( pText, p, fVerbose );
264  ABC_FREE( pText );
265  return Value;
266 }
static ABC_NAMESPACE_IMPL_START char * Msat_FileRead(FILE *pFile)
DECLARATIONS ///.
Definition: msatRead.c:47
static int Msat_ReadDimacs(char *pText, Msat_Solver_t **pS, int fVerbose)
Definition: msatRead.c:201
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
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
void Msat_SolverPrintAssignment ( Msat_Solver_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file msatSolverIo.c.

48 {
49  int i;
50  printf( "Current assignments are: \n" );
51  for ( i = 0; i < p->nVars; i++ )
52  printf( "%d", i % 10 );
53  printf( "\n" );
54  for ( i = 0; i < p->nVars; i++ )
55  if ( p->pAssigns[i] == MSAT_VAR_UNASSIGNED )
56  printf( "." );
57  else
58  {
59  assert( i == MSAT_LIT2VAR(p->pAssigns[i]) );
60  if ( MSAT_LITSIGN(p->pAssigns[i]) )
61  printf( "0" );
62  else
63  printf( "1" );
64  }
65  printf( "\n" );
66 }
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
#define MSAT_LITSIGN(l)
Definition: msat.h:58
#define assert(ex)
Definition: util_old.h:213
int nVars
Definition: llb3Image.c:58
void Msat_SolverPrintClauses ( Msat_Solver_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file msatSolverIo.c.

80 {
81  Msat_Clause_t ** pClauses;
82  int nClauses, i;
83 
84  printf( "Original clauses: \n" );
85  nClauses = Msat_ClauseVecReadSize( p->vClauses );
86  pClauses = Msat_ClauseVecReadArray( p->vClauses );
87  for ( i = 0; i < nClauses; i++ )
88  {
89  printf( "%3d: ", i );
90  Msat_ClausePrint( pClauses[i] );
91  }
92 
93  printf( "Learned clauses: \n" );
94  nClauses = Msat_ClauseVecReadSize( p->vLearned );
95  pClauses = Msat_ClauseVecReadArray( p->vLearned );
96  for ( i = 0; i < nClauses; i++ )
97  {
98  printf( "%3d: ", i );
99  Msat_ClausePrint( pClauses[i] );
100  }
101 
102  printf( "Variable activity: \n" );
103  for ( i = 0; i < p->nVars; i++ )
104  printf( "%3d : %.4f\n", i, p->pdActivity[i] );
105 }
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)
void Msat_ClausePrint(Msat_Clause_t *pC)
Definition: msatClause.c:468
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
int nVars
Definition: llb3Image.c:58
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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
int nVars
Definition: llb3Image.c:58
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
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
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
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
int Msat_SolverReadSolutions ( Msat_Solver_t p)
int* Msat_SolverReadSolutionsArray ( Msat_Solver_t p)
unsigned Msat_SolverReadTruth ( Msat_Solver_t p)
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
void Msat_SolverRemoveLearned ( Msat_Solver_t p)

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

Synopsis [Removes the learned clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 371 of file msatSolverSearch.c.

372 {
373  Msat_Clause_t ** pLearned;
374  int nLearned, i;
375 
376  // discard the learned clauses
377  nLearned = Msat_ClauseVecReadSize( p->vLearned );
378  pLearned = Msat_ClauseVecReadArray( p->vLearned );
379  for ( i = 0; i < nLearned; i++ )
380  {
381  assert( !Msat_ClauseIsLocked( p, pLearned[i]) );
382 
383  Msat_ClauseFree( p, pLearned[i], 1 );
384  }
385  Msat_ClauseVecShrink( p->vLearned, 0 );
386  p->nClauses = Msat_ClauseVecReadSize(p->vClauses);
387 
388  for ( i = 0; i < p->nVarsAlloc; i++ )
389  p->pReasons[i] = NULL;
390 }
void Msat_ClauseFree(Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
Definition: msatClause.c:223
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_ClauseIsLocked(Msat_Solver_t *p, Msat_Clause_t *pC)
Definition: msatClause.c:278
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_ClauseVecShrink(Msat_ClauseVec_t *p, int nSizeNew)
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
#define assert(ex)
Definition: util_old.h:213
void Msat_SolverRemoveMarked ( Msat_Solver_t p)

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

Synopsis [Removes the recently added clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 403 of file msatSolverSearch.c.

404 {
405  Msat_Clause_t ** pLearned, ** pClauses;
406  int nLearned, nClauses, i;
407 
408  // discard the learned clauses
409  nClauses = Msat_ClauseVecReadSize( p->vClauses );
410  pClauses = Msat_ClauseVecReadArray( p->vClauses );
411  for ( i = p->nClausesStart; i < nClauses; i++ )
412  {
413 // assert( !Msat_ClauseIsLocked( p, pClauses[i]) );
414  Msat_ClauseFree( p, pClauses[i], 1 );
415  }
416  Msat_ClauseVecShrink( p->vClauses, p->nClausesStart );
417 
418  // discard the learned clauses
419  nLearned = Msat_ClauseVecReadSize( p->vLearned );
420  pLearned = Msat_ClauseVecReadArray( p->vLearned );
421  for ( i = 0; i < nLearned; i++ )
422  {
423 // assert( !Msat_ClauseIsLocked( p, pLearned[i]) );
424  Msat_ClauseFree( p, pLearned[i], 1 );
425  }
426  Msat_ClauseVecShrink( p->vLearned, 0 );
427  p->nClauses = Msat_ClauseVecReadSize(p->vClauses);
428 /*
429  // undo the previous data
430  for ( i = 0; i < p->nVarsAlloc; i++ )
431  {
432  p->pAssigns[i] = MSAT_VAR_UNASSIGNED;
433  p->pReasons[i] = NULL;
434  p->pLevel[i] = -1;
435  p->pdActivity[i] = 0.0;
436  }
437  Msat_OrderClean( p->pOrder, p->nVars, NULL );
438  Msat_QueueClear( p->pQueue );
439 */
440 }
void Msat_ClauseFree(Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
Definition: msatClause.c:223
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)
void Msat_ClauseVecShrink(Msat_ClauseVec_t *p, int nSizeNew)
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
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_SolverSetProofWriting ( Msat_Solver_t p,
int  fProof 
)
void Msat_SolverSetVarMap ( Msat_Solver_t p,
Msat_IntVec_t vVarMap 
)
void Msat_SolverSetVarTypeA ( Msat_Solver_t p,
int  Var 
)
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
int Msat_SolverSimplifyDB ( Msat_Solver_t p)

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

Synopsis [Simplifies the data base.]

Description [Simplify all constraints according to the current top-level assigment (redundant constraints may be removed altogether).]

SideEffects []

SeeAlso []

Definition at line 282 of file msatSolverSearch.c.

283 {
284  Msat_ClauseVec_t * vClauses;
285  Msat_Clause_t ** pClauses;
286  int nClauses, Type, i, j;
287  int * pAssigns;
288  int Counter;
289 
291  if ( Msat_SolverPropagate(p) != NULL )
292  return 0;
293 //Msat_SolverPrintClauses( p );
294 //Msat_SolverPrintAssignment( p );
295 //printf( "Simplification\n" );
296 
297  // simplify and reassign clause numbers
298  Counter = 0;
299  pAssigns = Msat_SolverReadAssignsArray( p );
300  for ( Type = 0; Type < 2; Type++ )
301  {
302  vClauses = Type? p->vLearned : p->vClauses;
303  nClauses = Msat_ClauseVecReadSize( vClauses );
304  pClauses = Msat_ClauseVecReadArray( vClauses );
305  for ( i = j = 0; i < nClauses; i++ )
306  if ( Msat_ClauseSimplify( pClauses[i], pAssigns ) )
307  Msat_ClauseFree( p, pClauses[i], 1 );
308  else
309  {
310  pClauses[j++] = pClauses[i];
311  Msat_ClauseSetNum( pClauses[i], Counter++ );
312  }
313  Msat_ClauseVecShrink( vClauses, j );
314  }
315  p->nClauses = Counter;
316  return 1;
317 }
int Msat_SolverReadDecisionLevel(Msat_Solver_t *p)
Definition: msatSolverApi.c:50
void Msat_ClauseFree(Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
Definition: msatClause.c:223
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_Clause_t * Msat_SolverPropagate(Msat_Solver_t *p)
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_ClauseVecShrink(Msat_ClauseVec_t *p, int nSizeNew)
void Msat_ClauseSetNum(Msat_Clause_t *pC, int Num)
Definition: msatClause.c:263
int * Msat_SolverReadAssignsArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:56
int Msat_ClauseSimplify(Msat_Clause_t *pC, int *pAssigns)
Definition: msatClause.c:374
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
static int Counter
#define assert(ex)
Definition: util_old.h:213
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;
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 }
int Msat_SolverReadDecisionLevel(Msat_Solver_t *p)
Definition: msatSolverApi.c:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_QueueClear(Msat_Queue_t *p)
Definition: msatQueue.c:149
Msat_Type_t Msat_SolverSearch(Msat_Solver_t *p, int nConfLimit, int nLearnedLimit, int nBackTrackLimit, Msat_SearchParams_t *pPars)
Msat_Type_t
Definition: msat.h:50
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
static abctime Abc_Clock()
Definition: abc_global.h:279
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
void Msat_SolverCancelUntil(Msat_Solver_t *p, int Level)
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition: msatVec.c:217
Msat_Clause_t * Msat_SolverPropagate(Msat_Solver_t *p)
int Msat_SolverAssume(Msat_Solver_t *p, Msat_Lit_t Lit)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
void Msat_SolverWriteDimacs ( Msat_Solver_t p,
char *  pFileName 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file msatSolverIo.c.

119 {
120  FILE * pFile;
121  Msat_Clause_t ** pClauses;
122  int nClauses, i;
123 
124  nClauses = Msat_ClauseVecReadSize(p->vClauses) + Msat_ClauseVecReadSize(p->vLearned);
125  for ( i = 0; i < p->nVars; i++ )
126  nClauses += ( p->pLevel[i] == 0 );
127 
128  pFile = fopen( pFileName, "wb" );
129  fprintf( pFile, "c Produced by Msat_SolverWriteDimacs() on %s\n", Msat_TimeStamp() );
130  fprintf( pFile, "p cnf %d %d\n", p->nVars, nClauses );
131 
132  nClauses = Msat_ClauseVecReadSize( p->vClauses );
133  pClauses = Msat_ClauseVecReadArray( p->vClauses );
134  for ( i = 0; i < nClauses; i++ )
135  Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
136 
137  nClauses = Msat_ClauseVecReadSize( p->vLearned );
138  pClauses = Msat_ClauseVecReadArray( p->vLearned );
139  for ( i = 0; i < nClauses; i++ )
140  Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
141 
142  // write zero-level assertions
143  for ( i = 0; i < p->nVars; i++ )
144  if ( p->pLevel[i] == 0 )
145  fprintf( pFile, "%s%d 0\n", ((p->pAssigns[i]&1)? "-": ""), i + 1 );
146 
147  fprintf( pFile, "\n" );
148  fclose( pFile );
149 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static ABC_NAMESPACE_IMPL_START char * Msat_TimeStamp()
DECLARATIONS ///.
Definition: msatSolverIo.c:163
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_ClauseWriteDimacs(FILE *pFile, Msat_Clause_t *pC, int fIncrement)
Definition: msatClause.c:494
int nVars
Definition: llb3Image.c:58
Msat_VarHeap_t* Msat_VarHeapAlloc ( )
void Msat_VarHeapCheck ( Msat_VarHeap_t p)
void Msat_VarHeapCheckOne ( Msat_VarHeap_t p,
int  iVar 
)
int Msat_VarHeapContainsVar ( Msat_VarHeap_t p,
int  iVar 
)
int Msat_VarHeapCountNodes ( Msat_VarHeap_t p,
double  WeightLimit 
)
void Msat_VarHeapDelete ( Msat_VarHeap_t p,
int  iVar 
)
int Msat_VarHeapGetMax ( Msat_VarHeap_t p)
void Msat_VarHeapGrow ( Msat_VarHeap_t p,
int  nSize 
)
void Msat_VarHeapInsert ( Msat_VarHeap_t p,
int  iVar 
)
void Msat_VarHeapPrint ( FILE *  pFile,
Msat_VarHeap_t p 
)
int Msat_VarHeapReadMax ( Msat_VarHeap_t p)
double Msat_VarHeapReadMaxWeight ( Msat_VarHeap_t p)
void Msat_VarHeapSetActivity ( Msat_VarHeap_t p,
double *  pActivity 
)
void Msat_VarHeapStart ( Msat_VarHeap_t p,
int *  pVars,
int  nVars,
int  nVarsAlloc 
)
void Msat_VarHeapStop ( Msat_VarHeap_t p)
void Msat_VarHeapUpdate ( Msat_VarHeap_t p,
int  iVar 
)