From 030d976c23288e782feb72e9a4a773530fc342a4 Mon Sep 17 00:00:00 2001 From: Sebastian Heger Date: Wed, 26 Jan 2022 22:14:42 +0100 Subject: [PATCH] Fix gap setting after optimize Fixed rare case when gurobi returns unbounded model with a worthless solution --- mip/model.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mip/model.py b/mip/model.py index a9b6a915..7c38b2b7 100644 --- a/mip/model.py +++ b/mip/model.py @@ -616,8 +616,11 @@ def optimize( ) self._status = self.solver.optimize(relax) - # has a solution and is a MIP - if self.num_solutions and self.num_int > 0: + # has a solution + if self._status in ( + mip.OptimizationStatus.OPTIMAL, + mip.OptimizationStatus.FEASIBLE, + ) and self.num_int > 0: best = self.objective_value lb = self.objective_bound if abs(best) <= 1e-10: