Improve Mosek interface to select optimal solution#667
Open
mgrabovsky wants to merge 3 commits intoPyPSA:masterfrom
Open
Improve Mosek interface to select optimal solution#667mgrabovsky wants to merge 3 commits intoPyPSA:masterfrom
mgrabovsky wants to merge 3 commits intoPyPSA:masterfrom
Conversation
Mosek can produce two distinct solutions with separate statuses: an interior-point solution (soltype.itr) and a basic solution (soltype.bas) obtained by basis identification (crossover). Previously, linopy's Mosek interface only read the IPM solution. If the IPM terminated with solsta.dual_infeas_cer but crossover then recovers an optimal basic solution, linopy would report infeasible_or_unbounded with Objective: nan and the actual optimal solution would be silently discarded, even though Mosek itself had it. After this change, linopy picks the solution (between bas, itr and itg) with the best score, with the order being solsta.[integer_]optimal > any other defined status > undefined. If both bas and itr are optimal, the itr solution is chosen to preserve backward compatibility with the previous behavior. A similar bug was present in cvxpy (see cvxpy/cvxpy#335), fixed by @aszekMosek in cvxpy/cvxpy#347. Patch co-authored with Claude Opus 4.7. Fixes PyPSA#665
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #665
Changes proposed in this Pull Request
Mosek can produce two distinct solutions with separate statuses: an interior-point solution (soltype.itr) and a basic solution (soltype.bas) obtained by basis identification (crossover).
Previously, linopy's Mosek interface only read the IPM solution. If the IPM terminated with solsta.dual_infeas_cer but crossover then recovers an optimal basic solution, linopy would report infeasible_or_unbounded with Objective: nan and the actual optimal solution would be silently discarded, even though Mosek itself had it.
After this change, linopy picks the solution (between bas, itr and itg) with the best score, with the order being solsta.[integer_]optimal > any other defined status > undefined. If both bas and itr are optimal, the itr solution is chosen to preserve backward compatibility with the previous behavior.
This patch was co-authored with Claude Opus 4.7.
Checklist
doc.doc/release_notes.rstof the upcoming release is included.