ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
AbcGlucose2.h File Reference
#include "aig/gia/gia.h"
Include dependency graph for AbcGlucose2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Glucose2_Pars_
 

Macros

#define GLUCOSE_UNSAT   -1
 INCLUDES ///.
 
#define GLUCOSE_SAT   1
 
#define GLUCOSE_UNDEC   0
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Glucose2_Pars_ Glucose2_Pars
 BASIC TYPES ///.
 
typedef void bmcg2_sat_solver
 

Functions

bmcg2_sat_solverbmcg2_sat_solver_start ()
 MACRO DEFINITIONS ///.
 
void bmcg2_sat_solver_stop (bmcg2_sat_solver *s)
 
void bmcg2_sat_solver_reset (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_addclause (bmcg2_sat_solver *s, int *plits, int nlits)
 
void bmcg2_sat_solver_setcallback (bmcg2_sat_solver *s, void *pman, int(*pfunc)(void *, int, int *))
 
int bmcg2_sat_solver_solve (bmcg2_sat_solver *s, int *plits, int nlits)
 
int bmcg2_sat_solver_final (bmcg2_sat_solver *s, int **ppArray)
 
int bmcg2_sat_solver_addvar (bmcg2_sat_solver *s)
 
void bmcg2_sat_solver_set_nvars (bmcg2_sat_solver *s, int nvars)
 
int bmcg2_sat_solver_eliminate (bmcg2_sat_solver *s, int turn_off_elim)
 
int bmcg2_sat_solver_var_is_elim (bmcg2_sat_solver *s, int v)
 
void bmcg2_sat_solver_var_set_frozen (bmcg2_sat_solver *s, int v, int freeze)
 
int bmcg2_sat_solver_elim_varnum (bmcg2_sat_solver *s)
 
int * bmcg2_sat_solver_read_cex (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_read_cex_varvalue (bmcg2_sat_solver *s, int)
 
void bmcg2_sat_solver_set_stop (bmcg2_sat_solver *s, int *pstop)
 
void bmcg2_sat_solver_markapprox (bmcg2_sat_solver *s, int v0, int v1, int nlim)
 
abctime bmcg2_sat_solver_set_runtime_limit (bmcg2_sat_solver *s, abctime Limit)
 
void bmcg2_sat_solver_set_conflict_budget (bmcg2_sat_solver *s, int Limit)
 
int bmcg2_sat_solver_varnum (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_clausenum (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_learntnum (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_conflictnum (bmcg2_sat_solver *s)
 
int bmcg2_sat_solver_minimize_assumptions (bmcg2_sat_solver *s, int *plits, int nlits, int pivot)
 
int bmcg2_sat_solver_add_and (bmcg2_sat_solver *s, int iVar, int iVar0, int iVar1, int fCompl0, int fCompl1, int fCompl)
 
int bmcg2_sat_solver_add_xor (bmcg2_sat_solver *s, int iVarA, int iVarB, int iVarC, int fCompl)
 
int bmcg2_sat_solver_quantify (bmcg2_sat_solver *s[], Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
 
int bmcg2_sat_solver_equiv_overlap_check (bmcg2_sat_solver *s, Gia_Man_t *p, int iLit0, int iLit1, int fEquiv)
 
Vec_Str_tbmcg2_sat_solver_sop (Gia_Man_t *p, int CubeLimit)
 
int bmcg2_sat_solver_jftr (bmcg2_sat_solver *s)
 
void bmcg2_sat_solver_set_jftr (bmcg2_sat_solver *s, int jftr)
 
void bmcg2_sat_solver_set_var_fanin_lit (bmcg2_sat_solver *s, int var, int lit0, int lit1)
 
void bmcg2_sat_solver_start_new_round (bmcg2_sat_solver *s)
 
void bmcg2_sat_solver_mark_cone (bmcg2_sat_solver *s, int var)
 
void bmcg2_sat_solver_prelocate (bmcg2_sat_solver *s, int var_num)
 
void Glucose2_SolveCnf (char *pFilename, Glucose2_Pars *pPars)
 
int Glucose2_SolveAig (Gia_Man_t *p, Glucose2_Pars *pPars)
 

Macro Definition Documentation

◆ GLUCOSE_SAT

#define GLUCOSE_SAT   1

Definition at line 35 of file AbcGlucose2.h.

◆ GLUCOSE_UNDEC

#define GLUCOSE_UNDEC   0

Definition at line 36 of file AbcGlucose2.h.

◆ GLUCOSE_UNSAT

#define GLUCOSE_UNSAT   -1

INCLUDES ///.

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

FileName [AbcGlucose.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT solver Glucose 3.0 by Gilles Audemard and Laurent Simon.]

Synopsis [Interface to Glucose.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 6, 2017.]

Revision [

Id
AbcGlucose.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS ///

Definition at line 34 of file AbcGlucose2.h.

Typedef Documentation

◆ bmcg2_sat_solver

typedef void bmcg2_sat_solver

Definition at line 63 of file AbcGlucose2.h.

◆ Glucose2_Pars

typedef typedefABC_NAMESPACE_HEADER_START struct Glucose2_Pars_ Glucose2_Pars

BASIC TYPES ///.

Definition at line 45 of file AbcGlucose2.h.

Function Documentation

◆ bmcg2_sat_solver_add_and()

int bmcg2_sat_solver_add_and ( bmcg2_sat_solver * s,
int iVar,
int iVar0,
int iVar1,
int fCompl0,
int fCompl1,
int fCompl )
extern

Definition at line 316 of file AbcGlucose2.cpp.

317{
318 int Lits[3];
319
320 Lits[0] = Abc_Var2Lit( iVar, !fCompl );
321 Lits[1] = Abc_Var2Lit( iVar0, fCompl0 );
322 if ( !bmcg2_sat_solver_addclause( s, Lits, 2 ) )
323 return 0;
324
325 Lits[0] = Abc_Var2Lit( iVar, !fCompl );
326 Lits[1] = Abc_Var2Lit( iVar1, fCompl1 );
327 if ( !bmcg2_sat_solver_addclause( s, Lits, 2 ) )
328 return 0;
329
330 Lits[0] = Abc_Var2Lit( iVar, fCompl );
331 Lits[1] = Abc_Var2Lit( iVar0, !fCompl0 );
332 Lits[2] = Abc_Var2Lit( iVar1, !fCompl1 );
333 if ( !bmcg2_sat_solver_addclause( s, Lits, 3 ) )
334 return 0;
335
336 return 1;
337}
int bmcg2_sat_solver_addclause(bmcg2_sat_solver *s, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_add_xor()

int bmcg2_sat_solver_add_xor ( bmcg2_sat_solver * s,
int iVarA,
int iVarB,
int iVarC,
int fCompl )
extern

Definition at line 339 of file AbcGlucose2.cpp.

340{
341 int Lits[3];
342 int Cid;
343 assert( iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
344
345 Lits[0] = Abc_Var2Lit( iVarA, !fCompl );
346 Lits[1] = Abc_Var2Lit( iVarB, 1 );
347 Lits[2] = Abc_Var2Lit( iVarC, 1 );
348 Cid = bmcg2_sat_solver_addclause( pSat, Lits, 3 );
349 assert( Cid );
350
351 Lits[0] = Abc_Var2Lit( iVarA, !fCompl );
352 Lits[1] = Abc_Var2Lit( iVarB, 0 );
353 Lits[2] = Abc_Var2Lit( iVarC, 0 );
354 Cid = bmcg2_sat_solver_addclause( pSat, Lits, 3 );
355 assert( Cid );
356
357 Lits[0] = Abc_Var2Lit( iVarA, fCompl );
358 Lits[1] = Abc_Var2Lit( iVarB, 1 );
359 Lits[2] = Abc_Var2Lit( iVarC, 0 );
360 Cid = bmcg2_sat_solver_addclause( pSat, Lits, 3 );
361 assert( Cid );
362
363 Lits[0] = Abc_Var2Lit( iVarA, fCompl );
364 Lits[1] = Abc_Var2Lit( iVarB, 0 );
365 Lits[2] = Abc_Var2Lit( iVarC, 1 );
366 Cid = bmcg2_sat_solver_addclause( pSat, Lits, 3 );
367 assert( Cid );
368 return 4;
369}
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ bmcg2_sat_solver_addclause()

int bmcg2_sat_solver_addclause ( bmcg2_sat_solver * s,
int * plits,
int nlits )
extern

Definition at line 165 of file AbcGlucose2.cpp.

166{
167 return glucose2_solver_addclause((Gluco2::SimpSolver*)s,plits,nlits);
168}
int glucose2_solver_addclause(Gluco2::SimpSolver *S, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_addvar()

int bmcg2_sat_solver_addvar ( bmcg2_sat_solver * s)
extern

Definition at line 186 of file AbcGlucose2.cpp.

187{
189}
int glucose2_solver_addvar(Gluco2::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_clausenum()

int bmcg2_sat_solver_clausenum ( bmcg2_sat_solver * s)
extern

Definition at line 259 of file AbcGlucose2.cpp.

260{
261 return ((Gluco2::SimpSolver*)s)->nClauses();
262}

◆ bmcg2_sat_solver_conflictnum()

int bmcg2_sat_solver_conflictnum ( bmcg2_sat_solver * s)
extern

Definition at line 267 of file AbcGlucose2.cpp.

268{
269 return ((Gluco2::SimpSolver*)s)->conflicts;
270}

◆ bmcg2_sat_solver_elim_varnum()

int bmcg2_sat_solver_elim_varnum ( bmcg2_sat_solver * s)
extern

Definition at line 215 of file AbcGlucose2.cpp.

216{
217// return 0;
218 return ((Gluco2::SimpSolver*)s)->eliminated_vars;
219}

◆ bmcg2_sat_solver_eliminate()

int bmcg2_sat_solver_eliminate ( bmcg2_sat_solver * s,
int turn_off_elim )
extern

Definition at line 198 of file AbcGlucose2.cpp.

199{
200// return 1;
201 return ((Gluco2::SimpSolver*)s)->eliminate(turn_off_elim != 0);
202}

◆ bmcg2_sat_solver_equiv_overlap_check()

int bmcg2_sat_solver_equiv_overlap_check ( bmcg2_sat_solver * pSat,
Gia_Man_t * p,
int iLit0,
int iLit1,
int fEquiv )
extern

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

Synopsis [Checks equivalence or intersection of two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1432 of file AbcGlucose2.cpp.

1433{
1434 bmcg2_sat_solver * pSats[2] = { pSat, NULL };
1435 Vec_Int_t * vObjsUsed = Vec_IntAlloc( 100 );
1436 int i, iVar, iSatVar[2], iSatLit[2], Lits[2], status;
1437 if ( Vec_IntSize(&p->vCopies) < Gia_ManObjNum(p) )
1438 Vec_IntFillExtra( &p->vCopies, Gia_ManObjNum(p), -1 );
1439
1440 // assign const0 variable number 0
1441 iVar = Vec_IntSize(vObjsUsed);
1442 Vec_IntPush( vObjsUsed, 0 );
1443 Gia_ObjSetCopyArray( p, 0, iVar );
1444 assert( iVar == 0 );
1445
1446 iSatVar[0] = Gia_ManSatAndCollect2_rec( p, Abc_Lit2Var(iLit0), vObjsUsed, NULL );
1447 iSatVar[1] = Gia_ManSatAndCollect2_rec( p, Abc_Lit2Var(iLit1), vObjsUsed, NULL );
1448
1449 iSatLit[0] = Abc_Var2Lit( iSatVar[0], Abc_LitIsCompl(iLit0) );
1450 iSatLit[1] = Abc_Var2Lit( iSatVar[1], Abc_LitIsCompl(iLit1) );
1451 Gia_ManQuantLoadCnf2( p, vObjsUsed, pSats );
1452 Vec_IntForEachEntry( vObjsUsed, iVar, i )
1453 Gia_ObjSetCopyArray( p, iVar, -1 );
1454 Vec_IntFree( vObjsUsed );
1455
1456 if ( fEquiv )
1457 {
1458 Lits[0] = iSatLit[0];
1459 Lits[1] = Abc_LitNot(iSatLit[1]);
1460 status = bmcg2_sat_solver_solve( pSats[0], Lits, 2 );
1461 if ( status == GLUCOSE_UNSAT )
1462 {
1463 Lits[0] = Abc_LitNot(iSatLit[0]);
1464 Lits[1] = iSatLit[1];
1465 status = bmcg2_sat_solver_solve( pSats[0], Lits, 2 );
1466 }
1467 return status == GLUCOSE_UNSAT;
1468 }
1469 else
1470 {
1471 Lits[0] = iSatLit[0];
1472 Lits[1] = iSatLit[1];
1473 status = bmcg2_sat_solver_solve( pSats[0], Lits, 2 );
1474 return status == GLUCOSE_SAT;
1475 }
1476}
int Gia_ManSatAndCollect2_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vObjsUsed, Vec_Int_t *vCiVars)
int bmcg2_sat_solver_solve(bmcg2_sat_solver *s, int *plits, int nlits)
void Gia_ManQuantLoadCnf2(Gia_Man_t *p, Vec_Int_t *vObjsUsed, bmcg2_sat_solver *pSats[])
void bmcg2_sat_solver
Definition AbcGlucose2.h:63
#define GLUCOSE_UNSAT
INCLUDES ///.
Definition AbcGlucose.h:34
#define GLUCOSE_SAT
Definition AbcGlucose.h:35
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_final()

int bmcg2_sat_solver_final ( bmcg2_sat_solver * s,
int ** ppArray )
extern

Definition at line 180 of file AbcGlucose2.cpp.

181{
182 *ppArray = (int *)(Lit *)((Gluco2::SimpSolver*)s)->conflict;
183 return ((Gluco2::SimpSolver*)s)->conflict.size();
184}
Here is the caller graph for this function:

◆ bmcg2_sat_solver_jftr()

int bmcg2_sat_solver_jftr ( bmcg2_sat_solver * s)
extern

Definition at line 371 of file AbcGlucose2.cpp.

372{
373 return ((Gluco2::SimpSolver*)s)->jftr;
374}

◆ bmcg2_sat_solver_learntnum()

int bmcg2_sat_solver_learntnum ( bmcg2_sat_solver * s)
extern

Definition at line 263 of file AbcGlucose2.cpp.

264{
265 return ((Gluco2::SimpSolver*)s)->nLearnts();
266}

◆ bmcg2_sat_solver_mark_cone()

void bmcg2_sat_solver_mark_cone ( bmcg2_sat_solver * s,
int var )
extern

Definition at line 391 of file AbcGlucose2.cpp.

392{
393 ((Gluco2::SimpSolver*)s)->sat_solver_mark_cone(var);
394}
int var(Lit p)
Definition SolverTypes.h:73
Here is the call graph for this function:

◆ bmcg2_sat_solver_markapprox()

void bmcg2_sat_solver_markapprox ( bmcg2_sat_solver * s,
int v0,
int v1,
int nlim )
extern

Definition at line 235 of file AbcGlucose2.cpp.

236{
237 glucose2_markapprox((Gluco2::SimpSolver*)s, v0, v1, nlim);
238}
void glucose2_markapprox(Gluco2::SimpSolver *S, int v0, int v1, int nlim)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_minimize_assumptions()

int bmcg2_sat_solver_minimize_assumptions ( bmcg2_sat_solver * s,
int * plits,
int nlits,
int pivot )
extern

Definition at line 272 of file AbcGlucose2.cpp.

273{
274 vec<int>*array = &((Gluco2::SimpSolver*)s)->user_vec;
275 int i, nlitsL, nlitsR, nresL, nresR, status;
276 assert( pivot >= 0 );
277// assert( nlits - pivot >= 2 );
278 assert( nlits - pivot >= 1 );
279 if ( nlits - pivot == 1 )
280 {
281 // since the problem is UNSAT, we try to solve it without assuming the last literal
282 // if the result is UNSAT, the last literal can be dropped; otherwise, it is needed
283 status = bmcg2_sat_solver_solve( s, plits, pivot );
284 return status != GLUCOSE_UNSAT; // return 1 if the problem is not UNSAT
285 }
286 assert( nlits - pivot >= 2 );
287 nlitsL = (nlits - pivot) / 2;
288 nlitsR = (nlits - pivot) - nlitsL;
289 assert( nlitsL + nlitsR == nlits - pivot );
290 // solve with these assumptions
291 status = bmcg2_sat_solver_solve( s, plits, pivot + nlitsL );
292 if ( status == GLUCOSE_UNSAT ) // these are enough
293 return bmcg2_sat_solver_minimize_assumptions( s, plits, pivot + nlitsL, pivot );
294 // these are not enough
295 // solve for the right lits
296// nResL = nLitsR == 1 ? 1 : sat_solver_minimize_assumptions( s, pLits + nLitsL, nLitsR, nConfLimit );
297 nresL = nlitsR == 1 ? 1 : bmcg2_sat_solver_minimize_assumptions( s, plits, nlits, pivot + nlitsL );
298 // swap literals
299 array->clear();
300 for ( i = 0; i < nlitsL; i++ )
301 array->push(plits[pivot + i]);
302 for ( i = 0; i < nresL; i++ )
303 plits[pivot + i] = plits[pivot + nlitsL + i];
304 for ( i = 0; i < nlitsL; i++ )
305 plits[pivot + nresL + i] = (*array)[i];
306 // solve with these assumptions
307 status = bmcg2_sat_solver_solve( s, plits, pivot + nresL );
308 if ( status == GLUCOSE_UNSAT ) // these are enough
309 return nresL;
310 // solve for the left lits
311// nResR = nLitsL == 1 ? 1 : sat_solver_minimize_assumptions( s, pLits + nResL, nLitsL, nConfLimit );
312 nresR = nlitsL == 1 ? 1 : bmcg2_sat_solver_minimize_assumptions( s, plits, pivot + nresL + nlitsL, pivot + nresL );
313 return nresL + nresR;
314}
int bmcg2_sat_solver_minimize_assumptions(bmcg2_sat_solver *s, int *plits, int nlits, int pivot)
void push(void)
Definition Vec.h:77
void clear(bool dealloc=false)
Definition Vec.h:141
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_prelocate()

void bmcg2_sat_solver_prelocate ( bmcg2_sat_solver * s,
int var_num )
extern

Definition at line 396 of file AbcGlucose2.cpp.

396 {
397 ((Gluco2::SimpSolver*)s)->prelocate(var_num);
398}

◆ bmcg2_sat_solver_quantify()

int bmcg2_sat_solver_quantify ( bmcg2_sat_solver * s[],
Gia_Man_t * p,
int iLit,
int fHash,
int(* pFuncCiToKeep )(void *, int),
void * pData,
Vec_Int_t * vDLits )
extern

Definition at line 1274 of file AbcGlucose2.cpp.

1275{
1276 Vec_Int_t * vObjsUsed = Vec_IntAlloc( 100 ); // GIA objs
1277 Vec_Int_t * vCiVars = Vec_IntAlloc( 100 ); // CI SAT vars
1278 Vec_Int_t * vVarMap = NULL; Vec_Str_t * vSop = NULL;
1279 int i, iVar, iVarLast, Lit, RetValue, Count = 0, Result = -1;
1280 if ( vDLits ) Vec_IntClear( vDLits );
1281 if ( iLit < 2 )
1282 return iLit;
1283 if ( Vec_IntSize(&p->vCopies) < Gia_ManObjNum(p) )
1284 Vec_IntFillExtra( &p->vCopies, Gia_ManObjNum(p), -1 );
1285 // assign variable number 0 to const0 node
1286 iVar = Vec_IntSize(vObjsUsed);
1287 Vec_IntPush( vObjsUsed, 0 );
1288 Gia_ObjSetCopyArray( p, 0, iVar );
1289 assert( iVar == 0 );
1290
1291 // collect other variables
1292 iVarLast = Gia_ManSatAndCollect2_rec( p, Abc_Lit2Var(iLit), vObjsUsed, vCiVars );
1293 Gia_ManQuantLoadCnf2( p, vObjsUsed, pSats );
1294
1295 // check constants
1296 Lit = Abc_Var2Lit( iVarLast, !Abc_LitIsCompl(iLit) );
1297 RetValue = bmcg2_sat_solver_addclause( pSats[0], &Lit, 1 ); // offset
1298 if ( !RetValue || bmcg2_sat_solver_solve(pSats[0], NULL, 0) == GLUCOSE_UNSAT )
1299 {
1300 Result = 1;
1301 goto cleanup;
1302 }
1303 Lit = Abc_Var2Lit( iVarLast, Abc_LitIsCompl(iLit) );
1304 RetValue = bmcg2_sat_solver_addclause( pSats[1], &Lit, 1 ); // onset
1305 if ( !RetValue || bmcg2_sat_solver_solve(pSats[1], NULL, 0) == GLUCOSE_UNSAT )
1306 {
1307 Result = 0;
1308 goto cleanup;
1309 }
1310/*
1311 // reorder CI SAT variables to have keep-vars first
1312 Vec_Int_t * vCiVars2 = Vec_IntAlloc( 100 ); // CI SAT vars
1313 Vec_IntForEachEntry( vCiVars, iVar, i )
1314 {
1315 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1316 assert( Gia_ObjIsCi(pObj) );
1317 if ( pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1318 Vec_IntPush( vCiVars2, iVar );
1319 }
1320 Vec_IntForEachEntry( vCiVars, iVar, i )
1321 {
1322 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1323 assert( Gia_ObjIsCi(pObj) );
1324 if ( !pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1325 Vec_IntPush( vCiVars2, iVar );
1326 }
1327 ABC_SWAP( Vec_Int_t *, vCiVars2, vCiVars );
1328 Vec_IntFree( vCiVars2 );
1329*/
1330 // map CI SAT variables into their indexes used in the cubes
1331 vVarMap = Vec_IntStartFull( Vec_IntSize(vObjsUsed) );
1332 Vec_IntForEachEntry( vCiVars, iVar, i )
1333 {
1334 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1335 assert( Gia_ObjIsCi(pObj) );
1336 if ( pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1337 Vec_IntWriteEntry( vVarMap, iVar, i ), Count++;
1338 }
1339 if ( Count == 0 || Count == Vec_IntSize(vCiVars) )
1340 {
1341 Result = Count == 0 ? 1 : iLit;
1342 goto cleanup;
1343 }
1344 // generate cubes
1345 vSop = Glucose2_GenerateCubes( pSats, vCiVars, vVarMap, 0 );
1346 //printf( "%s", Vec_StrArray(vSop) );
1347 // convert into object IDs
1348 Vec_IntForEachEntry( vCiVars, iVar, i )
1349 Vec_IntWriteEntry( vCiVars, i, Vec_IntEntry(vObjsUsed, iVar) );
1350 // generate unate variables
1351 if ( vDLits )
1352 bmcg2_sat_generate_dvars( vCiVars, vSop, vDLits );
1353 // convert into an AIG
1354 RetValue = Gia_ManAndNum(p);
1355 Result = Gia_ManFactorSop2( p, vCiVars, vSop, fHash );
1356
1357 // report the result
1358// printf( "Performed quantification with %5d nodes, %3d keep-vars, %3d quant-vars, resulting in %5d cubes and %5d nodes. ",
1359// Vec_IntSize(vObjsUsed), Count, Vec_IntSize(vCiVars) - Count, Vec_StrCountEntry(vSop, '\n'), Gia_ManAndNum(p)-RetValue );
1360// Abc_PrintTime( 1, "Time", Abc_Clock() - clkAll );
1361
1362cleanup:
1363 Vec_IntForEachEntry( vObjsUsed, iVar, i )
1364 Gia_ObjSetCopyArray( p, iVar, -1 );
1365 Vec_IntFree( vObjsUsed );
1366 Vec_IntFree( vCiVars );
1367 Vec_IntFreeP( &vVarMap );
1368 Vec_StrFreeP( &vSop );
1369 return Result;
1370}
int Gia_ManFactorSop2(Gia_Man_t *p, Vec_Int_t *vCiObjIds, Vec_Str_t *vSop, int fHash)
void bmcg2_sat_generate_dvars(Vec_Int_t *vCiVars, Vec_Str_t *vSop, Vec_Int_t *vDLits)
Vec_Str_t * Glucose2_GenerateCubes(bmcg2_sat_solver *pSat[2], Vec_Int_t *vCiSatVars, Vec_Int_t *vVar2Index, int CubeLimit)
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_read_cex()

int * bmcg2_sat_solver_read_cex ( bmcg2_sat_solver * s)
extern

Definition at line 221 of file AbcGlucose2.cpp.

222{
224}
int * glucose2_solver_read_cex(Gluco2::SimpSolver *S)
Here is the call graph for this function:

◆ bmcg2_sat_solver_read_cex_varvalue()

int bmcg2_sat_solver_read_cex_varvalue ( bmcg2_sat_solver * s,
int ivar )
extern

Definition at line 225 of file AbcGlucose2.cpp.

226{
228}
int glucose2_solver_read_cex_varvalue(Gluco2::SimpSolver *S, int ivar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_reset()

void bmcg2_sat_solver_reset ( bmcg2_sat_solver * s)
extern

Definition at line 159 of file AbcGlucose2.cpp.

160{
162}
void glucose2_solver_reset(Gluco2::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_set_conflict_budget()

void bmcg2_sat_solver_set_conflict_budget ( bmcg2_sat_solver * s,
int Limit )
extern

Definition at line 247 of file AbcGlucose2.cpp.

248{
249 if ( Limit > 0 )
250 ((Gluco2::SimpSolver*)s)->setConfBudget( (int64_t)Limit );
251 else
252 ((Gluco2::SimpSolver*)s)->budgetOff();
253}

◆ bmcg2_sat_solver_set_jftr()

void bmcg2_sat_solver_set_jftr ( bmcg2_sat_solver * s,
int jftr )
extern

Definition at line 376 of file AbcGlucose2.cpp.

377{
378 ((Gluco2::SimpSolver*)s)->jftr = jftr;
379}

◆ bmcg2_sat_solver_set_nvars()

void bmcg2_sat_solver_set_nvars ( bmcg2_sat_solver * s,
int nvars )
extern

Definition at line 191 of file AbcGlucose2.cpp.

192{
193 int i;
194 for ( i = bmcg2_sat_solver_varnum(s); i < nvars; i++ )
196}
int bmcg2_sat_solver_varnum(bmcg2_sat_solver *s)
int bmcg2_sat_solver_addvar(bmcg2_sat_solver *s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_set_runtime_limit()

abctime bmcg2_sat_solver_set_runtime_limit ( bmcg2_sat_solver * s,
abctime Limit )
extern

Definition at line 240 of file AbcGlucose2.cpp.

241{
242 abctime nRuntimeLimit = ((Gluco2::SimpSolver*)s)->nRuntimeLimit;
243 ((Gluco2::SimpSolver*)s)->nRuntimeLimit = Limit;
244 return nRuntimeLimit;
245}
ABC_INT64_T abctime
Definition abc_global.h:332

◆ bmcg2_sat_solver_set_stop()

void bmcg2_sat_solver_set_stop ( bmcg2_sat_solver * s,
int * pstop )
extern

Definition at line 230 of file AbcGlucose2.cpp.

231{
233}
void glucose2_solver_setstop(Gluco2::SimpSolver *S, int *pstop)
Here is the call graph for this function:

◆ bmcg2_sat_solver_set_var_fanin_lit()

void bmcg2_sat_solver_set_var_fanin_lit ( bmcg2_sat_solver * s,
int var,
int lit0,
int lit1 )
extern

Definition at line 381 of file AbcGlucose2.cpp.

382{
383 ((Gluco2::SimpSolver*)s)->sat_solver_set_var_fanin_lit(var, lit0, lit1);
384}
Here is the call graph for this function:

◆ bmcg2_sat_solver_setcallback()

void bmcg2_sat_solver_setcallback ( bmcg2_sat_solver * s,
void * pman,
int(* pfunc )(void *, int, int *) )
extern

Definition at line 170 of file AbcGlucose2.cpp.

171{
173}
void glucose2_solver_setcallback(Gluco2::SimpSolver *S, void *pman, int(*pfunc)(void *, int, int *))
Here is the call graph for this function:

◆ bmcg2_sat_solver_solve()

int bmcg2_sat_solver_solve ( bmcg2_sat_solver * s,
int * plits,
int nlits )
extern

Definition at line 175 of file AbcGlucose2.cpp.

176{
177 return glucose2_solver_solve((Gluco2::SimpSolver*)s,plits,nlits);
178}
int glucose2_solver_solve(Gluco2::SimpSolver *S, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_sop()

Vec_Str_t * bmcg2_sat_solver_sop ( Gia_Man_t * p,
int CubeLimit )
extern

Definition at line 998 of file AbcGlucose2.cpp.

999{
1001
1002 // generate CNF for the on-set and off-set
1003 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8 /*nLutSize*/, 0 /*fCnfObjIds*/, 0/*fAddOrCla*/, 0, 0/*verbose*/ );
1004 int i, n, nVars = Gia_ManCiNum(p), Lit;//, Count = 0;
1005 int iFirstVar = pCnf->nVars - nVars;
1006 assert( Gia_ManCoNum(p) == 1 );
1007 for ( n = 0; n < 2; n++ )
1008 {
1009 bmcg2_sat_solver_set_nvars( pSat[n], pCnf->nVars );
1010 Lit = Abc_Var2Lit( 1, !n ); // output variable is 1
1011 for ( i = 0; i < pCnf->nClauses; i++ )
1012 if ( !bmcg2_sat_solver_addclause( pSat[n], pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
1013 assert( 0 );
1014 if ( !bmcg2_sat_solver_addclause( pSat[n], &Lit, 1 ) )
1015 {
1016 Vec_Str_t * vSop = Vec_StrAlloc( 10 );
1017 Vec_StrPrintF( vSop, " %d\n\0", !n );
1018 Cnf_DataFree( pCnf );
1019 return vSop;
1020 }
1021 }
1022 Cnf_DataFree( pCnf );
1023
1024 // collect cube vars and map SAT vars into them
1025 Vec_Int_t * vVars = Vec_IntAlloc( 100 );
1026 Vec_Int_t * vVarMap = Vec_IntStartFull( iFirstVar + nVars );
1027 for ( i = 0; i < nVars; i++ )
1028 {
1029 Vec_IntPush( vVars, iFirstVar+i );
1030 Vec_IntWriteEntry( vVarMap, iFirstVar+i, i );
1031 }
1032
1033 Vec_Str_t * vSop = Glucose2_GenerateCubes( pSat, vVars, vVarMap, CubeLimit );
1034 Vec_IntFree( vVarMap );
1035 Vec_IntFree( vVars );
1036
1037 bmcg2_sat_solver_stop( pSat[0] );
1038 bmcg2_sat_solver_stop( pSat[1] );
1039 return vSop;
1040}
void bmcg2_sat_solver_stop(bmcg2_sat_solver *s)
bmcg2_sat_solver * bmcg2_sat_solver_start()
MACRO DEFINITIONS ///.
void bmcg2_sat_solver_set_nvars(bmcg2_sat_solver *s, int nvars)
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
int nVars
Definition cnf.h:59
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_start()

bmcg2_sat_solver * bmcg2_sat_solver_start ( )
extern

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Wrapper APIs to calling from ABC.]

Description []

SideEffects []

SeeAlso []

Definition at line 151 of file AbcGlucose2.cpp.

152{
154}
SimpSolver * glucose2_solver_start()
FUNCTION DEFINITIONS ///.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_start_new_round()

void bmcg2_sat_solver_start_new_round ( bmcg2_sat_solver * s)
extern

Definition at line 386 of file AbcGlucose2.cpp.

387{
388 ((Gluco2::SimpSolver*)s)->sat_solver_start_new_round();
389}

◆ bmcg2_sat_solver_stop()

void bmcg2_sat_solver_stop ( bmcg2_sat_solver * s)
extern

Definition at line 155 of file AbcGlucose2.cpp.

156{
158}
void glucose2_solver_stop(Gluco2::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_var_is_elim()

int bmcg2_sat_solver_var_is_elim ( bmcg2_sat_solver * s,
int v )
extern

Definition at line 204 of file AbcGlucose2.cpp.

205{
206// return 0;
207 return ((Gluco2::SimpSolver*)s)->isEliminated(v);
208}

◆ bmcg2_sat_solver_var_set_frozen()

void bmcg2_sat_solver_var_set_frozen ( bmcg2_sat_solver * s,
int v,
int freeze )
extern

Definition at line 210 of file AbcGlucose2.cpp.

211{
212 ((Gluco2::SimpSolver*)s)->setFrozen(v, freeze != 0);
213}

◆ bmcg2_sat_solver_varnum()

int bmcg2_sat_solver_varnum ( bmcg2_sat_solver * s)
extern

Definition at line 255 of file AbcGlucose2.cpp.

256{
257 return ((Gluco2::SimpSolver*)s)->nVars();
258}
Here is the caller graph for this function:

◆ Glucose2_SolveAig()

int Glucose2_SolveAig ( Gia_Man_t * p,
Glucose2_Pars * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1505 of file AbcGlucose2.cpp.

1506{
1507 abctime clk = Abc_Clock();
1508
1509 SimpSolver S;
1510 S.verbosity = pPars->verb;
1511 S.verbEveryConflicts = 50000;
1512 S.showModel = false;
1513 //S.verbosity = 2;
1514 S.setConfBudget( pPars->nConfls > 0 ? (int64_t)pPars->nConfls : -1 );
1515
1516 S.parsing = 1;
1517 Vec_Int_t * vCnfIds = Glucose_SolverFromAig(p,S);
1518 S.parsing = 0;
1519
1520 if (pPars->verb)
1521 {
1522 printf("c ============================[ Problem Statistics ]=============================\n");
1523 printf("c | |\n");
1524 printf("c | Number of variables: %12d |\n", S.nVars());
1525 printf("c | Number of clauses: %12d |\n", S.nClauses());
1526 }
1527
1528 if (pPars->pre)
1529 {
1530 S.eliminate(true);
1531 printf( "c Simplification removed %d variables and %d clauses. ", S.eliminated_vars, S.eliminated_clauses );
1532 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1533 }
1534
1535 vec<Lit> dummy;
1536 lbool ret = S.solveLimited(dummy, 0);
1537
1538 if ( pPars->verb ) glucose2_print_stats(S, Abc_Clock() - clk);
1539 printf(ret == l_True ? "SATISFIABLE" : ret == l_False ? "UNSATISFIABLE" : "INDETERMINATE");
1540 Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
1541
1542 // port counterexample
1543 if (ret == l_True)
1544 {
1545 Gia_Obj_t * pObj; int i;
1546 p->pCexComb = Abc_CexAlloc(0,Gia_ManCiNum(p),1);
1547 Gia_ManForEachCi( p, pObj, i )
1548 {
1549 assert(Vec_IntEntry(vCnfIds,Gia_ObjId(p, pObj))!=-1);
1550 if (S.model[Vec_IntEntry(vCnfIds,Gia_ObjId(p, pObj))] == l_True)
1551 Abc_InfoSetBit( p->pCexComb->pData, i);
1552 }
1553 }
1554 Vec_IntFree(vCnfIds);
1555 return (ret == l_True ? 10 : ret == l_False ? 20 : 0);
1556}
void glucose2_print_stats(SimpSolver &s, abctime clk)
Vec_Int_t * Glucose_SolverFromAig(Gia_Man_t *p, SimpSolver &s)
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition utilCex.c:51
Here is the call graph for this function:

◆ Glucose2_SolveCnf()

void Glucose2_SolveCnf ( char * pFileName,
Glucose2_Pars * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 848 of file AbcGlucose2.cpp.

849{
850 abctime clk = Abc_Clock();
851
852 SimpSolver S;
853 S.verbosity = pPars->verb;
854 S.setConfBudget( pPars->nConfls > 0 ? (int64_t)pPars->nConfls : -1 );
855
856// gzFile in = gzopen(pFilename, "rb");
857// parse_DIMACS(in, S);
858// gzclose(in);
859 Glucose_ReadDimacs( pFileName, S );
860
861 if ( pPars->verb )
862 {
863 printf("c ============================[ Problem Statistics ]=============================\n");
864 printf("c | |\n");
865 printf("c | Number of variables: %12d |\n", S.nVars());
866 printf("c | Number of clauses: %12d |\n", S.nClauses());
867 }
868
869 if ( pPars->pre )
870 {
871 S.eliminate(true);
872 printf( "c Simplification removed %d variables and %d clauses. ", S.eliminated_vars, S.eliminated_clauses );
873 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
874 }
875
876 vec<Lit> dummy;
877 lbool ret = S.solveLimited(dummy, 0);
878 if ( pPars->verb ) glucose2_print_stats(S, Abc_Clock() - clk);
879 printf(ret == l_True ? "SATISFIABLE" : ret == l_False ? "UNSATISFIABLE" : "INDETERMINATE");
880 Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
881}
void Glucose_ReadDimacs(char *pFileName, SimpSolver &s)
Here is the call graph for this function: