coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
516 stars 90 forks source link

Add some more tests and fix a rare case at failed optimization of unbounded model #241

Closed sebheger closed 2 years ago

h-g-s commented 2 years ago

Thanks for your contribution Sebastian !
One comment, for validating the obtained results it is safer to use tolerances, e.g., replace the assert m.objective_value == value by something like assert abs(m.objective_value - value) <= TOL where TOL is a small (but not too small) constant, like 1e-4 For small (specially pure integer model) the solution may match exactly, but this is not guaranteed as linear programming based solvers are approximate by nature. These tolerances should be considered while checking the variable values also, like x.x.

sebheger commented 2 years ago

@h-g-s Yes, thanks for your feedback. I did some rework to use tolerances also for the simple tests. Better save than sorry.