abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
satSolver2.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "satVec.h"
#include "satClause.h"
#include "misc/vec/vecSet.h"
#include "satProof2.h"

Go to the source code of this file.

Data Structures

struct  sat_solver2_t
 

Typedefs

typedef struct sat_solver2_t sat_solver2
 
typedef struct Int2_Man_t_ Int2_Man_t
 
typedef struct varinfo2_t varinfo2
 

Functions

sat_solver2sat_solver2_new (void)
 
void sat_solver2_delete (sat_solver2 *s)
 
int sat_solver2_addclause (sat_solver2 *s, lit *begin, lit *end, int Id)
 
int sat_solver2_simplify (sat_solver2 *s)
 
int sat_solver2_solve (sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
 
void sat_solver2_rollback (sat_solver2 *s)
 
void sat_solver2_reducedb (sat_solver2 *s)
 
double sat_solver2_memory (sat_solver2 *s, int fAll)
 
double sat_solver2_memory_proof (sat_solver2 *s)
 
void sat_solver2_setnvars (sat_solver2 *s, int n)
 
void Sat_Solver2WriteDimacs (sat_solver2 *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
 
void Sat_Solver2PrintStats (FILE *pFile, sat_solver2 *p)
 
int * Sat_Solver2GetModel (sat_solver2 *p, int *pVars, int nVars)
 
void Sat_Solver2DoubleClauses (sat_solver2 *p, int iVar)
 
int var_is_assigned (sat_solver2 *s, int v)
 
int var_is_partA (sat_solver2 *s, int v)
 
void var_set_partA (sat_solver2 *s, int v, int partA)
 
void * Sat_ProofCore (sat_solver2 *s)
 
void * Sat_ProofInterpolant (sat_solver2 *s, void *pGloVars)
 
wordSat_ProofInterpolantTruth (sat_solver2 *s, void *pGloVars)
 
void Sat_ProofCheck (sat_solver2 *s)
 
Int2_Man_tInt2_ManStart (sat_solver2 *pSat, int *pGloVars, int nGloVars)
 FUNCTION DEFINITIONS ///. More...
 
void Int2_ManStop (Int2_Man_t *p)
 
int Int2_ManChainStart (Int2_Man_t *p, clause *c)
 
int Int2_ManChainResolve (Int2_Man_t *p, clause *c, int iLit, int varA)
 
void * Int2_ManReadInterpolant (sat_solver2 *s)
 
static clauseclause2_read (sat_solver2 *s, cla h)
 
static int clause2_proofid (sat_solver2 *s, clause *c, int varA)
 
static int clause2_is_partA (sat_solver2 *s, int h)
 
static void clause2_set_partA (sat_solver2 *s, int h, int partA)
 
static int clause2_id (sat_solver2 *s, int h)
 
static void clause2_set_id (sat_solver2 *s, int h, int id)
 
static int sat_solver2_nvars (sat_solver2 *s)
 
static int sat_solver2_nclauses (sat_solver2 *s)
 
static int sat_solver2_nlearnts (sat_solver2 *s)
 
static int sat_solver2_nconflicts (sat_solver2 *s)
 
static int sat_solver2_var_value (sat_solver2 *s, int v)
 
static int sat_solver2_var_literal (sat_solver2 *s, int v)
 
static void sat_solver2_act_var_clear (sat_solver2 *s)
 
static int sat_solver2_final (sat_solver2 *s, int **ppArray)
 
static abctime sat_solver2_set_runtime_limit (sat_solver2 *s, abctime Limit)
 
static int sat_solver2_set_learntmax (sat_solver2 *s, int nLearntMax)
 
static void sat_solver2_bookmark (sat_solver2 *s)
 
static int sat_solver2_add_const (sat_solver2 *pSat, int iVar, int fCompl, int fMark, int Id)
 
static int sat_solver2_add_buffer (sat_solver2 *pSat, int iVarA, int iVarB, int fCompl, int fMark, int Id)
 
static int sat_solver2_add_and (sat_solver2 *pSat, int iVar, int iVar0, int iVar1, int fCompl0, int fCompl1, int fMark, int Id)
 
static int sat_solver2_add_xor (sat_solver2 *pSat, int iVarA, int iVarB, int iVarC, int fCompl, int fMark, int Id)
 
static int sat_solver2_add_constraint (sat_solver2 *pSat, int iVar, int iVar2, int fCompl, int fMark, int Id)
 

Typedef Documentation

typedef struct Int2_Man_t_ Int2_Man_t

Definition at line 45 of file satSolver2.h.

typedef struct sat_solver2_t sat_solver2

Definition at line 44 of file satSolver2.h.

typedef struct varinfo2_t varinfo2

Definition at line 88 of file satSolver2.h.

Function Documentation

static int clause2_id ( sat_solver2 s,
int  h 
)
inlinestatic

Definition at line 184 of file satSolver2.h.

184 { return clause_id(clause2_read(s, h)); }
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
static int clause_id(clause *c)
Definition: satClause.h:144
static int clause2_is_partA ( sat_solver2 s,
int  h 
)
inlinestatic

Definition at line 182 of file satSolver2.h.

182 { return clause2_read(s, h)->partA; }
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
unsigned partA
Definition: satClause.h:53
static int clause2_proofid ( sat_solver2 s,
clause c,
int  varA 
)
inlinestatic

Definition at line 179 of file satSolver2.h.

179 { return c->lrn ? (veci_begin(&s->claProofs)[clause_id(c)]<<2) | (varA<<1) : (clause_id(c)<<2) | (varA<<1) | 1; }
static int clause_id(clause *c)
Definition: satClause.h:144
unsigned lrn
Definition: satClause.h:51
static int * veci_begin(veci *v)
Definition: satVec.h:45
static clause* clause2_read ( sat_solver2 s,
cla  h 
)
inlinestatic

Definition at line 178 of file satSolver2.h.

178 { return Sat_MemClauseHand( &s->Mem, h ); }
Sat_Mem_t Mem
Definition: satSolver2.h:129
static clause * Sat_MemClauseHand(Sat_Mem_t *p, cla h)
Definition: satClause.h:98
static void clause2_set_id ( sat_solver2 s,
int  h,
int  id 
)
inlinestatic

Definition at line 185 of file satSolver2.h.

185 { clause_set_id(clause2_read(s, h), id); }
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
static void clause_set_id(clause *c, int id)
Definition: satClause.h:145
static void clause2_set_partA ( sat_solver2 s,
int  h,
int  partA 
)
inlinestatic

Definition at line 183 of file satSolver2.h.

183 { clause2_read(s, h)->partA = partA; }
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
unsigned partA
Definition: satClause.h:53
int Int2_ManChainResolve ( Int2_Man_t p,
clause c,
int  iLit,
int  varA 
)

Definition at line 134 of file satSolver2i.c.

135 {
136  int iLit2 = Int2_ManChainStart( p, c );
137  assert( iLit >= 0 );
138  if ( varA )
139  iLit = Gia_ManHashOr( p->pGia, iLit, iLit2 );
140  else
141  iLit = Gia_ManHashAnd( p->pGia, iLit, iLit2 );
142  return iLit;
143 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Int2_ManChainStart(Int2_Man_t *p, clause *c)
Definition: satSolver2i.c:108
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Int2_ManChainStart ( Int2_Man_t p,
clause c 
)

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

Synopsis [Computing interpolant for a clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file satSolver2i.c.

109 {
110  if ( c->lrn )
111  return veci_begin(&p->pSat->claProofs)[clause_id(c)];
112  if ( !c->partA )
113  return 1;
114  if ( c->lits[c->size] < 0 )
115  {
116  int i, Var, CiId, Res = 0;
117  for ( i = 0; i < (int)c->size; i++ )
118  {
119  // get ID of the global variable
120  if ( Abc_Lit2Var(c->lits[i]) >= Vec_IntSize(p->vVar2Glo) )
121  continue;
122  Var = Vec_IntEntry( p->vVar2Glo, Abc_Lit2Var(c->lits[i]) );
123  if ( Var < 0 )
124  continue;
125  // get literal of the AIG node
126  CiId = Gia_ObjId( p->pGia, Gia_ManCi(p->pGia, Var) );
127  // compute interpolant of the clause
128  Res = Gia_ManHashOr( p->pGia, Res, Abc_Var2Lit(CiId, Abc_LitIsCompl(c->lits[i])) );
129  }
130  c->lits[c->size] = Res;
131  }
132  return c->lits[c->size];
133 }
lit lits[0]
Definition: satClause.h:56
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int clause_id(clause *c)
Definition: satClause.h:144
unsigned partA
Definition: satClause.h:53
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned size
Definition: satClause.h:55
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Var
Definition: SolverTypes.h:42
unsigned lrn
Definition: satClause.h:51
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
static int * veci_begin(veci *v)
Definition: satVec.h:45
void* Int2_ManReadInterpolant ( sat_solver2 s)

Definition at line 80 of file satSolver2i.c.

81 {
82  Int2_Man_t * p = pSat->pInt2;
83  Gia_Man_t * pTemp, * pGia = p->pGia; p->pGia = NULL;
84  // return NULL, if the interpolant is not ready (for example, when the solver returned 'sat')
85  if ( pSat->hProofLast == -1 )
86  return NULL;
87  // create AIG with one primary output
88  assert( Gia_ManPoNum(pGia) == 0 );
89  Gia_ManAppendCo( pGia, pSat->hProofLast );
90  pSat->hProofLast = -1;
91  // cleanup the resulting AIG
92  pGia = Gia_ManCleanup( pTemp = pGia );
93  Gia_ManStop( pTemp );
94  return (void *)pGia;
95 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Int2_Man_t_ Int2_Man_t
INCLUDES ///.
Definition: int2Int.h:45
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Int2_Man_t* Int2_ManStart ( sat_solver2 pSat,
int *  pGloVars,
int  nGloVars 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Managing interpolation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 56 of file satSolver2i.c.

57 {
58  Int2_Man_t * p;
59  int i;
60  p = ABC_CALLOC( Int2_Man_t, 1 );
61  p->pSat = pSat;
62  p->vGloVars = Vec_IntAllocArrayCopy( pGloVars, nGloVars );
63  p->vVar2Glo = Vec_IntInvert( p->vGloVars, -1 );
64  p->pGia = Gia_ManStart( 10 * Vec_IntSize(p->vGloVars) );
65  p->pGia->pName = Abc_UtilStrsav( "interpolant" );
66  for ( i = 0; i < nGloVars; i++ )
67  Gia_ManAppendCi( p->pGia );
68  Gia_ManHashStart( p->pGia );
69  return p;
70 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static Vec_Int_t * Vec_IntInvert(Vec_Int_t *p, int Fill)
Definition: vecInt.h:1092
typedefABC_NAMESPACE_HEADER_START struct Int2_Man_t_ Int2_Man_t
INCLUDES ///.
Definition: int2Int.h:45
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static Vec_Int_t * Vec_IntAllocArrayCopy(int *pArray, int nSize)
Definition: vecInt.h:192
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Int2_ManStop ( Int2_Man_t p)

Definition at line 71 of file satSolver2i.c.

72 {
73  if ( p == NULL )
74  return;
75  Gia_ManStopP( &p->pGia );
76  Vec_IntFree( p->vGloVars );
77  Vec_IntFree( p->vVar2Glo );
78  ABC_FREE( p );
79 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Sat_ProofCheck ( sat_solver2 s)
void* Sat_ProofCore ( sat_solver2 s)

Definition at line 1985 of file satSolver2.c.

1986 {
1987  extern void * Proof_DeriveCore( Vec_Set_t * vProof, int hRoot );
1988  if ( s->pPrf1 )
1989  return Proof_DeriveCore( s->pPrf1, s->hProofLast );
1990  if ( s->pPrf2 )
1991  {
1993  return Prf_ManUnsatCore( s->pPrf2 );
1994  }
1995  return NULL;
1996 }
void * Proof_DeriveCore(Vec_Set_t *vProof, int hRoot)
Definition: satProof.c:913
double dPrfMemory
Definition: satSolver2.h:167
static double Abc_MaxDouble(double a, double b)
Definition: abc_global.h:246
static Vec_Int_t * Prf_ManUnsatCore(Prf_Man_t *p)
Definition: satProof2.h:287
static double Prf_ManMemory(Prf_Man_t *p)
Definition: satProof2.h:104
typedefABC_NAMESPACE_HEADER_START struct Vec_Set_t_ Vec_Set_t
INCLUDES ///.
Definition: vecSet.h:49
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
Prf_Man_t * pPrf2
Definition: satSolver2.h:166
void* Sat_ProofInterpolant ( sat_solver2 s,
void *  pGloVars 
)
word* Sat_ProofInterpolantTruth ( sat_solver2 s,
void *  pGloVars 
)
static void sat_solver2_act_var_clear ( sat_solver2 s)
inlinestatic

Definition at line 220 of file satSolver2.h.

221 {
222  int i;
223  for (i = 0; i < s->size; i++)
224  s->activity[i] = 0;//.0;
225  s->var_inc = 1.0;
226 }
unsigned * activity
Definition: satSolver2.h:112
static int sat_solver2_add_and ( sat_solver2 pSat,
int  iVar,
int  iVar0,
int  iVar1,
int  fCompl0,
int  fCompl1,
int  fMark,
int  Id 
)
inlinestatic

Definition at line 294 of file satSolver2.h.

295 {
296  lit Lits[3];
297  int Cid;
298 
299  Lits[0] = toLitCond( iVar, 1 );
300  Lits[1] = toLitCond( iVar0, fCompl0 );
301  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
302  if ( fMark )
303  clause2_set_partA( pSat, Cid, 1 );
304 
305  Lits[0] = toLitCond( iVar, 1 );
306  Lits[1] = toLitCond( iVar1, fCompl1 );
307  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
308  if ( fMark )
309  clause2_set_partA( pSat, Cid, 1 );
310 
311  Lits[0] = toLitCond( iVar, 0 );
312  Lits[1] = toLitCond( iVar0, !fCompl0 );
313  Lits[2] = toLitCond( iVar1, !fCompl1 );
314  Cid = sat_solver2_addclause( pSat, Lits, Lits + 3, Id );
315  if ( fMark )
316  clause2_set_partA( pSat, Cid, 1 );
317  return 3;
318 }
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
Definition: satSolver2.c:1287
int lit
Definition: satVec.h:130
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static void clause2_set_partA(sat_solver2 *s, int h, int partA)
Definition: satSolver2.h:183
static int sat_solver2_add_buffer ( sat_solver2 pSat,
int  iVarA,
int  iVarB,
int  fCompl,
int  fMark,
int  Id 
)
inlinestatic

Definition at line 275 of file satSolver2.h.

276 {
277  lit Lits[2];
278  int Cid;
279  assert( iVarA >= 0 && iVarB >= 0 );
280 
281  Lits[0] = toLitCond( iVarA, 0 );
282  Lits[1] = toLitCond( iVarB, !fCompl );
283  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
284  if ( fMark )
285  clause2_set_partA( pSat, Cid, 1 );
286 
287  Lits[0] = toLitCond( iVarA, 1 );
288  Lits[1] = toLitCond( iVarB, fCompl );
289  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
290  if ( fMark )
291  clause2_set_partA( pSat, Cid, 1 );
292  return 2;
293 }
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
Definition: satSolver2.c:1287
int lit
Definition: satVec.h:130
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static void clause2_set_partA(sat_solver2 *s, int h, int partA)
Definition: satSolver2.h:183
#define assert(ex)
Definition: util_old.h:213
static int sat_solver2_add_const ( sat_solver2 pSat,
int  iVar,
int  fCompl,
int  fMark,
int  Id 
)
inlinestatic

Definition at line 263 of file satSolver2.h.

264 {
265  lit Lits[1];
266  int Cid;
267  assert( iVar >= 0 );
268 
269  Lits[0] = toLitCond( iVar, fCompl );
270  Cid = sat_solver2_addclause( pSat, Lits, Lits + 1, Id );
271  if ( fMark )
272  clause2_set_partA( pSat, Cid, 1 );
273  return 1;
274 }
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
Definition: satSolver2.c:1287
int lit
Definition: satVec.h:130
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static void clause2_set_partA(sat_solver2 *s, int h, int partA)
Definition: satSolver2.h:183
#define assert(ex)
Definition: util_old.h:213
static int sat_solver2_add_constraint ( sat_solver2 pSat,
int  iVar,
int  iVar2,
int  fCompl,
int  fMark,
int  Id 
)
inlinestatic

Definition at line 354 of file satSolver2.h.

355 {
356  lit Lits[2];
357  int Cid;
358  assert( iVar >= 0 );
359 
360  Lits[0] = toLitCond( iVar, fCompl );
361  Lits[1] = toLitCond( iVar2, 0 );
362  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
363  if ( fMark )
364  clause2_set_partA( pSat, Cid, 1 );
365 
366  Lits[0] = toLitCond( iVar, fCompl );
367  Lits[1] = toLitCond( iVar2, 1 );
368  Cid = sat_solver2_addclause( pSat, Lits, Lits + 2, Id );
369  if ( fMark )
370  clause2_set_partA( pSat, Cid, 1 );
371  return 2;
372 }
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
Definition: satSolver2.c:1287
int lit
Definition: satVec.h:130
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static void clause2_set_partA(sat_solver2 *s, int h, int partA)
Definition: satSolver2.h:183
#define assert(ex)
Definition: util_old.h:213
static int sat_solver2_add_xor ( sat_solver2 pSat,
int  iVarA,
int  iVarB,
int  iVarC,
int  fCompl,
int  fMark,
int  Id 
)
inlinestatic

Definition at line 319 of file satSolver2.h.

320 {
321  lit Lits[3];
322  int Cid;
323  assert( iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
324 
325  Lits[0] = toLitCond( iVarA, !fCompl );
326  Lits[1] = toLitCond( iVarB, 1 );
327  Lits[2] = toLitCond( iVarC, 1 );
328  Cid = sat_solver2_addclause( pSat, Lits, Lits + 3, Id );
329  if ( fMark )
330  clause2_set_partA( pSat, Cid, 1 );
331 
332  Lits[0] = toLitCond( iVarA, !fCompl );
333  Lits[1] = toLitCond( iVarB, 0 );
334  Lits[2] = toLitCond( iVarC, 0 );
335  Cid = sat_solver2_addclause( pSat, Lits, Lits + 3, Id );
336  if ( fMark )
337  clause2_set_partA( pSat, Cid, 1 );
338 
339  Lits[0] = toLitCond( iVarA, fCompl );
340  Lits[1] = toLitCond( iVarB, 1 );
341  Lits[2] = toLitCond( iVarC, 0 );
342  Cid = sat_solver2_addclause( pSat, Lits, Lits + 3, Id );
343  if ( fMark )
344  clause2_set_partA( pSat, Cid, 1 );
345 
346  Lits[0] = toLitCond( iVarA, fCompl );
347  Lits[1] = toLitCond( iVarB, 0 );
348  Lits[2] = toLitCond( iVarC, 1 );
349  Cid = sat_solver2_addclause( pSat, Lits, Lits + 3, Id );
350  if ( fMark )
351  clause2_set_partA( pSat, Cid, 1 );
352  return 4;
353 }
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
Definition: satSolver2.c:1287
int lit
Definition: satVec.h:130
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static void clause2_set_partA(sat_solver2 *s, int h, int partA)
Definition: satSolver2.h:183
#define assert(ex)
Definition: util_old.h:213
int sat_solver2_addclause ( sat_solver2 s,
lit begin,
lit end,
int  Id 
)

Definition at line 1287 of file satSolver2.c.

1288 {
1289  cla Cid;
1290  lit *i,*j,*iFree = NULL;
1291  int maxvar, count, temp;
1292  assert( solver2_dlevel(s) == 0 );
1293  assert( begin < end );
1294  assert( Id != 0 );
1295 
1296  // copy clause into storage
1297  veci_resize( &s->temp_clause, 0 );
1298  for ( i = begin; i < end; i++ )
1299  veci_push( &s->temp_clause, *i );
1300  begin = veci_begin( &s->temp_clause );
1301  end = begin + veci_size( &s->temp_clause );
1302 
1303  // insertion sort
1304  maxvar = lit_var(*begin);
1305  for (i = begin + 1; i < end; i++){
1306  lit l = *i;
1307  maxvar = lit_var(l) > maxvar ? lit_var(l) : maxvar;
1308  for (j = i; j > begin && *(j-1) > l; j--)
1309  *j = *(j-1);
1310  *j = l;
1311  }
1312  sat_solver2_setnvars(s,maxvar+1);
1313 
1314 
1315  // delete duplicates
1316  for (i = j = begin + 1; i < end; i++)
1317  {
1318  if ( *(i-1) == lit_neg(*i) ) // tautology
1319  return clause2_create_new( s, begin, end, 0, 0 ); // add it anyway, to preserve proper clause count
1320  if ( *(i-1) != *i )
1321  *j++ = *i;
1322  }
1323  end = j;
1324  assert( begin < end );
1325 
1326  // coount the number of 0-literals
1327  count = 0;
1328  for ( i = begin; i < end; i++ )
1329  {
1330  // make sure all literals are unique
1331  assert( i == begin || lit_var(*(i-1)) != lit_var(*i) );
1332  // consider the value of this literal
1333  if ( var_value(s, lit_var(*i)) == lit_sign(*i) ) // this clause is always true
1334  return clause2_create_new( s, begin, end, 0, 0 ); // add it anyway, to preserve proper clause count
1335  if ( var_value(s, lit_var(*i)) == varX ) // unassigned literal
1336  iFree = i;
1337  else
1338  count++; // literal is 0
1339  }
1340  assert( count < end-begin ); // the clause cannot be UNSAT
1341 
1342  // swap variables to make sure the clause is watched using unassigned variable
1343  temp = *iFree;
1344  *iFree = *begin;
1345  *begin = temp;
1346 
1347  // create a new clause
1348  Cid = clause2_create_new( s, begin, end, 0, 0 );
1349  if ( Id )
1350  clause2_set_id( s, Cid, Id );
1351 
1352  // handle unit clause
1353  if ( count+1 == end-begin )
1354  {
1355  if ( s->fProofLogging )
1356  {
1357  if ( count == 0 ) // original learned clause
1358  {
1359  var_set_unit_clause( s, lit_var(begin[0]), Cid );
1360  if ( !solver2_enqueue(s,begin[0],0) )
1361  assert( 0 );
1362  }
1363  else
1364  {
1365  // Log production of top-level unit clause:
1366  int x, k, proof_id, CidNew;
1367  clause* c = clause2_read(s, Cid);
1368  proof_chain_start( s, c );
1369  clause_foreach_var( c, x, k, 1 )
1370  proof_chain_resolve( s, NULL, x );
1371  proof_id = proof_chain_stop( s );
1372  // generate a new clause
1373  CidNew = clause2_create_new( s, begin, begin+1, 1, proof_id );
1374  var_set_unit_clause( s, lit_var(begin[0]), CidNew );
1375  if ( !solver2_enqueue(s,begin[0],Cid) )
1376  assert( 0 );
1377  }
1378  }
1379  }
1380  return Cid;
1381 }
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
static int lit_var(lit l)
Definition: satVec.h:145
static void veci_push(veci *v, int e)
Definition: satVec.h:53
veci temp_clause
Definition: satSolver2.h:153
static void var_set_unit_clause(sat_solver2 *s, int v, cla i)
Definition: satSolver2.c:152
static void veci_resize(veci *v, int k)
Definition: satVec.h:47
void sat_solver2_setnvars(sat_solver2 *s, int n)
Definition: satSolver2.c:1170
int cla
Definition: satVec.h:131
int lit
Definition: satVec.h:130
static void proof_chain_resolve(sat_solver2 *s, clause *cls, int Var)
Definition: satSolver2.c:187
static void clause2_set_id(sat_solver2 *s, int h, int id)
Definition: satSolver2.h:185
static lit lit_neg(lit l)
Definition: satVec.h:144
#define clause_foreach_var(p, var, i, start)
Definition: satSolver2.c:156
static int solver2_dlevel(sat_solver2 *s)
Definition: satSolver2.c:162
static const int varX
Definition: satSolver2.c:72
if(last==0)
Definition: sparse_int.h:34
static int solver2_enqueue(sat_solver2 *s, lit l, cla from)
Definition: satSolver2.c:455
static int var_value(sat_solver2 *s, int v)
Definition: satSolver2.c:90
static int lit_sign(lit l)
Definition: satVec.h:146
#define assert(ex)
Definition: util_old.h:213
static int proof_chain_stop(sat_solver2 *s)
Definition: satSolver2.c:210
static int clause2_create_new(sat_solver2 *s, lit *begin, lit *end, int learnt, int proof_id)
Definition: satSolver2.c:408
static int * veci_begin(veci *v)
Definition: satVec.h:45
static int veci_size(veci *v)
Definition: satVec.h:46
static void proof_chain_start(sat_solver2 *s, clause *c)
Definition: satSolver2.c:168
static void sat_solver2_bookmark ( sat_solver2 s)
inlinestatic

Definition at line 248 of file satSolver2.h.

249 {
250  assert( s->qhead == s->qtail );
251  s->iVarPivot = s->size;
252  s->iTrailPivot = s->qhead;
253  if ( s->pPrf1 )
255  Sat_MemBookMark( &s->Mem );
256  if ( s->activity2 )
257  {
258  s->var_inc2 = s->var_inc;
259  memcpy( s->activity2, s->activity, sizeof(unsigned) * s->iVarPivot );
260  }
261 }
static int Vec_SetHandCurrent(Vec_Set_t *p)
Definition: vecSet.h:83
char * memcpy()
Sat_Mem_t Mem
Definition: satSolver2.h:129
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
#define assert(ex)
Definition: util_old.h:213
unsigned * activity2
Definition: satSolver2.h:113
unsigned * activity
Definition: satSolver2.h:112
static void Sat_MemBookMark(Sat_Mem_t *p)
Definition: satClause.h:249
void sat_solver2_delete ( sat_solver2 s)

Definition at line 1225 of file satSolver2.c.

1226 {
1227  int fVerify = 0;
1228  if ( fVerify )
1229  {
1230  veci * pCore = (veci *)Sat_ProofCore( s );
1231 // Abc_Print(1, "UNSAT core contains %d clauses (%6.2f %%).\n", veci_size(pCore), 100.0*veci_size(pCore)/veci_size(&s->clauses) );
1232  veci_delete( pCore );
1233  ABC_FREE( pCore );
1234 // if ( s->fProofLogging )
1235 // Sat_ProofCheck( s );
1236  }
1237 
1238  // report statistics
1239 // Abc_Print(1, "Used %6.2f MB for proof-logging. Unit clauses = %d.\n", 1.0 * Vec_ReportMemory(&s->Proofs) / (1<<20), s->nUnits );
1240 
1241  // delete vectors
1242  veci_delete(&s->order);
1243  veci_delete(&s->trail_lim);
1244  veci_delete(&s->tagged);
1245  veci_delete(&s->stack);
1246  veci_delete(&s->temp_clause);
1247  veci_delete(&s->temp_proof);
1248  veci_delete(&s->conf_final);
1249  veci_delete(&s->mark_levels);
1252 // veci_delete(&s->learnt_live);
1253  veci_delete(&s->act_clas);
1254  veci_delete(&s->claProofs);
1255 // veci_delete(&s->clauses);
1256 // veci_delete(&s->lrns);
1257  Sat_MemFree_( &s->Mem );
1258 // veci_delete(&s->proofs);
1259  Vec_SetFree( s->pPrf1 );
1260  Prf_ManStop( s->pPrf2 );
1261  Int2_ManStop( s->pInt2 );
1262 
1263  // delete arrays
1264  if (s->vi != 0){
1265  int i;
1266  if ( s->wlists )
1267  for (i = 0; i < s->cap*2; i++)
1268  veci_delete(&s->wlists[i]);
1269  ABC_FREE(s->wlists );
1270  ABC_FREE(s->vi );
1271  ABC_FREE(s->levels );
1272  ABC_FREE(s->assigns );
1273  ABC_FREE(s->trail );
1274  ABC_FREE(s->orderpos );
1275  ABC_FREE(s->reasons );
1276  ABC_FREE(s->units );
1277  ABC_FREE(s->activity );
1278  ABC_FREE(s->activity2);
1279  ABC_FREE(s->model );
1280  }
1281  ABC_FREE(s);
1282 
1283 // Abc_PrintTime( 1, "Time", Time );
1284 }
veci * wlists
Definition: satSolver2.h:130
void * Sat_ProofCore(sat_solver2 *s)
Definition: satSolver2.c:1985
veci min_step_order
Definition: satSolver2.h:158
static void Vec_SetFree(Vec_Set_t *p)
Definition: vecSet.h:176
varinfo2 * vi
Definition: satSolver2.h:140
veci temp_clause
Definition: satSolver2.h:153
Int2_Man_t * pInt2
Definition: satSolver2.h:168
static void veci_delete(veci *v)
Definition: satVec.h:44
Definition: satVec.h:31
Sat_Mem_t Mem
Definition: satSolver2.h:129
static void Sat_MemFree_(Sat_Mem_t *p)
Definition: satClause.h:277
veci mark_levels
Definition: satSolver2.h:156
int * orderpos
Definition: satSolver2.h:144
veci min_lit_order
Definition: satSolver2.h:157
static void Int2_ManStop(Int2_Man_t *p)
Definition: int2Int.h:105
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Prf_ManStop(Prf_Man_t *p)
Definition: satProof2.h:91
Prf_Man_t * pPrf2
Definition: satSolver2.h:166
unsigned * activity2
Definition: satSolver2.h:113
unsigned * activity
Definition: satSolver2.h:112
char * assigns
Definition: satSolver2.h:142
static int sat_solver2_final ( sat_solver2 s,
int **  ppArray 
)
inlinestatic

Definition at line 228 of file satSolver2.h.

229 {
230  *ppArray = s->conf_final.ptr;
231  return s->conf_final.size;
232 }
int * ptr
Definition: satVec.h:34
int size
Definition: satVec.h:33
double sat_solver2_memory ( sat_solver2 s,
int  fAll 
)

Definition at line 1692 of file satSolver2.c.

1693 {
1694  int i;
1695  double Mem = sizeof(sat_solver2);
1696  if ( fAll )
1697  for (i = 0; i < s->cap*2; i++)
1698  Mem += s->wlists[i].cap * sizeof(int);
1699  Mem += s->cap * sizeof(veci); // ABC_FREE(s->wlists );
1700  Mem += s->act_clas.cap * sizeof(int);
1701  Mem += s->claProofs.cap * sizeof(int);
1702 // Mem += s->cap * sizeof(char); // ABC_FREE(s->polarity );
1703 // Mem += s->cap * sizeof(char); // ABC_FREE(s->tags );
1704  Mem += s->cap * sizeof(varinfo2); // ABC_FREE(s->vi );
1705  Mem += s->cap * sizeof(int); // ABC_FREE(s->levels );
1706  Mem += s->cap * sizeof(char); // ABC_FREE(s->assigns );
1707 #ifdef USE_FLOAT_ACTIVITY2
1708  Mem += s->cap * sizeof(double); // ABC_FREE(s->activity );
1709 #else
1710  Mem += s->cap * sizeof(unsigned); // ABC_FREE(s->activity );
1711  if ( s->activity2 )
1712  Mem += s->cap * sizeof(unsigned); // ABC_FREE(s->activity2);
1713 #endif
1714  Mem += s->cap * sizeof(lit); // ABC_FREE(s->trail );
1715  Mem += s->cap * sizeof(int); // ABC_FREE(s->orderpos );
1716  Mem += s->cap * sizeof(int); // ABC_FREE(s->reasons );
1717  Mem += s->cap * sizeof(int); // ABC_FREE(s->units );
1718  Mem += s->cap * sizeof(int); // ABC_FREE(s->model );
1719  Mem += s->tagged.cap * sizeof(int);
1720  Mem += s->stack.cap * sizeof(int);
1721  Mem += s->order.cap * sizeof(int);
1722  Mem += s->trail_lim.cap * sizeof(int);
1723  Mem += s->temp_clause.cap * sizeof(int);
1724  Mem += s->conf_final.cap * sizeof(int);
1725  Mem += s->mark_levels.cap * sizeof(int);
1726  Mem += s->min_lit_order.cap * sizeof(int);
1727  Mem += s->min_step_order.cap * sizeof(int);
1728  Mem += s->temp_proof.cap * sizeof(int);
1729  Mem += Sat_MemMemoryAll( &s->Mem );
1730 // Mem += Vec_ReportMemory( s->pPrf1 );
1731  return Mem;
1732 }
static double Sat_MemMemoryAll(Sat_Mem_t *p)
Definition: satClause.h:109
veci * wlists
Definition: satSolver2.h:130
veci min_step_order
Definition: satSolver2.h:158
veci temp_clause
Definition: satSolver2.h:153
Sat_Mem_t Mem
Definition: satSolver2.h:129
struct sat_solver2_t sat_solver2
Definition: satSolver2.h:44
int lit
Definition: satVec.h:130
veci mark_levels
Definition: satSolver2.h:156
veci min_lit_order
Definition: satSolver2.h:157
struct veci_t veci
Definition: satVec.h:36
struct varinfo2_t varinfo2
Definition: satSolver2.h:88
int cap
Definition: satVec.h:32
unsigned * activity2
Definition: satSolver2.h:113
double sat_solver2_memory_proof ( sat_solver2 s)

Definition at line 1733 of file satSolver2.c.

1734 {
1735  double Mem = s->dPrfMemory;
1736  if ( s->pPrf1 )
1737  Mem += Vec_ReportMemory( s->pPrf1 );
1738  return Mem;
1739 }
double dPrfMemory
Definition: satSolver2.h:167
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
static double Vec_ReportMemory(Vec_Set_t *p)
Definition: vecSet.h:194
static int sat_solver2_nclauses ( sat_solver2 s)
inlinestatic

Definition at line 195 of file satSolver2.h.

196 {
197  return (int)s->stats.clauses;
198 }
stats_t stats
Definition: satSolver2.h:172
unsigned clauses
Definition: satVec.h:153
static int sat_solver2_nconflicts ( sat_solver2 s)
inlinestatic

Definition at line 205 of file satSolver2.h.

206 {
207  return (int)s->stats.conflicts;
208 }
stats_t stats
Definition: satSolver2.h:172
ABC_INT64_T conflicts
Definition: satVec.h:154
sat_solver2* sat_solver2_new ( void  )

Definition at line 1109 of file satSolver2.c.

1110 {
1111  sat_solver2* s = (sat_solver2 *)ABC_CALLOC( char, sizeof(sat_solver2) );
1112 
1113 #ifdef USE_FLOAT_ACTIVITY2
1114  s->var_inc = 1;
1115  s->cla_inc = 1;
1116  s->var_decay = (float)(1 / 0.95 );
1117  s->cla_decay = (float)(1 / 0.999 );
1118 // s->cla_decay = 1;
1119 // s->var_decay = 1;
1120 #else
1121  s->var_inc = (1 << 5);
1122  s->cla_inc = (1 << 11);
1123 #endif
1124  s->random_seed = 91648253;
1125 
1126 #ifdef SAT_USE_PROOF_LOGGING
1127  s->fProofLogging = 1;
1128 #else
1129  s->fProofLogging = 0;
1130 #endif
1131  s->fSkipSimplify = 1;
1132  s->fNotUseRandom = 0;
1133  s->fVerbose = 0;
1134 
1135  s->nLearntStart = LEARNT_MAX_START_DEFAULT; // starting learned clause limit
1136  s->nLearntDelta = LEARNT_MAX_INCRE_DEFAULT; // delta of learned clause limit
1137  s->nLearntRatio = LEARNT_MAX_RATIO_DEFAULT; // ratio of learned clause limit
1138  s->nLearntMax = s->nLearntStart;
1139 
1140  // initialize vectors
1141  veci_new(&s->order);
1142  veci_new(&s->trail_lim);
1143  veci_new(&s->tagged);
1144  veci_new(&s->stack);
1145  veci_new(&s->temp_clause);
1146  veci_new(&s->temp_proof);
1147  veci_new(&s->conf_final);
1148  veci_new(&s->mark_levels);
1149  veci_new(&s->min_lit_order);
1150  veci_new(&s->min_step_order);
1151 // veci_new(&s->learnt_live);
1152  Sat_MemAlloc_( &s->Mem, 14 );
1153  veci_new(&s->act_clas);
1154  // proof-logging
1155  veci_new(&s->claProofs);
1156 // s->pPrf1 = Vec_SetAlloc( 20 );
1157  s->tempInter = -1;
1158 
1159  // initialize clause pointers
1160  s->hLearntLast = -1; // the last learnt clause
1161  s->hProofLast = -1; // the last proof ID
1162  // initialize rollback
1163  s->iVarPivot = 0; // the pivot for variables
1164  s->iTrailPivot = 0; // the pivot for trail
1165  s->hProofPivot = 1; // the pivot for proof records
1166  return s;
1167 }
veci min_step_order
Definition: satSolver2.h:158
veci temp_clause
Definition: satSolver2.h:153
Sat_Mem_t Mem
Definition: satSolver2.h:129
#define LEARNT_MAX_START_DEFAULT
INCLUDES ///.
Definition: satClause.h:37
veci mark_levels
Definition: satSolver2.h:156
static void veci_new(veci *v)
Definition: satVec.h:38
veci min_lit_order
Definition: satSolver2.h:157
#define LEARNT_MAX_INCRE_DEFAULT
Definition: satClause.h:38
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Sat_MemAlloc_(Sat_Mem_t *p, int nPageSize)
Definition: satClause.h:193
double random_seed
Definition: satSolver2.h:98
#define LEARNT_MAX_RATIO_DEFAULT
Definition: satClause.h:39
static int sat_solver2_nlearnts ( sat_solver2 s)
inlinestatic

Definition at line 200 of file satSolver2.h.

201 {
202  return (int)s->stats.learnts;
203 }
stats_t stats
Definition: satSolver2.h:172
unsigned learnts
Definition: satVec.h:153
static int sat_solver2_nvars ( sat_solver2 s)
inlinestatic

Definition at line 190 of file satSolver2.h.

191 {
192  return s->size;
193 }
void sat_solver2_reducedb ( sat_solver2 s)

Definition at line 1406 of file satSolver2.c.

1407 {
1408  static abctime TimeTotal = 0;
1409  Sat_Mem_t * pMem = &s->Mem;
1410  clause * c = NULL;
1411  int nLearnedOld = veci_size(&s->act_clas);
1412  int * act_clas = veci_begin(&s->act_clas);
1413  int * pPerm, * pSortValues, nCutoffValue, * pClaProofs;
1414  int i, j, k, Id, nSelected;//, LastSize = 0;
1415  int Counter, CounterStart;
1416  abctime clk = Abc_Clock();
1417  static int Count = 0;
1418  Count++;
1419  assert( s->nLearntMax );
1420  s->nDBreduces++;
1421 // printf( "Calling reduceDB with %d clause limit and parameters (%d %d %d).\n", s->nLearntMax, s->nLearntStart, s->nLearntDelta, s->nLearntRatio );
1422 
1423 /*
1424  // find the new limit
1425  s->nLearntMax = s->nLearntMax * 11 / 10;
1426  // preserve 1/10 of last clauses
1427  CounterStart = s->stats.learnts - (s->nLearntMax / 10);
1428  // preserve 1/10 of most active clauses
1429  pSortValues = veci_begin(&s->act_clas);
1430  pPerm = Abc_MergeSortCost( pSortValues, nLearnedOld );
1431  assert( pSortValues[pPerm[0]] <= pSortValues[pPerm[nLearnedOld-1]] );
1432  nCutoffValue = pSortValues[pPerm[nLearnedOld*9/10]];
1433  ABC_FREE( pPerm );
1434 // nCutoffValue = ABC_INFINITY;
1435 */
1436 
1437 
1438  // find the new limit
1439  s->nLearntMax = s->nLearntStart + s->nLearntDelta * s->nDBreduces;
1440  // preserve 1/20 of last clauses
1441  CounterStart = nLearnedOld - (s->nLearntMax / 20);
1442  // preserve 3/4 of most active clauses
1443  nSelected = nLearnedOld*s->nLearntRatio/100;
1444  // create sorting values
1445  pSortValues = ABC_ALLOC( int, nLearnedOld );
1446  Sat_MemForEachLearned( pMem, c, i, k )
1447  {
1448  Id = clause_id(c);
1449  pSortValues[Id] = (((7 - Abc_MinInt(c->lbd, 7)) << 28) | (act_clas[Id] >> 4));
1450 // pSortValues[Id] = act_clas[Id];
1451  assert( pSortValues[Id] >= 0 );
1452  }
1453  // find non-decreasing permutation
1454  pPerm = Abc_MergeSortCost( pSortValues, nLearnedOld );
1455  assert( pSortValues[pPerm[0]] <= pSortValues[pPerm[nLearnedOld-1]] );
1456  nCutoffValue = pSortValues[pPerm[nLearnedOld-nSelected]];
1457  ABC_FREE( pPerm );
1458 // nCutoffValue = ABC_INFINITY;
1459 
1460  // count how many clauses satisfy the condition
1461  Counter = j = 0;
1462  Sat_MemForEachLearned( pMem, c, i, k )
1463  {
1464  assert( c->mark == 0 );
1465  if ( Counter++ > CounterStart || clause_size(c) < 2 || pSortValues[clause_id(c)] >= nCutoffValue || s->reasons[lit_var(c->lits[0])] == Sat_MemHand(pMem, i, k) )
1466  {
1467  }
1468  else
1469  j++;
1470  if ( j >= nLearnedOld / 6 )
1471  break;
1472  }
1473  if ( j < nLearnedOld / 6 )
1474  {
1475  ABC_FREE( pSortValues );
1476  return;
1477  }
1478 
1479  // mark learned clauses to remove
1480  Counter = j = 0;
1481  pClaProofs = veci_size(&s->claProofs) ? veci_begin(&s->claProofs) : NULL;
1482  Sat_MemForEachLearned( pMem, c, i, k )
1483  {
1484  assert( c->mark == 0 );
1485  if ( Counter++ > CounterStart || clause_size(c) < 2 || pSortValues[clause_id(c)] >= nCutoffValue || s->reasons[lit_var(c->lits[0])] == Sat_MemHand(pMem, i, k) )
1486  {
1487  pSortValues[j] = pSortValues[clause_id(c)];
1488  if ( pClaProofs )
1489  pClaProofs[j] = pClaProofs[clause_id(c)];
1490  if ( s->pPrf2 )
1491  Prf_ManAddSaved( s->pPrf2, clause_id(c), j );
1492  j++;
1493  }
1494  else // delete
1495  {
1496  c->mark = 1;
1498  s->stats.learnts--;
1499  }
1500  }
1501  ABC_FREE( pSortValues );
1502  if ( s->pPrf2 )
1503  Prf_ManCompact( s->pPrf2, j );
1504 // if ( j == nLearnedOld )
1505 // return;
1506 
1507  assert( s->stats.learnts == (unsigned)j );
1508  assert( Counter == nLearnedOld );
1509  veci_resize(&s->act_clas,j);
1510  if ( veci_size(&s->claProofs) )
1511  veci_resize(&s->claProofs,j);
1512 
1513  // update ID of each clause to be its new handle
1514  Counter = Sat_MemCompactLearned( pMem, 0 );
1515  assert( Counter == (int)s->stats.learnts );
1516 
1517  // update reasons
1518  for ( i = 0; i < s->size; i++ )
1519  {
1520  if ( !s->reasons[i] ) // no reason
1521  continue;
1522  if ( clause_is_lit(s->reasons[i]) ) // 2-lit clause
1523  continue;
1524  if ( !clause_learnt_h(pMem, s->reasons[i]) ) // problem clause
1525  continue;
1526  assert( c->lrn );
1527  c = clause2_read( s, s->reasons[i] );
1528  assert( c->mark == 0 );
1529  s->reasons[i] = clause_id(c); // updating handle here!!!
1530  }
1531 
1532  // update watches
1533  for ( i = 0; i < s->size*2; i++ )
1534  {
1535  int * pArray = veci_begin(&s->wlists[i]);
1536  for ( j = k = 0; k < veci_size(&s->wlists[i]); k++ )
1537  {
1538  if ( clause_is_lit(pArray[k]) ) // 2-lit clause
1539  pArray[j++] = pArray[k];
1540  else if ( !clause_learnt_h(pMem, pArray[k]) ) // problem clause
1541  pArray[j++] = pArray[k];
1542  else
1543  {
1544  assert( c->lrn );
1545  c = clause2_read(s, pArray[k]);
1546  if ( !c->mark ) // useful learned clause
1547  pArray[j++] = clause_id(c); // updating handle here!!!
1548  }
1549  }
1550  veci_resize(&s->wlists[i],j);
1551  }
1552 
1553  // compact units
1554  if ( s->fProofLogging )
1555  for ( i = 0; i < s->size; i++ )
1556  if ( s->units[i] && clause_learnt_h(pMem, s->units[i]) )
1557  {
1558  assert( c->lrn );
1559  c = clause2_read( s, s->units[i] );
1560  assert( c->mark == 0 );
1561  s->units[i] = clause_id(c);
1562  }
1563 
1564  // perform final move of the clauses
1565  Counter = Sat_MemCompactLearned( pMem, 1 );
1566  assert( Counter == (int)s->stats.learnts );
1567 
1568  // compact proof (compacts 'proofs' and update 'claProofs')
1569  if ( s->pPrf1 )
1570  {
1571  extern int Sat_ProofReduce( Vec_Set_t * vProof, void * pRoots, int hProofPivot );
1573  }
1574 
1575  // report the results
1576  TimeTotal += Abc_Clock() - clk;
1577  if ( s->fVerbose )
1578  {
1579  Abc_Print(1, "reduceDB: Keeping %7d out of %7d clauses (%5.2f %%) ",
1580  s->stats.learnts, nLearnedOld, 100.0 * s->stats.learnts / nLearnedOld );
1581  Abc_PrintTime( 1, "Time", TimeTotal );
1582  }
1583 }
veci * wlists
Definition: satSolver2.h:130
lit lits[0]
Definition: satClause.h:56
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
unsigned lbd
Definition: satClause.h:54
static int lit_var(lit l)
Definition: satVec.h:145
Sat_Mem_t Mem
Definition: satSolver2.h:129
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void veci_resize(veci *v, int k)
Definition: satVec.h:47
static abctime Abc_Clock()
Definition: abc_global.h:279
stats_t stats
Definition: satSolver2.h:172
static int clause_id(clause *c)
Definition: satClause.h:144
#define Sat_MemForEachLearned(p, c, i, k)
Definition: satClause.h:126
ABC_INT64_T learnts_literals
Definition: satVec.h:155
static void Prf_ManAddSaved(Prf_Man_t *p, int i, int iNew)
Definition: satProof2.h:175
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int * Abc_MergeSortCost(int *pCosts, int nSize)
Definition: utilSort.c:238
static int clause_size(clause *c)
Definition: satClause.h:146
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int clause_learnt_h(Sat_Mem_t *p, cla h)
Definition: satClause.h:142
static void Prf_ManCompact(Prf_Man_t *p, int iNew)
Definition: satProof2.h:187
unsigned mark
Definition: satClause.h:52
static int Counter
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int pPerm[13719]
Definition: rwrTemp.c:32
unsigned learnts
Definition: satVec.h:153
static int clause_is_lit(cla h)
Definition: satClause.h:139
typedefABC_NAMESPACE_HEADER_START struct Vec_Set_t_ Vec_Set_t
INCLUDES ///.
Definition: vecSet.h:49
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
#define ABC_FREE(obj)
Definition: abc_global.h:232
Prf_Man_t * pPrf2
Definition: satSolver2.h:166
unsigned lrn
Definition: satClause.h:51
#define assert(ex)
Definition: util_old.h:213
static int Sat_MemCompactLearned(Sat_Mem_t *p, int fDoMove)
Definition: satClause.h:366
ABC_INT64_T abctime
Definition: abc_global.h:278
int Sat_ProofReduce(Vec_Set_t *vProof, void *pRoots, int hProofPivot)
Definition: satProof.c:383
static int * veci_begin(veci *v)
Definition: satVec.h:45
static cla Sat_MemHand(Sat_Mem_t *p, int i, int k)
Definition: satClause.h:101
static int veci_size(veci *v)
Definition: satVec.h:46
void sat_solver2_rollback ( sat_solver2 s)

Definition at line 1586 of file satSolver2.c.

1587 {
1588  Sat_Mem_t * pMem = &s->Mem;
1589  int i, k, j;
1590  static int Count = 0;
1591  Count++;
1592  assert( s->iVarPivot >= 0 && s->iVarPivot <= s->size );
1593  assert( s->iTrailPivot >= 0 && s->iTrailPivot <= s->qtail );
1594  assert( s->pPrf1 == NULL || (s->hProofPivot >= 1 && s->hProofPivot <= Vec_SetHandCurrent(s->pPrf1)) );
1595  // reset implication queue
1597  // update order
1598  if ( s->iVarPivot < s->size )
1599  {
1600  if ( s->activity2 )
1601  {
1602  s->var_inc = s->var_inc2;
1603  memcpy( s->activity, s->activity2, sizeof(unsigned) * s->iVarPivot );
1604  }
1605  veci_resize(&s->order, 0);
1606  for ( i = 0; i < s->iVarPivot; i++ )
1607  {
1608  if ( var_value(s, i) != varX )
1609  continue;
1610  s->orderpos[i] = veci_size(&s->order);
1611  veci_push(&s->order,i);
1612  order_update(s, i);
1613  }
1614  }
1615  // compact watches
1616  for ( i = 0; i < s->iVarPivot*2; i++ )
1617  {
1618  cla* pArray = veci_begin(&s->wlists[i]);
1619  for ( j = k = 0; k < veci_size(&s->wlists[i]); k++ )
1620  if ( Sat_MemClauseUsed(pMem, pArray[k]) )
1621  pArray[j++] = pArray[k];
1622  veci_resize(&s->wlists[i],j);
1623  }
1624  // reset watcher lists
1625  for ( i = 2*s->iVarPivot; i < 2*s->size; i++ )
1626  s->wlists[i].size = 0;
1627 
1628  // reset clause counts
1629  s->stats.clauses = pMem->BookMarkE[0];
1630  s->stats.learnts = pMem->BookMarkE[1];
1631  // rollback clauses
1632  Sat_MemRollBack( pMem );
1633 
1634  // resize learned arrays
1635  veci_resize(&s->act_clas, s->stats.learnts);
1636  if ( s->pPrf1 )
1637  {
1639  Vec_SetShrink(s->pPrf1, s->hProofPivot);
1640  // some weird bug here, which shows only on 64-bits!
1641  // temporarily, perform more general proof reduction
1642 // Sat_ProofReduce( s->pPrf1, &s->claProofs, s->hProofPivot );
1643  }
1644  assert( s->pPrf2 == NULL );
1645 // if ( s->pPrf2 )
1646 // Prf_ManShrink( s->pPrf2, s->stats.learnts );
1647 
1648  // initialize other vars
1649  s->size = s->iVarPivot;
1650  if ( s->size == 0 )
1651  {
1652  // s->size = 0;
1653  // s->cap = 0;
1654  s->qhead = 0;
1655  s->qtail = 0;
1656 #ifdef USE_FLOAT_ACTIVITY2
1657  s->var_inc = 1;
1658  s->cla_inc = 1;
1659  s->var_decay = (float)(1 / 0.95 );
1660  s->cla_decay = (float)(1 / 0.999 );
1661 #else
1662  s->var_inc = (1 << 5);
1663  s->cla_inc = (1 << 11);
1664 #endif
1665  s->root_level = 0;
1666  s->random_seed = 91648253;
1667  s->progress_estimate = 0;
1668  s->verbosity = 0;
1669 
1670  s->stats.starts = 0;
1671  s->stats.decisions = 0;
1672  s->stats.propagations = 0;
1673  s->stats.inspects = 0;
1674  s->stats.conflicts = 0;
1675  s->stats.clauses = 0;
1676  s->stats.clauses_literals = 0;
1677  s->stats.learnts = 0;
1678  s->stats.learnts_literals = 0;
1679  s->stats.tot_literals = 0;
1680  // initialize clause pointers
1681  s->hLearntLast = -1; // the last learnt clause
1682  s->hProofLast = -1; // the last proof ID
1683 
1684  // initialize rollback
1685  s->iVarPivot = 0; // the pivot for variables
1686  s->iTrailPivot = 0; // the pivot for trail
1687  s->hProofPivot = 1; // the pivot for proof records
1688  }
1689 }
ABC_INT64_T clauses_literals
Definition: satVec.h:155
veci * wlists
Definition: satSolver2.h:130
ABC_INT64_T tot_literals
Definition: satVec.h:155
static void veci_push(veci *v, int e)
Definition: satVec.h:53
static void solver2_canceluntil_rollback(sat_solver2 *s, int NewBound)
Definition: satSolver2.c:518
static int Vec_SetHandCurrent(Vec_Set_t *p)
Definition: vecSet.h:83
char * memcpy()
Sat_Mem_t Mem
Definition: satSolver2.h:129
static void veci_resize(veci *v, int k)
Definition: satVec.h:47
ABC_INT64_T decisions
Definition: satVec.h:154
stats_t stats
Definition: satSolver2.h:172
int cla
Definition: satVec.h:131
ABC_INT64_T learnts_literals
Definition: satVec.h:155
int * orderpos
Definition: satSolver2.h:144
static void Vec_SetShrink(Vec_Set_t *p, int h)
Definition: vecSet.h:257
static const int varX
Definition: satSolver2.c:72
static int size
Definition: cuddSign.c:86
static int var_value(sat_solver2 *s, int v)
Definition: satSolver2.c:90
ABC_INT64_T inspects
Definition: satVec.h:154
double progress_estimate
Definition: satSolver2.h:99
unsigned learnts
Definition: satVec.h:153
ABC_INT64_T conflicts
Definition: satVec.h:154
unsigned clauses
Definition: satVec.h:153
static void Sat_MemRollBack(Sat_Mem_t *p)
Definition: satClause.h:256
Vec_Set_t * pPrf1
Definition: satSolver2.h:162
Prf_Man_t * pPrf2
Definition: satSolver2.h:166
int BookMarkE[2]
Definition: satClause.h:75
ABC_INT64_T propagations
Definition: satVec.h:154
int size
Definition: satVec.h:33
double random_seed
Definition: satSolver2.h:98
#define assert(ex)
Definition: util_old.h:213
unsigned * activity2
Definition: satSolver2.h:113
unsigned * activity
Definition: satSolver2.h:112
static int Sat_MemClauseUsed(Sat_Mem_t *p, cla h)
Definition: satClause.h:104
unsigned starts
Definition: satVec.h:153
static int * veci_begin(veci *v)
Definition: satVec.h:45
static int veci_size(veci *v)
Definition: satVec.h:46
static void order_update(sat_solver2 *s, int v)
Definition: satSolver2.c:235
static int sat_solver2_set_learntmax ( sat_solver2 s,
int  nLearntMax 
)
inlinestatic

Definition at line 241 of file satSolver2.h.

242 {
243  int temp = s->nLearntMax;
244  s->nLearntMax = nLearntMax;
245  return temp;
246 }
static abctime sat_solver2_set_runtime_limit ( sat_solver2 s,
abctime  Limit 
)
inlinestatic

Definition at line 234 of file satSolver2.h.

235 {
236  abctime temp = s->nRuntimeLimit;
237  s->nRuntimeLimit = Limit;
238  return temp;
239 }
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime nRuntimeLimit
Definition: satSolver2.h:175
void sat_solver2_setnvars ( sat_solver2 s,
int  n 
)

Definition at line 1170 of file satSolver2.c.

1171 {
1172  int var;
1173 
1174  if (s->cap < n){
1175  int old_cap = s->cap;
1176  while (s->cap < n) s->cap = s->cap*2+1;
1177 
1178  s->wlists = ABC_REALLOC(veci, s->wlists, s->cap*2);
1179  s->vi = ABC_REALLOC(varinfo2, s->vi, s->cap);
1180  s->levels = ABC_REALLOC(int, s->levels, s->cap);
1181  s->assigns = ABC_REALLOC(char, s->assigns, s->cap);
1182  s->trail = ABC_REALLOC(lit, s->trail, s->cap);
1183  s->orderpos = ABC_REALLOC(int, s->orderpos, s->cap);
1184  s->reasons = ABC_REALLOC(cla, s->reasons, s->cap);
1185  if ( s->fProofLogging )
1186  s->units = ABC_REALLOC(cla, s->units, s->cap);
1187 #ifdef USE_FLOAT_ACTIVITY2
1188  s->activity = ABC_REALLOC(double, s->activity, s->cap);
1189 #else
1190  s->activity = ABC_REALLOC(unsigned, s->activity, s->cap);
1191  s->activity2 = ABC_REALLOC(unsigned, s->activity2,s->cap);
1192 #endif
1193  s->model = ABC_REALLOC(int, s->model, s->cap);
1194  memset( s->wlists + 2*old_cap, 0, 2*(s->cap-old_cap)*sizeof(vecp) );
1195  }
1196 
1197  for (var = s->size; var < n; var++){
1198  assert(!s->wlists[2*var].size);
1199  assert(!s->wlists[2*var+1].size);
1200  if ( s->wlists[2*var].ptr == NULL )
1201  veci_new(&s->wlists[2*var]);
1202  if ( s->wlists[2*var+1].ptr == NULL )
1203  veci_new(&s->wlists[2*var+1]);
1204  *((int*)s->vi + var) = 0; //s->vi[var].val = varX;
1205  s->levels [var] = 0;
1206  s->assigns [var] = varX;
1207  s->reasons [var] = 0;
1208  if ( s->fProofLogging )
1209  s->units [var] = 0;
1210 #ifdef USE_FLOAT_ACTIVITY2
1211  s->activity[var] = 0;
1212 #else
1213  s->activity[var] = (1<<10);
1214 #endif
1215  s->model [var] = 0;
1216  // does not hold because variables enqueued at top level will not be reinserted in the heap
1217  // assert(veci_size(&s->order) == var);
1218  s->orderpos[var] = veci_size(&s->order);
1219  veci_push(&s->order,var);
1220  order_update(s, var);
1221  }
1222  s->size = n > s->size ? n : s->size;
1223 }
char * memset()
veci * wlists
Definition: satSolver2.h:130
int * ptr
Definition: satVec.h:34
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int var(Lit p)
Definition: SolverTypes.h:62
static void veci_push(veci *v, int e)
Definition: satVec.h:53
varinfo2 * vi
Definition: satSolver2.h:140
Definition: satVec.h:31
int cla
Definition: satVec.h:131
int lit
Definition: satVec.h:130
int * orderpos
Definition: satSolver2.h:144
static void veci_new(veci *v)
Definition: satVec.h:38
static const int varX
Definition: satSolver2.c:72
int size
Definition: satVec.h:33
#define assert(ex)
Definition: util_old.h:213
unsigned * activity2
Definition: satSolver2.h:113
Definition: satVec.h:80
unsigned * activity
Definition: satSolver2.h:112
static int veci_size(veci *v)
Definition: satVec.h:46
static void order_update(sat_solver2 *s, int v)
Definition: satSolver2.c:235
char * assigns
Definition: satSolver2.h:142
int sat_solver2_simplify ( sat_solver2 s)

Definition at line 996 of file satSolver2.c.

997 {
998  assert(solver2_dlevel(s) == 0);
999  return (solver2_propagate(s) == NULL);
1000 }
static int solver2_dlevel(sat_solver2 *s)
Definition: satSolver2.c:162
#define assert(ex)
Definition: util_old.h:213
clause * solver2_propagate(sat_solver2 *s)
Definition: satSolver2.c:904
int sat_solver2_solve ( sat_solver2 s,
lit begin,
lit end,
ABC_INT64_T  nConfLimit,
ABC_INT64_T  nInsLimit,
ABC_INT64_T  nConfLimitGlobal,
ABC_INT64_T  nInsLimitGlobal 
)

Definition at line 1835 of file satSolver2.c.

1836 {
1837  int restart_iter = 0;
1838  ABC_INT64_T nof_conflicts;
1839  lbool status = l_Undef;
1840  int proof_id;
1841  lit * i;
1842 
1843  s->hLearntLast = -1;
1844  s->hProofLast = -1;
1845 
1846  // set the external limits
1847 // s->nCalls++;
1848 // s->nRestarts = 0;
1849  s->nConfLimit = 0;
1850  s->nInsLimit = 0;
1851  if ( nConfLimit )
1852  s->nConfLimit = s->stats.conflicts + nConfLimit;
1853  if ( nInsLimit )
1854 // s->nInsLimit = s->stats.inspects + nInsLimit;
1855  s->nInsLimit = s->stats.propagations + nInsLimit;
1856  if ( nConfLimitGlobal && (s->nConfLimit == 0 || s->nConfLimit > nConfLimitGlobal) )
1857  s->nConfLimit = nConfLimitGlobal;
1858  if ( nInsLimitGlobal && (s->nInsLimit == 0 || s->nInsLimit > nInsLimitGlobal) )
1859  s->nInsLimit = nInsLimitGlobal;
1860 
1861 /*
1862  // Perform assumptions:
1863  root_level = assumps.size();
1864  for (int i = 0; i < assumps.size(); i++){
1865  Lit p = assumps[i];
1866  assert(var(p) < nVars());
1867  if (!solver2_assume(p)){
1868  GClause r = reason[var(p)];
1869  if (r != Gclause2_NULL){
1870  clause* confl;
1871  if (r.isLit()){
1872  confl = propagate_tmpbin;
1873  (*confl)[1] = ~p;
1874  (*confl)[0] = r.lit();
1875  }else
1876  confl = r.clause();
1877  analyzeFinal(confl, true);
1878  conflict.push(~p);
1879  }else
1880  conflict.clear(),
1881  conflict.push(~p);
1882  cancelUntil(0);
1883  return false; }
1884  clause* confl = propagate();
1885  if (confl != NULL){
1886  analyzeFinal(confl), assert(conflict.size() > 0);
1887  cancelUntil(0);
1888  return false; }
1889  }
1890  assert(root_level == decisionLevel());
1891 */
1892 
1893  // Perform assumptions:
1894  s->root_level = end - begin;
1895  for ( i = begin; i < end; i++ )
1896  {
1897  lit p = *i;
1898  assert(lit_var(p) < s->size);
1899  veci_push(&s->trail_lim,s->qtail);
1900  if (!solver2_enqueue(s,p,0))
1901  {
1902  clause* r = clause2_read(s, lit_reason(s,p));
1903  if (r != NULL)
1904  {
1905  clause* confl = r;
1906  proof_id = solver2_analyze_final(s, confl, 1);
1907  veci_push(&s->conf_final, lit_neg(p));
1908  }
1909  else
1910  {
1911 // assert( 0 );
1912 // r = var_unit_clause( s, lit_var(p) );
1913 // assert( r != NULL );
1914 // proof_id = clause2_proofid(s, r, 0);
1915  proof_id = -1; // the only case when ProofId is not assigned (conflicting assumptions)
1916  veci_resize(&s->conf_final,0);
1917  veci_push(&s->conf_final, lit_neg(p));
1918  // the two lines below are a bug fix by Siert Wieringa
1919  if (var_level(s, lit_var(p)) > 0)
1920  veci_push(&s->conf_final, p);
1921  }
1922  s->hProofLast = proof_id;
1923  solver2_canceluntil(s, 0);
1924  return l_False;
1925  }
1926  else
1927  {
1928  clause* confl = solver2_propagate(s);
1929  if (confl != NULL){
1930  proof_id = solver2_analyze_final(s, confl, 0);
1931  assert(s->conf_final.size > 0);
1932  s->hProofLast = proof_id;
1933  solver2_canceluntil(s, 0);
1934  return l_False;
1935  }
1936  }
1937  }
1938  assert(s->root_level == solver2_dlevel(s));
1939 
1940  if (s->verbosity >= 1){
1941  Abc_Print(1,"==================================[MINISAT]===================================\n");
1942  Abc_Print(1,"| Conflicts | ORIGINAL | LEARNT | Progress |\n");
1943  Abc_Print(1,"| | Clauses Literals | Limit Clauses Literals Lit/Cl | |\n");
1944  Abc_Print(1,"==============================================================================\n");
1945  }
1946 
1947  while (status == l_Undef){
1948  if (s->verbosity >= 1)
1949  {
1950  Abc_Print(1,"| %9.0f | %7.0f %8.0f | %7.0f %7.0f %8.0f %7.1f | %6.3f %% |\n",
1951  (double)s->stats.conflicts,
1952  (double)s->stats.clauses,
1953  (double)s->stats.clauses_literals,
1954  (double)s->nLearntMax,
1955  (double)s->stats.learnts,
1956  (double)s->stats.learnts_literals,
1957  (s->stats.learnts == 0)? 0.0 : (double)s->stats.learnts_literals / s->stats.learnts,
1958  s->progress_estimate*100);
1959  fflush(stdout);
1960  }
1961  if ( s->nRuntimeLimit && Abc_Clock() > s->nRuntimeLimit )
1962  break;
1963  // reduce the set of learnt clauses
1964  if ( s->nLearntMax && veci_size(&s->act_clas) >= s->nLearntMax && s->pPrf2 == NULL )
1966  // perform next run
1967  nof_conflicts = (ABC_INT64_T)( 100 * luby2(2, restart_iter++) );
1968  status = solver2_search(s, nof_conflicts);
1969  // quit the loop if reached an external limit
1970  if ( s->nConfLimit && s->stats.conflicts > s->nConfLimit )
1971  break;
1972  if ( s->nInsLimit && s->stats.propagations > s->nInsLimit )
1973  break;
1974  }
1975  if (s->verbosity >= 1)
1976  Abc_Print(1,"==============================================================================\n");
1977 
1978  solver2_canceluntil(s,0);
1979 // assert( s->qhead == s->qtail );
1980 // if ( status == l_True )
1981 // sat_solver2_verify( s );
1982  return status;
1983 }
ABC_INT64_T clauses_literals
Definition: satVec.h:155
char lbool
Definition: satVec.h:133
static clause * clause2_read(sat_solver2 *s, cla h)
Definition: satSolver2.h:178
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define l_Undef
Definition: SolverTypes.h:86
static int lit_var(lit l)
Definition: satVec.h:145
static void veci_push(veci *v, int e)
Definition: satVec.h:53
static lbool solver2_search(sat_solver2 *s, ABC_INT64_T nof_conflicts)
Definition: satSolver2.c:1002
static void solver2_canceluntil(sat_solver2 *s, int level)
Definition: satSolver2.c:489
ABC_INT64_T nInsLimit
Definition: satSolver2.h:174
static void veci_resize(veci *v, int k)
Definition: satVec.h:47
static abctime Abc_Clock()
Definition: abc_global.h:279
stats_t stats
Definition: satSolver2.h:172
int lit
Definition: satVec.h:130
ABC_INT64_T learnts_literals
Definition: satVec.h:155
static lit lit_neg(lit l)
Definition: satVec.h:144
static int solver2_analyze_final(sat_solver2 *s, clause *conf, int skip_first)
Definition: satSolver2.c:618
static int var_level(sat_solver2 *s, int v)
Definition: satSolver2.c:88
static int solver2_dlevel(sat_solver2 *s)
Definition: satSolver2.c:162
static int lit_reason(sat_solver2 *s, int l)
Definition: satSolver2.c:150
static int solver2_enqueue(sat_solver2 *s, lit l, cla from)
Definition: satSolver2.c:455
double luby2(double y, int x)
Definition: satSolver2.c:1384
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
ABC_INT64_T nConfLimit
Definition: satSolver2.h:173
double progress_estimate
Definition: satSolver2.h:99
unsigned learnts
Definition: satVec.h:153
ABC_INT64_T conflicts
Definition: satVec.h:154
unsigned clauses
Definition: satVec.h:153
Prf_Man_t * pPrf2
Definition: satSolver2.h:166
#define l_False
Definition: SolverTypes.h:85
ABC_INT64_T propagations
Definition: satVec.h:154
int size
Definition: satVec.h:33
#define assert(ex)
Definition: util_old.h:213
void sat_solver2_reducedb(sat_solver2 *s)
Definition: satSolver2.c:1406
abctime nRuntimeLimit
Definition: satSolver2.h:175
static int veci_size(veci *v)
Definition: satVec.h:46
clause * solver2_propagate(sat_solver2 *s)
Definition: satSolver2.c:904
static int sat_solver2_var_literal ( sat_solver2 s,
int  v 
)
inlinestatic

Definition at line 215 of file satSolver2.h.

216 {
217  assert( v >= 0 && v < s->size );
218  return toLitCond( v, s->model[v] != l_True );
219 }
#define l_True
Definition: SolverTypes.h:84
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static int size
Definition: cuddSign.c:86
#define assert(ex)
Definition: util_old.h:213
static int sat_solver2_var_value ( sat_solver2 s,
int  v 
)
inlinestatic

Definition at line 210 of file satSolver2.h.

211 {
212  assert( v >= 0 && v < s->size );
213  return (int)(s->model[v] == l_True);
214 }
#define l_True
Definition: SolverTypes.h:84
static int size
Definition: cuddSign.c:86
#define assert(ex)
Definition: util_old.h:213
void Sat_Solver2DoubleClauses ( sat_solver2 p,
int  iVar 
)
int* Sat_Solver2GetModel ( sat_solver2 p,
int *  pVars,
int  nVars 
)

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

Synopsis [Returns a counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file satUtil.c.

288 {
289  int * pModel;
290  int i;
291  pModel = ABC_CALLOC( int, nVars+1 );
292  for ( i = 0; i < nVars; i++ )
293  pModel[i] = sat_solver2_var_value(p, pVars[i]);
294  return pModel;
295 }
static int sat_solver2_var_value(sat_solver2 *s, int v)
Definition: satSolver2.h:210
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Sat_Solver2PrintStats ( FILE *  pFile,
sat_solver2 s 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 210 of file satUtil.c.

211 {
212  printf( "starts : %10d\n", (int)s->stats.starts );
213  printf( "conflicts : %10d\n", (int)s->stats.conflicts );
214  printf( "decisions : %10d\n", (int)s->stats.decisions );
215  printf( "propagations : %10d\n", (int)s->stats.propagations );
216 // printf( "inspects : %10d\n", (int)s->stats.inspects );
217 // printf( "inspects2 : %10d\n", (int)s->stats.inspects2 );
218 /*
219  printf( "memory for variables %.1f MB (free %6.2f %%) and clauses %.1f MB (free %6.2f %%)\n",
220  1.0 * Sat_Solver2GetVarMem(s) * s->size / (1<<20),
221  100.0 * (s->cap - s->size) / s->cap,
222  4.0 * (s->clauses.cap + s->learnts.cap) / (1<<20),
223  100.0 * (s->clauses.cap - s->clauses.size +
224  s->learnts.cap - s->learnts.size) /
225  (s->clauses.cap + s->learnts.cap) );
226 */
227 }
ABC_INT64_T decisions
Definition: satVec.h:154
stats_t stats
Definition: satSolver2.h:172
ABC_INT64_T conflicts
Definition: satVec.h:154
ABC_INT64_T propagations
Definition: satVec.h:154
unsigned starts
Definition: satVec.h:153
void Sat_Solver2WriteDimacs ( sat_solver2 p,
char *  pFileName,
lit assumptionsBegin,
lit assumptionsEnd,
int  incrementVars 
)

Definition at line 123 of file satUtil.c.

124 {
125  Sat_Mem_t * pMem = &p->Mem;
126  FILE * pFile;
127  clause * c;
128  int i, k, nUnits;
129 
130  // count the number of unit clauses
131  nUnits = 0;
132  for ( i = 0; i < p->size; i++ )
133  if ( p->levels[i] == 0 && p->assigns[i] != 3 )
134  nUnits++;
135 
136  // start the file
137  pFile = fopen( pFileName, "wb" );
138  if ( pFile == NULL )
139  {
140  printf( "Sat_SolverWriteDimacs(): Cannot open the ouput file.\n" );
141  return;
142  }
143 // fprintf( pFile, "c CNF generated by ABC on %s\n", Extra_TimeStamp() );
144  fprintf( pFile, "p cnf %d %d\n", p->size, Sat_MemEntryNum(&p->Mem, 0)-1+Sat_MemEntryNum(&p->Mem, 1)+nUnits+(int)(assumpEnd-assumpBegin) );
145 
146  // write the original clauses
147  Sat_MemForEachClause2( pMem, c, i, k )
148  Sat_SolverClauseWriteDimacs( pFile, c, incrementVars );
149 
150  // write the learned clauses
151 // Sat_MemForEachLearned( pMem, c, i, k )
152 // Sat_SolverClauseWriteDimacs( pFile, c, incrementVars );
153 
154  // write zero-level assertions
155  for ( i = 0; i < p->size; i++ )
156  if ( p->levels[i] == 0 && p->assigns[i] != 3 ) // varX
157  fprintf( pFile, "%s%d%s\n",
158  (p->assigns[i] == 1)? "-": "", // var0
159  i + (int)(incrementVars>0),
160  (incrementVars) ? " 0" : "");
161 
162  // write the assump
163  if (assumpBegin) {
164  for (; assumpBegin != assumpEnd; assumpBegin++) {
165  fprintf( pFile, "%s%d%s\n",
166  lit_sign(*assumpBegin)? "-": "",
167  lit_var(*assumpBegin) + (int)(incrementVars>0),
168  (incrementVars) ? " 0" : "");
169  }
170  }
171 
172  fprintf( pFile, "\n" );
173  fclose( pFile );
174 }
#define Sat_MemForEachClause2(p, c, i, k)
Definition: satClause.h:122
static int lit_var(lit l)
Definition: satVec.h:145
Sat_Mem_t Mem
Definition: satSolver2.h:129
static ABC_NAMESPACE_IMPL_START void Sat_SolverClauseWriteDimacs(FILE *pFile, clause *pC, int fIncrement)
DECLARATIONS ///.
Definition: satUtil.c:50
for(p=first;p->value< newval;p=p->next)
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
static int lit_sign(lit l)
Definition: satVec.h:146
static int Sat_MemEntryNum(Sat_Mem_t *p, int lrn)
Definition: satClause.h:99
char * assigns
Definition: satSolver2.h:142
int var_is_assigned ( sat_solver2 s,
int  v 
)

Definition at line 83 of file satSolver2.c.

83 { return s->assigns[v] != varX; }
static const int varX
Definition: satSolver2.c:72
char * assigns
Definition: satSolver2.h:142
int var_is_partA ( sat_solver2 s,
int  v 
)

Definition at line 84 of file satSolver2.c.

84 { return s->vi[v].partA; }
unsigned partA
Definition: satSolver2.c:78
varinfo2 * vi
Definition: satSolver2.h:140
void var_set_partA ( sat_solver2 s,
int  v,
int  partA 
)

Definition at line 85 of file satSolver2.c.

85 { s->vi[v].partA = partA; }
unsigned partA
Definition: satSolver2.c:78
varinfo2 * vi
Definition: satSolver2.h:140