Skip to content

Commit

Permalink
Fix CLP termcode to LP_TIME_LIMIT only in the case a limit has been set
Browse files Browse the repository at this point in the history
  • Loading branch information
febattista committed Nov 22, 2024
1 parent a9b69cd commit aebd267
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/LP/lp_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2624,10 +2624,14 @@ int initial_lp_solve (LPdata *lp_data, int *iterd)
}else if (si->isIterationLimitReached()){
term = LP_D_ITLIM;
#ifdef __OSI_CLP__
double timelimit;
ClpDblParam key = ClpMaxWallSeconds;
lp_data->si->getModelPtr()->getDblParam(key, timelimit);
// YX: reset term if needed; Clp may return ITLIM at timeout
int itlim_chk = -1;
retval = si->getIntParam(OsiMaxNumIteration, itlim_chk);
if (si->getIterationCount() < itlim_chk){
// feb223: but check that a time limit has been actually set
if (timelimit > 0 && (si->getIterationCount() < itlim_chk)){
term = LP_TIME_LIMIT;
}
/* If max iterations and had switched to primal, bound is no good */
Expand Down Expand Up @@ -2747,12 +2751,16 @@ int dual_simplex(LPdata *lp_data, int *iterd)
}else if (si->isIterationLimitReached()){
term = LP_D_ITLIM;
#ifdef __OSI_CLP__
double timelimit;
ClpDblParam key = ClpMaxWallSeconds;
lp_data->si->getModelPtr()->getDblParam(key, timelimit);
// YX: reset term if needed; Clp may return ITLIM at timeout
int itlim_chk = -1;
retval = si->getIntParam(OsiMaxNumIteration, itlim_chk);
if (si->getIterationCount() < itlim_chk){
// feb223: but check that a time limit has been actually set
if (timelimit > 0 && (si->getIterationCount() < itlim_chk)){
term = LP_TIME_LIMIT;
}
}
/* If max iterations and had switched to primal, bound is no good */
if (si->getModelPtr()->secondaryStatus() == 10){
term = LP_ABANDONED;
Expand Down Expand Up @@ -2860,10 +2868,14 @@ int solve_hotstart(LPdata *lp_data, int *iterd)
else if (si->isIterationLimitReached()){
term = LP_D_ITLIM;
#ifdef __OSI_CLP__
double timelimit;
ClpDblParam key = ClpMaxWallSeconds;
lp_data->si->getModelPtr()->getDblParam(key, timelimit);
// YX: reset term if needed; Clp may return ITLIM at timeout
int itlim_chk = -1;
retval = si->getIntParam(OsiMaxNumIteration, itlim_chk);
if (si->getIterationCount() < itlim_chk){
// feb223: but check that a time limit has been actually set
if (timelimit > 0 && (si->getIterationCount() < itlim_chk)){
term = LP_TIME_LIMIT;
}
#endif
Expand Down

0 comments on commit aebd267

Please sign in to comment.