GurobiSolver: Flip upper/lower bound for minimization problems

pull/3/head
Alinson S. Xavier 5 years ago
parent b51c367257
commit 92615958fb

@ -146,14 +146,21 @@ class GurobiSolver(InternalSolver):
should_repeat = iteration_cb() should_repeat = iteration_cb()
if not should_repeat: if not should_repeat:
break break
log = streams[0].getvalue() log = streams[0].getvalue()
if self.model.modelSense == 1:
sense = "min"
lb = self.model.objBound
ub = self.model.objVal
else:
sense = "max"
lb = self.model.objVal
ub = self.model.objBound
return { return {
"Lower bound": self.model.objVal, "Lower bound": lb,
"Upper bound": self.model.objBound, "Upper bound": ub,
"Wallclock time": total_wallclock_time, "Wallclock time": total_wallclock_time,
"Nodes": total_nodes, "Nodes": total_nodes,
"Sense": ("min" if self.model.modelSense == 1 else "max"), "Sense": sense,
"Log": log, "Log": log,
"Warm start value": self._extract_warm_start_value(log), "Warm start value": self._extract_warm_start_value(log),
} }
@ -303,7 +310,18 @@ class GurobiSolver(InternalSolver):
return value return value
def __getstate__(self): def __getstate__(self):
return self.params return {
"params": self.params,
"lazy_cb_where": self.lazy_cb_where,
}
def __setstate__(self, state): def __setstate__(self, state):
self.params = state from gurobipy import GRB
self.params = state["params"]
self.lazy_cb_where = state["lazy_cb_where"]
self.GRB = GRB
self.instance = None
self.model = None
self._all_vars = None
self._bin_vars = None
self.cb_where = None

Loading…
Cancel
Save