-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add setBasis to highspy #1733
Comments
I've reproduced this, and checked that h.setSolution(solution) is returning |
You're using For brevity, I dropped When the basis is created, only 10 of the variables and none of the constraints are off their bounds. If the solution were non-degenerate, there would be 205 variables/constraints off their bounds. So only 10 of the necessary 205 basic variables in the optimal solution can be identified. The rest are added so that the basis matrix is well-conditioned. It's unfortunate that this means that the simplex algorithm starts from the origin (again) but not surprising in the context of the degeneracy in your problem. When re-starting an LP, it's much better to use a basis rather than a solution. I've done this in the C++ code and the second solve takes zero iterations - because it starts from the optimal basis: Unfortunately, although |
Thanks for the answer - that explains the extra iterations. --- aside --- I'm very happy with the HiGHS solver, and feel free to not answer by question below! It's more me not understanding why my LP is degenerate than a question on the solver. It's been awhile, but I link degeneracy to redundant constraints. Somehow I quite don't understand how this LP is degenerate. The intention at least to make an LP where I have to pick 1 option from So even simpler:
I expect (perhaps totally wrong) that the solution (
which is not degenerate. But even in this simpler setting HiGHS solves the LP again, from which I conclude it's degeneracy again. |
Yes, if you have an LP with an optimal solution, and add constraints that are active at the optimal solution, then the solution for the modified LP will be degenerate, as the slack variables for those constraints will be basic and zero. In the example you've given, if the variables are just non-negative, then the optimal solution is the one you give, with both basic variables being positive, so it's not degenerate. However, in the problem generated by your Python code, you've put upper bounds of 1 on all the variables. The optimal solution has 1795 values at 0 and 195 values at 1, a total of 1990 / 2000, so 10 are off their bounds (as observed earlier). All 195 variables at their upper bounds are basic, so the solution is degenerate. I removed the upper bounds on the variables, and the solution was unchanged: the upper bounds were redundant, and the solution of the modified LP was not degenerate. Hence, when I used |
Thanks! I got it now - I didn’t think about the upper bounds on the
variables. Makes sense.
Op zo 28 apr 2024 om 14:32 schreef Julian Hall ***@***.***>
… Yes, if you have an LP with an optimal solution, and add constraints that
are active at the optimal solution, then the solution for the modified LP
will be degenerate, as the slack variables for those constraints will be
basic and zero.
In the example you've given, if the variables are just non-negative, then
the optimal solution is the one you give, with both basic variables being
positive, so it's not degenerate.
However, in the problem generated by your Python code, you've put upper
bounds of 1 on all the variables. The optimal solution has 1795 values at 0
and 195 values at 1, a total of 1990 / 2000, with 10 off their bounds. All
195 variables at their upper bounds are basic, so the solution is
degenerate.
I removed the upper bounds on the variables, and the solution was
unchanged: the upper bounds were redundant, and the solution of the
modified LP was not degenerate. Hence, when I used setSolution to resolve
the LP, the optimal basis was deduced, and no simplex iterations were
performed.
—
Reply to this email directly, view it on GitHub
<#1733 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFZEPSCYLK3ZMMEQI3QLT43Y7TT6LAVCNFSM6AAAAABGYRL7EOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGQ3TAMJVG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Fixed by #1740 |
Description
I expected if I set an optimal solution the LP would be solved without iterations, but it seems to ignore the supplied solution.
In the script I do the following:
x
x
as the solution(1) and (2) take the same amount of time. Am I using
setSolution
wrong?Environment
Windows,
Python
Running HiGHS 1.7.0 (git hash: 27ccfaa): Copyright (c) 2024 HiGHS under MIT licence terms
Script
Output:
The text was updated successfully, but these errors were encountered: