abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
msat.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [msat.h]
4 
5  PackageName [A C version of SAT solver MINISAT, originally developed
6  in C++ by Niklas Een and Niklas Sorensson, Chalmers University of
7  Technology, Sweden: http://www.cs.chalmers.se/~een/Satzoo.]
8 
9  Synopsis [External definitions of the solver.]
10 
11  Author [Alan Mishchenko <alanmi@eecs.berkeley.edu>]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - January 1, 2004.]
16 
17  Revision [$Id: msat.h,v 1.6 2004/05/12 06:30:20 satrajit Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__sat__msat__msat_h
22 #define ABC__sat__msat__msat_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// PARAMETERS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 
34 
36 
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// STRUCTURE DEFINITIONS ///
40 ////////////////////////////////////////////////////////////////////////
41 
43 
44 // the vector of intergers and of clauses
47 typedef struct Msat_VarHeap_t_ Msat_VarHeap_t;
48 
49 // the return value of the solver
50 typedef enum { MSAT_FALSE = -1, MSAT_UNKNOWN = 0, MSAT_TRUE = 1 } Msat_Type_t;
51 
52 // representation of variables and literals
53 // the literal (l) is the variable (v) and the sign (s)
54 // s = 0 the variable is positive
55 // s = 1 the variable is negative
56 #define MSAT_VAR2LIT(v,s) (2*(v)+(s))
57 #define MSAT_LITNOT(l) ((l)^1)
58 #define MSAT_LITSIGN(l) ((l)&1)
59 #define MSAT_LIT2VAR(l) ((l)>>1)
60 
61 ////////////////////////////////////////////////////////////////////////
62 /// GLOBAL VARIABLES ///
63 ////////////////////////////////////////////////////////////////////////
64 
65 ////////////////////////////////////////////////////////////////////////
66 /// MACRO DEFINITIONS ///
67 ////////////////////////////////////////////////////////////////////////
68 
69 ////////////////////////////////////////////////////////////////////////
70 /// FUNCTION DECLARATIONS ///
71 ////////////////////////////////////////////////////////////////////////
72 
73 /*=== satRead.c ============================================================*/
74 extern int Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose );
75 /*=== satSolver.c ===========================================================*/
76 // adding vars, clauses, simplifying the database, and solving
77 extern int Msat_SolverAddVar( Msat_Solver_t * p, int Level );
78 extern int Msat_SolverAddClause( Msat_Solver_t * p, Msat_IntVec_t * pLits );
79 extern int Msat_SolverSimplifyDB( Msat_Solver_t * p );
80 extern int Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * pVecAssumps, int nBackTrackLimit, int nTimeLimit );
81 // printing stats, assignments, and clauses
82 extern void Msat_SolverPrintStats( Msat_Solver_t * p );
84 extern void Msat_SolverPrintClauses( Msat_Solver_t * p );
85 extern void Msat_SolverWriteDimacs( Msat_Solver_t * p, char * pFileName );
86 // access to the solver internal data
87 extern int Msat_SolverReadVarNum( Msat_Solver_t * p );
91 extern int * Msat_SolverReadModelArray( Msat_Solver_t * p );
92 extern unsigned Msat_SolverReadTruth( Msat_Solver_t * p );
95 extern void Msat_SolverSetVerbosity( Msat_Solver_t * p, int fVerbose );
96 extern void Msat_SolverSetProofWriting( Msat_Solver_t * p, int fProof );
97 extern void Msat_SolverSetVarTypeA( Msat_Solver_t * p, int Var );
98 extern void Msat_SolverSetVarMap( Msat_Solver_t * p, Msat_IntVec_t * vVarMap );
101 extern float * Msat_SolverReadFactors( Msat_Solver_t * p );
102 // returns the solution after incremental solving
108 /*=== satSolverSearch.c ===========================================================*/
109 extern void Msat_SolverRemoveLearned( Msat_Solver_t * p );
110 extern void Msat_SolverRemoveMarked( Msat_Solver_t * p );
111 /*=== satSolverApi.c ===========================================================*/
112 // allocation, cleaning, and freeing the solver
113 extern Msat_Solver_t * Msat_SolverAlloc( int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose );
114 extern void Msat_SolverResize( Msat_Solver_t * pMan, int nVarsAlloc );
115 extern void Msat_SolverClean( Msat_Solver_t * p, int nVars );
116 extern void Msat_SolverPrepare( Msat_Solver_t * pSat, Msat_IntVec_t * vVars );
117 extern void Msat_SolverFree( Msat_Solver_t * p );
118 /*=== satVec.c ===========================================================*/
119 extern Msat_IntVec_t * Msat_IntVecAlloc( int nCap );
120 extern Msat_IntVec_t * Msat_IntVecAllocArray( int * pArray, int nSize );
121 extern Msat_IntVec_t * Msat_IntVecAllocArrayCopy( int * pArray, int nSize );
122 extern Msat_IntVec_t * Msat_IntVecDup( Msat_IntVec_t * pVec );
124 extern void Msat_IntVecFree( Msat_IntVec_t * p );
125 extern void Msat_IntVecFill( Msat_IntVec_t * p, int nSize, int Entry );
126 extern int * Msat_IntVecReleaseArray( Msat_IntVec_t * p );
127 extern int * Msat_IntVecReadArray( Msat_IntVec_t * p );
128 extern int Msat_IntVecReadSize( Msat_IntVec_t * p );
129 extern int Msat_IntVecReadEntry( Msat_IntVec_t * p, int i );
131 extern void Msat_IntVecWriteEntry( Msat_IntVec_t * p, int i, int Entry );
132 extern void Msat_IntVecGrow( Msat_IntVec_t * p, int nCapMin );
133 extern void Msat_IntVecShrink( Msat_IntVec_t * p, int nSizeNew );
134 extern void Msat_IntVecClear( Msat_IntVec_t * p );
135 extern void Msat_IntVecPush( Msat_IntVec_t * p, int Entry );
136 extern int Msat_IntVecPushUnique( Msat_IntVec_t * p, int Entry );
137 extern void Msat_IntVecPushUniqueOrder( Msat_IntVec_t * p, int Entry, int fIncrease );
138 extern int Msat_IntVecPop( Msat_IntVec_t * p );
139 extern void Msat_IntVecSort( Msat_IntVec_t * p, int fReverse );
140 /*=== satHeap.c ===========================================================*/
142 extern void Msat_VarHeapSetActivity( Msat_VarHeap_t * p, double * pActivity );
143 extern void Msat_VarHeapStart( Msat_VarHeap_t * p, int * pVars, int nVars, int nVarsAlloc );
144 extern void Msat_VarHeapGrow( Msat_VarHeap_t * p, int nSize );
145 extern void Msat_VarHeapStop( Msat_VarHeap_t * p );
146 extern void Msat_VarHeapPrint( FILE * pFile, Msat_VarHeap_t * p );
147 extern void Msat_VarHeapCheck( Msat_VarHeap_t * p );
148 extern void Msat_VarHeapCheckOne( Msat_VarHeap_t * p, int iVar );
149 extern int Msat_VarHeapContainsVar( Msat_VarHeap_t * p, int iVar );
150 extern void Msat_VarHeapInsert( Msat_VarHeap_t * p, int iVar );
151 extern void Msat_VarHeapUpdate( Msat_VarHeap_t * p, int iVar );
152 extern void Msat_VarHeapDelete( Msat_VarHeap_t * p, int iVar );
153 extern double Msat_VarHeapReadMaxWeight( Msat_VarHeap_t * p );
154 extern int Msat_VarHeapCountNodes( Msat_VarHeap_t * p, double WeightLimit );
155 extern int Msat_VarHeapReadMax( Msat_VarHeap_t * p );
156 extern int Msat_VarHeapGetMax( Msat_VarHeap_t * p );
157 
158 
159 
161 
162 
163 
164 #endif
165 
166 ////////////////////////////////////////////////////////////////////////
167 /// END OF FILE ///
168 ////////////////////////////////////////////////////////////////////////
int Msat_SolverReadInspects(Msat_Solver_t *p)
Definition: msatSolverApi.c:59
int Msat_SolverReadBackTracks(Msat_Solver_t *p)
Definition: msatSolverApi.c:58
struct Msat_VarHeap_t_ Msat_VarHeap_t
Definition: msat.h:47
Msat_IntVec_t * Msat_SolverReadVarsUsed(Msat_Solver_t *p)
void Msat_VarHeapDelete(Msat_VarHeap_t *p, int iVar)
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * Msat_SolverReadModelArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:57
int Msat_SolverAddClause(Msat_Solver_t *p, Msat_IntVec_t *pLits)
int * Msat_SolverReadSolutionsArray(Msat_Solver_t *p)
void Msat_SolverSetVarMap(Msat_Solver_t *p, Msat_IntVec_t *vVarMap)
int Msat_IntVecReadEntryLast(Msat_IntVec_t *p)
Definition: msatVec.c:283
void Msat_VarHeapCheck(Msat_VarHeap_t *p)
void Msat_SolverFree(Msat_Solver_t *p)
Msat_IntVec_t * Msat_SolverReadConeVars(Msat_Solver_t *p)
void Msat_SolverPrintClauses(Msat_Solver_t *p)
Definition: msatSolverIo.c:79
Msat_IntVec_t * Msat_IntVecAllocArrayCopy(int *pArray, int nSize)
Definition: msatVec.c:92
int Msat_SolverSimplifyDB(Msat_Solver_t *p)
void Msat_SolverRemoveMarked(Msat_Solver_t *p)
Msat_Type_t
Definition: msat.h:50
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition: msatVec.c:335
int Msat_SolverReadSolutions(Msat_Solver_t *p)
Definition: msat.h:50
float * Msat_SolverReadFactors(Msat_Solver_t *p)
Definition: msatSolverApi.c:70
void Msat_SolverSetVarTypeA(Msat_Solver_t *p, int Var)
Msat_IntVec_t * Msat_IntVecDup(Msat_IntVec_t *pVec)
Definition: msatVec.c:114
void Msat_SolverPrintAssignment(Msat_Solver_t *p)
FUNCTION DEFINITIONS ///.
Definition: msatSolverIo.c:47
Msat_Solver_t * Msat_SolverAlloc(int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose)
int Msat_SolverReadClauseNum(Msat_Solver_t *p)
Definition: msatSolverApi.c:48
int Msat_SolverAddVar(Msat_Solver_t *p, int Level)
DECLARATIONS ///.
void Msat_VarHeapCheckOne(Msat_VarHeap_t *p, int iVar)
void Msat_SolverRemoveLearned(Msat_Solver_t *p)
int Msat_VarHeapContainsVar(Msat_VarHeap_t *p, int iVar)
Msat_IntVec_t * Msat_IntVecDupArray(Msat_IntVec_t *pVec)
Definition: msatVec.c:136
int Msat_SolverParseDimacs(FILE *pFile, Msat_Solver_t **p, int fVerbose)
GLOBAL VARIABLES ///.
Definition: msatRead.c:258
void Msat_SolverMarkLastClauseTypeA(Msat_Solver_t *p)
Definition: msatSolverApi.c:68
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_SolverReadAssignsArray(Msat_Solver_t *p)
Definition: msatSolverApi.c:56
Msat_IntVec_t * Msat_IntVecAllocArray(int *pArray, int nSize)
Definition: msatVec.c:71
int * Msat_IntVecReleaseArray(Msat_IntVec_t *p)
Definition: msatVec.c:197
void Msat_VarHeapStop(Msat_VarHeap_t *p)
void Msat_VarHeapInsert(Msat_VarHeap_t *p, int iVar)
void Msat_SolverWriteDimacs(Msat_Solver_t *p, char *pFileName)
Definition: msatSolverIo.c:118
void Msat_VarHeapSetActivity(Msat_VarHeap_t *p, double *pActivity)
int Msat_IntVecPop(Msat_IntVec_t *p)
Definition: msatVec.c:425
void Msat_SolverMarkClausesStart(Msat_Solver_t *p)
Definition: msatSolverApi.c:69
void Msat_VarHeapPrint(FILE *pFile, Msat_VarHeap_t *p)
int Msat_VarHeapReadMax(Msat_VarHeap_t *p)
void Msat_VarHeapUpdate(Msat_VarHeap_t *p, int iVar)
void Msat_IntVecFill(Msat_IntVec_t *p, int nSize, int Entry)
Definition: msatVec.c:177
void Msat_SolverResize(Msat_Solver_t *pMan, int nVarsAlloc)
void Msat_SolverPrepare(Msat_Solver_t *pSat, Msat_IntVec_t *vVars)
int Msat_IntVecReadEntry(Msat_IntVec_t *p, int i)
Definition: msatVec.c:249
void Msat_VarHeapStart(Msat_VarHeap_t *p, int *pVars, int nVars, int nVarsAlloc)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
double Msat_VarHeapReadMaxWeight(Msat_VarHeap_t *p)
unsigned Msat_SolverReadTruth(Msat_Solver_t *p)
void Msat_VarHeapGrow(Msat_VarHeap_t *p, int nSize)
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
Msat_IntVec_t * Msat_IntVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: msatVec.c:48
void Msat_IntVecFree(Msat_IntVec_t *p)
Definition: msatVec.c:160
void Msat_SolverSetVerbosity(Msat_Solver_t *p, int fVerbose)
Definition: msatSolverApi.c:63
Msat_VarHeap_t * Msat_VarHeapAlloc()
int Msat_VarHeapCountNodes(Msat_VarHeap_t *p, double WeightLimit)
Msat_ClauseVec_t * Msat_SolverReadAdjacents(Msat_Solver_t *p)
int Msat_IntVecPushUnique(Msat_IntVec_t *p, int Entry)
Definition: msatVec.c:374
int Msat_VarHeapGetMax(Msat_VarHeap_t *p)
void Msat_SolverClean(Msat_Solver_t *p, int nVars)
int Msat_SolverReadVarNum(Msat_Solver_t *p)
FUNCTION DEFINITIONS ///.
Definition: msatSolverApi.c:47
void Msat_SolverSetProofWriting(Msat_Solver_t *p, int fProof)
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
void Msat_IntVecWriteEntry(Msat_IntVec_t *p, int i, int Entry)
Definition: msatVec.c:266
int Msat_SolverReadVarAllocNum(Msat_Solver_t *p)
Definition: msatSolverApi.c:49
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition: msatVec.c:299
void Msat_IntVecPushUniqueOrder(Msat_IntVec_t *p, int Entry, int fIncrease)
Definition: msatVec.c:395
void Msat_SolverPrintStats(Msat_Solver_t *p)
void Msat_IntVecSort(Msat_IntVec_t *p, int fReverse)
Definition: msatVec.c:442
typedefABC_NAMESPACE_HEADER_START struct Msat_Solver_t_ Msat_Solver_t
INCLUDES ///.
Definition: msat.h:42
int Msat_SolverSolve(Msat_Solver_t *p, Msat_IntVec_t *pVecAssumps, int nBackTrackLimit, int nTimeLimit)