137{
138 int nIterMax = 1000000;
139 int i, iLit, Iter, status;
140 int nLits, * pLits;
141 abctime clkTotal = Abc_Clock();
149 Cnf_Dat_t * pCnf = Cnf_DeriveGiaRemapped( pM );
152 assert( Gia_ManRegNum(
p) > 0 );
153 if ( fVerbose )
154 printf( "Running with %d frames and %sgiven init state.\n", nFrames, vInit ? "":"no " );
155
158 sat_solver_set_runtime_limit( pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
159 for ( i = 0; i < pCnf->
nClauses; i++ )
162
163
164 vLits = Vec_IntAlloc( Gia_ManCoNum(
p) );
166 Vec_IntPush( vLits, Abc_Var2Lit(pCnf->
pVarNums[Gia_ObjId(pM, pObj)], 0) );
168
169
170 Vec_IntClear( vLits );
172 if ( i == Gia_ManRegNum(
p) )
173 break;
174 else if ( Vec_IntEntry(vInit, i) == 0 || Vec_IntEntry(vInit, i) == 1 )
175 Vec_IntPush( vLits, Abc_Var2Lit(pCnf->
pVarNums[Gia_ObjId(pM, pObj)], 1) );
176
177 if ( fVerbose )
178 {
179 printf( "Iter%6d : ", 0 );
183 printf( "Subset =%6d ", Vec_IntSize(vLits) );
184 Abc_PrintTime( 1, "Time", clkSat );
185
186 }
187 for ( Iter = 0; Iter < nIterMax; Iter++ )
188 {
190 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
191 clkSat += Abc_Clock() - clk;
193 {
194
195
196 printf( "Timeout reached after %d seconds and %d iterations. ", nTimeOut, Iter );
197 break;
198 }
200 {
201
202
203 printf( "The problem is SAT after %d iterations. ", Iter );
204 break;
205 }
207 nLits = sat_solver_final( pSat, &pLits );
208 if ( fVerbose )
209 {
210 printf( "Iter%6d : ", Iter+1 );
214 printf( "Subset =%6d ", nLits );
215 Abc_PrintTime( 1, "Time", clkSat );
216
217 }
218 if ( Vec_IntSize(vLits) == nLits )
219 {
220
221
222 printf( "Reached fixed point with %d entries after %d iterations. ", Vec_IntSize(vLits), Iter+1 );
223 break;
224 }
225
226 Vec_IntClear( vLits );
227 for ( i = 0; i < nLits; i++ )
228 Vec_IntPush( vLits, Abc_LitNot(pLits[i]) );
229 }
230
231 vMap = Vec_IntStart( pCnf->
nVars );
233 Vec_IntWriteEntry( vMap, Abc_Lit2Var(iLit), 1 );
234
235
236 Vec_IntFree( vLits );
237 vLits = Vec_IntDup(vInit);
239 if ( i == Gia_ManRegNum(
p) )
240 break;
241 else if ( Vec_IntEntry(vLits, i) == 4 || Vec_IntEntry(vLits, i) == 5 )
242 Vec_IntWriteEntry( vLits, i, Vec_IntEntry(vLits, i) );
243 else if ( (Vec_IntEntry(vLits, i) == 0 || Vec_IntEntry(vLits, i) == 1) && !Vec_IntEntry(vMap, pCnf->
pVarNums[Gia_ObjId(pM, pObj)]) )
244 Vec_IntWriteEntry( vLits, i, Vec_IntEntry(vLits, i) | 2 );
245 Vec_IntFree( vMap );
246
247
251 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
252 return vLits;
253}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Gia_Man_t * Gia_ManMaxiUnfold(Gia_Man_t *p, int nFrames, int fUseVars, Vec_Int_t *vInit)
#define sat_solver_addclause
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachPi(p, pObj, i)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManMiter(Gia_Man_t *pAig0, Gia_Man_t *pAig1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose)
#define Gia_ManForEachCo(p, pObj, i)
sat_solver * sat_solver_new(void)
int sat_solver_nconflicts(sat_solver *s)
int sat_solver_nclauses(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
void sat_solver_delete(sat_solver *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.