question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MAINT: Refactor `_linprog.py` and `_linprog_ip.py` to remove duplicate behaviour.

See original GitHub issue

Problem

_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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mdhabercommented, Jun 23, 2018

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.

0reactions
mdhabercommented, Sep 12, 2018

Agreed that this is closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: 5 Ways to Remove Duplicates from List - FavTutor
Remove duplicates from a list in python with these unique ways. Learn how to remove duplicates in a python list with source code...
Read more >
Duplicate Code - Refactoring.Guru
Use Extract Method for both classes, followed by Pull Up Field for the fields used in the method that you're pulling up. If...
Read more >
How do I remove duplicates from a list, while preserving order?
In CPython 3.6+ (and all other Python implementations starting with Python 3.7+), dictionaries are ordered, so the way to remove duplicates from an...
Read more >
Python - Ways to remove duplicates from list - GeeksforGeeks
Removing duplicates from list operation has a large number of applications and hence, its knowledge is good to have. Method 1: Using *set()....
Read more >
Keep or remove duplicate rows (Power Query)
Removes all rows from a Power Query table, in the Query Editor, where the values in the selected columns duplicate earlier values.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found