117static inline int Tas_VarIsAssigned(
Gia_Obj_t * pVar ) {
return pVar->
fMark0; }
122static inline int Tas_VarIsJust(
Gia_Obj_t * pVar ) {
return Gia_ObjIsAnd(pVar) && !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) && !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)); }
123static inline int Tas_VarFanin0Value(
Gia_Obj_t * pVar ) {
return !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin0(pVar)) ^ Gia_ObjFaninC0(pVar)); }
124static inline int Tas_VarFanin1Value(
Gia_Obj_t * pVar ) {
return !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin1(pVar)) ^ Gia_ObjFaninC1(pVar)); }
125static inline int Tas_VarToLit(
Tas_Man_t *
p,
Gia_Obj_t * pObj ) {
assert( Tas_VarIsAssigned(pObj) );
return Abc_Var2Lit( Gia_ObjId(
p->pAig, pObj), !Tas_VarValue(pObj) ); }
126static inline int Tas_LitIsTrue(
Gia_Obj_t * pObj,
int Lit ) {
assert( Tas_VarIsAssigned(pObj) );
return Tas_VarValue(pObj) != Abc_LitIsCompl(Lit); }
128static inline int Tas_ClsHandle(
Tas_Man_t *
p,
Tas_Cls_t * pClause ) {
return ((
int *)pClause) -
p->pStore.pData; }
134static inline int Tas_ClauseDecLevel(
Tas_Man_t *
p,
int hClause ) {
return Tas_VarDecLevel(
p,
p->pClauses.pData[hClause] ); }
136static inline int Tas_VarHasReasonCls(
Tas_Man_t *
p,
Gia_Obj_t * pVar ) {
assert( pVar->
Value != ~0 );
return Vec_IntEntry(
p->vLevReas, 3*pVar->
Value+1) == 0 && Vec_IntEntry(
p->vLevReas, 3*pVar->
Value+2) != 0; }
139#define Tas_QueForEachEntry( Que, pObj, i ) \
140 for ( i = (Que).iHead; (i < (Que).iTail) && ((pObj) = (Que).pData[i]); i++ )
142#define Tas_ClauseForEachVar( p, hClause, pObj ) \
143 for ( (p)->pIter = (p)->pClauses.pData + hClause; (pObj = *pIter); (p)->pIter++ )
144#define Tas_ClauseForEachVar1( p, hClause, pObj ) \
145 for ( (p)->pIter = (p)->pClauses.pData+hClause+1; (pObj = *pIter); (p)->pIter++ )
165 pPars->nBTLimit = 2000;
166 pPars->nJustLimit = 2000;
167 pPars->fUseActive = 0;
168 pPars->fUseHighest = 1;
169 pPars->fUseLowest = 0;
170 pPars->fUseMaxFF = 0;
172 pPars->VarDecay = (float)0.95;
193 p->Pars.nBTLimit = nBTLimit;
194 p->pProp.nSize =
p->pJust.nSize =
p->pClauses.nSize = 10000;
198 p->pClauses.iHead =
p->pClauses.iTail = 1;
199 p->vModel = Vec_IntAlloc( 1000 );
200 p->vLevReas = Vec_IntAlloc( 1000 );
201 p->vTemp = Vec_PtrAlloc( 1000 );
203 p->pStore.nSize = 10000;
204 p->pStore.pData =
ABC_ALLOC(
int,
p->pStore.nSize );
205 p->pWatches =
ABC_CALLOC(
int, 2 * Gia_ManObjNum(pAig) );
206 p->vWatchLits = Vec_IntAlloc( 100 );
207 p->pActivity =
ABC_CALLOC(
float, Gia_ManObjNum(pAig) );
208 p->vActiveVars = Vec_IntAlloc( 100 );
225 Vec_IntFree(
p->vActiveVars );
226 Vec_IntFree(
p->vWatchLits );
227 Vec_IntFree(
p->vLevReas );
228 Vec_IntFree(
p->vModel );
229 Vec_PtrFree(
p->vTemp );
269static inline int Tas_ManCheckLimits(
Tas_Man_t *
p )
271 return p->Pars.nJustThis >
p->Pars.nJustLimit ||
p->Pars.nBTThis >
p->Pars.nBTLimit;
289 Vec_IntClear( vCex );
294 if ( Gia_ObjIsCi(pVar) )
296 Vec_IntPush( vCex, Abc_Var2Lit(Gia_ObjCioId(pVar), !Tas_VarValue(pVar)) );
322static inline int Tas_QueIsEmpty(
Tas_Que_t *
p )
324 return p->iHead ==
p->iTail;
340 if (
p->iTail ==
p->nSize )
345 p->pData[
p->iTail++] = pObj;
380static inline void Tas_QueStore(
Tas_Que_t *
p,
int * piHeadOld,
int * piTailOld )
383 *piHeadOld =
p->iHead;
384 *piTailOld =
p->iTail;
385 for ( i = *piHeadOld; i < *piTailOld; i++ )
386 Tas_QuePush(
p,
p->pData[i] );
387 p->iHead = *piTailOld;
401static inline void Tas_QueRestore(
Tas_Que_t *
p,
int iHeadOld,
int iTailOld )
418static inline int Tas_QueFinish(
Tas_Que_t *
p )
420 int iHeadOld =
p->iHead;
422 Tas_QuePush(
p, NULL );
442 assert( !Gia_IsComplement(pObj) );
443 assert( Gia_ObjIsAnd(pObj) );
444 Count0 = Gia_ObjRefNum(
p->pAig, Gia_ObjFanin0(pObj) );
445 Count1 = Gia_ObjRefNum(
p->pAig, Gia_ObjFanin1(pObj) );
446 return Abc_MaxInt( Count0, Count1 );
465 float BestCost = 0.0;
469 assert( Gia_ObjIsAnd(pObj) );
470 ObjId = Gia_ObjId(
p->pAig, pObj );
471 if ( pObjMax == NULL ||
472 p->pActivity[Gia_ObjFaninId0(pObj,ObjId)] > BestCost ||
473 (
p->pActivity[Gia_ObjFaninId0(pObj,ObjId)] == BestCost && pObjMax < Gia_ObjFanin0(pObj)) )
475 pObjMax = Gia_ObjFanin0(pObj);
476 BestCost =
p->pActivity[Gia_ObjFaninId0(pObj,ObjId)];
478 if (
p->pActivity[Gia_ObjFaninId1(pObj,ObjId)] > BestCost ||
479 (
p->pActivity[Gia_ObjFaninId1(pObj,ObjId)] == BestCost && pObjMax < Gia_ObjFanin1(pObj)) )
481 pObjMax = Gia_ObjFanin1(pObj);
482 BestCost =
p->pActivity[Gia_ObjFaninId1(pObj,ObjId)];
505 assert( Gia_ObjIsAnd(pObj) );
506 ObjId = Gia_ObjId(
p->pAig, pObj );
507 if ( pObjMax == NULL || pObjMax < Gia_ObjFanin0(pObj) )
508 pObjMax = Gia_ObjFanin0(pObj);
509 if ( pObjMax < Gia_ObjFanin1(pObj) )
510 pObjMax = Gia_ObjFanin1(pObj);
533 if ( pObjMax == NULL || pObjMax < pObj )
557 if ( pObjMax == NULL ||
558 p->pActivity[Gia_ObjId(
p->pAig, pObjMax)] <
p->pActivity[Gia_ObjId(
p->pAig, pObj)] )
580 if ( pObjMin == NULL || pObjMin > pObj )
599 int i, iMaxFF = 0, iCurFF;
600 assert(
p->pAig->pRefs != NULL );
603 iCurFF = Tas_VarFaninFanoutMax(
p, pObj );
605 if ( iMaxFF < iCurFF )
627static inline void Tas_ManCancelUntil(
Tas_Man_t *
p,
int iBound )
631 assert( iBound <= p->pProp.iTail );
632 p->pProp.iHead = iBound;
634 Tas_VarUnassign( pVar );
635 p->pProp.iTail = iBound;
636 Vec_IntShrink(
p->vLevReas, 3*iBound );
657 assert( Gia_ObjIsCand(pObjR) );
658 assert( !Tas_VarIsAssigned(pObjR) );
659 Tas_VarAssign( pObjR );
660 Tas_VarSetValue( pObjR, !Gia_IsComplement(pObj) );
662 pObjR->
Value =
p->pProp.iTail;
663 Tas_QuePush( &
p->pProp, pObjR );
664 Vec_IntPush(
p->vLevReas, Level );
665 if ( pRes0 == NULL && pRes1 != 0 )
667 Vec_IntPush(
p->vLevReas, 0 );
668 Vec_IntPush(
p->vLevReas, Tas_ClsHandle(
p, (
Tas_Cls_t *)pRes1 ) );
672 Vec_IntPush(
p->vLevReas, pRes0 ? pRes0-pObjR : 0 );
673 Vec_IntPush(
p->vLevReas, pRes1 ? pRes1-pObjR : 0 );
675 assert( Vec_IntSize(
p->vLevReas) == 3 *
p->pProp.iTail );
691static inline int Tas_ManClauseSize(
Tas_Man_t *
p,
int hClause )
695 for ( pIter = pQue->
pData + hClause; *pIter; pIter++ );
696 return pIter - pQue->
pData - hClause ;
710static inline void Tas_ManPrintClause(
Tas_Man_t *
p,
int Level,
int hClause )
715 assert( Tas_QueIsEmpty( pQue ) );
716 printf(
"Level %2d : ", Level );
717 for ( i = hClause; (pObj = pQue->
pData[i]); i++ )
718 printf(
"%d=%d(%d) ", Gia_ObjId(
p->pAig, pObj), Tas_VarValue(pObj), Tas_VarDecLevel(
p, pObj) );
733static inline void Tas_ManPrintClauseNew(
Tas_Man_t *
p,
int Level,
int hClause )
738 assert( Tas_QueIsEmpty( pQue ) );
739 printf(
"Level %2d : ", Level );
740 for ( i = hClause; (pObj = pQue->
pData[i]); i++ )
741 printf(
"%c%d ", Tas_VarValue(pObj)?
'+':
'-', Gia_ObjId(
p->pAig, pObj) );
756static inline void Tas_ManDeriveReason(
Tas_Man_t *
p,
int Level )
760 int i, k, j, iLitLevel, iLitLevel2;
771 Vec_PtrClear(
p->vTemp );
772 for ( i = k = pQue->
iHead + 1; i < pQue->iTail; i++ )
774 pObj = pQue->
pData[i];
779 Vec_PtrPush(
p->vTemp, pObj );
786 iLitLevel = Tas_VarDecLevel(
p, pObj );
787 if ( iLitLevel < Level )
789 pQue->
pData[k++] = pObj;
792 assert( iLitLevel == Level );
793 if ( Tas_VarHasReasonCls(
p, pObj ) )
795 Tas_Cls_t * pCls = Tas_VarReasonCls(
p, pObj );
796 pReason = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCls->
pLits[0]) );
797 assert( pReason == pObj );
798 for ( j = 1; j < pCls->
nLits; j++ )
800 pReason = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCls->
pLits[j]) );
801 iLitLevel2 = Tas_VarDecLevel(
p, pReason );
802 assert( Tas_VarIsAssigned( pReason ) );
803 assert( !Tas_LitIsTrue( pReason, pCls->
pLits[j] ) );
804 Tas_QuePush( pQue, pReason );
809 pReason = Tas_VarReason0(
p, pObj );
810 if ( pReason == pObj )
816 Tas_QuePush( pQue, pObj );
819 Tas_QuePush( pQue, pReason );
820 pReason = Tas_VarReason1(
p, pObj );
821 if ( pReason != pObj )
822 Tas_QuePush( pQue, pReason );
827 printf(
"Tas_ManDeriveReason(): Failed to derive the clause!!!\n" );
848 assert( Tas_VarIsAssigned(pVar) );
849 assert( Tas_VarIsAssigned(pFan0) );
850 assert( pFan1 == NULL || Tas_VarIsAssigned(pFan1) );
851 assert( Tas_QueIsEmpty( pQue ) );
852 Tas_QuePush( pQue, NULL );
853 Tas_QuePush( pQue, pVar );
854 Tas_QuePush( pQue, pFan0 );
856 Tas_QuePush( pQue, pFan1 );
857 Tas_ManDeriveReason(
p, Level );
858 return Tas_QueFinish( pQue );
873static inline int Tas_ManResolve(
Tas_Man_t *
p,
int Level,
int hClause0,
int hClause1 )
877 int i, LevelMax = -1, LevelCur;
886 assert( Tas_QueIsEmpty( pQue ) );
887 Tas_QuePush( pQue, NULL );
888 for ( i = hClause0 + 1; (pObj = pQue->
pData[i]); i++ )
894 Tas_QuePush( pQue, pObj );
895 LevelCur = Tas_VarDecLevel(
p, pObj );
896 if ( LevelMax < LevelCur )
899 for ( i = hClause1 + 1; (pObj = pQue->
pData[i]); i++ )
905 Tas_QuePush( pQue, pObj );
906 LevelCur = Tas_VarDecLevel(
p, pObj );
907 if ( LevelMax < LevelCur )
910 for ( i = pQue->
iHead + 1; i < pQue->iTail; i++ )
912 Tas_ManDeriveReason(
p, LevelMax );
913 return Tas_QueFinish( pQue );
932 if (
p->pStore.iCur + nSize >
p->pStore.nSize )
934 p->pStore.nSize *= 2;
935 p->pStore.pData =
ABC_REALLOC(
int,
p->pStore.pData,
p->pStore.nSize );
937 pCls = Tas_ClsFromHandle(
p,
p->pStore.iCur );
p->pStore.iCur += nSize;
938 memset( pCls, 0,
sizeof(
int) * nSize );
956 assert( Abc_Lit2Var(Lit) < Gia_ManObjNum(
p->pAig) );
959 if ( pClause->
pLits[0] == Lit )
960 pClause->
iNext[0] =
p->pWatches[Abc_LitNot(Lit)];
962 pClause->
iNext[1] =
p->pWatches[Abc_LitNot(Lit)];
963 if (
p->pWatches[Abc_LitNot(Lit)] == 0 )
964 Vec_IntPush(
p->vWatchLits, Abc_LitNot(Lit) );
965 p->pWatches[Abc_LitNot(Lit)] = Tas_ClsHandle(
p, pClause );
985 assert( Tas_QueIsEmpty( pQue ) );
987 for ( i = hClause; (pObj = pQue->
pData[i]); i++ )
992 pClause = Tas_ManAllocCls(
p, nLits + 3 );
993 pClause->
nLits = nLits;
994 for ( i = hClause; (pObj = pQue->
pData[i]); i++ )
996 assert( Tas_VarIsAssigned( pObj ) );
997 pClause->
pLits[i-hClause] = Abc_LitNot( Tas_VarToLit(
p, pObj) );
1002 Tas_ManWatchClause(
p, pClause, pClause->
pLits[0] );
1003 Tas_ManWatchClause(
p, pClause, pClause->
pLits[1] );
1026 assert( Tas_QueIsEmpty( pQue ) );
1027 Tas_QuePush( pQue, NULL );
1028 for ( i = 0; i < pCls->
nLits; i++ )
1030 pObj = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCls->
pLits[i]) );
1031 assert( Tas_VarIsAssigned(pObj) );
1033 Tas_QuePush( pQue, pObj );
1035 Tas_ManDeriveReason(
p, Level );
1036 return Tas_QueFinish( pQue );
1050static inline int Tas_ManPropagateWatch(
Tas_Man_t *
p,
int Level,
int Lit )
1054 int * piPrev, iCur, iTemp;
1055 int i, LitF = Abc_LitNot(Lit);
1057 piPrev =
p->pWatches + Lit;
1058 for ( iCur =
p->pWatches[Lit]; iCur; iCur = *piPrev )
1060 pCur = Tas_ClsFromHandle(
p, iCur );
1062 if ( pCur->
pLits[0] == LitF )
1065 pCur->
pLits[1] = LitF;
1066 iTemp = pCur->
iNext[0];
1068 pCur->
iNext[1] = iTemp;
1074 pObj = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCur->
pLits[0]) );
1075 if ( Tas_VarIsAssigned(pObj) && Tas_LitIsTrue( pObj, pCur->
pLits[0] ) )
1077 piPrev = &pCur->
iNext[1];
1082 for ( i = 2; i < (int)pCur->
nLits; i++ )
1086 pObj = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCur->
pLits[i]) );
1087 if ( Tas_VarIsAssigned(pObj) && !Tas_LitIsTrue( pObj, pCur->
pLits[i] ) )
1091 pCur->
pLits[i] = LitF;
1093 *piPrev = pCur->
iNext[1];
1095 Tas_ManWatchClause(
p, pCur, pCur->
pLits[1] );
1098 if ( i < (
int)pCur->
nLits )
1102 pObj = Gia_ManObj(
p->pAig, Abc_Lit2Var(pCur->
pLits[0]) );
1103 if ( !Tas_VarIsAssigned(pObj) )
1118 Tas_ManAssign(
p, Gia_ObjFromLit(
p->pAig, pCur->
pLits[0]), Level, NULL, (
Gia_Obj_t *)pCur );
1119 piPrev = &pCur->
iNext[1];
1124 return Tas_ManCreateFromCls(
p, pCur, Level );
1144 int Value0, Value1, hClause;
1145 assert( !Gia_IsComplement(pVar) );
1146 assert( Tas_VarIsAssigned(pVar) );
1148 if ( (hClause = Tas_ManPropagateWatch(
p, Level, Tas_VarToLit(
p, pVar) )) )
1150 if ( Gia_ObjIsCi(pVar) )
1160 assert( Gia_ObjIsAnd(pVar) );
1161 Value0 = Tas_VarFanin0Value(pVar);
1162 Value1 = Tas_VarFanin1Value(pVar);
1163 if ( Tas_VarValue(pVar) )
1165 if ( Value0 == 0 || Value1 == 0 )
1167 if ( Value0 == 0 && Value1 != 0 )
1168 return Tas_ManAnalyze(
p, Level, pVar, Gia_ObjFanin0(pVar), NULL );
1169 if ( Value0 != 0 && Value1 == 0 )
1170 return Tas_ManAnalyze(
p, Level, pVar, Gia_ObjFanin1(pVar), NULL );
1171 assert( Value0 == 0 && Value1 == 0 );
1172 return Tas_ManAnalyze(
p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
1175 Tas_ManAssign(
p, Gia_ObjChild0(pVar), Level, pVar, NULL );
1177 Tas_ManAssign(
p, Gia_ObjChild1(pVar), Level, pVar, NULL );
1181 if ( Value0 == 0 || Value1 == 0 )
1183 if ( Value0 == 1 && Value1 == 1 )
1184 return Tas_ManAnalyze(
p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
1185 if ( Value0 == 1 || Value1 == 1 )
1188 Tas_ManAssign(
p, Gia_Not(Gia_ObjChild0(pVar)), Level, pVar, Gia_ObjFanin1(pVar) );
1190 Tas_ManAssign(
p, Gia_Not(Gia_ObjChild1(pVar)), Level, pVar, Gia_ObjFanin0(pVar) );
1193 assert( Tas_VarIsJust(pVar) );
1194 assert( !Tas_QueHasNode( &
p->pJust, pVar ) );
1195 Tas_QuePush( &
p->pJust, pVar );
1214 assert( !Gia_IsComplement(pVar) );
1215 assert( Gia_ObjIsAnd(pVar) );
1216 assert( Tas_VarIsAssigned(pVar) );
1217 assert( !Tas_VarValue(pVar) );
1218 Value0 = Tas_VarFanin0Value(pVar);
1219 Value1 = Tas_VarFanin1Value(pVar);
1221 if ( Value0 == 0 || Value1 == 0 )
1223 if ( Value0 == 1 && Value1 == 1 )
1224 return Tas_ManAnalyze(
p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
1225 assert( Value0 == 1 || Value1 == 1 );
1227 Tas_ManAssign(
p, Gia_Not(Gia_ObjChild0(pVar)), Level, pVar, Gia_ObjFanin1(pVar) );
1229 Tas_ManAssign(
p, Gia_Not(Gia_ObjChild1(pVar)), Level, pVar, Gia_ObjFanin0(pVar) );
1254 if ( (hClause = Tas_ManPropagateOne(
p, pVar, Level )) )
1257 p->pProp.iHead =
p->pProp.iTail;
1261 if ( Tas_VarIsJust( pVar ) )
1262 p->pJust.pData[k++] = pVar;
1263 else if ( (hClause = Tas_ManPropagateTwo(
p, pVar, Level )) )
1266 if ( k ==
p->pJust.iTail )
1288 Gia_Obj_t * pVar = NULL, * pDecVar = NULL;
1289 int hClause, hLearn0, hLearn1;
1290 int iPropHead, iJustHead, iJustTail;
1292 assert( !Tas_QueIsEmpty(&
p->pProp) );
1295 Tas_ManCreateCls(
p, hClause );
1299 assert( Tas_QueIsEmpty(&
p->pProp) );
1300 if ( Tas_QueIsEmpty(&
p->pJust) )
1303 p->Pars.nJustThis = Abc_MaxInt(
p->Pars.nJustThis,
p->pJust.iTail -
p->pJust.iHead );
1304 if ( Tas_ManCheckLimits(
p ) )
1307 iPropHead =
p->pProp.iHead;
1308 Tas_QueStore( &
p->pJust, &iJustHead, &iJustTail );
1310 if (
p->Pars.fUseActive )
1311 pVar = NULL, pDecVar = Tas_ManFindActive(
p );
1312 else if (
p->Pars.fUseHighest )
1314 pVar = Tas_ManDecideHighest(
p );
1315 else if (
p->Pars.fUseLowest )
1316 pVar = Tas_ManDecideLowest(
p );
1317 else if (
p->Pars.fUseMaxFF )
1318 pVar = Tas_ManDecideMaxFF(
p );
1323 assert( Tas_VarIsJust( pVar ) );
1324 if ( Gia_ObjRefNum(
p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefNum(
p->pAig, Gia_ObjFanin1(pVar)) )
1325 pDecVar = Gia_Not(Gia_ObjChild0(pVar));
1327 pDecVar = Gia_Not(Gia_ObjChild1(pVar));
1331 Tas_ManAssign(
p, pDecVar, Level+1, NULL, NULL );
1334 if ( pQue->
pData[hLearn0] != Gia_Regular(pDecVar) )
1336 Tas_ManCancelUntil(
p, iPropHead );
1337 Tas_QueRestore( &
p->pJust, iJustHead, iJustTail );
1339 Tas_ManAssign(
p, Gia_Not(pDecVar), Level+1, NULL, NULL );
1342 if ( pQue->
pData[hLearn1] != Gia_Regular(pDecVar) )
1344 hClause = Tas_ManResolve(
p, Level, hLearn0, hLearn1 );
1345 Tas_ManCreateCls(
p, hClause );
1368 int i, Entry, RetValue = 0;
1370 Vec_IntClear(
p->vModel );
1371 if ( pObj == Gia_ManConst0(
p->pAig) || pObj2 == Gia_ManConst0(
p->pAig) || pObj == Gia_Not(pObj2) )
1373 if ( pObj == Gia_ManConst1(
p->pAig) && (pObj2 == NULL || pObj2 == Gia_ManConst1(
p->pAig)) )
1375 assert( !
p->pProp.iHead && !
p->pProp.iTail );
1376 assert( !
p->pJust.iHead && !
p->pJust.iTail );
1377 assert(
p->pClauses.iHead == 1 &&
p->pClauses.iTail == 1 );
1378 p->Pars.nBTThis =
p->Pars.nJustThis =
p->Pars.nBTThisNc = 0;
1379 Tas_ManAssign(
p, pObj, 0, NULL, NULL );
1380 if ( pObj2 && !Tas_VarIsAssigned(Gia_Regular(pObj2)) )
1381 Tas_ManAssign(
p, pObj2, 0, NULL, NULL );
1383 Tas_ManSaveModel(
p,
p->vModel );
1386 Tas_ManCancelUntil(
p, 0 );
1387 p->pJust.iHead =
p->pJust.iTail = 0;
1388 p->pClauses.iHead =
p->pClauses.iTail = 1;
1390 if (
p->nClauses > 0 )
1392 p->pStore.iCur = 16;
1394 p->pWatches[Entry] = 0;
1395 Vec_IntClear(
p->vWatchLits );
1400 p->pActivity[Entry] = 0.0;
1401 Vec_IntClear(
p->vActiveVars );
1403 p->Pars.nBTTotal +=
p->Pars.nBTThis;
1404 p->Pars.nJustTotal = Abc_MaxInt(
p->Pars.nJustTotal,
p->Pars.nJustThis );
1405 if ( Tas_ManCheckLimits(
p ) )
1426 int i, Entry, RetValue = 0;
1430 Vec_IntClear(
p->vModel );
1432 if ( pObj == Gia_ManConst0(
p->pAig) )
1434 assert( !
p->pProp.iHead && !
p->pProp.iTail );
1435 assert( !
p->pJust.iHead && !
p->pJust.iTail );
1436 assert(
p->pClauses.iHead == 1 &&
p->pClauses.iTail == 1 );
1437 p->Pars.nBTThis =
p->Pars.nJustThis =
p->Pars.nBTThisNc = 0;
1439 if ( pObj != Gia_ManConst1(
p->pAig) && !Tas_VarIsAssigned(Gia_Regular(pObj)) )
1440 Tas_ManAssign(
p, pObj, 0, NULL, NULL );
1442 Tas_ManSaveModel(
p,
p->vModel );
1445 Tas_ManCancelUntil(
p, 0 );
1446 p->pJust.iHead =
p->pJust.iTail = 0;
1447 p->pClauses.iHead =
p->pClauses.iTail = 1;
1449 if (
p->nClauses > 0 )
1451 p->pStore.iCur = 16;
1453 p->pWatches[Entry] = 0;
1454 Vec_IntClear(
p->vWatchLits );
1459 p->pActivity[Entry] = 0.0;
1460 Vec_IntClear(
p->vActiveVars );
1462 p->Pars.nBTTotal +=
p->Pars.nBTThis;
1463 p->Pars.nJustTotal = Abc_MaxInt(
p->Pars.nJustTotal,
p->Pars.nJustThis );
1464 if ( Tas_ManCheckLimits(
p ) )
1489 printf(
"CO = %8d ", Gia_ManCoNum(
p->pAig) );
1490 printf(
"AND = %8d ", Gia_ManAndNum(
p->pAig) );
1491 printf(
"Conf = %6d ",
p->Pars.nBTLimit );
1492 printf(
"JustMax = %5d ",
p->Pars.nJustLimit );
1494 printf(
"Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
1495 p->nSatUnsat,
p->nSatTotal? 100.0*
p->nSatUnsat/
p->nSatTotal :0.0,
p->nSatUnsat? 1.0*
p->nConfUnsat/
p->nSatUnsat :0.0 );
1496 ABC_PRTP(
"Time",
p->timeSatUnsat,
p->timeTotal );
1497 printf(
"Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
1498 p->nSatSat,
p->nSatTotal? 100.0*
p->nSatSat/
p->nSatTotal :0.0,
p->nSatSat? 1.0*
p->nConfSat/
p->nSatSat : 0.0 );
1499 ABC_PRTP(
"Time",
p->timeSatSat,
p->timeTotal );
1500 printf(
"Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
1501 p->nSatUndec,
p->nSatTotal? 100.0*
p->nSatUndec/
p->nSatTotal :0.0,
p->nSatUndec? 1.0*
p->nConfUndec/
p->nSatUndec : 0.0 );
1502 ABC_PRTP(
"Time",
p->timeSatUndec,
p->timeTotal );
1503 ABC_PRT(
"Total time",
p->timeTotal );
1522 Vec_Int_t * vCex, * vVisit, * vCexStore;
1528 abctime clk, clkTotal = Abc_Clock();
1529 assert( Gia_ManRegNum(pAig) == 0 );
1541 vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
1542 vCexStore = Vec_IntAlloc( 10000 );
1543 vVisit = Vec_IntAlloc( 100 );
1550 Vec_IntClear( vCex );
1551 if ( Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) )
1553 if ( Gia_ObjFaninC0(pRoot) )
1557 Vec_StrPush( vStatus, 0 );
1562 Vec_StrPush( vStatus, 1 );
1568 p->Pars.fUseHighest = 1;
1569 p->Pars.fUseLowest = 0;
1580 Vec_StrPush( vStatus, (
char)status );
1586 p->nConfUndec +=
p->Pars.nBTThis;
1588 p->timeSatUndec += Abc_Clock() - clk;
1599 p->nConfUnsat +=
p->Pars.nBTThis;
1600 p->timeSatUnsat += Abc_Clock() - clk;
1604 p->nConfSat +=
p->Pars.nBTThis;
1607 p->timeSatSat += Abc_Clock() - clk;
1616 Vec_IntFree( vVisit );
1617 p->nSatTotal = Gia_ManPoNum(pAig);
1618 p->timeTotal = Abc_Clock() - clkTotal;
1623 *pvStatus = vStatus;
1644 unsigned * pInfo, * pPres;
1646 for ( i = 0; i < nLits; i++ )
1648 pInfo = (
unsigned *)Vec_PtrEntry(vInfo, Abc_Lit2Var(pLits[i]));
1649 pPres = (
unsigned *)Vec_PtrEntry(vPres, Abc_Lit2Var(pLits[i]));
1650 if ( Abc_InfoHasBit( pPres, iBit ) &&
1651 Abc_InfoHasBit( pInfo, iBit ) == Abc_LitIsCompl(pLits[i]) )
1654 for ( i = 0; i < nLits; i++ )
1656 pInfo = (
unsigned *)Vec_PtrEntry(vInfo, Abc_Lit2Var(pLits[i]));
1657 pPres = (
unsigned *)Vec_PtrEntry(vPres, Abc_Lit2Var(pLits[i]));
1658 Abc_InfoSetBit( pPres, iBit );
1659 if ( Abc_InfoHasBit( pInfo, iBit ) == Abc_LitIsCompl(pLits[i]) )
1660 Abc_InfoXorBit( pInfo, iBit );
1679 for ( k = 1; k < 32; k++ )
1680 if (
Tas_StorePatternTry( vSimInfo, vPres, k, (
int *)Vec_IntArray(vCex), Vec_IntSize(vCex) ) )
1682 return (
int)(k < 32);
1704 Vec_Int_t * vCex, * vVisit, * vCexStore;
1708 abctime clk, clkTotal = Abc_Clock();
1709 int Tried = 0, Stored = 0, Step = Gia_ManCoNum(pAig) / nPatMax;
1710 assert( Gia_ManRegNum(pAig) == 0 );
1722 vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
1723 vCexStore = Vec_IntAlloc( 10000 );
1724 vVisit = Vec_IntAlloc( 100 );
1727 vPres = Vec_PtrAllocSimInfo( Gia_ManCiNum(pAig), 1 );
1728 Vec_PtrCleanSimInfo( vPres, 0, 1 );
1732 assert( !Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) );
1733 Vec_IntClear( vCex );
1735 p->Pars.fUseHighest = 1;
1736 p->Pars.fUseLowest = 0;
1738 Vec_StrPush( vStatus, (
char)status );
1742 p->nConfUndec +=
p->Pars.nBTThis;
1744 p->timeSatUndec += Abc_Clock() - clk;
1752 p->nConfUnsat +=
p->Pars.nBTThis;
1753 p->timeSatUnsat += Abc_Clock() - clk;
1755 pOldRoot = (
Gia_Obj_t *)Vec_PtrEntry( vOldRoots, i );
1756 assert( !Gia_ObjProved( pAigOld, Gia_ObjId(pAigOld, pOldRoot) ) );
1757 Gia_ObjSetProved( pAigOld, Gia_ObjId(pAigOld, pOldRoot) );
1763 p->nConfSat +=
p->Pars.nBTThis;
1770 p->timeSatSat += Abc_Clock() - clk;
1773 printf(
"Tried = %d Stored = %d\n", Tried, Stored );
1774 Vec_IntFree( vVisit );
1775 p->nSatTotal = Gia_ManPoNum(pAig);
1776 p->timeTotal = Abc_Clock() - clkTotal;
1780 Vec_PtrFree( vPres );
1781 Vec_StrFree( vStatus );
#define ABC_ALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_REALLOC(type, obj, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
void Cec_ManSatAddToStore(Vec_Int_t *vCexStore, Vec_Int_t *vCex, int Out)
void Tas_ManSatPrintStats(Tas_Man_t *p)
#define Tas_QueForEachEntry(Que, pObj, i)
Vec_Int_t * Tas_ManSolveMiterNc(Gia_Man_t *pAig, int nConfs, Vec_Str_t **pvStatus, int fVerbose)
int Tas_ManPropagate(Tas_Man_t *p, int Level)
struct Tas_Sto_t_ Tas_Sto_t
Tas_Man_t * Tas_ManAlloc(Gia_Man_t *pAig, int nBTLimit)
struct Tas_Que_t_ Tas_Que_t
Vec_Int_t * Tas_ReadModel(Tas_Man_t *p)
int Tas_ManSolveArray(Tas_Man_t *p, Vec_Ptr_t *vObjs)
void Tas_SetDefaultParams(Tas_Par_t *pPars)
FUNCTION DEFINITIONS ///.
int Tas_ManSolve_rec(Tas_Man_t *p, int Level)
typedefABC_NAMESPACE_IMPL_START struct Tas_Par_t_ Tas_Par_t
DECLARATIONS ///.
void Tas_ManStop(Tas_Man_t *p)
int Tas_StorePattern(Vec_Ptr_t *vSimInfo, Vec_Ptr_t *vPres, Vec_Int_t *vCex)
int Tas_ManSolve(Tas_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pObj2)
void Tas_ManSolveMiterNc2(Gia_Man_t *pAig, int nConfs, Gia_Man_t *pAigOld, Vec_Ptr_t *vOldRoots, Vec_Ptr_t *vSimInfo)
int Tas_StorePatternTry(Vec_Ptr_t *vInfo, Vec_Ptr_t *vPres, int iBit, int *pLits, int nLits)
struct Tas_Cls_t_ Tas_Cls_t
void Gia_ManCollectTest(Gia_Man_t *p)
struct Tas_Man_t_ Tas_Man_t
struct Gia_Obj_t_ Gia_Obj_t
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
void Gia_ManCleanPhase(Gia_Man_t *p)
void Gia_ManCleanMark0(Gia_Man_t *p)
void Gia_ManCreateRefs(Gia_Man_t *p)
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManCleanMark1(Gia_Man_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.