@@ -145,6 +145,29 @@ lbool printScipStats(ScipSolver *scip_solver)
145145 return l_Undef;
146146}
147147
148+ void saveFixedVariables (ScipSolver *scip_solver)
149+ {
150+ std::lock_guard<std::mutex> lck (fixed_vars_mtx);
151+ int fixed = 0 ;
152+ for (int i = 0 ; i < (int )scip_solver->vars .size (); i++) {
153+ SCIP_VAR *v = scip_solver->vars [i];
154+ if (v != nullptr ) {
155+ SCIP_VAR * trans_var = SCIPvarGetTransVar (v);
156+ if (trans_var != nullptr && SCIPvarGetStatus (trans_var) == SCIP_VARSTATUS_FIXED) {
157+ SCIP_Real lb = SCIPvarGetLbGlobal (trans_var),
158+ ub = SCIPvarGetUbGlobal (trans_var);
159+ lbool val = (SCIPisZero (scip_solver->scip , lb) &&
160+ SCIPisZero (scip_solver->scip , ub) ? l_False :
161+ (SCIPisZero (scip_solver->scip , lb - 1 ) &&
162+ SCIPisZero (scip_solver->scip , ub - 1 ) ? l_True : l_Undef));
163+ if (val != l_Undef)
164+ scip_solver->fixed_vars .push (mkLit (i, val == l_False)), ++fixed;
165+ }
166+ }
167+ }
168+ if (opt_verbosity >= 2 && fixed > 0 ) reportf (" SCIP fixed %d vars\n " , fixed);
169+ }
170+
148171lbool scip_solve_async (ScipSolver *scip_solver, MsSolver *solver)
149172{
150173 extern double opt_scip_cpu, opt_scip_cpu_add;
@@ -218,7 +241,7 @@ lbool scip_solve_async(ScipSolver *scip_solver, MsSolver *solver)
218241 int64_t (round (dualb)) + scip_solver->obj_offset : INT64_MIN);
219242 int64_t ubound = (!SCIPisInfinity (scip_solver->scip , primb) ?
220243 int64_t (round (primb)) + scip_solver->obj_offset : INT64_MAX);
221- if (opt_finder.load () != OPT_MSAT && (!solver->ipamir_used || opt_verbosity > 0 ))
244+ if (opt_finder.load () != OPT_MSAT && opt_scip_cpu > 0 && (!solver->ipamir_used || opt_verbosity > 0 ))
222245 reportf (" SCIP timeout with lower and upper bounds: [%lld, %lld]\n " , lbound, ubound);
223246 int64_t gcd = fromweight (solver->goal_gcd );
224247 if (!SCIPisInfinity (scip_solver->scip , dualb)) {
@@ -268,7 +291,9 @@ lbool scip_solve_async(ScipSolver *scip_solver, MsSolver *solver)
268291 }
269292 }
270293 }
271- if (!scip_solver->interrupted && lbound != INT64_MIN && try_count > 0 && double (ubound - lbound)/max (int64_t (1 ),max (abs (lbound),abs (ubound))) < 0.10 && ubound - lbound < bound_gap) {
294+ if (!scip_solver->interrupted && opt_scip_cpu > 0 && lbound != INT64_MIN && try_count > 0 &&
295+ double (ubound - lbound)/max (int64_t (1 ),max (abs (lbound),abs (ubound))) < 0.10 &&
296+ ubound - lbound < bound_gap) {
272297 try_count--; opt_scip_cpu += opt_scip_cpu_add;
273298 bound_gap = ubound - lbound;
274299 MY_SCIP_CALL (SCIPsetRealParam (scip_solver->scip , " limits/time" , opt_scip_cpu));
@@ -278,6 +303,11 @@ lbool scip_solve_async(ScipSolver *scip_solver, MsSolver *solver)
278303 try_again = true ;
279304 }
280305 }
306+ if (opt_scip_cpu == 0 && !scip_solver->interrupted ) {
307+ saveFixedVariables (scip_solver);
308+ MY_SCIP_CALL (SCIPsetRealParam (scip_solver->scip , " limits/time" , 1e+20 ));
309+ try_again = true ;
310+ }
281311 }
282312 } while (try_again);
283313
@@ -312,27 +342,7 @@ lbool scip_solve_async(ScipSolver *scip_solver, MsSolver *solver)
312342 std::_Exit (30 );
313343 }
314344 }
315- } else {
316- std::lock_guard<std::mutex> lck (fixed_vars_mtx);
317- int fixed = 0 ;
318- for (int i = 0 ; i < (int )scip_solver->vars .size (); i++) {
319- SCIP_VAR *v = scip_solver->vars [i];
320- if (v != nullptr ) {
321- SCIP_VAR * trans_var = SCIPvarGetTransVar (v);
322- if (trans_var != nullptr && SCIPvarGetStatus (trans_var) == SCIP_VARSTATUS_FIXED) {
323- SCIP_Real lb = SCIPvarGetLbGlobal (trans_var),
324- ub = SCIPvarGetUbGlobal (trans_var);
325- lbool val = (SCIPisZero (scip_solver->scip , lb) &&
326- SCIPisZero (scip_solver->scip , ub) ? l_False :
327- (SCIPisZero (scip_solver->scip , lb - 1 ) &&
328- SCIPisZero (scip_solver->scip , ub - 1 ) ? l_True : l_Undef));
329- if (val != l_Undef)
330- scip_solver->fixed_vars .push (mkLit (i, val == l_False)), ++fixed;
331- }
332- }
333- }
334- if (opt_verbosity >= 2 && fixed > 0 ) reportf (" SCIP fixed %d vars\n " , fixed);
335- }
345+ } else saveFixedVariables (scip_solver);
336346clean_and_return:
337347 // release SCIP vars
338348 for (auto v: scip_solver->vars )
@@ -369,7 +379,7 @@ class ScipClauseIterator : public CaDiCaL::ClauseIterator {
369379
370380lbool MsSolver::scip_init (ScipSolver &scip_solver, int sat_orig_vars)
371381{
372- extern double opt_scip_cpu;
382+ extern double opt_scip_cpu, opt_scip_cpu_add ;
373383 extern bool opt_force_scip;
374384
375385 if (scip_solver.scip != nullptr ) return l_Undef;
@@ -395,6 +405,8 @@ lbool MsSolver::scip_init(ScipSolver &scip_solver, int sat_orig_vars)
395405 MY_SCIP_CALL (SCIPsetEmphasis (scip, SCIP_PARAMEMPHASIS_DEFAULT, TRUE ));
396406 if (opt_scip_cpu > 0 )
397407 MY_SCIP_CALL (SCIPsetRealParam (scip, " limits/time" , opt_scip_cpu));
408+ else
409+ MY_SCIP_CALL (SCIPsetRealParam (scip, " limits/time" , opt_scip_cpu_add));
398410 if (opt_verbosity <= 1 )
399411 MY_SCIP_CALL (SCIPsetIntParam (scip, " display/verblevel" , 0 ));
400412 if (declared_intsize > 0 && declared_intsize < 49 ) {
0 commit comments