00001
00021 #include "fra.h"
00022
00026
00030
00042 void Fra_ParamsDefault( Fra_Par_t * pPars )
00043 {
00044 memset( pPars, 0, sizeof(Fra_Par_t) );
00045 pPars->nSimWords = 32;
00046 pPars->dSimSatur = 0.005;
00047 pPars->fPatScores = 0;
00048 pPars->MaxScore = 25;
00049 pPars->fDoSparse = 1;
00050
00051
00052 pPars->dActConeRatio = 0.3;
00053 pPars->dActConeBumpMax = 10.0;
00054 pPars->nBTLimitNode = 100;
00055 pPars->nBTLimitMiter = 500000;
00056 pPars->nFramesK = 0;
00057 pPars->fConeBias = 1;
00058 pPars->fRewrite = 0;
00059 }
00060
00072 void Fra_ParamsDefaultSeq( Fra_Par_t * pPars )
00073 {
00074 memset( pPars, 0, sizeof(Fra_Par_t) );
00075 pPars->nSimWords = 1;
00076 pPars->dSimSatur = 0.005;
00077 pPars->fPatScores = 0;
00078 pPars->MaxScore = 25;
00079 pPars->fDoSparse = 1;
00080 pPars->dActConeRatio = 0.3;
00081 pPars->dActConeBumpMax = 10.0;
00082 pPars->nBTLimitNode = 10000000;
00083 pPars->nBTLimitMiter = 500000;
00084 pPars->nFramesK = 1;
00085 pPars->fConeBias = 0;
00086 pPars->fRewrite = 0;
00087 pPars->fLatchCorr = 0;
00088 }
00089
00101 Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars )
00102 {
00103 Fra_Man_t * p;
00104 Aig_Obj_t * pObj;
00105 int i;
00106
00107 p = ALLOC( Fra_Man_t, 1 );
00108 memset( p, 0, sizeof(Fra_Man_t) );
00109 p->pPars = pPars;
00110 p->pManAig = pManAig;
00111 p->nSizeAlloc = Aig_ManObjNumMax( pManAig );
00112 p->nFramesAll = pPars->nFramesK + 1;
00113
00114 p->nPatWords = Aig_BitWordNum( (Aig_ManPiNum(pManAig) - Aig_ManRegNum(pManAig)) * p->nFramesAll + Aig_ManRegNum(pManAig) );
00115 p->pPatWords = ALLOC( unsigned, p->nPatWords );
00116 p->vPiVars = Vec_PtrAlloc( 100 );
00117
00118 p->pCla = Fra_ClassesStart( pManAig );
00119
00120 p->pMemFraig = ALLOC( Aig_Obj_t *, p->nSizeAlloc * p->nFramesAll );
00121 memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll );
00122
00123 srand( 0xABCABC );
00124
00125 Aig_ManForEachObj( p->pManAig, pObj, i )
00126 pObj->pData = p;
00127 return p;
00128 }
00129
00141 void Fra_ManClean( Fra_Man_t * p, int nNodesMax )
00142 {
00143 int i;
00144
00145 for ( i = 0; i < p->nMemAlloc; i++ )
00146 if ( p->pMemFanins[i] && p->pMemFanins[i] != (void *)1 )
00147 Vec_PtrFree( p->pMemFanins[i] );
00148
00149 if ( p->nMemAlloc < nNodesMax )
00150 {
00151 int nMemAllocNew = nNodesMax + 5000;
00152 p->pMemFanins = REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew );
00153 p->pMemSatNums = REALLOC( int, p->pMemSatNums, nMemAllocNew );
00154 p->nMemAlloc = nMemAllocNew;
00155 }
00156
00157 memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
00158 memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
00159 }
00160
00172 Aig_Man_t * Fra_ManPrepareComb( Fra_Man_t * p )
00173 {
00174 Aig_Man_t * pManFraig;
00175 Aig_Obj_t * pObj;
00176 int i;
00177 assert( p->pManFraig == NULL );
00178
00179 pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pManAig) );
00180 pManFraig->pName = Aig_UtilStrsav( p->pManAig->pName );
00181 pManFraig->nRegs = p->pManAig->nRegs;
00182 pManFraig->nAsserts = p->pManAig->nAsserts;
00183
00184 Fra_ObjSetFraig( Aig_ManConst1(p->pManAig), 0, Aig_ManConst1(pManFraig) );
00185 Aig_ManForEachPi( p->pManAig, pObj, i )
00186 Fra_ObjSetFraig( pObj, 0, Aig_ObjCreatePi(pManFraig) );
00187
00188 Aig_ManForEachObj( pManFraig, pObj, i )
00189 pObj->pData = p;
00190
00191 p->nMemAlloc = p->nSizeAlloc;
00192 p->pMemFanins = ALLOC( Vec_Ptr_t *, p->nMemAlloc );
00193 memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
00194 p->pMemSatNums = ALLOC( int, p->nMemAlloc );
00195 memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
00196
00197 assert( pManFraig->pData == NULL );
00198 return pManFraig;
00199 }
00200
00212 void Fra_ManFinalizeComb( Fra_Man_t * p )
00213 {
00214 Aig_Obj_t * pObj;
00215 int i;
00216
00217 Aig_ManForEachPo( p->pManAig, pObj, i )
00218 Aig_ObjCreatePo( p->pManFraig, Fra_ObjChild0Fra(pObj,0) );
00219
00220 Aig_ManCleanMarkB( p->pManFraig );
00221 }
00222
00223
00235 void Fra_ManStop( Fra_Man_t * p )
00236 {
00237 if ( p->pPars->fVerbose )
00238 Fra_ManPrint( p );
00239
00240 if ( p->pManAig )
00241 {
00242 if ( p->pManAig->pObjCopies )
00243 free( p->pManAig->pObjCopies );
00244 p->pManAig->pObjCopies = p->pMemFraig;
00245 p->pMemFraig = NULL;
00246 }
00247 Fra_ManClean( p, 0 );
00248 if ( p->vTimeouts ) Vec_PtrFree( p->vTimeouts );
00249 if ( p->vPiVars ) Vec_PtrFree( p->vPiVars );
00250 if ( p->pSat ) sat_solver_delete( p->pSat );
00251 if ( p->pCla ) Fra_ClassesStop( p->pCla );
00252 if ( p->pSml ) Fra_SmlStop( p->pSml );
00253 if ( p->vCex ) Vec_IntFree( p->vCex );
00254 FREE( p->pMemFraig );
00255 FREE( p->pMemFanins );
00256 FREE( p->pMemSatNums );
00257 FREE( p->pPatWords );
00258 free( p );
00259 }
00260
00272 void Fra_ManPrint( Fra_Man_t * p )
00273 {
00274 double nMemory = 1.0*Aig_ManObjNumMax(p->pManAig)*(p->pSml->nWordsTotal*sizeof(unsigned)+6*sizeof(void*))/(1<<20);
00275 printf( "SimWord = %d. Round = %d. Mem = %0.2f Mb. LitBeg = %d. LitEnd = %d. (%6.2f %%).\n",
00276 p->pPars->nSimWords, p->pSml->nSimRounds, nMemory, p->nLitsBeg, p->nLitsEnd, 100.0*p->nLitsEnd/(p->nLitsBeg?p->nLitsBeg:1) );
00277 printf( "Proof = %d. Cex = %d. Fail = %d. FailReal = %d. C-lim = %d. ImpRatio = %6.2f %%\n",
00278 p->nSatProof, p->nSatCallsSat, p->nSatFails, p->nSatFailsReal, p->pPars->nBTLimitNode, Fra_ImpComputeStateSpaceRatio(p) );
00279 printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
00280 p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/(p->nNodesBeg?p->nNodesBeg:1),
00281 p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) );
00282 if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
00283 PRT( "AIG simulation ", p->pSml->timeSim );
00284 PRT( "AIG traversal ", p->timeTrav );
00285 if ( p->timeRwr )
00286 {
00287 PRT( "AIG rewriting ", p->timeRwr );
00288 }
00289 PRT( "SAT solving ", p->timeSat );
00290 PRT( " Unsat ", p->timeSatUnsat );
00291 PRT( " Sat ", p->timeSatSat );
00292 PRT( " Fail ", p->timeSatFail );
00293 PRT( "Class refining ", p->timeRef );
00294 PRT( "TOTAL RUNTIME ", p->timeTotal );
00295 if ( p->time1 ) { PRT( "time1 ", p->time1 ); }
00296 if ( p->nSpeculs )
00297 printf( "Speculations = %d.\n", p->nSpeculs );
00298 }
00299
00303
00304