ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
xsatSolver.h
Go to the documentation of this file.
1
21#ifndef ABC__sat__xSAT__xsatSolver_h
22#define ABC__sat__xSAT__xsatSolver_h
23
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <assert.h>
31
33#include "misc/vec/vecStr.h"
34
35#include "xsat.h"
36#include "xsatBQueue.h"
37#include "xsatClause.h"
38#include "xsatHeap.h"
39#include "xsatMemory.h"
40#include "xsatWatchList.h"
41
43
44#ifndef __cplusplus
45#ifndef false
46# define false 0
47#endif
48#ifndef true
49# define true 1
50#endif
51#endif
52
53enum
54{
55 Var0 = 1,
56 Var1 = 0,
57 VarX = 3
58};
59
60enum
61{
65};
66
67enum
68{
71};
72
73#define CRefUndef 0xFFFFFFFF
74
80{
82
83 // Limits
84 iword nConfLimit; // external limit on the number of conflicts
85 iword nInsLimit; // external limit on the number of implications
86 abctime nRuntimeLimit; // external limit on runtime
87
88 // Constants used for restart heuristic
89 double K; // Forces a restart
90 double R; // Block a restart
91 int nFirstBlockRestart; // Lower bound number of conflicts for start blocking restarts
92 int nSizeLBDQueue; // Size of the moving avarege queue for LBD (force restart)
93 int nSizeTrailQueue; // Size of the moving avarege queue for Trail size (block restart)
94
95 // Constants used for clause database reduction heuristic
96 int nConfFirstReduce; // Number of conflicts before first reduction
97 int nIncReduce; // Increment to reduce
98 int nSpecialIncReduce; // Special increment to reduce
100};
101
116
118{
119 /* Clauses Database */
125
126 /* Activity heuristic */
127 int nVarActInc; /* Amount to bump next variable with. */
128 int nClaActInc; /* Amount to bump next clause with. */
129
130 /* Variable Information */
131 Vec_Int_t * vActivity; /* A heuristic measurement of the activity of a variable. */
133 Vec_Int_t * vLevels; /* Decision level of the current assignment */
134 Vec_Int_t * vReasons; /* Reason (clause) of the current assignment */
135 Vec_Str_t * vAssigns; /* Current assignment. */
138
139 /* Assignments */
141 Vec_Int_t * vTrailLim; // Separator indices for different decision levels in 'trail'.
142 int iQhead; // Head of propagation queue (as index into the trail).
143
144 int nAssignSimplify; /* Number of top-level assignments since last
145 * execution of 'simplify()'. */
146 iword nPropSimplify; /* Remaining number of propagations that must be
147 * made before next execution of 'simplify()'. */
148
149 /* Temporary data used by Search method */
152 float nSumLBD;
154 long nRC1;
155 int nRC2;
156
157 /* Temporary data used by Analyze */
163
164 /* Misc temporary */
165 unsigned nStamp;
166 Vec_Int_t * vStamp; /* Multipurpose stamp used to calculate LBD and
167 * clauses minimization with binary resolution */
168
171};
172
173static inline int xSAT_Var2Lit( int Var, int c )
174{
175 return Var + Var + ( c != 0 );
176}
177
178static inline int xSAT_NegLit( int Lit )
179{
180 return Lit ^ 1;
181}
182
183static inline int xSAT_Lit2Var( int Lit )
184{
185 return Lit >> 1;
186}
187
188static inline int xSAT_LitSign( int Lit )
189{
190 return Lit & 1;
191}
192
193static inline int xSAT_SolverDecisionLevel( xSAT_Solver_t * s )
194{
195 return Vec_IntSize( s->vTrailLim );
196}
197
198static inline xSAT_Clause_t * xSAT_SolverReadClause( xSAT_Solver_t * s, unsigned h )
199{
200 return xSAT_MemClauseHand( s->pMemory, h );
201}
202
203static inline int xSAT_SolverIsClauseSatisfied( xSAT_Solver_t * s, xSAT_Clause_t * pCla )
204{
205 int i;
206 int * Lits = &( pCla->pData[0].Lit );
207
208 for ( i = 0; i < pCla->nSize; i++ )
209 if ( Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( Lits[i] ) ) == xSAT_LitSign( ( Lits[i] ) ) )
210 return true;
211
212 return false;
213}
214
215static inline void xSAT_SolverPrintClauses( xSAT_Solver_t * s )
216{
217 int i;
218 unsigned CRef;
219
220 Vec_IntForEachEntry( s->vClauses, CRef, i )
221 xSAT_ClausePrint( xSAT_SolverReadClause( s, CRef ) );
222}
223
224static inline void xSAT_SolverPrintState( xSAT_Solver_t * s )
225{
226 printf( "starts : %10d\n", s->Stats.nStarts );
227 printf( "conflicts : %10ld\n", s->Stats.nConflicts );
228 printf( "decisions : %10ld\n", s->Stats.nDecisions );
229 printf( "propagations : %10ld\n", s->Stats.nPropagations );
230}
231
232
236extern unsigned xSAT_SolverClaNew( xSAT_Solver_t* s, Vec_Int_t * vLits, int fLearnt );
237extern char xSAT_SolverSearch( xSAT_Solver_t * s );
238
240
241extern int xSAT_SolverEnqueue( xSAT_Solver_t* s, int Lit, unsigned From );
242extern void xSAT_SolverCancelUntil( xSAT_Solver_t* s, int Level);
243extern unsigned xSAT_SolverPropagate( xSAT_Solver_t* s );
245
247
248#endif
ABC_INT64_T iword
Definition abc_global.h:244
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
int Var
Definition exorList.c:228
RegionAllocator< uint32_t >::Ref CRef
unsigned nLBDFrozenClause
Definition xsatSolver.h:99
Vec_Int_t * vLastDLevel
Definition xsatSolver.h:162
Vec_Str_t * vPolarity
Definition xsatSolver.h:136
Vec_Int_t * vStamp
Definition xsatSolver.h:166
Vec_Int_t * vActivity
Definition xsatSolver.h:131
Vec_Str_t * vTags
Definition xsatSolver.h:137
Vec_Str_t * vSeen
Definition xsatSolver.h:159
xSAT_Mem_t * pMemory
Definition xsatSolver.h:120
Vec_Int_t * vTagged
Definition xsatSolver.h:160
xSAT_SolverOptions_t Config
Definition xsatSolver.h:169
xSAT_VecWatchList_t * vWatches
Definition xsatSolver.h:123
Vec_Int_t * vReasons
Definition xsatSolver.h:134
iword nPropSimplify
Definition xsatSolver.h:146
Vec_Int_t * vLearntClause
Definition xsatSolver.h:158
Vec_Int_t * vTrail
Definition xsatSolver.h:140
unsigned nStamp
Definition xsatSolver.h:165
xSAT_BQueue_t * bqLBD
Definition xsatSolver.h:151
Vec_Int_t * vLevels
Definition xsatSolver.h:133
Vec_Int_t * vTrailLim
Definition xsatSolver.h:141
Vec_Int_t * vClauses
Definition xsatSolver.h:122
Vec_Int_t * vLearnts
Definition xsatSolver.h:121
xSAT_BQueue_t * bqTrail
Definition xsatSolver.h:150
Vec_Int_t * vStack
Definition xsatSolver.h:161
xSAT_Stats_t Stats
Definition xsatSolver.h:170
xSAT_VecWatchList_t * vBinWatches
Definition xsatSolver.h:124
xSAT_Heap_t * hOrder
Definition xsatSolver.h:132
Vec_Str_t * vAssigns
Definition xsatSolver.h:135
iword nLearntLits
Definition xsatSolver.h:114
unsigned nReduceDB
Definition xsatSolver.h:106
iword nPropagations
Definition xsatSolver.h:109
unsigned nStarts
Definition xsatSolver.h:105
iword nClauseLits
Definition xsatSolver.h:113
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct xSAT_BQueue_t_ xSAT_BQueue_t
INCLUDES ///.
Definition xsatBQueue.h:34
typedefABC_NAMESPACE_HEADER_START struct xSAT_Clause_t_ xSAT_Clause_t
INCLUDES ///.
Definition xsatClause.h:34
typedefABC_NAMESPACE_HEADER_START struct xSAT_Heap_t_ xSAT_Heap_t
STRUCTURE DEFINITIONS ///.
Definition xsatHeap.h:32
typedefABC_NAMESPACE_HEADER_START struct xSAT_Mem_t_ xSAT_Mem_t
INCLUDES ///.
Definition xsatMemory.h:36
void xSAT_SolverRebuildOrderHeap(xSAT_Solver_t *s)
Definition xsatSolver.c:77
@ VarX
Definition xsatSolver.h:57
@ Var1
Definition xsatSolver.h:56
@ Var0
Definition xsatSolver.h:55
int xSAT_SolverEnqueue(xSAT_Solver_t *s, int Lit, unsigned From)
Definition xsatSolver.c:333
@ LitUndef
Definition xsatSolver.h:70
@ VarUndef
Definition xsatSolver.h:69
struct xSAT_SolverOptions_t_ xSAT_SolverOptions_t
STRUCTURE DEFINITIONS ///.
Definition xsatSolver.h:78
void xSAT_SolverGarbageCollect(xSAT_Solver_t *s)
Definition xsatSolver.c:964
void xSAT_SolverCancelUntil(xSAT_Solver_t *s, int Level)
Definition xsatSolver.c:375
char xSAT_SolverSearch(xSAT_Solver_t *s)
Definition xsatSolver.c:847
struct xSAT_Stats_t_ xSAT_Stats_t
Definition xsatSolver.h:102
unsigned xSAT_SolverPropagate(xSAT_Solver_t *s)
Definition xsatSolver.c:665
unsigned xSAT_SolverClaNew(xSAT_Solver_t *s, Vec_Int_t *vLits, int fLearnt)
FUNCTION DECLARATIONS ///.
Definition xsatSolver.c:269
@ LBoolFalse
Definition xsatSolver.h:64
@ LBoolTrue
Definition xsatSolver.h:63
@ LBoolUndef
Definition xsatSolver.h:62
struct xSAT_VecWatchList_t_ xSAT_VecWatchList_t
struct xSAT_Solver_t_ xSAT_Solver_t
Definition xsat.h:36