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
BUG: scipy.optimize.linprog gives optimized solution which does not respect linear equation #20336
Comments
This seems to be a scaling issue. Scaling the left and right hand side like: i = np.abs(b_eq) > 0
a_eq[i, :] = a_eq[i, :] / b_eq[i, np.newaxis]
b_eq[i] = b_eq[i]/b_eq[i] Results in
I'm not sure what is going on with the norm residual provided by @HaoZeke are you able to check this out with a more recent version of HiGHS? |
as the correct residuum is a bit large, the problem seems most likely to be that linprog didn't solve the problem or solved the wrong problem. I now use google ortools, which didn't have the problem. |
Does it help by tweaking the various tolerance parameters to the function? It seems the default tolerances ( In general, I find it a hard exercise as an average user to pick a tolerance for many numerical routines of this kind. it would be ideal if these routines specify a default tolerance that is “as accurate as possible”, or provide clear guidance on how to pick the tolerances. At least, elaborate the exact definition of the tolerance in the doc (just “feasibility tolerance” is not clear enough). |
@fancidev: You are trying to solve my optimization problem. The problem here is a bug with linprog. It may be ok if linprog doesn't find a solution, it may be ok if it finds a bad (almost) solution with a residuum>0, but claiming to have found a solution with residuum 0 when in fact the solution given has a quite large residuum is simple a bug. |
Describe your issue.
in the code example below the solution fond by linprog does not respect the linear equation even though it claims otherwise.
If I run the code snippet below, I get the following output
norm residual x on input equation is 0.021185053416350418
norm residual x given by linprog is 0.0
Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: