Skip to content

Commit 9c56ab8

Browse files
committed
adapt assert to Gurobi version
In older Gurobi versions (prior to version 12), the barrier does not return valid objective bounds. For newer versions, there might be an epsilon difference.
1 parent 28c8509 commit 9c56ab8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lpi/lpi_grb.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4166,14 +4166,20 @@ SCIP_RETCODE SCIPlpiGetObjval(
41664166

41674167
#ifndef NDEBUG
41684168
{
4169+
/* in older version the barrier method does not seem to return valid objective bounds */
4170+
#if GRB_VERSION_MAJOR < 12
41694171
double obnd = -GRB_INFINITY;
41704172
int algo;
4171-
4172-
(void)GRBgetintparam(lpi->grbenv, GRB_INT_PAR_METHOD, &algo);
41734173
(void)GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_OBJBOUND, &obnd);
4174-
4175-
/* currently the barrier method does not seem to return valid objective bounds */
4174+
(void)GRBgetintparam(lpi->grbenv, GRB_INT_PAR_METHOD, &algo);
41764175
assert(algo == GRB_METHOD_BARRIER || lpi->solstat != GRB_OPTIMAL || *objval == obnd); /*lint !e777*/
4176+
#else
4177+
double obnd;
4178+
double eps;
4179+
(void)GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_OBJBOUND, &obnd);
4180+
(void)GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_FEASIBILITYTOL, &eps);
4181+
assert(lpi->solstat != GRB_OPTIMAL || fabs(*objval - obnd) <= eps); /*lint !e777*/
4182+
#endif
41774183
}
41784184
#endif
41794185

0 commit comments

Comments
 (0)