94 static inline unsigned Abc_ZddHash(
int Arg0,
int Arg1,
int Arg2 ) {
return 12582917 * Arg0 + 4256249 * Arg1 + 741457 * Arg2; }
123 return (pEnt->
Arg0 == Arg0 && pEnt->
Arg1 == Arg1 && pEnt->
Arg2 == Arg2) ? pEnt->
Res : -1;
128 pEnt->
Arg0 = Arg0; pEnt->
Arg1 = Arg1; pEnt->
Arg2 = Arg2; pEnt->
Res = Res;
136 for ( ; *q; q = p->
pNexts + *q )
143 assert( Var >= 0 && Var < p->nVars );
150 for ( ; *q; q = p->
pNexts + *q )
154 printf(
"Aborting because the number of nodes exceeded %d.\n", p->
nObjsAlloc ), fflush(stdout);
168 for ( i = Size - 1; i >= 0; i-- )
200 for ( i = 0; i < nVars; i++ )
212 assert( 2 * p->
nVars == nPermSize * (nPermSize - 1) );
218 for ( i = 0; i < nPermSize; i++ )
219 for ( j = i + 1; j < nPermSize; j++ )
229 printf(
"ZDD stats: Var = %d Obj = %d Alloc = %d Hit = %d Miss = %d ",
231 printf(
"Mem = %.2f MB\n", 4.0*(
int)(p->
nMemory/(1<<20)) );
257 if ( a == 0 )
return 0;
258 if ( b == 0 )
return a;
259 if ( a == b )
return 0;
267 else if ( A->
Var > B->
Var )
279 if ( a == 0 )
return b;
280 if ( b == 0 )
return a;
281 if ( a == b )
return a;
290 else if ( A->
Var > B->
Var )
303 if ( a == 0 )
return b;
304 if ( b == 0 )
return a;
305 if ( a == b )
return a;
314 else if ( A->
Var > B->
Var )
328 if ( a == 0 )
return 0;
329 if ( b == 0 )
return 0;
330 if ( a == b )
return a;
339 else if ( A->
Var > B->
Var )
352 if ( a < 2 )
return a;
354 if ( (
int)A->
Var > Var )
358 if ( (
int)A->
Var < Var )
370 if ( a < 2 )
return a;
372 if ( (
int)A->
Var > Var )
376 if ( (
int)A->
Var < Var )
389 if ( a < 2 )
return a;
440 int i, Id, Count = 0;
463 if ( a < 2 )
return a;
464 if ( b == 0 )
return 0;
476 int r0, r1, b2, t1, t2, r;
477 if ( a == 0 )
return 0;
478 if ( b == 0 )
return 0;
479 if ( a == 1 )
return b;
480 if ( b == 1 )
return a;
489 else if ( A->
Var > B->
Var )
504 int r0, r1, b2, t1, t2, r;
505 if ( a == 0 )
return 0;
506 if ( b == 0 )
return 0;
507 if ( a == 1 )
return b;
508 if ( b == 1 )
return a;
517 else if ( A->
Var > B->
Var )
548 if ( a == 0 )
return 0;
555 else if ( (
int)A->
Var == Var )
565 assert( Ai < Aj && Bi < Bj && Ai <= Bi );
594 if ( a == 0 )
return 0;
595 if ( a == 1 )
return b;
596 if ( b == 0 )
return 0;
597 if ( b == 1 )
return a;
623 for ( i = 0; i < Size; i++ )
624 printf(
" %2d", pPerm[i] );
631 printf(
"Empty set" );
632 for ( i = 0; i < nTrans; i++ )
633 printf(
"(%d %d)", pComb[i] >> 16, pComb[i] & 0xffff );
638 int i, j, nTrans = 0;
639 for ( i = 0; i < Size; i++ )
642 for ( j = i+1; j < Size; j++ )
645 pComb[nTrans++] = (i << 16) | j;
646 ABC_SWAP(
int, pPerm[i], pPerm[j] );
654 for ( v = 0; v < Size; v++ )
656 for ( v = nTrans-1; v >= 0; v-- )
657 ABC_SWAP(
int, pPerm[pComb[v] >> 16], pPerm[pComb[v] & 0xffff] );
662 int pPerm[10] = { 6, 5, 7, 0, 3, 2, 1, 8, 9, 4 };
663 int pComb[10], nTrans;
686 if ( a == 0 )
return;
690 int pPerm[24], pComb[24], i;
692 for ( i = 0; i < Size; i++ )
693 pComb[i] = (p->
pV2TI[pPath[i]] << 16) | p->
pV2TJ[pPath[i]];
701 pPath[Size] = A->
Var;
717 int pSets[3][5] = { {5, 0, 2, 10, 7}, {3, 11, 10, 7, 2}, {0, 2, 5, 10, 7} };
718 int i, Set, Union = 0;
719 for ( i = 0; i < nSets; i++ )
725 printf(
"Resulting set:\n" );
793 int pPerms[3][5] = { {1, 0, 2, 4, 3}, {1, 2, 4, 0, 3}, {0, 3, 2, 1, 4} };
794 int pComb[5], nTrans;
795 int i, k, Set, Union = 0, iPivot;
796 for ( i = 0; i < nPerms; i++ )
798 for ( i = 0; i < nPerms; i++ )
800 printf(
"Perm %d:\n", i );
804 for ( k = 0; k < nTrans; k++ )
805 pComb[k] =
Abc_ZddVarIJ( p, pComb[k] >> 16, pComb[k] & 0xFFFF );
811 printf(
"\nResulting set of permutations:\n" );
818 printf(
"\nResulting set of permutations:\n" );
847 int pXYZ[3][9][2] = {
848 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
849 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
850 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
857 int i, k, pComb[9],
pPerm[24], nSize;
858 int ZddTurn1, ZddTurn2, ZddTurn3, ZddTurns, ZddAll;
860 printf(
"Enumerating states of 2x2x2 cube.\n" );
864 printf(
"Iter %2d -> %8d Nodes = %7d Used = %10d ", 0, 1, 0, 2 );
868 for ( i = 0; i < 3; i++ )
870 for ( k = 0; k < 24; k++ )
872 for ( k = 0; k < 9; k++ )
873 ABC_SWAP(
int, pPerm[pXYZ[i][k][0]-1], pPerm[pXYZ[i][k][1]-1] );
876 for ( k = 0; k < 9; k++ )
877 pComb[k] =
Abc_ZddVarIJ( p, pComb[k] >> 16, pComb[k] & 0xffff );
897 for ( i = 2; i <= 100; i++ )
899 int ZddAllPrev = ZddAll;
903 if ( ZddAllPrev == ZddAll )
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
#define ABC_SWAP(Type, a, b)
#define Gia_ManForEachCi(p, pObj, i)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static int Gia_ManAndNum(Gia_Man_t *p)
static void Vec_IntSelectSort(int *pArray, int nSize)
static int Abc_MinInt(int a, int b)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
#define Gia_ManForEachAnd(p, pObj, i)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManFillValue(Gia_Man_t *p)
#define ABC_NAMESPACE_IMPL_START
static int Abc_Base2Log(unsigned n)
#define ABC_CALLOC(type, num)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Gia_ManObjNum(Gia_Man_t *p)
#define ABC_FALLOC(type, num)