ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
AbcGlucose2.cpp File Reference
Include dependency graph for AbcGlucose2.cpp:

Go to the source code of this file.

Macros

#define USE_SIMP_SOLVER   1
 DECLARATIONS ///.
 
#define Gia_CubeForEachVar(pCube, Value, i)
 
#define Gia_SopForEachCube(pSop, nFanins, pCube)
 

Functions

SimpSolverglucose2_solver_start ()
 FUNCTION DEFINITIONS ///.
 
void glucose2_solver_stop (Gluco2::SimpSolver *S)
 
void glucose2_solver_reset (Gluco2::SimpSolver *S)
 
int glucose2_solver_addclause (Gluco2::SimpSolver *S, int *plits, int nlits)
 
void glucose2_solver_setcallback (Gluco2::SimpSolver *S, void *pman, int(*pfunc)(void *, int, int *))
 
int glucose2_solver_solve (Gluco2::SimpSolver *S, int *plits, int nlits)
 
int glucose2_solver_addvar (Gluco2::SimpSolver *S)
 
int * glucose2_solver_read_cex (Gluco2::SimpSolver *S)
 
int glucose2_solver_read_cex_varvalue (Gluco2::SimpSolver *S, int ivar)
 
void glucose2_solver_setstop (Gluco2::SimpSolver *S, int *pstop)
 
void glucose2_markapprox (Gluco2::SimpSolver *S, int v0, int v1, int nlim)
 
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 ivar)
 
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 *pSat, int iVarA, int iVarB, int iVarC, int fCompl)
 
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_print_stats (SimpSolver &s, abctime clk)
 
void Glucose_ReadDimacs (char *pFileName, SimpSolver &s)
 
void Glucose2_SolveCnf (char *pFileName, Glucose2_Pars *pPars)
 
Vec_Int_tGlucose_SolverFromAig (Gia_Man_t *p, SimpSolver &s)
 
Vec_Int_tGlucose_SolverFromAig2 (Gia_Man_t *p, SimpSolver &S)
 
Vec_Str_tGlucose2_GenerateCubes (bmcg2_sat_solver *pSat[2], Vec_Int_t *vCiSatVars, Vec_Int_t *vVar2Index, int CubeLimit)
 
Vec_Str_tbmcg2_sat_solver_sop (Gia_Man_t *p, int CubeLimit)
 
void bmcg2_sat_solver_print_sop (Gia_Man_t *p)
 
void bmcg2_sat_solver_print_sop_lit (Gia_Man_t *p, int Lit)
 
void bmcg2_sat_generate_dvars (Vec_Int_t *vCiVars, Vec_Str_t *vSop, Vec_Int_t *vDLits)
 
int bmcg2_sat_solver_quantify2 (Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
 
int Gia_ManSatAndCollect2_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vObjsUsed, Vec_Int_t *vCiVars)
 
void Gia_ManQuantLoadCnf2 (Gia_Man_t *p, Vec_Int_t *vObjsUsed, bmcg2_sat_solver *pSats[])
 
int Gia_ManFactorSop2 (Gia_Man_t *p, Vec_Int_t *vCiObjIds, Vec_Str_t *vSop, int fHash)
 
int bmcg2_sat_solver_quantify (bmcg2_sat_solver *pSats[], Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
 
int Gia_ManCiIsToKeep2 (void *pData, int i)
 
void Glucose2_QuantifyAigTest (Gia_Man_t *p)
 
int bmcg2_sat_solver_quantify_test (bmcg2_sat_solver *pSats[], 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 *pSat, Gia_Man_t *p, int iLit0, int iLit1, int fEquiv)
 
void Glucose2_CheckTwoNodesTest (Gia_Man_t *p)
 
int Glucose2_SolveAig (Gia_Man_t *p, Glucose2_Pars *pPars)
 

Macro Definition Documentation

◆ Gia_CubeForEachVar

#define Gia_CubeForEachVar ( pCube,
Value,
i )
Value:
for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )

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

Synopsis [Computing d-literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 1074 of file AbcGlucose2.cpp.

1074#define Gia_CubeForEachVar( pCube, Value, i ) \
1075 for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )

◆ Gia_SopForEachCube

#define Gia_SopForEachCube ( pSop,
nFanins,
pCube )
Value:
for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )

Definition at line 1076 of file AbcGlucose2.cpp.

1076#define Gia_SopForEachCube( pSop, nFanins, pCube ) \
1077 for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )

◆ USE_SIMP_SOLVER

#define USE_SIMP_SOLVER   1

DECLARATIONS ///.

Definition at line 42 of file AbcGlucose2.cpp.

Function Documentation

◆ bmcg2_sat_generate_dvars()

