hoytak / pylpsolve

PyLPSolve is an object oriented wrapper for the open source LP solver `lpsolve`_. The focus is on usability and integration with existing python packages used for scientific programming (i.e. numpy and scipy).
http://www.stat.washington.edu/code/pylpsolve
GNU Lesser General Public License v2.1
15 stars 10 forks source link

Add support for 'timeout' parameter. #8

Open rwe opened 8 years ago

rwe commented 8 years ago

Provides support for the timeout parameter. The timeout parameter is the positive integer seconds before either returning the optimal result or raising a timeout error.

The parameter defaults as 0, meaning no timeout.

In current hotyak/pylpsolve@master, if a timeout occurrs and is infeasible, a general LPException will be raised, identified by the message "Error 7: Timeout Occurred.". If a timeout occurs and the result was feasible, a warning will be printed with the string ""Solver solution suboptimal".

Under #7, if a timeout occurs and is infeasible, an LPTimeout instance will be raised. If a timeout occurs and the result is feasible, an LPSuboptimalException is raised instead (and the solver result can be used). This allows a timeout to be set, preventing unbounded computation, while still being able to programmatically identify a suboptimal result.