56 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
57 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
58 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
60 Vec_Int_t * vData = Vec_IntStart( 6 * (1 << 22) );
61 Hsh_IntMan_t * vHash = Hsh_IntManStart( vData, 6, 1 << 22 );
62 int i, k, v, RetValue, Beg, End, Counter = 0;
63 char pStart[24], pFirst[9][24];
65 printf(
"Enumerating states of 2x2x2 cube.\n" );
67 for ( v = 0; v < 24; v++ )
69 Abc_StatePush( vData, pStart, Counter );
70 RetValue = Hsh_IntManAdd( vHash, Counter );
71 assert( RetValue == Counter );
74 for ( i = 0; i < 3; i++ )
76 memcpy( pFirst[i], pStart, 24 );
77 for ( v = 0; v < 9; v++ )
78 ABC_SWAP(
char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
79 Abc_StatePush( vData, pFirst[i], Counter );
80 RetValue = Hsh_IntManAdd( vHash, Counter );
81 assert( RetValue == Counter );
85 memcpy( pFirst[3+i], pFirst[i], 24 );
86 for ( v = 0; v < 9; v++ )
87 ABC_SWAP(
char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
88 Abc_StatePush( vData, pFirst[3+i], Counter );
89 RetValue = Hsh_IntManAdd( vHash, Counter );
90 assert( RetValue == Counter );
94 memcpy( pFirst[6+i], pFirst[3+i], 24 );
95 for ( v = 0; v < 9; v++ )
96 ABC_SWAP(
char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
97 Abc_StatePush( vData, pFirst[6+i], Counter );
98 RetValue = Hsh_IntManAdd( vHash, Counter );
99 assert( RetValue == Counter );
103 printf(
"Iter %2d -> %8d ", 0, 1 );
104 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
105 printf(
"Iter %2d -> %8d ", 1, Counter );
106 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
108 for ( i = 2; i <= 100; i++ )
112 for ( k = Beg; k < End; k++ )
113 for ( v = 0; v < 9; v++ )
115 Abc_StatePerm( (
char *)Vec_IntEntryP(vData, 6*k), pFirst[v], (
char *)Vec_IntEntryP(vData, 6*Counter) );
116 RetValue = Hsh_IntManAdd( vHash, Counter );
117 if ( RetValue == Counter )
119 if ( Counter == (1<<22) )
121 printf(
"Did not converge. " );
122 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
126 Beg = End; End = Counter;
127 printf(
"Iter %2d -> %8d ", i, Counter );
128 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
130 Hsh_IntManStop( vHash );
131 Vec_IntFree( vData );
168 static int Var2Cor[24] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, -1, -1, -1, 6, 6, 6 };
169 static int Var2Per[24] = { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, -1, -1, -1, 0, 1, 2 };
194 int pXYZ[3][9][2] = {
195 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
196 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
197 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
199 Vec_Int_t * vData = Vec_IntStart( 6 * (1 << 22) );
201 int i, k, v, Beg, End, Counter = 0;
202 char * pPrev, * pState, pStart[24], pFirst[9][24];
204 printf(
"Enumerating states of 2x2x2 cube.\n" );
206 for ( v = 0; v < 24; v++ )
208 Abc_StatePush( vData, pStart, Counter );
209 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pStart) );
212 for ( i = 0; i < 3; i++ )
214 memcpy( pFirst[i], pStart, 24 );
215 for ( v = 0; v < 9; v++ )
216 ABC_SWAP(
char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
217 Abc_StatePush( vData, pFirst[i], Counter );
218 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[i]) );
222 memcpy( pFirst[3+i], pFirst[i], 24 );
223 for ( v = 0; v < 9; v++ )
224 ABC_SWAP(
char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
225 Abc_StatePush( vData, pFirst[3+i], Counter );
226 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[3+i]) );
230 memcpy( pFirst[6+i], pFirst[3+i], 24 );
231 for ( v = 0; v < 9; v++ )
232 ABC_SWAP(
char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
233 Abc_StatePush( vData, pFirst[6+i], Counter );
234 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[6+i]) );
238 printf(
"Iter %2d -> %8d ", 0, 1 );
239 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
240 printf(
"Iter %2d -> %8d ", 1, Counter );
241 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
243 for ( i = 2; i <= 100; i++ )
247 for ( k = Beg; k < End; k++ )
249 pPrev = (
char *)Vec_IntEntryP(vData, 6*k);
250 for ( v = 0; v < 9; v++ )
252 pState = (
char *)Vec_IntEntryP(vData, 6*Counter);
253 Abc_StatePerm( pPrev, pFirst[v], pState );
254 State = Abc_CubeGenerateSign( pState );
255 if ( !Abc_DataHasBit(pHash, State) )
256 Abc_DataXorBit(pHash, State), Counter++;
257 if ( Counter == (1<<22) )
259 printf(
"Did not converge. " );
260 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
265 Beg = End; End = Counter;
266 printf(
"Iter %2d -> %8d ", i, Counter );
267 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
269 Vec_IntFree( vData );