void bmcg2_sat_generate_dvars ( Vec_Int_t * vCiVars,
Vec_Str_t * vSop,
Vec_Int_t * vDLits )

Definition at line 1079 of file AbcGlucose2.cpp.

1080{
1081 int i, Lit, Counter, nCubes = 0;
1082 char Value, * pCube, * pSop = Vec_StrArray( vSop );
1083 Vec_Int_t * vCounts = Vec_IntStart( 2*Vec_IntSize(vCiVars) );
1084 Vec_IntClear( vDLits );
1085 Gia_SopForEachCube( pSop, Vec_IntSize(vCiVars), pCube )
1086 {
1087 nCubes++;
1088 Gia_CubeForEachVar( pCube, Value, i )
1089 {
1090 if ( Value == '1' )
1091 Vec_IntAddToEntry( vCounts, 2*i, 1 );
1092 else if ( Value == '0' )
1093 Vec_IntAddToEntry( vCounts, 2*i+1, 1 );
1094 }
1095 }
1096 Vec_IntForEachEntry( vCounts, Counter, Lit )
1097 if ( Counter == nCubes )
1098 Vec_IntPush( vDLits, Abc_Var2Lit(Vec_IntEntry(vCiVars, Abc_Lit2Var(Lit)), Abc_LitIsCompl(Lit)) );
1099 Vec_IntSort( vDLits, 0 );
1100 Vec_IntFree( vCounts );
1101}
#define Gia_SopForEachCube(pSop, nFanins, pCube)
#define Gia_CubeForEachVar(pCube, Value, i)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ 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 )

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 * pSat,
int iVarA,
int iVarB,
int iVarC,
int fCompl )

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 )

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)

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)

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)

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)

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 )

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 )

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
Cube * p
Definition exorList.c:222
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 )

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)

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)

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 )

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 )

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 )

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 )

Definition at line 396 of file AbcGlucose2.cpp.

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

◆ bmcg2_sat_solver_print_sop()

void bmcg2_sat_solver_print_sop ( Gia_Man_t * p)

Definition at line 1041 of file AbcGlucose2.cpp.

1042{
1043 Vec_Str_t * vSop = bmcg2_sat_solver_sop( p, 0 );
1044 printf( "%s", Vec_StrArray(vSop) );
1045 Vec_StrFree( vSop );
1046}
Vec_Str_t * bmcg2_sat_solver_sop(Gia_Man_t *p, int CubeLimit)
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_print_sop_lit()

void bmcg2_sat_solver_print_sop_lit ( Gia_Man_t * p,
int Lit )

Definition at line 1047 of file AbcGlucose2.cpp.

