-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suboptimal solution returned by scipy.optimize.linprog #7044
Comments
It turns out that A_eq in the problem is rank-deficient. After finding and removing rows that are a linear combination of others, linprog's solution agrees with the other. So linprog is producing a suboptimal solution when an equality constraint matrix is rank-deficient. Perhaps the algorithm does not need to be modified, but I think linprog should at least warn the user of rank-deficiency and/or mention in the documentation that the equality constraints need to be linearly independent. |
The new file scipy/optimize/linprog_ip.py contains a new function, linprog, intended to replace the one in scipy/optimize/_linprog.py. The new linprog function works exactly the same way as the old one, except that now the 'method' argument can be either "simplex" or "interior-point". scipy/optimize/_removeRedundancy.py contains a function _removeRedundancy that is used in the presolve procedure of the interior point method. It's in a separate file as scipy/optimize/_linprog/_linprog_simplex would benefit from calling it to eliminate redundancies in equality constraints. This would help fix some of its issues, e.g. scipy#7044. scipy/optimize/tests/test_linprog_ip contains the unit tests for the new linprog function. It contains all the tests for the old simplex method and several new tests, some of which would be relevant to the old simplex method. Please forgive the mess. I have no idea what I'm doing.
The new file scipy/optimize/linprog_ip.py contains a new function, linprog, intended to replace the one in scipy/optimize/_linprog.py. The new linprog function works exactly the same way as the old one, except that now the 'method' argument can be either "simplex" or "interior-point". scipy/optimize/_removeRedundancy.py contains a function _removeRedundancy that is used in the presolve procedure of the interior point method. It's in a separate file as scipy/optimize/_linprog/_linprog_simplex would benefit from calling it to eliminate redundancies in equality constraints. This would help fix some of its issues, e.g. scipy#7044. scipy/optimize/tests/test_linprog_ip contains the unit tests for the new linprog function. It contains all the tests for the old simplex method and several new tests, some of which would be relevant to the old simplex method. Please forgive the mess. I have no idea what I'm doing.
The new file scipy/optimize/linprog_ip.py contains a new function, linprog, intended to replace the one in scipy/optimize/_linprog.py. The new linprog function works exactly the same way as the old one, except that now the 'method' argument can be either "simplex" or "interior-point". scipy/optimize/_removeRedundancy.py contains a function _removeRedundancy that is used in the presolve procedure of the interior point method. It's in a separate file as scipy/optimize/_linprog/_linprog_simplex would benefit from calling it to eliminate redundancies in equality constraints. This would help fix some of its issues, e.g. scipy#7044. scipy/optimize/tests/test_linprog_ip contains the unit tests for the new linprog function. It contains all the tests for the old simplex method and several new tests, some of which would be relevant to the old simplex method. Please forgive the mess. I have no idea what I'm doing.
The new file scipy/optimize/linprog_ip.py contains a new function, linprog, intended to replace the one in scipy/optimize/_linprog.py. The new linprog function works exactly the same way as the old one, except that now the 'method' argument can be either "simplex" or "interior-point". scipy/optimize/_removeRedundancy.py contains a function _removeRedundancy that is used in the presolve procedure of the interior point method. It's in a separate file as scipy/optimize/_linprog/_linprog_simplex would benefit from calling it to eliminate redundancies in equality constraints. This would help fix some of its issues, e.g. scipy#7044. scipy/optimize/tests/test_linprog_ip contains the unit tests for the new linprog function. It contains all the tests for the old simplex method and several new tests, some of which would be relevant to the old simplex method. Please forgive the mess. I have no idea what I'm doing.
The new file scipy/optimize/linprog_ip.py contains a new function, linprog, intended to replace the one in scipy/optimize/_linprog.py. The new linprog function works exactly the same way as the old one, except that now the 'method' argument can be either "simplex" or "interior-point". scipy/optimize/_removeRedundancy.py contains a function _removeRedundancy that is used in the presolve procedure of the interior point method. It's in a separate file as scipy/optimize/_linprog/_linprog_simplex would benefit from calling it to eliminate redundancies in equality constraints. This would help fix some of its issues, e.g. scipy#7044. scipy/optimize/tests/test_linprog_ip contains the unit tests for the new linprog function. It contains all the tests for the old simplex method and several new tests, some of which would be relevant to the old simplex method. Please forgive the mess. I have no idea what I'm doing.
Closed via #8909 |
Also fixed minor bug checking for positive u, which should enable correct solution of scipy#5400 and scipy#7044
Also fixed minor bug checking for positive u, which should enable correct solution of scipy#5400 and scipy#7044
Also fixed minor bug checking for positive u, which should enable correct solution of scipy#5400 and scipy#7044
Also fixed minor bug checking for positive u, which should enable correct solution of scipy#5400 and scipy#7044
I have been working on an interior point algorithm for scipy.optimize.linprog, and I happened to find that my code found a solution with a lower objective than that returned by the simplex algorithm. I have double-checked, and my code's solution satisfies the constraints. This suggests that the simplex algorithm is returning a suboptimal solution. Since the simplex algorithm is supposed to find a global optimum, there must be a bug in the implementation.
Here is the relevant code. First, solve the problem with scipy.optimize.linprog. Confirm that the objective function value reported by linprog is c.dot(x) and that the equality constraints and non-negativity constraints are satisfied.
This prints:
So linprog is finding a feasible solution to the problem, and it is calculating the objective value for that solution correctly.
Then consider the alternate solution I found: confirm that it is feasible, and calculate the objective.
This prints:
So we have another feasible solution that yields an objective lower than that returned by scipy.optimize.linprog.
Note that another version of this problem (with a zero objective function and bounds), exposed another bug; scipy.optimize.linprog did not respect the constraints. See #6690.
The text was updated successfully, but these errors were encountered: