abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
msatInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "misc/util/abc_global.h"
#include "msat.h"

Go to the source code of this file.

Data Structures

struct  Msat_SolverStats_t_
 
struct  Msat_SearchParams_t_
 
struct  Msat_Solver_t_
 
struct  Msat_ClauseVec_t_
 
struct  Msat_IntVec_t_
 

Macros

#define MSAT_VAR_UNASSIGNED   (-1)
 
#define MSAT_LIT_UNASSIGNED   (-2)
 
#define MSAT_ORDER_UNKNOWN   (-3)
 
#define L_IND   "%-*d"
 
#define L_ind   Msat_SolverReadDecisionLevel(p)*3+3,Msat_SolverReadDecisionLevel(p)
 
#define L_LIT   "%s%d"
 
#define L_lit(Lit)   MSAT_LITSIGN(Lit)?"-":"", MSAT_LIT2VAR(Lit)+1
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Msat_Clause_t_ 
Msat_Clause_t
 INCLUDES ///. More...
 
typedef struct Msat_Queue_t_ Msat_Queue_t
 
typedef struct Msat_Order_t_ Msat_Order_t
 
typedef struct Msat_MmFixed_t_ Msat_MmFixed_t
 
typedef struct Msat_MmFlex_t_ Msat_MmFlex_t
 
typedef struct Msat_MmStep_t_ Msat_MmStep_t
 
typedef int Msat_Lit_t
 
typedef int Msat_Var_t
 
typedef struct Msat_SolverStats_t_ Msat_SolverStats_t
 
typedef struct Msat_SearchParams_t_ Msat_SearchParams_t
 

Functions

void Msat_SolverVarDecayActivity (Msat_Solver_t *p)
 GLOBAL VARIABLES ///. More...
 
void Msat_SolverVarRescaleActivity (Msat_Solver_t *p)
 
void Msat_SolverClaDecayActivity (Msat_Solver_t *p)
 
void Msat_SolverClaRescaleActivity (Msat_Solver_t *p)
 
Msat_Clause_tMsat_SolverReadClause (Msat_Solver_t *p, int Num)
 
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_SolverReadSeenArray (Msat_Solver_t *p)
 
int Msat_SolverIncrementSeenId (Msat_Solver_t *p)
 
Msat_MmStep_tMsat_SolverReadMem (Msat_Solver_t *p)
 
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_SolverVarBumpActivity (Msat_Solver_t *p, Msat_Lit_t Lit)
 DECLARATIONS ///. More...
 
void Msat_SolverClaBumpActivity (Msat_Solver_t *p, Msat_Clause_t *pC)
 
int Msat_SolverEnqueue (Msat_Solver_t *p, Msat_Lit_t Lit, Msat_Clause_t *pC)
 
double Msat_SolverProgressEstimate (Msat_Solver_t *p)
 
int Msat_SolverAssume (Msat_Solver_t *p, Msat_Lit_t Lit)
 FUNCTION DEFINITIONS ///. More...
 
Msat_Clause_tMsat_SolverPropagate (Msat_Solver_t *p)
 
void Msat_SolverCancelUntil (Msat_Solver_t *p, int Level)
 
Msat_Type_t Msat_SolverSearch (Msat_Solver_t *p, int nConfLimit, int nLearnedLimit, int nBackTrackLimit, Msat_SearchParams_t *pPars)
 
Msat_Queue_tMsat_QueueAlloc (int nVars)
 FUNCTION DEFINITIONS ///. More...
 
void Msat_QueueFree (Msat_Queue_t *p)
 
int Msat_QueueReadSize (Msat_Queue_t *p)
 
void Msat_QueueInsert (Msat_Queue_t *p, int Lit)
 
int Msat_QueueExtract (Msat_Queue_t *p)
 
void Msat_QueueClear (Msat_Queue_t *p)
 
Msat_Order_tMsat_OrderAlloc (Msat_Solver_t *pSat)
 FUNCTION DEFINITIONS ///. More...
 
void Msat_OrderSetBounds (Msat_Order_t *p, int nVarsMax)
 
void Msat_OrderClean (Msat_Order_t *p, Msat_IntVec_t *vCone)
 
int Msat_OrderCheck (Msat_Order_t *p)
 
void Msat_OrderFree (Msat_Order_t *p)
 
int Msat_OrderVarSelect (Msat_Order_t *p)
 
void Msat_OrderVarAssigned (Msat_Order_t *p, int Var)
 
void Msat_OrderVarUnassigned (Msat_Order_t *p, int Var)
 
void Msat_OrderUpdate (Msat_Order_t *p, int Var)
 
int Msat_ClauseCreate (Msat_Solver_t *p, Msat_IntVec_t *vLits, int fLearnt, Msat_Clause_t **pClause_out)
 FUNCTION DEFINITIONS ///. More...
 
Msat_Clause_tMsat_ClauseCreateFake (Msat_Solver_t *p, Msat_IntVec_t *vLits)
 
Msat_Clause_tMsat_ClauseCreateFakeLit (Msat_Solver_t *p, Msat_Lit_t Lit)
 
int Msat_ClauseReadLearned (Msat_Clause_t *pC)
 
int Msat_ClauseReadSize (Msat_Clause_t *pC)
 
int * Msat_ClauseReadLits (Msat_Clause_t *pC)
 
int Msat_ClauseReadMark (Msat_Clause_t *pC)
 
void Msat_ClauseSetMark (Msat_Clause_t *pC, int fMark)
 
int Msat_ClauseReadNum (Msat_Clause_t *pC)
 
void Msat_ClauseSetNum (Msat_Clause_t *pC, int Num)
 
int Msat_ClauseReadTypeA (Msat_Clause_t *pC)
 
void Msat_ClauseSetTypeA (Msat_Clause_t *pC, int fTypeA)
 
int Msat_ClauseIsLocked (Msat_Solver_t *p, Msat_Clause_t *pC)
 
float Msat_ClauseReadActivity (Msat_Clause_t *pC)
 
void Msat_ClauseWriteActivity (Msat_Clause_t *pC, float Num)
 
void Msat_ClauseFree (Msat_Solver_t *p, Msat_Clause_t *pC, int fRemoveWatched)
 
int Msat_ClausePropagate (Msat_Clause_t *pC, Msat_Lit_t Lit, int *pAssigns, Msat_Lit_t *pLit_out)
 
int Msat_ClauseSimplify (Msat_Clause_t *pC, int *pAssigns)
 
void Msat_ClauseCalcReason (Msat_Solver_t *p, Msat_Clause_t *pC, Msat_Lit_t Lit, Msat_IntVec_t *vLits_out)
 
void Msat_ClauseRemoveWatch (Msat_ClauseVec_t *vClauses, Msat_Clause_t *pC)
 
void Msat_ClausePrint (Msat_Clause_t *pC)
 
void Msat_ClausePrintSymbols (Msat_Clause_t *pC)
 
void Msat_ClauseWriteDimacs (FILE *pFile, Msat_Clause_t *pC, int fIncrement)
 
unsigned Msat_ClauseComputeTruth (Msat_Solver_t *p, Msat_Clause_t *pC)
 
void Msat_SolverSortDB (Msat_Solver_t *p)
 FUNCTION DEFINITIONS ///. More...
 
Msat_ClauseVec_tMsat_ClauseVecAlloc (int nCap)
 DECLARATIONS ///. More...
 
void Msat_ClauseVecFree (Msat_ClauseVec_t *p)
 
Msat_Clause_t ** Msat_ClauseVecReadArray (Msat_ClauseVec_t *p)
 
int Msat_ClauseVecReadSize (Msat_ClauseVec_t *p)
 
void Msat_ClauseVecGrow (Msat_ClauseVec_t *p, int nCapMin)
 
void Msat_ClauseVecShrink (Msat_ClauseVec_t *p, int nSizeNew)
 
void Msat_ClauseVecClear (Msat_ClauseVec_t *p)
 
void Msat_ClauseVecPush (Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
 
Msat_Clause_tMsat_ClauseVecPop (Msat_ClauseVec_t *p)
 
void Msat_ClauseVecWriteEntry (Msat_ClauseVec_t *p, int i, Msat_Clause_t *Entry)
 
Msat_Clause_tMsat_ClauseVecReadEntry (Msat_ClauseVec_t *p, int i)
 
Msat_MmFixed_tMsat_MmFixedStart (int nEntrySize)
 FUNCTION DEFINITIONS ///. More...
 
void Msat_MmFixedStop (Msat_MmFixed_t *p, int fVerbose)
 
char * Msat_MmFixedEntryFetch (Msat_MmFixed_t *p)
 
void Msat_MmFixedEntryRecycle (Msat_MmFixed_t *p, char *pEntry)
 
void Msat_MmFixedRestart (Msat_MmFixed_t *p)
 
int Msat_MmFixedReadMemUsage (Msat_MmFixed_t *p)
 
Msat_MmFlex_tMsat_MmFlexStart ()
 
void Msat_MmFlexStop (Msat_MmFlex_t *p, int fVerbose)
 
char * Msat_MmFlexEntryFetch (Msat_MmFlex_t *p, int nBytes)
 
int Msat_MmFlexReadMemUsage (Msat_MmFlex_t *p)
 
Msat_MmStep_tMsat_MmStepStart (int nSteps)
 
void Msat_MmStepStop (Msat_MmStep_t *p, int fVerbose)
 
char * Msat_MmStepEntryFetch (Msat_MmStep_t *p, int nBytes)
 
void Msat_MmStepEntryRecycle (Msat_MmStep_t *p, char *pEntry, int nBytes)
 
int Msat_MmStepReadMemUsage (Msat_MmStep_t *p)
 

Macro Definition Documentation

#define L_IND   "%-*d"

Definition at line 73 of file msatInt.h.

Definition at line 74 of file msatInt.h.

#define L_LIT   "%s%d"

Definition at line 75 of file msatInt.h.

#define L_lit (   Lit)    MSAT_LITSIGN(Lit)?"-":"", MSAT_LIT2VAR(Lit)+1

Definition at line 76 of file msatInt.h.

#define MSAT_LIT_UNASSIGNED   (-2)

Definition at line 69 of file msatInt.h.

#define MSAT_ORDER_UNKNOWN   (-3)

Definition at line 70 of file msatInt.h.

#define MSAT_VAR_UNASSIGNED   (-1)

Definition at line 68 of file msatInt.h.

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t

INCLUDES ///.

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

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

]PARAMETERS ///STRUCTURE DEFINITIONS ///

Definition at line 57 of file msatInt.h.

typedef int Msat_Lit_t

Definition at line 65 of file msatInt.h.

Definition at line 61 of file msatInt.h.

typedef struct Msat_MmFlex_t_ Msat_MmFlex_t

Definition at line 62 of file msatInt.h.

typedef struct Msat_MmStep_t_ Msat_MmStep_t

Definition at line 63 of file msatInt.h.

typedef struct Msat_Order_t_ Msat_Order_t

Definition at line 59 of file msatInt.h.

typedef struct Msat_Queue_t_ Msat_Queue_t

Definition at line 58 of file msatInt.h.

Definition at line 89 of file msatInt.h.

Definition at line 78 of file msatInt.h.

typedef int Msat_Var_t

Definition at line 66 of file msatInt.h.

Function Documentation

void Msat_ClauseCalcReason ( Msat_Solver_t p,
Msat_Clause_t pC,
Msat_Lit_t  Lit,
Msat_IntVec_t vLits_out 
)

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

Synopsis [Computes reason of conflict in the given clause.]

Description [If the literal is unassigned, finds the reason by complementing literals in the given cluase (pC). If the literal is assigned, makes sure that this literal is the first one in the clause and computes the complement of all other literals in the clause. Returns the reason in the given array (vLits_out). If the clause is learned, bumps its activity.]

SideEffects []

SeeAlso []

Definition at line 418 of file msatClause.c.

419 {
420  int i;
421  // clear the reason
422  Msat_IntVecClear( vLits_out );
423  assert( Lit == MSAT_LIT_UNASSIGNED || Lit == pC->pData[0] );
424  for ( i = (Lit != MSAT_LIT_UNASSIGNED); i < (int)pC->nSize; i++ )
425  {
426  assert( Msat_SolverReadAssignsArray(p)[MSAT_LIT2VAR(pC->pData[i])] == MSAT_LITNOT(pC->pData[i]) );
427  Msat_IntVecPush( vLits_out, MSAT_LITNOT(pC->pData[i]) );
428  }
429  if ( pC->fLearned )
431 }
#define MSAT_LIT_UNASSIGNED
Definition: msatInt.h:69
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition: msatVec.c:335
#define MSAT_LITNOT(l)
Definition: msat.h:57
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:351
int * Msat_SolverReadAssignsArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:56
#define assert(ex)
Definition: util_old.h:213
void Msat_SolverClaBumpActivity(Msat_Solver_t *p, Msat_Clause_t *pC)
Definition: msatActivity.c:105
unsigned Msat_ClauseComputeTruth ( Msat_Solver_t p,
Msat_Clause_t pC 
)
int Msat_ClauseCreate ( Msat_Solver_t p,
Msat_IntVec_t vLits,
int  fLearned,
Msat_Clause_t **  pClause_out 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates a new clause.]

Description [Returns FALSE if top-level conflict detected (must be handled); TRUE otherwise. 'pClause_out' may be set to NULL if clause is already satisfied by the top-level assignment.]

SideEffects []

SeeAlso []

Definition at line 58 of file msatClause.c.

59 {
60  int * pAssigns = Msat_SolverReadAssignsArray(p);
61  Msat_ClauseVec_t ** pvWatched;
62  Msat_Clause_t * pC;
63  int * pLits;
64  int nLits, i, j;
65  int nBytes;
67  int Sign;
68 
69  *pClause_out = NULL;
70 
71  nLits = Msat_IntVecReadSize(vLits);
72  pLits = Msat_IntVecReadArray(vLits);
73 
74  if ( !fLearned )
75  {
76  int * pSeen = Msat_SolverReadSeenArray( p );
77  int nSeenId;
79  // sorting literals makes the code trace-equivalent
80  // with to the original C++ solver
81  Msat_IntVecSort( vLits, 0 );
82  // increment the counter of seen twice
83  nSeenId = Msat_SolverIncrementSeenId( p );
84  nSeenId = Msat_SolverIncrementSeenId( p );
85  // nSeenId - 1 stands for negative
86  // nSeenId stands for positive
87  // Remove false literals
88 
89  // there is a bug here!!!!
90  // when the same var in opposite polarities is given, it drops one polarity!!!
91 
92  for ( i = j = 0; i < nLits; i++ ) {
93  // get the corresponding variable
94  Var = MSAT_LIT2VAR(pLits[i]);
95  Sign = MSAT_LITSIGN(pLits[i]); // Sign=0 for positive
96  // check if we already saw this variable in the this clause
97  if ( pSeen[Var] >= nSeenId - 1 )
98  {
99  if ( (pSeen[Var] != nSeenId) == Sign ) // the same lit
100  continue;
101  return 1; // two opposite polarity lits -- don't add the clause
102  }
103  // mark the variable as seen
104  pSeen[Var] = nSeenId - !Sign;
105 
106  // analize the value of this literal
107  if ( pAssigns[Var] != MSAT_VAR_UNASSIGNED )
108  {
109  if ( pAssigns[Var] == pLits[i] )
110  return 1; // the clause is always true -- don't add anything
111  // the literal has no impact - skip it
112  continue;
113  }
114  // otherwise, add this literal to the clause
115  pLits[j++] = pLits[i];
116  }
117  Msat_IntVecShrink( vLits, j );
118  nLits = j;
119 /*
120  // the problem with this code is that performance is very
121  // sensitive to the ordering of adjacency lits
122  // the best ordering requires fanins first, next fanouts
123  // this ordering is more convenient to make from FRAIG
124 
125  // create the adjacency information
126  if ( nLits > 2 )
127  {
128  Msat_Var_t VarI, VarJ;
129  Msat_IntVec_t * pAdjI, * pAdjJ;
130 
131  for ( i = 0; i < nLits; i++ )
132  {
133  VarI = MSAT_LIT2VAR(pLits[i]);
134  pAdjI = (Msat_IntVec_t *)p->vAdjacents->pArray[VarI];
135 
136  for ( j = i+1; j < nLits; j++ )
137  {
138  VarJ = MSAT_LIT2VAR(pLits[j]);
139  pAdjJ = (Msat_IntVec_t *)p->vAdjacents->pArray[VarJ];
140 
141  Msat_IntVecPushUniqueOrder( pAdjI, VarJ, 1 );
142  Msat_IntVecPushUniqueOrder( pAdjJ, VarI, 1 );
143  }
144  }
145  }
146 */
147  }
148  // 'vLits' is now the (possibly) reduced vector of literals.
149  if ( nLits == 0 )
150  return 0;
151  if ( nLits == 1 )
152  return Msat_SolverEnqueue( p, pLits[0], NULL );
153 
154  // Allocate clause:
155 // nBytes = sizeof(unsigned)*(nLits + 1 + (int)fLearned);
156  nBytes = sizeof(unsigned)*(nLits + 2 + (int)fLearned);
157 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
158  pC = (Msat_Clause_t *)ABC_ALLOC( char, nBytes );
159 #else
161 #endif
162  pC->Num = p->nClauses++;
163  pC->fTypeA = 0;
164  pC->fMark = 0;
165  pC->fLearned = fLearned;
166  pC->nSize = nLits;
167  pC->nSizeAlloc = nBytes;
168  memcpy( pC->pData, pLits, sizeof(int)*nLits );
169 
170  // For learnt clauses only:
171  if ( fLearned )
172  {
173  int * pLevel = Msat_SolverReadDecisionLevelArray( p );
174  int iLevelMax, iLevelCur, iLitMax;
175 
176  // Put the second watch on the literal with highest decision level:
177  iLitMax = 1;
178  iLevelMax = pLevel[ MSAT_LIT2VAR(pLits[1]) ];
179  for ( i = 2; i < nLits; i++ )
180  {
181  iLevelCur = pLevel[ MSAT_LIT2VAR(pLits[i]) ];
182  assert( iLevelCur != -1 );
183  if ( iLevelMax < iLevelCur )
184  // this is very strange - shouldn't it be???
185  // if ( iLevelMax > iLevelCur )
186  iLevelMax = iLevelCur, iLitMax = i;
187  }
188  pC->pData[1] = pLits[iLitMax];
189  pC->pData[iLitMax] = pLits[1];
190 
191  // Bumping:
192  // (newly learnt clauses should be considered active)
193  Msat_ClauseWriteActivity( pC, 0.0 );
195 // if ( nLits < 20 )
196  for ( i = 0; i < nLits; i++ )
197  {
198  Msat_SolverVarBumpActivity( p, pLits[i] );
199 // Msat_SolverVarBumpActivity( p, pLits[i] );
200 // p->pFreq[ MSAT_LIT2VAR(pLits[i]) ]++;
201  }
202  }
203 
204  // Store clause:
205  pvWatched = Msat_SolverReadWatchedArray( p );
206  Msat_ClauseVecPush( pvWatched[ MSAT_LITNOT(pC->pData[0]) ], pC );
207  Msat_ClauseVecPush( pvWatched[ MSAT_LITNOT(pC->pData[1]) ], pC );
208  *pClause_out = pC;
209  return 1;
210 }
int Msat_SolverReadDecisionLevel(Msat_Solver_t *p)
Definition: msatSolverApi.c:50
int Msat_Var_t
Definition: msatInt.h:66
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
int * Msat_SolverReadSeenArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:61
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * Msat_MmStepEntryFetch(Msat_MmStep_t *p, int nBytes)
Definition: msatMem.c:479
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
int Msat_SolverIncrementSeenId(Msat_Solver_t *p)
Definition: msatSolverApi.c:62
char * memcpy()
#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_SolverEnqueue(Msat_Solver_t *p, Msat_Lit_t Lit, Msat_Clause_t *pC)
ABC_NAMESPACE_IMPL_START void Msat_SolverVarBumpActivity(Msat_Solver_t *p, Msat_Lit_t Lit)
DECLARATIONS ///.
Definition: msatActivity.c:45
void Msat_ClauseWriteActivity(Msat_Clause_t *pC, float Num)
Definition: msatClause.c:314
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
#define MSAT_LITNOT(l)
Definition: msat.h:57
int * Msat_SolverReadAssignsArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:56
void Msat_ClauseVecPush(Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
Msat_MmStep_t * Msat_SolverReadMem(Msat_Solver_t *p)
Definition: msatSolverApi.c:60
#define MSAT_LITSIGN(l)
Definition: msat.h:58
Msat_ClauseVec_t ** Msat_SolverReadWatchedArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:55
void Msat_IntVecShrink(Msat_IntVec_t *p, int nSizeNew)
Definition: msatVec.c:318
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition: msatVec.c:217
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
int * Msat_SolverReadDecisionLevelArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:51
void Msat_IntVecSort(Msat_IntVec_t *p, int fReverse)
Definition: msatVec.c:442
void Msat_SolverClaBumpActivity(Msat_Solver_t *p, Msat_Clause_t *pC)
Definition: msatActivity.c:105
Msat_Clause_t* Msat_ClauseCreateFake ( Msat_Solver_t p,
Msat_IntVec_t vLits 
)
Msat_Clause_t* Msat_ClauseCreateFakeLit ( Msat_Solver_t p,
Msat_Lit_t  Lit 
)
void Msat_ClauseFree ( Msat_Solver_t p,
Msat_Clause_t pC,
int  fRemoveWatched 
)

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

Synopsis [Deallocates the clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file msatClause.c.

224 {
225  if ( fRemoveWatched )
226  {
227  Msat_Lit_t Lit;
228  Msat_ClauseVec_t ** pvWatched;
229  pvWatched = Msat_SolverReadWatchedArray( p );
230  Lit = MSAT_LITNOT( pC->pData[0] );
231  Msat_ClauseRemoveWatch( pvWatched[Lit], pC );
232  Lit = MSAT_LITNOT( pC->pData[1] );
233  Msat_ClauseRemoveWatch( pvWatched[Lit], pC );
234  }
235 
236 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
237  ABC_FREE( pC );
238 #else
239  Msat_MmStepEntryRecycle( Msat_SolverReadMem(p), (char *)pC, pC->nSizeAlloc );
240 #endif
241 
242 }
void Msat_ClauseRemoveWatch(Msat_ClauseVec_t *vClauses, Msat_Clause_t *pC)
Definition: msatClause.c:444
void Msat_MmStepEntryRecycle(Msat_MmStep_t *p, char *pEntry, int nBytes)
Definition: msatMem.c:503
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_Lit_t
Definition: msatInt.h:65
#define MSAT_LITNOT(l)
Definition: msat.h:57
Msat_MmStep_t * Msat_SolverReadMem(Msat_Solver_t *p)
Definition: msatSolverApi.c:60
Msat_ClauseVec_t ** Msat_SolverReadWatchedArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:55
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Msat_ClauseIsLocked ( Msat_Solver_t p,
Msat_Clause_t pC 
)

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

Synopsis [Checks whether the learned clause is locked.]

Description [The clause may be locked if it is the reason of a recent conflict. Such clause cannot be removed from the database.]

SideEffects []

SeeAlso []

Definition at line 278 of file msatClause.c.

279 {
280  Msat_Clause_t ** pReasons = Msat_SolverReadReasonArray( p );
281  return (int )(pReasons[MSAT_LIT2VAR(pC->pData[0])] == pC);
282 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
Msat_Clause_t ** Msat_SolverReadReasonArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:52
void Msat_ClausePrint ( Msat_Clause_t pC)

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

Synopsis [Prints the given clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 468 of file msatClause.c.

469 {
470  int i;
471  if ( pC == NULL )
472  printf( "NULL pointer" );
473  else
474  {
475  if ( pC->fLearned )
476  printf( "Act = %.4f ", Msat_ClauseReadActivity(pC) );
477  for ( i = 0; i < (int)pC->nSize; i++ )
478  printf( " %s%d", ((pC->pData[i]&1)? "-": ""), pC->pData[i]/2 + 1 );
479  }
480  printf( "\n" );
481 }
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
void Msat_ClausePrintSymbols ( Msat_Clause_t pC)

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

Synopsis [Prints the given clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 515 of file msatClause.c.

516 {
517  int i;
518  if ( pC == NULL )
519  printf( "NULL pointer" );
520  else
521  {
522 // if ( pC->fLearned )
523 // printf( "Act = %.4f ", Msat_ClauseReadActivity(pC) );
524  for ( i = 0; i < (int)pC->nSize; i++ )
525  printf(" "L_LIT, L_lit(pC->pData[i]));
526  }
527  printf( "\n" );
528 }
#define L_lit(p)
Definition: satSolver.c:43
#define L_LIT
Definition: satSolver.c:42
int Msat_ClausePropagate ( Msat_Clause_t pC,
Msat_Lit_t  Lit,
int *  pAssigns,
Msat_Lit_t pLit_out 
)

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

Synopsis [Propages the assignment.]

Description [The literal that has become true (Lit) is given to this procedure. The array of current variable assignments is given for efficiency. The output literal (pLit_out) can be the second watched literal (if TRUE is returned) or the conflict literal (if FALSE is returned). This messy interface is used to improve performance. This procedure accounts for ~50% of the runtime of the solver.]

SideEffects []

SeeAlso []

Definition at line 335 of file msatClause.c.

336 {
337  // make sure the false literal is pC->pData[1]
338  Msat_Lit_t LitF = MSAT_LITNOT(Lit);
339  if ( pC->pData[0] == LitF )
340  pC->pData[0] = pC->pData[1], pC->pData[1] = LitF;
341  assert( pC->pData[1] == LitF );
342  // if the 0-th watch is true, clause is already satisfied
343  if ( pAssigns[MSAT_LIT2VAR(pC->pData[0])] == pC->pData[0] )
344  return 1;
345  // look for a new watch
346  if ( pC->nSize > 2 )
347  {
348  int i;
349  for ( i = 2; i < (int)pC->nSize; i++ )
350  if ( pAssigns[MSAT_LIT2VAR(pC->pData[i])] != MSAT_LITNOT(pC->pData[i]) )
351  {
352  pC->pData[1] = pC->pData[i], pC->pData[i] = LitF;
353  *pLit_out = MSAT_LITNOT(pC->pData[1]);
354  return 1;
355  }
356  }
357  // clause is unit under assignment
358  *pLit_out = pC->pData[0];
359  return 0;
360 }
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
int Msat_Lit_t
Definition: msatInt.h:65
#define MSAT_LITNOT(l)
Definition: msat.h:57
#define assert(ex)
Definition: util_old.h:213
float Msat_ClauseReadActivity ( Msat_Clause_t pC)

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

Synopsis [Reads the activity of the given clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 295 of file msatClause.c.

296 {
297  float f;
298 
299  memcpy( &f, pC->pData + pC->nSize, sizeof (f));
300  return f;
301 }
char * memcpy()
int Msat_ClauseReadLearned ( Msat_Clause_t pC)

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

Synopsis [Access the data field of the clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file msatClause.c.

255 { return pC->fLearned; }
int* Msat_ClauseReadLits ( Msat_Clause_t pC)

Definition at line 257 of file msatClause.c.

257 { return pC->pData; }
int Msat_ClauseReadMark ( Msat_Clause_t pC)

Definition at line 258 of file msatClause.c.

258 { return pC->fMark; }
int Msat_ClauseReadNum ( Msat_Clause_t pC)

Definition at line 259 of file msatClause.c.

259 { return pC->Num; }
int Msat_ClauseReadSize ( Msat_Clause_t pC)

Definition at line 256 of file msatClause.c.

256 { return pC->nSize; }
int Msat_ClauseReadTypeA ( Msat_Clause_t pC)

Definition at line 260 of file msatClause.c.

260 { return pC->fTypeA; }
void Msat_ClauseRemoveWatch ( Msat_ClauseVec_t vClauses,
Msat_Clause_t pC 
)

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

Synopsis [Removes the given clause from the watched list.]

Description []

SideEffects []

SeeAlso []

Definition at line 444 of file msatClause.c.

445 {
446  Msat_Clause_t ** pClauses;
447  int nClauses, i;
448  nClauses = Msat_ClauseVecReadSize( vClauses );
449  pClauses = Msat_ClauseVecReadArray( vClauses );
450  for ( i = 0; pClauses[i] != pC; i++ )
451  assert( i < nClauses );
452  for ( ; i < nClauses - 1; i++ )
453  pClauses[i] = pClauses[i+1];
454  Msat_ClauseVecPop( vClauses );
455 }
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
Msat_Clause_t * Msat_ClauseVecPop(Msat_ClauseVec_t *p)
#define assert(ex)
Definition: util_old.h:213
void Msat_ClauseSetMark ( Msat_Clause_t pC,
int  fMark 
)

Definition at line 262 of file msatClause.c.

262 { pC->fMark = fMark; }
void Msat_ClauseSetNum ( Msat_Clause_t pC,
int  Num 
)

Definition at line 263 of file msatClause.c.

263 { pC->Num = Num; }
void Msat_ClauseSetTypeA ( Msat_Clause_t pC,
int  fTypeA 
)

Definition at line 264 of file msatClause.c.

264 { pC->fTypeA = fTypeA; }
int Msat_ClauseSimplify ( Msat_Clause_t pC,
int *  pAssigns 
)

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

Synopsis [Simplifies the clause.]

Description [Assumes everything has been propagated! (esp. watches in clauses are NOT unsatisfied)]

SideEffects []

SeeAlso []

Definition at line 374 of file msatClause.c.

375 {
376  Msat_Var_t Var;
377  int i, j;
378  for ( i = j = 0; i < (int)pC->nSize; i++ )
379  {
380  Var = MSAT_LIT2VAR(pC->pData[i]);
381  if ( pAssigns[Var] == MSAT_VAR_UNASSIGNED )
382  {
383  pC->pData[j++] = pC->pData[i];
384  continue;
385  }
386  if ( pAssigns[Var] == pC->pData[i] )
387  return 1;
388  // otherwise, the value of the literal is false
389  // make sure, this literal is not watched
390  assert( i >= 2 );
391  }
392  // if the size has changed, update it and move activity
393  if ( j < (int)pC->nSize )
394  {
395  float Activ = Msat_ClauseReadActivity(pC);
396  pC->nSize = j;
397  Msat_ClauseWriteActivity(pC, Activ);
398  }
399  return 0;
400 }
int Msat_Var_t
Definition: msatInt.h:66
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
void Msat_ClauseWriteActivity(Msat_Clause_t *pC, float Num)
Definition: msatClause.c:314
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
Msat_ClauseVec_t* Msat_ClauseVecAlloc ( int  nCap)

DECLARATIONS ///.

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

FileName [msatClauseVec.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 [Procedures working with arrays of SAT clauses.]

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

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file msatClauseVec.c.

46 {
48  p = ABC_ALLOC( Msat_ClauseVec_t, 1 );
49  if ( nCap > 0 && nCap < 16 )
50  nCap = 16;
51  p->nSize = 0;
52  p->nCap = nCap;
53  p->pArray = p->nCap? ABC_ALLOC( Msat_Clause_t *, p->nCap ) : NULL;
54  return p;
55 }
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
Msat_Clause_t ** pArray
Definition: msatInt.h:157
void Msat_ClauseVecClear ( Msat_ClauseVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file msatClauseVec.c.

154 {
155  p->nSize = 0;
156 }
void Msat_ClauseVecFree ( Msat_ClauseVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file msatClauseVec.c.

69 {
70  ABC_FREE( p->pArray );
71  ABC_FREE( p );
72 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
Msat_Clause_t ** pArray
Definition: msatInt.h:157
void Msat_ClauseVecGrow ( Msat_ClauseVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file msatClauseVec.c.

118 {
119  if ( p->nCap >= nCapMin )
120  return;
121  p->pArray = ABC_REALLOC( Msat_Clause_t *, p->pArray, nCapMin );
122  p->nCap = nCapMin;
123 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
Msat_Clause_t ** pArray
Definition: msatInt.h:157
Msat_Clause_t* Msat_ClauseVecPop ( Msat_ClauseVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file msatClauseVec.c.

193 {
194  return p->pArray[--p->nSize];
195 }
Msat_Clause_t ** pArray
Definition: msatInt.h:157
void Msat_ClauseVecPush ( Msat_ClauseVec_t p,
Msat_Clause_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 169 of file msatClauseVec.c.

170 {
171  if ( p->nSize == p->nCap )
172  {
173  if ( p->nCap < 16 )
174  Msat_ClauseVecGrow( p, 16 );
175  else
176  Msat_ClauseVecGrow( p, 2 * p->nCap );
177  }
178  p->pArray[p->nSize++] = Entry;
179 }
void Msat_ClauseVecGrow(Msat_ClauseVec_t *p, int nCapMin)
Msat_Clause_t ** pArray
Definition: msatInt.h:157
Msat_Clause_t** Msat_ClauseVecReadArray ( Msat_ClauseVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file msatClauseVec.c.

86 {
87  return p->pArray;
88 }
Msat_Clause_t ** pArray
Definition: msatInt.h:157
Msat_Clause_t* Msat_ClauseVecReadEntry ( Msat_ClauseVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file msatClauseVec.c.

226 {
227  assert( i >= 0 && i < p->nSize );
228  return p->pArray[i];
229 }
Msat_Clause_t ** pArray
Definition: msatInt.h:157
#define assert(ex)
Definition: util_old.h:213
int Msat_ClauseVecReadSize ( Msat_ClauseVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file msatClauseVec.c.

102 {
103  return p->nSize;
104 }
void Msat_ClauseVecShrink ( Msat_ClauseVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file msatClauseVec.c.

137 {
138  assert( p->nSize >= nSizeNew );
139  p->nSize = nSizeNew;
140 }
#define assert(ex)
Definition: util_old.h:213
void Msat_ClauseVecWriteEntry ( Msat_ClauseVec_t p,
int  i,
Msat_Clause_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file msatClauseVec.c.

209 {
210  assert( i >= 0 && i < p->nSize );
211  p->pArray[i] = Entry;
212 }
Msat_Clause_t ** pArray
Definition: msatInt.h:157
#define assert(ex)
Definition: util_old.h:213
void Msat_ClauseWriteActivity ( Msat_Clause_t pC,
float  Num 
)

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

Synopsis [Sets the activity of the clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 314 of file msatClause.c.

315 {
316  memcpy( pC->pData + pC->nSize, &Num, sizeof (Num) );
317 }
char * memcpy()
void Msat_ClauseWriteDimacs ( FILE *  pFile,
Msat_Clause_t pC,
int  fIncrement 
)

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

Synopsis [Writes the given clause in a file in DIMACS format.]

Description []

SideEffects []

SeeAlso []

Definition at line 494 of file msatClause.c.

495 {
496  int i;
497  for ( i = 0; i < (int)pC->nSize; i++ )
498  fprintf( pFile, "%s%d ", ((pC->pData[i]&1)? "-": ""), pC->pData[i]/2 + (int)(fIncrement>0) );
499  if ( fIncrement )
500  fprintf( pFile, "0" );
501  fprintf( pFile, "\n" );
502 }
char* Msat_MmFixedEntryFetch ( Msat_MmFixed_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file msatMem.c.

162 {
163  char * pTemp;
164  int i;
165 
166  // check if there are still free entries
167  if ( p->nEntriesUsed == p->nEntriesAlloc )
168  { // need to allocate more entries
169  assert( p->pEntriesFree == NULL );
170  if ( p->nChunks == p->nChunksAlloc )
171  {
172  p->nChunksAlloc *= 2;
173  p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
174  }
175  p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
176  p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
177  // transform these entries into a linked list
178  pTemp = p->pEntriesFree;
179  for ( i = 1; i < p->nChunkSize; i++ )
180  {
181  *((char **)pTemp) = pTemp + p->nEntrySize;
182  pTemp += p->nEntrySize;
183  }
184  // set the last link
185  *((char **)pTemp) = NULL;
186  // add the chunk to the chunk storage
187  p->pChunks[ p->nChunks++ ] = p->pEntriesFree;
188  // add to the number of entries allocated
189  p->nEntriesAlloc += p->nChunkSize;
190  }
191  // incrememt the counter of used entries
192  p->nEntriesUsed++;
193  if ( p->nEntriesMax < p->nEntriesUsed )
194  p->nEntriesMax = p->nEntriesUsed;
195  // return the first entry in the free entry list
196  pTemp = p->pEntriesFree;
197  p->pEntriesFree = *((char **)pTemp);
198  return pTemp;
199 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pEntriesFree
Definition: msatMem.c:37
int nEntriesMax
Definition: msatMem.c:36
char ** pChunks
Definition: msatMem.c:43
int nMemoryAlloc
Definition: msatMem.c:47
int nChunkSize
Definition: msatMem.c:40
int nEntrySize
Definition: msatMem.c:33
#define assert(ex)
Definition: util_old.h:213
int nEntriesAlloc
Definition: msatMem.c:34
int nEntriesUsed
Definition: msatMem.c:35
int nChunksAlloc
Definition: msatMem.c:41
void Msat_MmFixedEntryRecycle ( Msat_MmFixed_t p,
char *  pEntry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file msatMem.c.

213 {
214  // decrement the counter of used entries
215  p->nEntriesUsed--;
216  // add the entry to the linked list of free entries
217  *((char **)pEntry) = p->pEntriesFree;
218  p->pEntriesFree = pEntry;
219 }
char * pEntriesFree
Definition: msatMem.c:37
int nEntriesUsed
Definition: msatMem.c:35
int Msat_MmFixedReadMemUsage ( Msat_MmFixed_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file msatMem.c.

271 {
272  return p->nMemoryAlloc;
273 }
int nMemoryAlloc
Definition: msatMem.c:47
void Msat_MmFixedRestart ( Msat_MmFixed_t p)

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

Synopsis []

Description [Relocates all the memory except the first chunk.]

SideEffects []

SeeAlso []

Definition at line 232 of file msatMem.c.

233 {
234  int i;
235  char * pTemp;
236 
237  // deallocate all chunks except the first one
238  for ( i = 1; i < p->nChunks; i++ )
239  ABC_FREE( p->pChunks[i] );
240  p->nChunks = 1;
241  // transform these entries into a linked list
242  pTemp = p->pChunks[0];
243  for ( i = 1; i < p->nChunkSize; i++ )
244  {
245  *((char **)pTemp) = pTemp + p->nEntrySize;
246  pTemp += p->nEntrySize;
247  }
248  // set the last link
249  *((char **)pTemp) = NULL;
250  // set the free entry list
251  p->pEntriesFree = p->pChunks[0];
252  // set the correct statistics
253  p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
254  p->nMemoryUsed = 0;
255  p->nEntriesAlloc = p->nChunkSize;
256  p->nEntriesUsed = 0;
257 }
char * pEntriesFree
Definition: msatMem.c:37
int nMemoryUsed
Definition: msatMem.c:46
char ** pChunks
Definition: msatMem.c:43
int nMemoryAlloc
Definition: msatMem.c:47
int nChunkSize
Definition: msatMem.c:40
int nEntrySize
Definition: msatMem.c:33
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nEntriesAlloc
Definition: msatMem.c:34
int nEntriesUsed
Definition: msatMem.c:35
Msat_MmFixed_t* Msat_MmFixedStart ( int  nEntrySize)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates memory pieces of fixed size.]

Description [The size of the chunk is computed as the minimum of 1024 entries and 64K. Can only work with entry size at least 4 byte long.]

SideEffects []

SeeAlso []

Definition at line 93 of file msatMem.c.

94 {
95  Msat_MmFixed_t * p;
96 
97  p = ABC_ALLOC( Msat_MmFixed_t, 1 );
98  memset( p, 0, sizeof(Msat_MmFixed_t) );
99 
100  p->nEntrySize = nEntrySize;
101  p->nEntriesAlloc = 0;
102  p->nEntriesUsed = 0;
103  p->pEntriesFree = NULL;
104 
105  if ( nEntrySize * (1 << 10) < (1<<16) )
106  p->nChunkSize = (1 << 10);
107  else
108  p->nChunkSize = (1<<16) / nEntrySize;
109  if ( p->nChunkSize < 8 )
110  p->nChunkSize = 8;
111 
112  p->nChunksAlloc = 64;
113  p->nChunks = 0;
114  p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
115 
116  p->nMemoryUsed = 0;
117  p->nMemoryAlloc = 0;
118  return p;
119 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pEntriesFree
Definition: msatMem.c:37
DECLARATIONS ///.
Definition: msatMem.c:30
int nMemoryUsed
Definition: msatMem.c:46
char ** pChunks
Definition: msatMem.c:43
int nMemoryAlloc
Definition: msatMem.c:47
int nChunkSize
Definition: msatMem.c:40
int nEntrySize
Definition: msatMem.c:33
int nEntriesAlloc
Definition: msatMem.c:34
int nEntriesUsed
Definition: msatMem.c:35
int nChunksAlloc
Definition: msatMem.c:41
void Msat_MmFixedStop ( Msat_MmFixed_t p,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file msatMem.c.

133 {
134  int i;
135  if ( p == NULL )
136  return;
137  if ( fVerbose )
138  {
139  printf( "Fixed memory manager: Entry = %5d. Chunk = %5d. Chunks used = %5d.\n",
140  p->nEntrySize, p->nChunkSize, p->nChunks );
141  printf( " Entries used = %8d. Entries peak = %8d. Memory used = %8d. Memory alloc = %8d.\n",
143  }
144  for ( i = 0; i < p->nChunks; i++ )
145  ABC_FREE( p->pChunks[i] );
146  ABC_FREE( p->pChunks );
147  ABC_FREE( p );
148 }
int nEntriesMax
Definition: msatMem.c:36
char ** pChunks
Definition: msatMem.c:43
int nMemoryAlloc
Definition: msatMem.c:47
int nChunkSize
Definition: msatMem.c:40
int nEntrySize
Definition: msatMem.c:33
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nEntriesUsed
Definition: msatMem.c:35
char* Msat_MmFlexEntryFetch ( Msat_MmFlex_t p,
int  nBytes 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file msatMem.c.

350 {
351  char * pTemp;
352  // check if there are still free entries
353  if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
354  { // need to allocate more entries
355  if ( p->nChunks == p->nChunksAlloc )
356  {
357  p->nChunksAlloc *= 2;
358  p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
359  }
360  if ( nBytes > p->nChunkSize )
361  {
362  // resize the chunk size if more memory is requested than it can give
363  // (ideally, this should never happen)
364  p->nChunkSize = 2 * nBytes;
365  }
366  p->pCurrent = ABC_ALLOC( char, p->nChunkSize );
367  p->pEnd = p->pCurrent + p->nChunkSize;
368  p->nMemoryAlloc += p->nChunkSize;
369  // add the chunk to the chunk storage
370  p->pChunks[ p->nChunks++ ] = p->pCurrent;
371  }
372  assert( p->pCurrent + nBytes <= p->pEnd );
373  // increment the counter of used entries
374  p->nEntriesUsed++;
375  // keep track of the memory used
376  p->nMemoryUsed += nBytes;
377  // return the next entry
378  pTemp = p->pCurrent;
379  p->pCurrent += nBytes;
380  return pTemp;
381 }
char * pEnd
Definition: msatMem.c:55
int nMemoryAlloc
Definition: msatMem.c:65
int nChunkSize
Definition: msatMem.c:58
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int nMemoryUsed
Definition: msatMem.c:64
int nChunksAlloc
Definition: msatMem.c:59
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nEntriesUsed
Definition: msatMem.c:53
char * pCurrent
Definition: msatMem.c:54
char ** pChunks
Definition: msatMem.c:61
#define assert(ex)
Definition: util_old.h:213
int Msat_MmFlexReadMemUsage ( Msat_MmFlex_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file msatMem.c.

395 {
396  return p->nMemoryAlloc;
397 }
int nMemoryAlloc
Definition: msatMem.c:65
Msat_MmFlex_t* Msat_MmFlexStart ( )

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

Synopsis [Allocates entries of flexible size.]

Description [Can only work with entry size at least 4 byte long.]

SideEffects []

SeeAlso []

Definition at line 288 of file msatMem.c.

289 {
290  Msat_MmFlex_t * p;
291 
292  p = ABC_ALLOC( Msat_MmFlex_t, 1 );
293  memset( p, 0, sizeof(Msat_MmFlex_t) );
294 
295  p->nEntriesUsed = 0;
296  p->pCurrent = NULL;
297  p->pEnd = NULL;
298 
299  p->nChunkSize = (1 << 12);
300  p->nChunksAlloc = 64;
301  p->nChunks = 0;
302  p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
303 
304  p->nMemoryUsed = 0;
305  p->nMemoryAlloc = 0;
306  return p;
307 }
char * memset()
char * pEnd
Definition: msatMem.c:55
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nMemoryAlloc
Definition: msatMem.c:65
int nChunkSize
Definition: msatMem.c:58
int nMemoryUsed
Definition: msatMem.c:64
int nChunksAlloc
Definition: msatMem.c:59
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nEntriesUsed
Definition: msatMem.c:53
char * pCurrent
Definition: msatMem.c:54
char ** pChunks
Definition: msatMem.c:61
void Msat_MmFlexStop ( Msat_MmFlex_t p,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file msatMem.c.

321 {
322  int i;
323  if ( p == NULL )
324  return;
325  if ( fVerbose )
326  {
327  printf( "Flexible memory manager: Chunk size = %d. Chunks used = %d.\n",
328  p->nChunkSize, p->nChunks );
329  printf( " Entries used = %d. Memory used = %d. Memory alloc = %d.\n",
331  }
332  for ( i = 0; i < p->nChunks; i++ )
333  ABC_FREE( p->pChunks[i] );
334  ABC_FREE( p->pChunks );
335  ABC_FREE( p );
336 }
int nMemoryAlloc
Definition: msatMem.c:65
int nChunkSize
Definition: msatMem.c:58
int nMemoryUsed
Definition: msatMem.c:64
int nEntriesUsed
Definition: msatMem.c:53
char ** pChunks
Definition: msatMem.c:61
#define ABC_FREE(obj)
Definition: abc_global.h:232
char* Msat_MmStepEntryFetch ( Msat_MmStep_t p,
int  nBytes 
)

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

Synopsis [Creates the entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 479 of file msatMem.c.

480 {
481  if ( nBytes == 0 )
482  return NULL;
483  if ( nBytes > p->nMapSize )
484  {
485 // printf( "Allocating %d bytes.\n", nBytes );
486  return ABC_ALLOC( char, nBytes );
487  }
488  return Msat_MmFixedEntryFetch( p->pMap[nBytes] );
489 }
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Msat_MmFixed_t ** pMap
Definition: msatMem.c:74
int nMapSize
Definition: msatMem.c:73
char * Msat_MmFixedEntryFetch(Msat_MmFixed_t *p)
Definition: msatMem.c:161
void Msat_MmStepEntryRecycle ( Msat_MmStep_t p,
char *  pEntry,
int  nBytes 
)

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

Synopsis [Recycles the entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file msatMem.c.

504 {
505  if ( nBytes == 0 )
506  return;
507  if ( nBytes > p->nMapSize )
508  {
509  ABC_FREE( pEntry );
510  return;
511  }
512  Msat_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
513 }
void Msat_MmFixedEntryRecycle(Msat_MmFixed_t *p, char *pEntry)
Definition: msatMem.c:212
Msat_MmFixed_t ** pMap
Definition: msatMem.c:74
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nMapSize
Definition: msatMem.c:73
int Msat_MmStepReadMemUsage ( Msat_MmStep_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 526 of file msatMem.c.

527 {
528  int i, nMemTotal = 0;
529  for ( i = 0; i < p->nMems; i++ )
530  nMemTotal += p->pMems[i]->nMemoryAlloc;
531  return nMemTotal;
532 }
Msat_MmFixed_t ** pMems
Definition: msatMem.c:72
int nMemoryAlloc
Definition: msatMem.c:47
Msat_MmStep_t* Msat_MmStepStart ( int  nSteps)

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

Synopsis [Starts the hierarchical memory manager.]

Description [This manager can allocate entries of any size. Iternally they are mapped into the entries with the number of bytes equal to the power of 2. The smallest entry size is 8 bytes. The next one is 16 bytes etc. So, if the user requests 6 bytes, he gets 8 byte entry. If we asks for 25 bytes, he gets 32 byte entry etc. The input parameters "nSteps" says how many fixed memory managers are employed internally. Calling this procedure with nSteps equal to 10 results in 10 hierarchically arranged internal memory managers, which can allocate up to 4096 (1Kb) entries. Requests for larger entries are handed over to malloc() and then ABC_FREE()ed.]

SideEffects []

SeeAlso []

Definition at line 423 of file msatMem.c.

424 {
425  Msat_MmStep_t * p;
426  int i, k;
427  p = ABC_ALLOC( Msat_MmStep_t, 1 );
428  p->nMems = nSteps;
429  // start the fixed memory managers
430  p->pMems = ABC_ALLOC( Msat_MmFixed_t *, p->nMems );
431  for ( i = 0; i < p->nMems; i++ )
432  p->pMems[i] = Msat_MmFixedStart( (8<<i) );
433  // set up the mapping of the required memory size into the corresponding manager
434  p->nMapSize = (4<<p->nMems);
435  p->pMap = ABC_ALLOC( Msat_MmFixed_t *, p->nMapSize+1 );
436  p->pMap[0] = NULL;
437  for ( k = 1; k <= 4; k++ )
438  p->pMap[k] = p->pMems[0];
439  for ( i = 0; i < p->nMems; i++ )
440  for ( k = (4<<i)+1; k <= (8<<i); k++ )
441  p->pMap[k] = p->pMems[i];
442 //for ( i = 1; i < 100; i ++ )
443 //printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize );
444  return p;
445 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
for(p=first;p->value< newval;p=p->next)
Msat_MmFixed_t ** pMap
Definition: msatMem.c:74
Msat_MmFixed_t ** pMems
Definition: msatMem.c:72
DECLARATIONS ///.
Definition: msatMem.c:30
int nMapSize
Definition: msatMem.c:73
Msat_MmFixed_t * Msat_MmFixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition: msatMem.c:93
void Msat_MmStepStop ( Msat_MmStep_t p,
int  fVerbose 
)

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

Synopsis [Stops the memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 458 of file msatMem.c.

459 {
460  int i;
461  for ( i = 0; i < p->nMems; i++ )
462  Msat_MmFixedStop( p->pMems[i], fVerbose );
463  ABC_FREE( p->pMems );
464  ABC_FREE( p->pMap );
465  ABC_FREE( p );
466 }
Msat_MmFixed_t ** pMap
Definition: msatMem.c:74
Msat_MmFixed_t ** pMems
Definition: msatMem.c:72
void Msat_MmFixedStop(Msat_MmFixed_t *p, int fVerbose)
Definition: msatMem.c:132
#define ABC_FREE(obj)
Definition: abc_global.h:232
Msat_Order_t* Msat_OrderAlloc ( Msat_Solver_t pSat)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file msatOrderH.c.

79 {
80  Msat_Order_t * p;
81  p = ABC_ALLOC( Msat_Order_t, 1 );
82  memset( p, 0, sizeof(Msat_Order_t) );
83  p->pSat = pSat;
84  p->vIndex = Msat_IntVecAlloc( 0 );
85  p->vHeap = Msat_IntVecAlloc( 0 );
86  Msat_OrderSetBounds( p, pSat->nVarsAlloc );
87  return p;
88 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
DECLARATIONS ///.
Definition: msatOrderH.c:31
Msat_IntVec_t * vIndex
Definition: msatOrderH.c:34
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Msat_OrderSetBounds(Msat_Order_t *p, int nVarsMax)
Definition: msatOrderH.c:101
Msat_IntVec_t * vHeap
Definition: msatOrderH.c:35
Msat_IntVec_t * Msat_IntVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: msatVec.c:48
Msat_Solver_t * pSat
Definition: msatOrderH.c:33
int Msat_OrderCheck ( Msat_Order_t p)

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

Synopsis [Checks that the J-boundary is okay.]

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file msatOrderH.c.

148 {
149  return Msat_HeapCheck_rec( p, 1 );
150 }
static int Msat_HeapCheck_rec(Msat_Order_t *p, int i)
Definition: msatOrderH.c:282
void Msat_OrderClean ( Msat_Order_t p,
Msat_IntVec_t vCone 
)

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

Synopsis [Cleans the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file msatOrderH.c.

121 {
122  int i;
123  for ( i = 0; i < p->vIndex->nSize; i++ )
124  p->vIndex->pArray[i] = 0;
125  for ( i = 0; i < vCone->nSize; i++ )
126  {
127  assert( i+1 < p->vHeap->nCap );
128  p->vHeap->pArray[i+1] = vCone->pArray[i];
129 
130  assert( vCone->pArray[i] < p->vIndex->nSize );
131  p->vIndex->pArray[vCone->pArray[i]] = i+1;
132  }
133  p->vHeap->nSize = vCone->nSize + 1;
134 }
Msat_IntVec_t * vIndex
Definition: msatOrderH.c:34
for(p=first;p->value< newval;p=p->next)
Msat_IntVec_t * vHeap
Definition: msatOrderH.c:35
#define assert(ex)
Definition: util_old.h:213
int * pArray
Definition: msatInt.h:164
void Msat_OrderFree ( Msat_Order_t p)

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

Synopsis [Frees the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file msatOrderH.c.

164 {
165  Msat_IntVecFree( p->vHeap );
166  Msat_IntVecFree( p->vIndex );
167  ABC_FREE( p );
168 }
Msat_IntVec_t * vIndex
Definition: msatOrderH.c:34
Msat_IntVec_t * vHeap
Definition: msatOrderH.c:35
void Msat_IntVecFree(Msat_IntVec_t *p)
Definition: msatVec.c:160
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Msat_OrderSetBounds ( Msat_Order_t p,
int  nVarsMax 
)

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

Synopsis [Sets the bound of the ordering structure.]

Description [Should be called whenever the SAT solver is resized.]

SideEffects []

SeeAlso []

Definition at line 101 of file msatOrderH.c.

102 {
103  Msat_IntVecGrow( p->vIndex, nVarsMax );
104  Msat_IntVecGrow( p->vHeap, nVarsMax + 1 );
105  p->vIndex->nSize = nVarsMax;
106  p->vHeap->nSize = 0;
107 }
Msat_IntVec_t * vIndex
Definition: msatOrderH.c:34
Msat_IntVec_t * vHeap
Definition: msatOrderH.c:35
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition: msatVec.c:299
void Msat_OrderUpdate ( Msat_Order_t p,
int  Var 
)

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

Synopsis [Updates the order after a variable changed weight.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file msatOrderH.c.

258 {
259 // if (heap.inHeap(x))
260 // heap.increase(x);
261 
262  abctime clk = Abc_Clock();
263  if ( HINHEAP(p,Var) )
264  Msat_HeapIncrease( p, Var );
265 timeSelect += Abc_Clock() - clk;
266 }
static void Msat_HeapIncrease(Msat_Order_t *p, int n)
Definition: msatOrderH.c:348
#define HINHEAP(p, i)
Definition: msatOrderH.c:51
static abctime Abc_Clock()
Definition: abc_global.h:279
int Var
Definition: SolverTypes.h:42
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeSelect
DECLARATIONS ///.
Definition: fraigMan.c:28
void Msat_OrderVarAssigned ( Msat_Order_t p,
int  Var 
)

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

Synopsis [Updates J-boundary when the variable is assigned.]

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file msatOrderH.c.

221 {
222 }
int Msat_OrderVarSelect ( Msat_Order_t p)

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

Synopsis [Selects the next variable to assign.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file msatOrderH.c.

184 {
185  // Activity based decision:
186 // while (!heap.empty()){
187 // Var next = heap.getmin();
188 // if (toLbool(assigns[next]) == l_Undef)
189 // return next;
190 // }
191 // return var_Undef;
192 
193  int Var;
194  abctime clk = Abc_Clock();
195 
196  while ( !HEMPTY(p) )
197  {
198  Var = Msat_HeapGetTop(p);
199  if ( (p)->pSat->pAssigns[Var] == MSAT_VAR_UNASSIGNED )
200  {
201 //assert( Msat_OrderCheck(p) );
202 timeSelect += Abc_Clock() - clk;
203  return Var;
204  }
205  }
206  return MSAT_ORDER_UNKNOWN;
207 }
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
#define MSAT_ORDER_UNKNOWN
Definition: msatInt.h:70
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Msat_HeapGetTop(Msat_Order_t *p)
Definition: msatOrderH.c:305
#define HEMPTY(p)
Definition: msatOrderH.c:52
int Var
Definition: SolverTypes.h:42
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeSelect
DECLARATIONS ///.
Definition: fraigMan.c:28
void Msat_OrderVarUnassigned ( Msat_Order_t p,
int  Var 
)

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

Synopsis [Updates the order after a variable is unassigned.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file msatOrderH.c.

236 {
237 // if (!heap.inHeap(x))
238 // heap.insert(x);
239 
240  abctime clk = Abc_Clock();
241  if ( !HINHEAP(p,Var) )
242  Msat_HeapInsert( p, Var );
243 timeSelect += Abc_Clock() - clk;
244 }
#define HINHEAP(p, i)
Definition: msatOrderH.c:51
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Msat_HeapInsert(Msat_Order_t *p, int n)
Definition: msatOrderH.c:329
int Var
Definition: SolverTypes.h:42
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeSelect
DECLARATIONS ///.
Definition: fraigMan.c:28
Msat_Queue_t* Msat_QueueAlloc ( int  nVars)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates the variable propagation queue.]

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file msatQueue.c.

54 {
55  Msat_Queue_t * p;
56  p = ABC_ALLOC( Msat_Queue_t, 1 );
57  memset( p, 0, sizeof(Msat_Queue_t) );
58  p->nVars = nVars;
59  p->pVars = ABC_ALLOC( int, nVars );
60  return p;
61 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pVars
Definition: msatQueue.c:33
DECLARATIONS ///.
Definition: msatQueue.c:30
void Msat_QueueClear ( Msat_Queue_t p)

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

Synopsis [Resets the queue.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file msatQueue.c.

150 {
151  p->iFirst = 0;
152  p->iLast = 0;
153 }
int Msat_QueueExtract ( Msat_Queue_t p)

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

Synopsis [Extracts an entry from the queue.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file msatQueue.c.

132 {
133  if ( p->iFirst == p->iLast )
134  return -1;
135  return p->pVars[p->iFirst++];
136 }
int * pVars
Definition: msatQueue.c:33
void Msat_QueueFree ( Msat_Queue_t p)

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

Synopsis [Deallocate the variable propagation queue.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file msatQueue.c.

75 {
76  ABC_FREE( p->pVars );
77  ABC_FREE( p );
78 }
int * pVars
Definition: msatQueue.c:33
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Msat_QueueInsert ( Msat_Queue_t p,
int  Lit 
)

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

Synopsis [Insert an entry into the queue.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file msatQueue.c.

108 {
109  if ( p->iLast == p->nVars )
110  {
111  int i;
112  assert( 0 );
113  for ( i = 0; i < p->iLast; i++ )
114  printf( "entry = %2d lit = %2d var = %2d \n", i, p->pVars[i], p->pVars[i]/2 );
115  }
116  assert( p->iLast < p->nVars );
117  p->pVars[p->iLast++] = Lit;
118 }
int * pVars
Definition: msatQueue.c:33
#define assert(ex)
Definition: util_old.h:213
int Msat_QueueReadSize ( Msat_Queue_t p)

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

Synopsis [Reads the queue size.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file msatQueue.c.

92 {
93  return p->iLast - p->iFirst;
94 }
int Msat_SolverAssume ( Msat_Solver_t p,
Msat_Lit_t  Lit 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Makes the next assumption (Lit).]

Description [Returns FALSE if immediate conflict.]

SideEffects []

SeeAlso []

Definition at line 51 of file msatSolverSearch.c.

52 {
53  assert( Msat_QueueReadSize(p->pQueue) == 0 );
54  if ( p->fVerbose )
55  printf(L_IND"assume("L_LIT")\n", L_ind, L_lit(Lit));
56  Msat_IntVecPush( p->vTrailLim, Msat_IntVecReadSize(p->vTrail) );
57 // assert( Msat_IntVecReadSize(p->vTrailLim) <= Msat_IntVecReadSize(p->vTrail) + 1 );
58 // assert( Msat_IntVecReadSize( p->vTrailLim ) < p->nVars );
59  return Msat_SolverEnqueue( p, Lit, NULL );
60 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define L_lit(p)
Definition: satSolver.c:43
#define L_ind
Definition: satSolver.c:41
int Msat_QueueReadSize(Msat_Queue_t *p)
Definition: msatQueue.c:91
#define L_LIT
Definition: satSolver.c:42
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:351
#define L_IND
Definition: satSolver.c:40
#define assert(ex)
Definition: util_old.h:213
int Msat_SolverEnqueue(Msat_Solver_t *p, Msat_Lit_t Lit, Msat_Clause_t *pC)
void Msat_SolverCancelUntil ( Msat_Solver_t p,
int  Level 
)

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

Synopsis [Reverts to the state at given level.]

Description []

SideEffects []

SeeAlso []

Definition at line 128 of file msatSolverSearch.c.

129 {
130  while ( Msat_IntVecReadSize(p->vTrailLim) > Level )
132 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
static void Msat_SolverCancel(Msat_Solver_t *p)
void Msat_SolverClaBumpActivity ( Msat_Solver_t p,
Msat_Clause_t pC 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file msatActivity.c.

106 {
107  float Activ;
108  Activ = Msat_ClauseReadActivity(pC);
109  if ( Activ + p->dClaInc > 1e20 )
110  {
112  Activ = Msat_ClauseReadActivity( pC );
113  }
114  Msat_ClauseWriteActivity( pC, Activ + (float)p->dClaInc );
115 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_ClauseWriteActivity(Msat_Clause_t *pC, float Num)
Definition: msatClause.c:314
void Msat_SolverClaRescaleActivity(Msat_Solver_t *p)
Definition: msatActivity.c:144
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
void Msat_SolverClaDecayActivity ( Msat_Solver_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 128 of file msatActivity.c.

129 {
130  p->dClaInc *= p->dClaDecay;
131 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverClaRescaleActivity ( Msat_Solver_t p)

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

Synopsis [Divide all constraint activities by 1e20.]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file msatActivity.c.

145 {
146  Msat_Clause_t ** pLearned;
147  int nLearned, i;
148  float Activ;
149  nLearned = Msat_ClauseVecReadSize( p->vLearned );
150  pLearned = Msat_ClauseVecReadArray( p->vLearned );
151  for ( i = 0; i < nLearned; i++ )
152  {
153  Activ = Msat_ClauseReadActivity( pLearned[i] );
154  Msat_ClauseWriteActivity( pLearned[i], Activ * (float)1e-20 );
155  }
156  p->dClaInc *= 1e-20;
157 }
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_ClauseWriteActivity(Msat_Clause_t *pC, float Num)
Definition: msatClause.c:314
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
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
int Msat_SolverEnqueue ( Msat_Solver_t p,
Msat_Lit_t  Lit,
Msat_Clause_t pC 
)

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

Synopsis [Enqueues one variable assignment.]

Description [Puts a new fact on the propagation queue and immediately updates the variable value. Should a conflict arise, FALSE is returned. Otherwise returns TRUE.]

SideEffects []

SeeAlso []

Definition at line 173 of file msatSolverSearch.c.

174 {
175  Msat_Var_t Var = MSAT_LIT2VAR(Lit);
176 
177  // skip literals that are not in the current cone
178  if ( !Msat_IntVecReadEntry( p->vVarsUsed, Var ) )
179  return 1;
180 
181 // assert( Msat_QueueReadSize(p->pQueue) == Msat_IntVecReadSize(p->vTrail) );
182  // if the literal is assigned
183  // return 1 if the assignment is consistent
184  // return 0 if the assignment is inconsistent (conflict)
185  if ( p->pAssigns[Var] != MSAT_VAR_UNASSIGNED )
186  return p->pAssigns[Var] == Lit;
187  // new fact - store it
188  if ( p->fVerbose )
189  {
190 // printf(L_IND"bind("L_LIT")\n", L_ind, L_lit(Lit));
191  printf(L_IND"bind("L_LIT") ", L_ind, L_lit(Lit));
193  }
194  p->pAssigns[Var] = Lit;
195  p->pLevel[Var] = Msat_IntVecReadSize(p->vTrailLim);
196 // p->pReasons[Var] = p->pLevel[Var]? pC: NULL;
197  p->pReasons[Var] = pC;
198  Msat_IntVecPush( p->vTrail, Lit );
199  Msat_QueueInsert( p->pQueue, Lit );
200 
201  Msat_OrderVarAssigned( p->pOrder, Var );
202  return 1;
203 }
int Msat_Var_t
Definition: msatInt.h:66
void Msat_OrderVarAssigned(Msat_Order_t *p, int Var)
Definition: msatOrderH.c:220
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define L_lit(p)
Definition: satSolver.c:43
void Msat_QueueInsert(Msat_Queue_t *p, int Lit)
Definition: msatQueue.c:107
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
#define L_ind
Definition: satSolver.c:41
#define L_LIT
Definition: satSolver.c:42
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:351
int Msat_IntVecReadEntry(Msat_IntVec_t *p, int i)
Definition: msatVec.c:249
#define L_IND
Definition: satSolver.c:40
int Var
Definition: SolverTypes.h:42
void Msat_ClausePrintSymbols(Msat_Clause_t *pC)
Definition: msatClause.c:515
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
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
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVars
Definition: llb3Image.c:58
Msat_Clause_t* Msat_SolverPropagate ( Msat_Solver_t p)

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

Synopsis [Propagates the assignments in the queue.]

Description [Propagates all enqueued facts. If a conflict arises, the conflicting clause is returned, otherwise NULL.]

SideEffects [The propagation queue is empty, even if there was a conflict.]

SeeAlso []

Definition at line 217 of file msatSolverSearch.c.

218 {
219  Msat_ClauseVec_t ** pvWatched = p->pvWatched;
220  Msat_Clause_t ** pClauses;
221  Msat_Clause_t * pConflict;
222  Msat_Lit_t Lit, Lit_out;
223  int i, j, nClauses;
224 
225  // propagate all the literals in the queue
226  while ( (Lit = Msat_QueueExtract( p->pQueue )) >= 0 )
227  {
228  p->Stats.nPropagations++;
229  // get the clauses watched by this literal
230  nClauses = Msat_ClauseVecReadSize( pvWatched[Lit] );
231  pClauses = Msat_ClauseVecReadArray( pvWatched[Lit] );
232  // go through the watched clauses and decide what to do with them
233  for ( i = j = 0; i < nClauses; i++ )
234  {
235  p->Stats.nInspects++;
236  // clear the returned literal
237  Lit_out = -1;
238  // propagate the clause
239  if ( !Msat_ClausePropagate( pClauses[i], Lit, p->pAssigns, &Lit_out ) )
240  { // the clause is unit
241  // "Lit_out" contains the new assignment to be enqueued
242  if ( Msat_SolverEnqueue( p, Lit_out, pClauses[i] ) )
243  { // consistent assignment
244  // no changes to the implication queue; the watch is the same too
245  pClauses[j++] = pClauses[i];
246  continue;
247  }
248  // remember the reason of conflict (will be returned)
249  pConflict = pClauses[i];
250  // leave the remaning clauses in the same watched list
251  for ( ; i < nClauses; i++ )
252  pClauses[j++] = pClauses[i];
253  Msat_ClauseVecShrink( pvWatched[Lit], j );
254  // clear the propagation queue
255  Msat_QueueClear( p->pQueue );
256  return pConflict;
257  }
258  // the clause is not unit
259  // in this case "Lit_out" contains the new watch if it has changed
260  if ( Lit_out >= 0 )
261  Msat_ClauseVecPush( pvWatched[Lit_out], pClauses[i] );
262  else // the watch did not change
263  pClauses[j++] = pClauses[i];
264  }
265  Msat_ClauseVecShrink( pvWatched[Lit], j );
266  }
267  return NULL;
268 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_QueueClear(Msat_Queue_t *p)
Definition: msatQueue.c:149
int Msat_ClausePropagate(Msat_Clause_t *pC, Msat_Lit_t Lit, int *pAssigns, Msat_Lit_t *pLit_out)
Definition: msatClause.c:335
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_Lit_t
Definition: msatInt.h:65
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_ClauseVecPush(Msat_ClauseVec_t *p, Msat_Clause_t *Entry)
int Msat_QueueExtract(Msat_Queue_t *p)
Definition: msatQueue.c:131
int Msat_SolverEnqueue(Msat_Solver_t *p, Msat_Lit_t Lit, Msat_Clause_t *pC)
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_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
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
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
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
Msat_Type_t Msat_SolverSearch ( Msat_Solver_t p,
int  nConfLimit,
int  nLearnedLimit,
int  nBackTrackLimit,
Msat_SearchParams_t pPars 
)

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

Synopsis [The search procedure called between the restarts.]

Description [Search for a satisfying solution as long as the number of conflicts does not exceed the limit (nConfLimit) while keeping the number of learnt clauses below the provided limit (nLearnedLimit). NOTE! Use negative value for nConfLimit or nLearnedLimit to indicate infinity.]

SideEffects []

SeeAlso []

Definition at line 535 of file msatSolverSearch.c.

536 {
537  Msat_Clause_t * pConf;
538  Msat_Var_t Var;
539  int nLevelBack, nConfs, nAssigns, Value;
540  int i;
541 
542  assert( Msat_SolverReadDecisionLevel(p) == p->nLevelRoot );
543  p->Stats.nStarts++;
544  p->dVarDecay = 1 / pPars->dVarDecay;
545  p->dClaDecay = 1 / pPars->dClaDecay;
546 
547  // reset the activities
548  for ( i = 0; i < p->nVars; i++ )
549  p->pdActivity[i] = (double)p->pFactors[i];
550 // p->pdActivity[i] = 0.0;
551 
552  nConfs = 0;
553  while ( 1 )
554  {
555  pConf = Msat_SolverPropagate( p );
556  if ( pConf != NULL ){
557  // CONFLICT
558  if ( p->fVerbose )
559  {
560 // printf(L_IND"**CONFLICT**\n", L_ind);
561  printf(L_IND"**CONFLICT** ", L_ind);
562  Msat_ClausePrintSymbols( pConf );
563  }
564  // count conflicts
565  p->Stats.nConflicts++;
566  nConfs++;
567 
568  // if top level, return UNSAT
569  if ( Msat_SolverReadDecisionLevel(p) == p->nLevelRoot )
570  return MSAT_FALSE;
571 
572  // perform conflict analysis
573  Msat_SolverAnalyze( p, pConf, p->vTemp, &nLevelBack );
574  Msat_SolverCancelUntil( p, (p->nLevelRoot > nLevelBack)? p->nLevelRoot : nLevelBack );
575  Msat_SolverRecord( p, p->vTemp );
576 
577  // it is important that recording is done after cancelling
578  // because canceling cleans the queue while recording adds to it
581 
582  }
583  else{
584  // NO CONFLICT
585  if ( Msat_IntVecReadSize(p->vTrailLim) == 0 ) {
586  // Simplify the set of problem clauses:
587 // Value = Msat_SolverSimplifyDB(p);
588 // assert( Value );
589  }
590  nAssigns = Msat_IntVecReadSize( p->vTrail );
591  if ( nLearnedLimit >= 0 && Msat_ClauseVecReadSize(p->vLearned) >= nLearnedLimit + nAssigns ) {
592  // Reduce the set of learnt clauses:
594  }
595 
596  Var = Msat_OrderVarSelect( p->pOrder );
597  if ( Var == MSAT_ORDER_UNKNOWN ) {
598  // Model found and stored in p->pAssigns
599  memcpy( p->pModel, p->pAssigns, sizeof(int) * p->nVars );
600  Msat_QueueClear( p->pQueue );
601  Msat_SolverCancelUntil( p, p->nLevelRoot );
602  return MSAT_TRUE;
603  }
604  if ( nConfLimit > 0 && nConfs > nConfLimit ) {
605  // Reached bound on number of conflicts:
606  p->dProgress = Msat_SolverProgressEstimate( p );
607  Msat_QueueClear( p->pQueue );
608  Msat_SolverCancelUntil( p, p->nLevelRoot );
609  return MSAT_UNKNOWN;
610  }
611  else if ( nBackTrackLimit > 0 && (int)p->Stats.nConflicts - p->nBackTracks > nBackTrackLimit ) {
612  // Reached bound on number of conflicts:
613  Msat_QueueClear( p->pQueue );
614  Msat_SolverCancelUntil( p, p->nLevelRoot );
615  return MSAT_UNKNOWN;
616  }
617  else{
618  // New variable decision:
619  p->Stats.nDecisions++;
620  assert( Var != MSAT_ORDER_UNKNOWN && Var >= 0 && Var < p->nVars );
621  Value = Msat_SolverAssume(p, MSAT_VAR2LIT(Var,0) );
622  assert( Value );
623  }
624  }
625  }
626 }
int Msat_SolverReadDecisionLevel(Msat_Solver_t *p)
Definition: msatSolverApi.c:50
int Msat_Var_t
Definition: msatInt.h:66
void Msat_SolverClaDecayActivity(Msat_Solver_t *p)
Definition: msatActivity.c:128
#define MSAT_ORDER_UNKNOWN
Definition: msatInt.h:70
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_QueueClear(Msat_Queue_t *p)
Definition: msatQueue.c:149
Msat_Clause_t * Msat_SolverPropagate(Msat_Solver_t *p)
#define L_ind
Definition: satSolver.c:41
char * memcpy()
Definition: msat.h:50
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
int Msat_OrderVarSelect(Msat_Order_t *p)
Definition: msatOrderH.c:183
void Msat_SolverVarDecayActivity(Msat_Solver_t *p)
GLOBAL VARIABLES ///.
Definition: msatActivity.c:69
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition: msatVec.c:233
static void Msat_SolverAnalyze(Msat_Solver_t *p, Msat_Clause_t *pC, Msat_IntVec_t *vLits_out, int *pLevel_out)
void Msat_SolverCancelUntil(Msat_Solver_t *p, int Level)
int Msat_SolverAssume(Msat_Solver_t *p, Msat_Lit_t Lit)
FUNCTION DEFINITIONS ///.
#define L_IND
Definition: satSolver.c:40
static Msat_Clause_t * Msat_SolverRecord(Msat_Solver_t *p, Msat_IntVec_t *vLits)
static void Msat_SolverReduceDB(Msat_Solver_t *p)
int Var
Definition: SolverTypes.h:42
#define MSAT_VAR2LIT(v, s)
Definition: msat.h:56
#define assert(ex)
Definition: util_old.h:213
void Msat_ClausePrintSymbols(Msat_Clause_t *pC)
Definition: msatClause.c:515
double Msat_SolverProgressEstimate(Msat_Solver_t *p)
int nVars
Definition: llb3Image.c:58
void Msat_SolverSortDB ( Msat_Solver_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Msat_SolverSort the learned clauses in the increasing order of activity.]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file msatSort.c.

62 {
63  Msat_ClauseVec_t * pVecClauses;
64  Msat_Clause_t ** pLearned;
65  int nLearned;
66  // read the parameters
67  pVecClauses = Msat_SolverReadLearned( p );
68  nLearned = Msat_ClauseVecReadSize( pVecClauses );
69  pLearned = Msat_ClauseVecReadArray( pVecClauses );
70  // Msat_SolverSort the array
71 // qMsat_SolverSort( (void *)pLearned, nLearned, sizeof(Msat_Clause_t *),
72 // (int (*)(const void *, const void *)) Msat_SolverSortCompare );
73 // printf( "Msat_SolverSorting.\n" );
74  Msat_SolverSort( pLearned, nLearned, 91648253 );
75 /*
76  if ( nLearned > 2 )
77  {
78  printf( "Clause 1: %0.20f\n", Msat_ClauseReadActivity(pLearned[0]) );
79  printf( "Clause 2: %0.20f\n", Msat_ClauseReadActivity(pLearned[1]) );
80  printf( "Clause 3: %0.20f\n", Msat_ClauseReadActivity(pLearned[2]) );
81  }
82 */
83 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_ClauseVec_t * Msat_SolverReadLearned(Msat_Solver_t *p)
Definition: msatSolverApi.c:54
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
static void Msat_SolverSort(Msat_Clause_t **array, int size, double seed)
Definition: msatSort.c:147
void Msat_SolverVarBumpActivity ( Msat_Solver_t p,
Msat_Lit_t  Lit 
)

DECLARATIONS ///.

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

FileName [msatActivity.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 [Procedures controlling activity of variables and clauses.]

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file msatActivity.c.

46 {
48  if ( p->dVarDecay < 0 ) // (negative decay means static variable order -- don't bump)
49  return;
50  Var = MSAT_LIT2VAR(Lit);
51  p->pdActivity[Var] += p->dVarInc;
52 // p->pdActivity[Var] += p->dVarInc * p->pFactors[Var];
53  if ( p->pdActivity[Var] > 1e100 )
55  Msat_OrderUpdate( p->pOrder, Var );
56 }
int Msat_Var_t
Definition: msatInt.h:66
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
int Var
Definition: SolverTypes.h:42
void Msat_OrderUpdate(Msat_Order_t *p, int Var)
Definition: msatOrderH.c:257
void Msat_SolverVarRescaleActivity(Msat_Solver_t *p)
Definition: msatActivity.c:86
void Msat_SolverVarDecayActivity ( Msat_Solver_t p)

GLOBAL VARIABLES ///.

MACRO DEFINITIONS ///FUNCTION DECLARATIONS ///

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file msatActivity.c.

70 {
71  if ( p->dVarDecay >= 0 )
72  p->dVarInc *= p->dVarDecay;
73 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Msat_SolverVarRescaleActivity ( Msat_Solver_t p)

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

Synopsis [Divide all variable activities by 1e100.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file msatActivity.c.

87 {
88  int i;
89  for ( i = 0; i < p->nVars; i++ )
90  p->pdActivity[i] *= 1e-100;
91  p->dVarInc *= 1e-100;
92 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVars
Definition: llb3Image.c:58