1048{
1049 Vec_Int_t * vCisUsed = Vec_IntAlloc( 100 );
1050 int i, ObjId, iNode = Abc_Lit2Var( Lit );
1051 Gia_ManCollectCis( p, &iNode, 1, vCisUsed );
1052 Vec_IntSort( vCisUsed, 0 );
1053 Vec_IntForEachEntry( vCisUsed, ObjId, i )
1054 Vec_IntWriteEntry( vCisUsed, i, Gia_ManIdToCioId(p, ObjId) );
1055 Vec_IntPrint( vCisUsed );
1056 Gia_Man_t * pNew = Gia_ManDupConeSupp( p, Lit, vCisUsed );
1057 Vec_IntFree( vCisUsed );
1059 Gia_ManStop( pNew );
1060 printf( "\n" );
1061}
void bmcg2_sat_solver_print_sop(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManDupConeSupp(Gia_Man_t *p, int iLit, Vec_Int_t *vCiIds)
Definition giaDup.c:2235
void Gia_ManCollectCis(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vSupp)
Definition giaDfs.c:71
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_quantify()

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

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 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_quantify2()

int bmcg2_sat_solver_quantify2 ( Gia_Man_t * p,
int iLit,
int fHash,
int(* pFuncCiToKeep )(void *, int),
void * pData,
Vec_Int_t * vDLits )

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

Synopsis [Performs SAT-based quantification.]

Description []

SideEffects []

SeeAlso []

Definition at line 1114 of file AbcGlucose2.cpp.

1115{
1116 int fSynthesize = 0;
1117 extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp );
1118 Gia_Man_t * pMan, * pNew, * pTemp; Vec_Str_t * vSop;
1119 int i, CiId, ObjId, Res, nCubes = 0, nNodes, Count = 0, iNode = Abc_Lit2Var(iLit);
1120 Vec_Int_t * vCisUsed = Vec_IntAlloc( 100 );
1121 Gia_ManCollectCis( p, &iNode, 1, vCisUsed );
1122 Vec_IntSort( vCisUsed, 0 );
1123 if ( vDLits ) Vec_IntClear( vDLits );
1124 if ( iLit < 2 )
1125 return iLit;
1126 // remap into CI Ids
1127 Vec_IntForEachEntry( vCisUsed, ObjId, i )
1128 Vec_IntWriteEntry( vCisUsed, i, Gia_ManIdToCioId(p, ObjId) );
1129 // duplicate cone
1130 pNew = Gia_ManDupConeSupp( p, iLit, vCisUsed );
1131 assert( Gia_ManCiNum(pNew) == Vec_IntSize(vCisUsed) );
1132 nNodes = Gia_ManAndNum(pNew);
1133
1134 // perform quantification one CI at a time
1135 assert( pFuncCiToKeep );
1136 Vec_IntForEachEntry( vCisUsed, CiId, i )
1137 if ( !pFuncCiToKeep( pData, CiId ) )
1138 {
1139 //printf( "Quantifying %d.\n", CiId );
1140 pNew = Gia_ManDupExist( pTemp = pNew, i );
1141 Gia_ManStop( pTemp );
1142 Count++;
1143 }
1144 if ( Gia_ManPoIsConst(pNew, 0) )
1145 {
1146 int RetValue = Gia_ManPoIsConst1(pNew, 0);
1147 Vec_IntFree( vCisUsed );
1148 Gia_ManStop( pNew );
1149 return RetValue;
1150 }
1151
1152 if ( fSynthesize )
1153 {
1154 vSop = bmcg2_sat_solver_sop( pNew, 0 );
1155 Gia_ManStop( pNew );
1156 pMan = Abc_SopSynthesizeOne( Vec_StrArray(vSop), 1 );
1157 nCubes = Vec_StrCountEntry(vSop, '\n');
1158 if ( vDLits )
1159 {
1160 // convert into object IDs
1161 Vec_Int_t * vCisObjs = Vec_IntAlloc( Vec_IntSize(vCisUsed) );
1162 Vec_IntForEachEntry( vCisUsed, CiId, i )
1163 Vec_IntPush( vCisObjs, CiId + 1 );
1164 bmcg2_sat_generate_dvars( vCisObjs, vSop, vDLits );
1165 Vec_IntFree( vCisObjs );
1166 }
1167 Vec_StrFree( vSop );
1168
1169 if ( Gia_ManPoIsConst(pMan, 0) )
1170 {
1171 int RetValue = Gia_ManPoIsConst1(pMan, 0);
1172 Vec_IntFree( vCisUsed );
1173 Gia_ManStop( pMan );
1174 return RetValue;
1175 }
1176 }
1177 else
1178 {
1179 pMan = pNew;
1180 }
1181
1182 Res = Gia_ManDupConeBack( p, pMan, vCisUsed );
1183
1184 // report the result
1185 //printf( "Performed quantification with %5d nodes, %3d keep-vars, %3d quant-vars, resulting in %5d cubes and %5d nodes. ",
1186 // nNodes, Vec_IntSize(vCisUsed) - Count, Count, nCubes, Gia_ManAndNum(pMan) );
1187 //Abc_PrintTime( 1, "Time", Abc_Clock() - clkAll );
1188
1189 Vec_IntFree( vCisUsed );
1190 Gia_ManStop( pMan );
1191 return Res;
1192}
ABC_DLL Gia_Man_t * Abc_SopSynthesizeOne(char *pSop, int fClp)
Definition abcUtil.c:3244
Gia_Man_t * Gia_ManDupExist(Gia_Man_t *p, int iVar)
Definition giaDup.c:2012
int Gia_ManDupConeBack(Gia_Man_t *p, Gia_Man_t *pNew, Vec_Int_t *vCiIds)
Definition giaDup.c:2270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmcg2_sat_solver_quantify_test()

int bmcg2_sat_solver_quantify_test ( bmcg2_sat_solver * pSats[],
Gia_Man_t * p,
int iLit,
int fHash,
int(* pFuncCiToKeep )(void *, int),
void * pData,
Vec_Int_t * vDLits )

Definition at line 1402 of file AbcGlucose2.cpp.

1403{
1404 extern int Gia_ManQuantExist( Gia_Man_t * p, int iLit, int(*pFuncCiToKeep)(void *, int), void * pData );
1405 int Res1 = Gia_ManQuantExist( p, iLit, pFuncCiToKeep, pData );
1406 int Res2 = bmcg2_sat_solver_quantify2( p, iLit, 1, pFuncCiToKeep, pData, NULL );
1407
1409 if ( bmcg2_sat_solver_equiv_overlap_check( pSat, p, Res1, Res2, 1 ) )
1410 printf( "Verification passed.\n" );
1411 else
1412 {
1413 printf( "Verification FAILED.\n" );
1416 printf( "\n" );
1417 }
1418 return Res1;
1419}
int bmcg2_sat_solver_quantify2(Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
bmcg2_sat_solver * bmcg2_sat_solver_start()
MACRO DEFINITIONS ///.
void bmcg2_sat_solver_print_sop_lit(Gia_Man_t *p, int Lit)
int bmcg2_sat_solver_equiv_overlap_check(bmcg2_sat_solver *pSat, Gia_Man_t *p, int iLit0, int iLit1, int fEquiv)
int Gia_ManQuantExist(Gia_Man_t *p, int iLit, int(*pFuncCiToKeep)(void *, int), void *pData)
Definition giaExist.c:505
Here is the call graph for this function:

◆ bmcg2_sat_solver_read_cex()

int * bmcg2_sat_solver_read_cex ( bmcg2_sat_solver * s)

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 )

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)

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 )

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 )

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 )

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 )

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 )

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 )

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 *) )

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 )

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 )

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)
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 ( )

MACRO DEFINITIONS ///.

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)

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)

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 )

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 )

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)

Definition at line 255 of file AbcGlucose2.cpp.

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

◆ Gia_ManCiIsToKeep2()

int Gia_ManCiIsToKeep2 ( void * pData,
int i )

Definition at line 1371 of file AbcGlucose2.cpp.

1372{
1373 return i % 5 != 0;
1374}
Here is the caller graph for this function:

◆ Gia_ManFactorSop2()

int Gia_ManFactorSop2 ( Gia_Man_t * p,
Vec_Int_t * vCiObjIds,
Vec_Str_t * vSop,
int fHash )

Definition at line 1255 of file AbcGlucose2.cpp.

1256{
1257 extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp );
1258 Gia_Man_t * pMan = Abc_SopSynthesizeOne( Vec_StrArray(vSop), 1 );
1259 Gia_Obj_t * pObj; int i, Result;
1260 assert( Gia_ManPiNum(pMan) == Vec_IntSize(vCiObjIds) );
1261 Gia_ManConst0(pMan)->Value = 0;
1262 Gia_ManForEachPi( pMan, pObj, i )
1263 pObj->Value = Abc_Var2Lit( Vec_IntEntry(vCiObjIds, i), 0 );
1264 Gia_ManForEachAnd( pMan, pObj, i )
1265 if ( fHash )
1266 pObj->Value = Gia_ManHashAnd( p, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1267 else
1268 pObj->Value = Gia_ManAppendAnd( p, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1269 pObj = Gia_ManPo(pMan, 0);
1270 Result = Gia_ObjFanin0Copy(pObj);
1271 Gia_ManStop( pMan );
1272 return Result;
1273}
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManQuantLoadCnf2()

void Gia_ManQuantLoadCnf2 ( Gia_Man_t * p,
Vec_Int_t * vObjsUsed,
bmcg2_sat_solver * pSats[] )

Definition at line 1225 of file AbcGlucose2.cpp.

1226{
1227 Gia_Obj_t * pObj; int i;
1228 bmcg2_sat_solver_reset( pSats[0] );
1229 if ( pSats[1] )
1230 bmcg2_sat_solver_reset( pSats[1] );
1231 bmcg2_sat_solver_set_nvars( pSats[0], Vec_IntSize(vObjsUsed) );
1232 if ( pSats[1] )
1233 bmcg2_sat_solver_set_nvars( pSats[1], Vec_IntSize(vObjsUsed) );
1234 Gia_ManForEachObjVec( vObjsUsed, p, pObj, i )
1235 if ( Gia_ObjIsAnd(pObj) )
1236 {
1237 int iObj = Gia_ObjId( p, pObj );
1238 int iVar = Gia_ObjCopyArray(p, iObj);
1239 int iVar0 = Gia_ObjCopyArray(p, Gia_ObjFaninId0(pObj, iObj));
1240 int iVar1 = Gia_ObjCopyArray(p, Gia_ObjFaninId1(pObj, iObj));
1241 bmcg2_sat_solver_add_and( pSats[0], iVar, iVar0, iVar1, Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj), 0 );
1242 if ( pSats[1] )
1243 bmcg2_sat_solver_add_and( pSats[1], iVar, iVar0, iVar1, Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj), 0 );
1244 }
1245 else if ( Gia_ObjIsConst0(pObj) )
1246 {
1247 int Lit = Abc_Var2Lit( Gia_ObjCopyArray(p, 0), 1 );
1248 int RetValue = bmcg2_sat_solver_addclause( pSats[0], &Lit, 1 );
1249 assert( RetValue );
1250 if ( pSats[1] )
1251 bmcg2_sat_solver_addclause( pSats[1], &Lit, 1 );
1252 assert( Lit == 1 );
1253 }
1254}
void bmcg2_sat_solver_reset(bmcg2_sat_solver *s)
int bmcg2_sat_solver_add_and(bmcg2_sat_solver *s, int iVar, int iVar0, int iVar1, int fCompl0, int fCompl1, int fCompl)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatAndCollect2_rec()

