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

Go to the source code of this file.

Classes

struct  Glucose_Pars_
 

Macros

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

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Glucose_Pars_ Glucose_Pars
 BASIC TYPES ///.
 
typedef void bmcg_sat_solver
 

Functions

bmcg_sat_solverbmcg_sat_solver_start ()
 MACRO DEFINITIONS ///.
 
void bmcg_sat_solver_stop (bmcg_sat_solver *s)
 
void bmcg_sat_solver_reset (bmcg_sat_solver *s)
 
int bmcg_sat_solver_addclause (bmcg_sat_solver *s, int *plits, int nlits)
 
void bmcg_sat_solver_setcallback (bmcg_sat_solver *s, void *pman, int(*pfunc)(void *, int, int *))
 
int bmcg_sat_solver_solve (bmcg_sat_solver *s, int *plits, int nlits)
 
int bmcg_sat_solver_final (bmcg_sat_solver *s, int **ppArray)
 
int bmcg_sat_solver_addvar (bmcg_sat_solver *s)
 
void bmcg_sat_solver_set_nvars (bmcg_sat_solver *s, int nvars)
 
int bmcg_sat_solver_eliminate (bmcg_sat_solver *s, int turn_off_elim)
 
int bmcg_sat_solver_var_is_elim (bmcg_sat_solver *s, int v)
 
void bmcg_sat_solver_var_set_frozen (bmcg_sat_solver *s, int v, int freeze)
 
int bmcg_sat_solver_elim_varnum (bmcg_sat_solver *s)
 
int * bmcg_sat_solver_read_cex (bmcg_sat_solver *s)
 
int bmcg_sat_solver_read_cex_varvalue (bmcg_sat_solver *s, int)
 
void bmcg_sat_solver_set_stop (bmcg_sat_solver *s, int *pstop)
 
abctime bmcg_sat_solver_set_runtime_limit (bmcg_sat_solver *s, abctime Limit)
 
void bmcg_sat_solver_set_conflict_budget (bmcg_sat_solver *s, int Limit)
 
int bmcg_sat_solver_varnum (bmcg_sat_solver *s)
 
int bmcg_sat_solver_clausenum (bmcg_sat_solver *s)
 
int bmcg_sat_solver_learntnum (bmcg_sat_solver *s)
 
int bmcg_sat_solver_conflictnum (bmcg_sat_solver *s)
 
int bmcg_sat_solver_minimize_assumptions (bmcg_sat_solver *s, int *plits, int nlits, int pivot)
 
int bmcg_sat_solver_add_and (bmcg_sat_solver *s, int iVar, int iVar0, int iVar1, int fCompl0, int fCompl1, int fCompl)
 
int bmcg_sat_solver_add_xor (bmcg_sat_solver *s, int iVarA, int iVarB, int iVarC, int fCompl)
 
int bmcg_sat_solver_quantify (bmcg_sat_solver *s[], Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
 
int bmcg_sat_solver_equiv_overlap_check (bmcg_sat_solver *s, Gia_Man_t *p, int iLit0, int iLit1, int fEquiv)
 
Vec_Str_tbmcg_sat_solver_sop (Gia_Man_t *p, int CubeLimit)
 
int bmcg_sat_solver_jftr (bmcg_sat_solver *s)
 
void bmcg_sat_solver_set_jftr (bmcg_sat_solver *s, int jftr)
 
void bmcg_sat_solver_set_var_fanin_lit (bmcg_sat_solver *s, int var, int lit0, int lit1)
 
void bmcg_sat_solver_start_new_round (bmcg_sat_solver *s)
 
void bmcg_sat_solver_mark_cone (bmcg_sat_solver *s, int var)
 
void Glucose_SolveCnf (char *pFilename, Glucose_Pars *pPars, int fDumpCnf)
 
int Glucose_SolveAig (Gia_Man_t *p, Glucose_Pars *pPars)
 

Macro Definition Documentation

◆ GLUCOSE_SAT

#define GLUCOSE_SAT   1

Definition at line 35 of file AbcGlucose.h.

◆ GLUCOSE_UNDEC

#define GLUCOSE_UNDEC   0

Definition at line 36 of file AbcGlucose.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 AbcGlucose.h.

Typedef Documentation

◆ bmcg_sat_solver

typedef void bmcg_sat_solver

Definition at line 63 of file AbcGlucose.h.

◆ Glucose_Pars

typedef typedefABC_NAMESPACE_HEADER_START struct Glucose_Pars_ Glucose_Pars

BASIC TYPES ///.

Definition at line 45 of file AbcGlucose.h.

Function Documentation

◆ bmcg_sat_solver_add_and()

int bmcg_sat_solver_add_and ( bmcg_sat_solver * s,
int iVar,
int iVar0,
int iVar1,
int fCompl0,
int fCompl1,
int fCompl )
extern

Definition at line 306 of file AbcGlucose.cpp.

307{
308 int Lits[3];
309
310 Lits[0] = Abc_Var2Lit( iVar, !fCompl );
311 Lits[1] = Abc_Var2Lit( iVar0, fCompl0 );
312 if ( !bmcg_sat_solver_addclause( s, Lits, 2 ) )
313 return 0;
314
315 Lits[0] = Abc_Var2Lit( iVar, !fCompl );
316 Lits[1] = Abc_Var2Lit( iVar1, fCompl1 );
317 if ( !bmcg_sat_solver_addclause( s, Lits, 2 ) )
318 return 0;
319
320 Lits[0] = Abc_Var2Lit( iVar, fCompl );
321 Lits[1] = Abc_Var2Lit( iVar0, !fCompl0 );
322 Lits[2] = Abc_Var2Lit( iVar1, !fCompl1 );
323 if ( !bmcg_sat_solver_addclause( s, Lits, 3 ) )
324 return 0;
325
326 return 1;
327}
int bmcg_sat_solver_addclause(bmcg_sat_solver *s, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_add_xor()

int bmcg_sat_solver_add_xor ( bmcg_sat_solver * s,
int iVarA,
int iVarB,
int iVarC,
int fCompl )
extern

◆ bmcg_sat_solver_addclause()

int bmcg_sat_solver_addclause ( bmcg_sat_solver * s,
int * plits,
int nlits )
extern

Definition at line 160 of file AbcGlucose.cpp.

161{
162 return glucose_solver_addclause((Gluco::SimpSolver*)s,plits,nlits);
163}
int glucose_solver_addclause(Gluco::SimpSolver *S, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_addvar()

int bmcg_sat_solver_addvar ( bmcg_sat_solver * s)
extern

Definition at line 181 of file AbcGlucose.cpp.

182{
184}
int glucose_solver_addvar(Gluco::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_clausenum()

int bmcg_sat_solver_clausenum ( bmcg_sat_solver * s)
extern

Definition at line 249 of file AbcGlucose.cpp.

250{
251 return ((Gluco::SimpSolver*)s)->nClauses();
252}
Here is the caller graph for this function:

◆ bmcg_sat_solver_conflictnum()

int bmcg_sat_solver_conflictnum ( bmcg_sat_solver * s)
extern

Definition at line 257 of file AbcGlucose.cpp.

258{
259 return ((Gluco::SimpSolver*)s)->conflicts;
260}
Here is the caller graph for this function:

◆ bmcg_sat_solver_elim_varnum()

int bmcg_sat_solver_elim_varnum ( bmcg_sat_solver * s)
extern

Definition at line 210 of file AbcGlucose.cpp.

211{
212// return 0;
213 return ((Gluco::SimpSolver*)s)->eliminated_vars;
214}
Here is the caller graph for this function:

◆ bmcg_sat_solver_eliminate()

int bmcg_sat_solver_eliminate ( bmcg_sat_solver * s,
int turn_off_elim )
extern

Definition at line 193 of file AbcGlucose.cpp.

194{
195// return 1;
196 return ((Gluco::SimpSolver*)s)->eliminate(turn_off_elim != 0);
197}
Here is the caller graph for this function:

◆ bmcg_sat_solver_equiv_overlap_check()

int bmcg_sat_solver_equiv_overlap_check ( bmcg_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 1414 of file AbcGlucose.cpp.

1415{
1416 bmcg_sat_solver * pSats[2] = { pSat, NULL };
1417 Vec_Int_t * vObjsUsed = Vec_IntAlloc( 100 );
1418 int i, iVar, iSatVar[2], iSatLit[2], Lits[2], status;
1419 if ( Vec_IntSize(&p->vCopies) < Gia_ManObjNum(p) )
1420 Vec_IntFillExtra( &p->vCopies, Gia_ManObjNum(p), -1 );
1421
1422 // assign const0 variable number 0
1423 iVar = Vec_IntSize(vObjsUsed);
1424 Vec_IntPush( vObjsUsed, 0 );
1425 Gia_ObjSetCopyArray( p, 0, iVar );
1426 assert( iVar == 0 );
1427
1428 iSatVar[0] = Gia_ManSatAndCollect_rec( p, Abc_Lit2Var(iLit0), vObjsUsed, NULL );
1429 iSatVar[1] = Gia_ManSatAndCollect_rec( p, Abc_Lit2Var(iLit1), vObjsUsed, NULL );
1430
1431 iSatLit[0] = Abc_Var2Lit( iSatVar[0], Abc_LitIsCompl(iLit0) );
1432 iSatLit[1] = Abc_Var2Lit( iSatVar[1], Abc_LitIsCompl(iLit1) );
1433 Gia_ManQuantLoadCnf( p, vObjsUsed, pSats );
1434 Vec_IntForEachEntry( vObjsUsed, iVar, i )
1435 Gia_ObjSetCopyArray( p, iVar, -1 );
1436 Vec_IntFree( vObjsUsed );
1437
1438 if ( fEquiv )
1439 {
1440 Lits[0] = iSatLit[0];
1441 Lits[1] = Abc_LitNot(iSatLit[1]);
1442 status = bmcg_sat_solver_solve( pSats[0], Lits, 2 );
1443 if ( status == GLUCOSE_UNSAT )
1444 {
1445 Lits[0] = Abc_LitNot(iSatLit[0]);
1446 Lits[1] = iSatLit[1];
1447 status = bmcg_sat_solver_solve( pSats[0], Lits, 2 );
1448 }
1449 return status == GLUCOSE_UNSAT;
1450 }
1451 else
1452 {
1453 Lits[0] = iSatLit[0];
1454 Lits[1] = iSatLit[1];
1455 status = bmcg_sat_solver_solve( pSats[0], Lits, 2 );
1456 return status == GLUCOSE_SAT;
1457 }
1458}
void Gia_ManQuantLoadCnf(Gia_Man_t *p, Vec_Int_t *vObjsUsed, bmcg_sat_solver *pSats[])
int Gia_ManSatAndCollect_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vObjsUsed, Vec_Int_t *vCiVars)
int bmcg_sat_solver_solve(bmcg_sat_solver *s, int *plits, int nlits)
#define GLUCOSE_UNSAT
INCLUDES ///.
Definition AbcGlucose.h:34
void bmcg_sat_solver
Definition AbcGlucose.h:63
#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 assert(ex)
Definition util_old.h:213
#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:

◆ bmcg_sat_solver_final()

int bmcg_sat_solver_final ( bmcg_sat_solver * s,
int ** ppArray )
extern

Definition at line 175 of file AbcGlucose.cpp.

176{
177 *ppArray = (int *)(Lit *)((Gluco::SimpSolver*)s)->conflict;
178 return ((Gluco::SimpSolver*)s)->conflict.size();
179}
Here is the caller graph for this function:

◆ bmcg_sat_solver_jftr()

int bmcg_sat_solver_jftr ( bmcg_sat_solver * s)
extern

Definition at line 361 of file AbcGlucose.cpp.

362{
363 return ((Gluco::SimpSolver*)s)->jftr;
364}

◆ bmcg_sat_solver_learntnum()

int bmcg_sat_solver_learntnum ( bmcg_sat_solver * s)
extern

Definition at line 253 of file AbcGlucose.cpp.

254{
255 return ((Gluco::SimpSolver*)s)->nLearnts();
256}
Here is the caller graph for this function:

◆ bmcg_sat_solver_mark_cone()

void bmcg_sat_solver_mark_cone ( bmcg_sat_solver * s,
int var )
extern

Definition at line 381 of file AbcGlucose.cpp.

382{
383 ((Gluco::SimpSolver*)s)->sat_solver_mark_cone(var);
384}
int var(Lit p)
Definition SolverTypes.h:71
Here is the call graph for this function:

◆ bmcg_sat_solver_minimize_assumptions()

int bmcg_sat_solver_minimize_assumptions ( bmcg_sat_solver * s,
int * plits,
int nlits,
int pivot )
extern

Definition at line 262 of file AbcGlucose.cpp.

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

◆ bmcg_sat_solver_quantify()

int bmcg_sat_solver_quantify ( bmcg_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 1256 of file AbcGlucose.cpp.

1257{
1258 Vec_Int_t * vObjsUsed = Vec_IntAlloc( 100 ); // GIA objs
1259 Vec_Int_t * vCiVars = Vec_IntAlloc( 100 ); // CI SAT vars
1260 Vec_Int_t * vVarMap = NULL; Vec_Str_t * vSop = NULL;
1261 int i, iVar, iVarLast, Lit, RetValue, Count = 0, Result = -1;
1262 if ( vDLits ) Vec_IntClear( vDLits );
1263 if ( iLit < 2 )
1264 return iLit;
1265 if ( Vec_IntSize(&p->vCopies) < Gia_ManObjNum(p) )
1266 Vec_IntFillExtra( &p->vCopies, Gia_ManObjNum(p), -1 );
1267 // assign variable number 0 to const0 node
1268 iVar = Vec_IntSize(vObjsUsed);
1269 Vec_IntPush( vObjsUsed, 0 );
1270 Gia_ObjSetCopyArray( p, 0, iVar );
1271 assert( iVar == 0 );
1272
1273 // collect other variables
1274 iVarLast = Gia_ManSatAndCollect_rec( p, Abc_Lit2Var(iLit), vObjsUsed, vCiVars );
1275 Gia_ManQuantLoadCnf( p, vObjsUsed, pSats );
1276
1277 // check constants
1278 Lit = Abc_Var2Lit( iVarLast, !Abc_LitIsCompl(iLit) );
1279 RetValue = bmcg_sat_solver_addclause( pSats[0], &Lit, 1 ); // offset
1280 if ( !RetValue || bmcg_sat_solver_solve(pSats[0], NULL, 0) == GLUCOSE_UNSAT )
1281 {
1282 Result = 1;
1283 goto cleanup;
1284 }
1285 Lit = Abc_Var2Lit( iVarLast, Abc_LitIsCompl(iLit) );
1286 RetValue = bmcg_sat_solver_addclause( pSats[1], &Lit, 1 ); // onset
1287 if ( !RetValue || bmcg_sat_solver_solve(pSats[1], NULL, 0) == GLUCOSE_UNSAT )
1288 {
1289 Result = 0;
1290 goto cleanup;
1291 }
1292/*
1293 // reorder CI SAT variables to have keep-vars first
1294 Vec_Int_t * vCiVars2 = Vec_IntAlloc( 100 ); // CI SAT vars
1295 Vec_IntForEachEntry( vCiVars, iVar, i )
1296 {
1297 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1298 assert( Gia_ObjIsCi(pObj) );
1299 if ( pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1300 Vec_IntPush( vCiVars2, iVar );
1301 }
1302 Vec_IntForEachEntry( vCiVars, iVar, i )
1303 {
1304 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1305 assert( Gia_ObjIsCi(pObj) );
1306 if ( !pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1307 Vec_IntPush( vCiVars2, iVar );
1308 }
1309 ABC_SWAP( Vec_Int_t *, vCiVars2, vCiVars );
1310 Vec_IntFree( vCiVars2 );
1311*/
1312 // map CI SAT variables into their indexes used in the cubes
1313 vVarMap = Vec_IntStartFull( Vec_IntSize(vObjsUsed) );
1314 Vec_IntForEachEntry( vCiVars, iVar, i )
1315 {
1316 Gia_Obj_t * pObj = Gia_ManObj( p, Vec_IntEntry(vObjsUsed, iVar) );
1317 assert( Gia_ObjIsCi(pObj) );
1318 if ( pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) )
1319 Vec_IntWriteEntry( vVarMap, iVar, i ), Count++;
1320 }
1321 if ( Count == 0 || Count == Vec_IntSize(vCiVars) )
1322 {
1323 Result = Count == 0 ? 1 : iLit;
1324 goto cleanup;
1325 }
1326 // generate cubes
1327 vSop = Glucose_GenerateCubes( pSats, vCiVars, vVarMap, 0 );
1328 //printf( "%s", Vec_StrArray(vSop) );
1329 // convert into object IDs
1330 Vec_IntForEachEntry( vCiVars, iVar, i )
1331 Vec_IntWriteEntry( vCiVars, i, Vec_IntEntry(vObjsUsed, iVar) );
1332 // generate unate variables
1333 if ( vDLits )
1334 bmcg_sat_generate_dvars( vCiVars, vSop, vDLits );
1335 // convert into an AIG
1336 RetValue = Gia_ManAndNum(p);
1337 Result = Gia_ManFactorSop( p, vCiVars, vSop, fHash );
1338
1339 // report the result
1340// printf( "Performed quantification with %5d nodes, %3d keep-vars, %3d quant-vars, resulting in %5d cubes and %5d nodes. ",
1341// Vec_IntSize(vObjsUsed), Count, Vec_IntSize(vCiVars) - Count, Vec_StrCountEntry(vSop, '\n'), Gia_ManAndNum(p)-RetValue );
1342// Abc_PrintTime( 1, "Time", Abc_Clock() - clkAll );
1343
1344cleanup:
1345 Vec_IntForEachEntry( vObjsUsed, iVar, i )
1346 Gia_ObjSetCopyArray( p, iVar, -1 );
1347 Vec_IntFree( vObjsUsed );
1348 Vec_IntFree( vCiVars );
1349 Vec_IntFreeP( &vVarMap );
1350 Vec_StrFreeP( &vSop );
1351 return Result;
1352}
Vec_Str_t * Glucose_GenerateCubes(bmcg_sat_solver *pSat[2], Vec_Int_t *vCiSatVars, Vec_Int_t *vVar2Index, int CubeLimit)
int Gia_ManFactorSop(Gia_Man_t *p, Vec_Int_t *vCiObjIds, Vec_Str_t *vSop, int fHash)
void bmcg_sat_generate_dvars(Vec_Int_t *vCiVars, Vec_Str_t *vSop, Vec_Int_t *vDLits)
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:

◆ bmcg_sat_solver_read_cex()

int * bmcg_sat_solver_read_cex ( bmcg_sat_solver * s)
extern

Definition at line 216 of file AbcGlucose.cpp.

217{
219}
int * glucose_solver_read_cex(Gluco::SimpSolver *S)
Here is the call graph for this function:

◆ bmcg_sat_solver_read_cex_varvalue()

int bmcg_sat_solver_read_cex_varvalue ( bmcg_sat_solver * s,
int ivar )
extern

Definition at line 220 of file AbcGlucose.cpp.

221{
223}
int glucose_solver_read_cex_varvalue(Gluco::SimpSolver *S, int ivar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_reset()

void bmcg_sat_solver_reset ( bmcg_sat_solver * s)
extern

Definition at line 154 of file AbcGlucose.cpp.

155{
157}
void glucose_solver_reset(Gluco::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_set_conflict_budget()

void bmcg_sat_solver_set_conflict_budget ( bmcg_sat_solver * s,
int Limit )
extern

Definition at line 237 of file AbcGlucose.cpp.

238{
239 if ( Limit > 0 )
240 ((Gluco::SimpSolver*)s)->setConfBudget( (int64_t)Limit );
241 else
242 ((Gluco::SimpSolver*)s)->budgetOff();
243}
Here is the caller graph for this function:

◆ bmcg_sat_solver_set_jftr()

void bmcg_sat_solver_set_jftr ( bmcg_sat_solver * s,
int jftr )
extern

Definition at line 366 of file AbcGlucose.cpp.

367{
368 ((Gluco::SimpSolver*)s)->jftr = jftr;
369}

◆ bmcg_sat_solver_set_nvars()

void bmcg_sat_solver_set_nvars ( bmcg_sat_solver * s,
int nvars )
extern

Definition at line 186 of file AbcGlucose.cpp.

187{
188 int i;
189 for ( i = bmcg_sat_solver_varnum(s); i < nvars; i++ )
191}
int bmcg_sat_solver_varnum(bmcg_sat_solver *s)
int bmcg_sat_solver_addvar(bmcg_sat_solver *s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_set_runtime_limit()

abctime bmcg_sat_solver_set_runtime_limit ( bmcg_sat_solver * s,
abctime Limit )
extern

Definition at line 230 of file AbcGlucose.cpp.

231{
232 abctime nRuntimeLimit = ((Gluco::SimpSolver*)s)->nRuntimeLimit;
233 ((Gluco::SimpSolver*)s)->nRuntimeLimit = Limit;
234 return nRuntimeLimit;
235}
ABC_INT64_T abctime
Definition abc_global.h:332
Here is the caller graph for this function:

◆ bmcg_sat_solver_set_stop()

void bmcg_sat_solver_set_stop ( bmcg_sat_solver * s,
int * pstop )
extern

Definition at line 225 of file AbcGlucose.cpp.

226{
228}
void glucose_solver_setstop(Gluco::SimpSolver *S, int *pstop)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_set_var_fanin_lit()

void bmcg_sat_solver_set_var_fanin_lit ( bmcg_sat_solver * s,
int var,
int lit0,
int lit1 )
extern

Definition at line 371 of file AbcGlucose.cpp.

372{
373 ((Gluco::SimpSolver*)s)->sat_solver_set_var_fanin_lit(var, lit0, lit1);
374}
Here is the call graph for this function:

◆ bmcg_sat_solver_setcallback()

void bmcg_sat_solver_setcallback ( bmcg_sat_solver * s,
void * pman,
int(* pfunc )(void *, int, int *) )
extern

Definition at line 165 of file AbcGlucose.cpp.

166{
168}
void glucose_solver_setcallback(Gluco::SimpSolver *S, void *pman, int(*pfunc)(void *, int, int *))
Here is the call graph for this function:

◆ bmcg_sat_solver_solve()

int bmcg_sat_solver_solve ( bmcg_sat_solver * s,
int * plits,
int nlits )
extern

Definition at line 170 of file AbcGlucose.cpp.

171{
172 return glucose_solver_solve((Gluco::SimpSolver*)s,plits,nlits);
173}
int glucose_solver_solve(Gluco::SimpSolver *S, int *plits, int nlits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_sop()

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

Definition at line 980 of file AbcGlucose.cpp.

981{
983
984 // generate CNF for the on-set and off-set
985 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8 /*nLutSize*/, 0 /*fCnfObjIds*/, 0/*fAddOrCla*/, 0, 0/*verbose*/ );
986 int i, n, nVars = Gia_ManCiNum(p), Lit;//, Count = 0;
987 int iFirstVar = pCnf->nVars - nVars;
988 assert( Gia_ManCoNum(p) == 1 );
989 for ( n = 0; n < 2; n++ )
990 {
991 bmcg_sat_solver_set_nvars( pSat[n], pCnf->nVars );
992 Lit = Abc_Var2Lit( 1, !n ); // output variable is 1
993 for ( i = 0; i < pCnf->nClauses; i++ )
994 if ( !bmcg_sat_solver_addclause( pSat[n], pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
995 assert( 0 );
996 if ( !bmcg_sat_solver_addclause( pSat[n], &Lit, 1 ) )
997 {
998 Vec_Str_t * vSop = Vec_StrAlloc( 10 );
999 Vec_StrPrintF( vSop, " %d\n\0", !n );
1000 Cnf_DataFree( pCnf );
1001 return vSop;
1002 }
1003 }
1004 Cnf_DataFree( pCnf );
1005
1006 // collect cube vars and map SAT vars into them
1007 Vec_Int_t * vVars = Vec_IntAlloc( 100 );
1008 Vec_Int_t * vVarMap = Vec_IntStartFull( iFirstVar + nVars );
1009 for ( i = 0; i < nVars; i++ )
1010 {
1011 Vec_IntPush( vVars, iFirstVar+i );
1012 Vec_IntWriteEntry( vVarMap, iFirstVar+i, i );
1013 }
1014
1015 Vec_Str_t * vSop = Glucose_GenerateCubes( pSat, vVars, vVarMap, CubeLimit );
1016 Vec_IntFree( vVarMap );
1017 Vec_IntFree( vVars );
1018
1019 bmcg_sat_solver_stop( pSat[0] );
1020 bmcg_sat_solver_stop( pSat[1] );
1021 return vSop;
1022}
bmcg_sat_solver * bmcg_sat_solver_start()
MACRO DEFINITIONS ///.
void bmcg_sat_solver_set_nvars(bmcg_sat_solver *s, int nvars)
void bmcg_sat_solver_stop(bmcg_sat_solver *s)
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:

◆ bmcg_sat_solver_start()

bmcg_sat_solver * bmcg_sat_solver_start ( )
extern

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Wrapper APIs to calling from ABC.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file AbcGlucose.cpp.

147{
149}
SimpSolver * glucose_solver_start()
FUNCTION DEFINITIONS ///.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_start_new_round()

void bmcg_sat_solver_start_new_round ( bmcg_sat_solver * s)
extern

Definition at line 376 of file AbcGlucose.cpp.

377{
378 ((Gluco::SimpSolver*)s)->sat_solver_start_new_round();
379}

◆ bmcg_sat_solver_stop()

void bmcg_sat_solver_stop ( bmcg_sat_solver * s)
extern

Definition at line 150 of file AbcGlucose.cpp.

151{
153}
void glucose_solver_stop(Gluco::SimpSolver *S)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg_sat_solver_var_is_elim()

int bmcg_sat_solver_var_is_elim ( bmcg_sat_solver * s,
int v )
extern

Definition at line 199 of file AbcGlucose.cpp.

200{
201// return 0;
202 return ((Gluco::SimpSolver*)s)->isEliminated(v);
203}
Here is the caller graph for this function:

◆ bmcg_sat_solver_var_set_frozen()

void bmcg_sat_solver_var_set_frozen ( bmcg_sat_solver * s,
int v,
int freeze )
extern

Definition at line 205 of file AbcGlucose.cpp.

206{
207 ((Gluco::SimpSolver*)s)->setFrozen(v, freeze != 0);
208}
Here is the caller graph for this function:

◆ bmcg_sat_solver_varnum()

int bmcg_sat_solver_varnum ( bmcg_sat_solver * s)
extern

Definition at line 245 of file AbcGlucose.cpp.

246{
247 return ((Gluco::SimpSolver*)s)->nVars();
248}
Here is the caller graph for this function:

◆ Glucose_SolveAig()

int Glucose_SolveAig ( Gia_Man_t * p,
Glucose_Pars * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1487 of file AbcGlucose.cpp.

1488{
1489 abctime clk = Abc_Clock();
1490
1491 SimpSolver S;
1492 S.verbosity = pPars->verb;
1493 S.verbEveryConflicts = 50000;
1494 S.showModel = false;
1495 //S.verbosity = 2;
1496 S.setConfBudget( pPars->nConfls > 0 ? (int64_t)pPars->nConfls : -1 );
1497
1498 S.parsing = 1;
1499 Vec_Int_t * vCnfIds = Glucose_SolverFromAig(p,S);
1500 S.parsing = 0;
1501
1502 if (pPars->verb)
1503 {
1504 printf("c ============================[ Problem Statistics ]=============================\n");
1505 printf("c | |\n");
1506 printf("c | Number of variables: %12d |\n", S.nVars());
1507 printf("c | Number of clauses: %12d |\n", S.nClauses());
1508 }
1509
1510 if (pPars->pre)
1511 {
1512 S.eliminate(true);
1513 printf( "c Simplification removed %d variables and %d clauses. ", S.eliminated_vars, S.eliminated_clauses );
1514 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1515 }
1516
1517 vec<Lit> dummy;
1518 lbool ret = S.solveLimited(dummy, 0);
1519
1520 if ( pPars->verb ) glucose_print_stats(S, Abc_Clock() - clk);
1521 printf(ret == l_True ? "SATISFIABLE" : ret == l_False ? "UNSATISFIABLE" : "INDETERMINATE");
1522 Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
1523
1524 // port counterexample
1525 if (ret == l_True)
1526 {
1527 Gia_Obj_t * pObj; int i;
1528 p->pCexComb = Abc_CexAlloc(0,Gia_ManCiNum(p),1);
1529 Gia_ManForEachCi( p, pObj, i )
1530 {
1531 assert(Vec_IntEntry(vCnfIds,Gia_ObjId(p, pObj))!=-1);
1532 if (S.model[Vec_IntEntry(vCnfIds,Gia_ObjId(p, pObj))] == l_True)
1533 Abc_InfoSetBit( p->pCexComb->pData, i);
1534 }
1535 }
1536 Vec_IntFree(vCnfIds);
1537 return (ret == l_True ? 10 : ret == l_False ? 20 : 0);
1538}
void glucose_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
int verbosity
Definition Solver.h:158
#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:

◆ Glucose_SolveCnf()

void Glucose_SolveCnf ( char * pFileName,
Glucose_Pars * pPars,
int fDumpCnf )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 821 of file AbcGlucose.cpp.

822{
823 abctime clk = Abc_Clock();
824
825 SimpSolver S;
826 S.verbosity = pPars->verb;
827 S.setConfBudget( pPars->nConfls > 0 ? (int64_t)pPars->nConfls : -1 );
828
829// gzFile in = gzopen(pFilename, "rb");
830// parse_DIMACS(in, S);
831// gzclose(in);
832 Glucose_ReadDimacs( pFileName, S );
833
834 if ( pPars->verb )
835 {
836 printf("c ============================[ Problem Statistics ]=============================\n");
837 printf("c | |\n");
838 printf("c | Number of variables: %12d |\n", S.nVars());
839 printf("c | Number of clauses: %12d |\n", S.nClauses());
840 }
841
842 if ( pPars->pre )
843 {
844 S.eliminate(true);
845 printf( "c Simplification removed %d variables and %d clauses. ", S.eliminated_vars, S.eliminated_clauses );
846 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
847
848 if ( fDumpCnf )
849 {
850 char * pFileCnf = Extra_FileNameGenericAppend( pFileName, "_out.cnf" );
851 S.toDimacs(pFileCnf);
852 printf( "Finished dumping CNF after preprocessing into file \"%s\".\n", pFileCnf );
853 printf( "SAT solving is not performed.\n" );
854 return;
855 }
856 }
857
858 vec<Lit> dummy;
859 lbool ret = S.solveLimited(dummy, 0);
860 if ( pPars->verb ) glucose_print_stats(S, Abc_Clock() - clk);
861 printf(ret == l_True ? "SATISFIABLE" : ret == l_False ? "UNSATISFIABLE" : "INDETERMINATE");
862 Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
863}
void Glucose_ReadDimacs(char *pFileName, SimpSolver &s)
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
Here is the call graph for this function: