MAINT: Refactor `_linprog.py` and `_linprog_ip.py` to remove duplicate behaviour.
See original GitHub issueProblem
_linprog.py solves linear programming problems, originally via the simplex method. An implementation of the interior-point method was later added via _linprog_ip.py using the original _linprog.py as the top-level interface. The simplex and interior-point implementations duplicate similar behaviour and arguments especially to:
- Clean user input.
- Convert problem to standard equality form.
- Call-back functions (not (yet) implemented in IP)
Further _linprog_ip.py implements the _presolve(...) and _postprocess(...), which may also improve the simplex method.
Proposed changes
I’m proposing to refactor _linprog.py and _linprog_ip.py into three new files _linprog.py, _linprog_ip.py and _linprog_simplex.py
_linprog.py to be the top level linear programming interface and handle behaviour common to all linear programming methods:
- Validating and cleaning input.
- Conversion to standard form.
- Call-back functions.
- Pre-solving and post-processing.
_linprog_ip.py and _linprog_simplex.py to implement the specific methods.
Benefits
- Remove code implementing similar behaviour.
- Avoid calling more complex solvers if problem is trivially solved.
- Supply problem in standard equality form to all solvers.
- Reduce the complexity of
_linprog_simplex(...)by reusing_clean_inputs(...)and_get_Abc(...)from the interior point method. - Improve simplex method implementation by pre-solving and post-processing.
Would this be worth refactoring or are there any other suggestions? @rgommers @mdhaber
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
If you see some code restructuring as the best way to resolve bugs or if you think it will help you find the bugs, go for it. Just thought that restructuring with the primary purpose being cleaner code or improving simplex performance (without fixing bugs) was premature.
Agreed that this is closed.