int Gia_ManSatAndCollect2_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vObjsUsed,
Vec_Int_t * vCiVars )

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

Synopsis [Performs SAT-based quantification.]

Description []

SideEffects []

SeeAlso []

Definition at line 1206 of file AbcGlucose2.cpp.

1207{
1208 Gia_Obj_t * pObj; int iVar;
1209 if ( (iVar = Gia_ObjCopyArray(p, iObj)) >= 0 )
1210 return iVar;
1211 pObj = Gia_ManObj( p, iObj );
1212 assert( Gia_ObjIsCand(pObj) );
1213 if ( Gia_ObjIsAnd(pObj) )
1214 {
1215 Gia_ManSatAndCollect2_rec( p, Gia_ObjFaninId0(pObj, iObj), vObjsUsed, vCiVars );
1216 Gia_ManSatAndCollect2_rec( p, Gia_ObjFaninId1(pObj, iObj), vObjsUsed, vCiVars );
1217 }
1218 iVar = Vec_IntSize( vObjsUsed );
1219 Vec_IntPush( vObjsUsed, iObj );
1220 Gia_ObjSetCopyArray( p, iObj, iVar );
1221 if ( vCiVars && Gia_ObjIsCi(pObj) )
1222 Vec_IntPush( vCiVars, iVar );
1223 return iVar;
1224}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Glucose2_CheckTwoNodesTest()

void Glucose2_CheckTwoNodesTest ( Gia_Man_t * p)

Definition at line 1477 of file AbcGlucose2.cpp.

1478{
1479 int n, Res;
1481 for ( n = 0; n < 2; n++ )
1482 {
1484 pSat, p,
1485 Gia_ObjFaninLit0p(p, Gia_ManPo(p, 0)),
1486 Gia_ObjFaninLit0p(p, Gia_ManPo(p, 1)),
1487 n );
1488 bmcg2_sat_solver_reset( pSat );
1489 printf( "%s %s.\n", n ? "Equivalence" : "Overlap", Res ? "holds" : "fails" );
1490 }
1491 bmcg2_sat_solver_stop( pSat );
1492}
Here is the call graph for this function:

◆ Glucose2_GenerateCubes()

Vec_Str_t * Glucose2_GenerateCubes ( bmcg2_sat_solver * pSat[2],
Vec_Int_t * vCiSatVars,
Vec_Int_t * vVar2Index,
int CubeLimit )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 940 of file AbcGlucose2.cpp.

941{
942 int fCreatePrime = 1;
943 int nCubes, nSupp = Vec_IntSize(vCiSatVars);
944 Vec_Str_t * vSop = Vec_StrAlloc( 1000 );
945 Vec_Int_t * vLits = Vec_IntAlloc( nSupp );
946 Vec_Str_t * vCube = Vec_StrAlloc( nSupp + 4 );
947 Vec_StrFill( vCube, nSupp, '-' );
948 Vec_StrPrintF( vCube, " 1\n\0" );
949 for ( nCubes = 0; !CubeLimit || nCubes < CubeLimit; nCubes++ )
950 {
951 int * pFinal, nFinal, iVar, i, k = 0;
952 // generate onset minterm
953 int status = bmcg2_sat_solver_solve( pSat[1], NULL, 0 );
954 if ( status == GLUCOSE_UNSAT )
955 break;
956 assert( status == GLUCOSE_SAT );
957 Vec_IntClear( vLits );
958 Vec_IntForEachEntry( vCiSatVars, iVar, i )
959 Vec_IntPush( vLits, Abc_Var2Lit(iVar, !bmcg2_sat_solver_read_cex_varvalue(pSat[1], iVar)) );
960 // expand against offset
961 if ( fCreatePrime )
962 {
963 nFinal = bmcg2_sat_solver_minimize_assumptions( pSat[0], Vec_IntArray(vLits), Vec_IntSize(vLits), 0 );
964 Vec_IntShrink( vLits, nFinal );
965 pFinal = Vec_IntArray( vLits );
966 for ( i = 0; i < nFinal; i++ )
967 pFinal[i] = Abc_LitNot(pFinal[i]);
968 }
969 else
970 {
971 status = bmcg2_sat_solver_solve( pSat[0], Vec_IntArray(vLits), Vec_IntSize(vLits) );
972 assert( status == GLUCOSE_UNSAT );
973 nFinal = bmcg2_sat_solver_final( pSat[0], &pFinal );
974 }
975 // print cube
976 Vec_StrFill( vCube, nSupp, '-' );
977 for ( i = 0; i < nFinal; i++ )
978 {
979 int Index = Vec_IntEntry(vVar2Index, Abc_Lit2Var(pFinal[i]));
980 if ( Index == -1 )
981 continue;
982 pFinal[k++] = pFinal[i];
983 assert( Index >= 0 && Index < nSupp );
984 Vec_StrWriteEntry( vCube, Index, (char)('0' + Abc_LitIsCompl(pFinal[i])) );
985 }
986 nFinal = k;
987 Vec_StrAppend( vSop, Vec_StrArray(vCube) );
988 //printf( "%s\n", Vec_StrArray(vCube) );
989 // add blocking clause
990 if ( !bmcg2_sat_solver_addclause( pSat[1], pFinal, nFinal ) )
991 break;
992 }
993 Vec_IntFree( vLits );
994 Vec_StrFree( vCube );
995 Vec_StrPush( vSop, '\0' );
996 return vSop;
997}
int bmcg2_sat_solver_final(bmcg2_sat_solver *s, int **ppArray)
int bmcg2_sat_solver_read_cex_varvalue(bmcg2_sat_solver *s, int ivar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ glucose2_markapprox()

void glucose2_markapprox ( Gluco2::SimpSolver * S,
int v0,
int v1,
int nlim )

Definition at line 135 of file AbcGlucose2.cpp.

136{
137 S->markApprox(v0, v1, nlim);
138}
Here is the caller graph for this function:

◆ glucose2_print_stats()

void glucose2_print_stats ( SimpSolver & s,
abctime clk )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 766 of file AbcGlucose2.cpp.

767{
768 double cpu_time = (double)(unsigned)clk / CLOCKS_PER_SEC;
769 double mem_used = memUsed();
770 printf("c restarts : %d (%d conflicts on average)\n", (int)s.starts, s.starts > 0 ? (int)(s.conflicts/s.starts) : 0);
771 printf("c blocked restarts : %d (multiple: %d) \n", (int)s.nbstopsrestarts, (int)s.nbstopsrestartssame);
772 printf("c last block at restart : %d\n", (int)s.lastblockatrestart);
773 printf("c nb ReduceDB : %-12d\n", (int)s.nbReduceDB);
774 printf("c nb removed Clauses : %-12d\n", (int)s.nbRemovedClauses);
775 printf("c nb learnts DL2 : %-12d\n", (int)s.nbDL2);
776 printf("c nb learnts size 2 : %-12d\n", (int)s.nbBin);
777 printf("c nb learnts size 1 : %-12d\n", (int)s.nbUn);
778 printf("c conflicts : %-12d (%.0f /sec)\n", (int)s.conflicts, s.conflicts /cpu_time);
779 printf("c decisions : %-12d (%4.2f %% random) (%.0f /sec)\n", (int)s.decisions, (float)s.rnd_decisions*100 / (float)s.decisions, s.decisions /cpu_time);
780 printf("c propagations : %-12d (%.0f /sec)\n", (int)s.propagations, s.propagations/cpu_time);
781 printf("c conflict literals : %-12d (%4.2f %% deleted)\n", (int)s.tot_literals, (s.max_literals - s.tot_literals)*100 / (double)s.max_literals);
782 printf("c nb reduced Clauses : %-12d\n", (int)s.nbReducedClauses);
783 if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used);
784 //printf("c CPU time : %.2f sec\n", cpu_time);
785}
int64_t decisions
Definition Solver.h:200
int64_t nbstopsrestarts
Definition Solver.h:200
int64_t conflicts
Definition Solver.h:200
int64_t nbUn
Definition Solver.h:200
int64_t lastblockatrestart
Definition Solver.h:200
int64_t starts
Definition Solver.h:200
int64_t tot_literals
Definition Solver.h:201
int64_t max_literals
Definition Solver.h:201
int64_t nbReduceDB
Definition Solver.h:200
int64_t nbDL2
Definition Solver.h:200
int64_t nbstopsrestartssame
Definition Solver.h:200
int64_t nbReducedClauses
Definition Solver.h:200
int64_t propagations
Definition Solver.h:200
int64_t nbBin
Definition Solver.h:200
int64_t rnd_decisions
Definition Solver.h:200
int64_t nbRemovedClauses
Definition Solver.h:200
double memUsed()
Definition System2.cpp:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Glucose2_QuantifyAigTest()

void Glucose2_QuantifyAigTest ( Gia_Man_t * p)

Definition at line 1375 of file AbcGlucose2.cpp.

1376{
1378
1379 abctime clk1 = Abc_Clock();
1380 int iRes1 = bmcg2_sat_solver_quantify( pSats, p, Gia_ObjFaninLit0p(p, Gia_ManPo(p, 0)), 0, Gia_ManCiIsToKeep2, NULL, NULL );
1381 abctime clk1d = Abc_Clock()-clk1;
1382
1383 abctime clk2 = Abc_Clock();
1384 int iRes2 = bmcg2_sat_solver_quantify2( p, Gia_ObjFaninLit0p(p, Gia_ManPo(p, 0)), 0, Gia_ManCiIsToKeep2, NULL, NULL );
1385 abctime clk2d = Abc_Clock()-clk2;
1386
1387 Abc_PrintTime( 1, "Time1", clk1d );
1388 Abc_PrintTime( 1, "Time2", clk2d );
1389
1390 if ( bmcg2_sat_solver_equiv_overlap_check( pSats[2], p, iRes1, iRes2, 1 ) )
1391 printf( "Verification passed.\n" );
1392 else
1393 printf( "Verification FAILED.\n" );
1394
1395 Gia_ManAppendCo( p, iRes1 );
1396 Gia_ManAppendCo( p, iRes2 );
1397
1398 bmcg2_sat_solver_stop( pSats[0] );
1399 bmcg2_sat_solver_stop( pSats[1] );
1400 bmcg2_sat_solver_stop( pSats[2] );
1401}
int bmcg2_sat_solver_quantify(bmcg2_sat_solver *pSats[], Gia_Man_t *p, int iLit, int fHash, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vDLits)
int Gia_ManCiIsToKeep2(void *pData, int i)
Here is the call graph for this function:

◆ Glucose2_SolveAig()

int Glucose2_SolveAig ( Gia_Man_t * p,
Glucose2_Pars * pPars )

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 )

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:

◆ glucose2_solver_addclause()

int glucose2_solver_addclause ( Gluco2::SimpSolver * S,
int * plits,
int nlits )

Definition at line 78 of file AbcGlucose2.cpp.

79{
80 vec<Lit> lits;
81 for ( int i = 0; i < nlits; i++,plits++)
82 {
83 // note: Glucose uses the same var->lit conventiaon as ABC
84 while ((*plits)/2 >= S->nVars()) S->newVar();
85 assert((*plits)/2 < S->nVars()); // NOTE: since we explicitely use new function bmc_add_var
86 Lit p;
87 p.x = *plits;
88 lits.push(p);
89 }
90 return S->addClause(lits); // returns 0 if the problem is UNSAT
91}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ glucose2_solver_addvar()

int glucose2_solver_addvar ( Gluco2::SimpSolver * S)

Definition at line 114 of file AbcGlucose2.cpp.

115{
116 S->newVar();
117 return S->nVars() - 1;
118}
Here is the caller graph for this function:

◆ glucose2_solver_read_cex()

int * glucose2_solver_read_cex ( Gluco2::SimpSolver * S)

Definition at line 120 of file AbcGlucose2.cpp.

121{
122 return S->getCex();
123}
Here is the caller graph for this function:

◆ glucose2_solver_read_cex_varvalue()

int glucose2_solver_read_cex_varvalue ( Gluco2::SimpSolver * S,
int ivar )

Definition at line 125 of file AbcGlucose2.cpp.

126{
127 return S->model[ivar] == l_True;
128}
Here is the caller graph for this function:

◆ glucose2_solver_reset()

void glucose2_solver_reset ( Gluco2::SimpSolver * S)

Definition at line 73 of file AbcGlucose2.cpp.

74{
75 S->reset();
76}
Here is the caller graph for this function:

◆ glucose2_solver_setcallback()

void glucose2_solver_setcallback ( Gluco2::SimpSolver * S,
void * pman,
int(* pfunc )(void *, int, int *) )

Definition at line 93 of file AbcGlucose2.cpp.

94{
95 S->pCnfMan = pman;
96 S->pCnfFunc = pfunc;
97 S->nCallConfl = 1000;
98}
Here is the caller graph for this function:

◆ glucose2_solver_setstop()

void glucose2_solver_setstop ( Gluco2::SimpSolver * S,
int * pstop )

Definition at line 130 of file AbcGlucose2.cpp.

131{
132 S->pstop = pstop;
133}
Here is the caller graph for this function:

◆ glucose2_solver_solve()

int glucose2_solver_solve ( Gluco2::SimpSolver * S,
int * plits,
int nlits )

Definition at line 100 of file AbcGlucose2.cpp.

101{
102// vec<Lit> lits;
103// for (int i=0;i<nlits;i++,plits++)
104// {
105// Lit p;
106// p.x = *plits;
107// lits.push(p);
108// }
109// Gluco2::lbool res = S->solveLimited(lits, 0);
110// return (res == l_True ? 1 : res == l_False ? -1 : 0);
111 return S->solveLimited(plits, nlits, 0);
112}
Here is the caller graph for this function:

◆ glucose2_solver_start()

SimpSolver * glucose2_solver_start ( )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file AbcGlucose2.cpp.

62{
63 SimpSolver * S = new SimpSolver;
65 return S;
66}
void setIncrementalMode()
Definition Glucose2.cpp:206
Here is the call graph for this function:
Here is the caller graph for this function:

◆ glucose2_solver_stop()

void glucose2_solver_stop ( Gluco2::SimpSolver * S)

Definition at line 68 of file AbcGlucose2.cpp.

69{
70 delete S;
71}
Here is the caller graph for this function:

◆ Glucose_ReadDimacs()

void Glucose_ReadDimacs ( char * pFileName,
SimpSolver & s )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 798 of file AbcGlucose2.cpp.

799{
800 vec<Lit> * lits = &s.user_lits;
801 char * pBuffer = Extra_FileReadContents( pFileName );
802 char * pTemp; int fComp, Var, VarMax = 0;
803 lits->clear();
804 for ( pTemp = pBuffer; *pTemp; pTemp++ )
805 {
806 if ( *pTemp == 'c' || *pTemp == 'p' ) {
807 while ( *pTemp != '\n' )
808 pTemp++;
809 continue;
810 }
811 while ( *pTemp == ' ' || *pTemp == '\t' || *pTemp == '\r' || *pTemp == '\n' )
812 pTemp++;
813 fComp = 0;
814 if ( *pTemp == '-' )
815 fComp = 1, pTemp++;
816 if ( *pTemp == '+' )
817 pTemp++;
818 Var = atoi( pTemp );
819 if ( Var == 0 ) {
820 if ( lits->size() > 0 ) {
821 s.addVar( VarMax );
822 s.addClause(*lits);
823 lits->clear();
824 }
825 }
826 else {
827 Var--;
828 VarMax = Abc_MaxInt( VarMax, Var );
829 lits->push( toLit(Abc_Var2Lit(Var, fComp)) );
830 }
831 while ( *pTemp >= '0' && *pTemp <= '9' )
832 pTemp++;
833 }
834 ABC_FREE( pBuffer );
835}
#define ABC_FREE(obj)
Definition abc_global.h:267
bool addClause(const vec< Lit > &ps)
Definition SimpSolver.h:198
void addVar(Var v)
Definition SimpSolver.h:223
vec< Lit > user_lits
Definition Solver.h:67
int size(void) const
Definition Vec.h:65
char * Extra_FileReadContents(char *pFileName)
int Var
Definition SolverTypes.h:54
Lit toLit(int i)
Definition SolverTypes.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Glucose_SolverFromAig()

Vec_Int_t * Glucose_SolverFromAig ( Gia_Man_t * p,
SimpSolver & s )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 894 of file AbcGlucose2.cpp.

895{
896 abctime clk = Abc_Clock();
897 vec<Lit> * lits = &s.user_lits;
898 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8 /*nLutSize*/, 0 /*fCnfObjIds*/, 1/*fAddOrCla*/, 0, 0/*verbose*/ );
899 for ( int i = 0; i < pCnf->nClauses; i++ )
900 {
901 lits->clear();
902 for ( int * pLit = pCnf->pClauses[i]; pLit < pCnf->pClauses[i+1]; pLit++ )
903 lits->push( toLit(*pLit) ), s.addVar( *pLit >> 1 );
904 s.addClause(*lits);
905 }
906 Vec_Int_t * vCnfIds = Vec_IntAllocArrayCopy(pCnf->pVarNums, Gia_ManObjNum(p));
907 printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
908 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
909 Cnf_DataFree(pCnf);
910 return vCnfIds;
911}
int nLiterals
Definition cnf.h:60
int * pVarNums
Definition cnf.h:63
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Glucose_SolverFromAig2()

Vec_Int_t * Glucose_SolverFromAig2 ( Gia_Man_t * p,
SimpSolver & S )

Definition at line 914 of file AbcGlucose2.cpp.

915{
916 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8 /*nLutSize*/, 0 /*fCnfObjIds*/, 1/*fAddOrCla*/, 0, 0/*verbose*/ );
917 for ( int i = 0; i < pCnf->nClauses; i++ )
918 if ( !glucose2_solver_addclause( &S, pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
919 assert( 0 );
920 Vec_Int_t * vCnfIds = Vec_IntAllocArrayCopy(pCnf->pVarNums, Gia_ManObjNum(p));
921 //printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
922 //Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
923 Cnf_DataFree(pCnf);
924 return vCnfIds;
925}
Here is the call graph for this function: