Repository navigation
Conversation
When solving from a file, the SCIP interface asked for dual values of every constraint, also for MILPs, which have none. SCIP printed errors such as "cannot get reduced costs, because node LP is not processed" and the returned duals were meaningless. They are now left empty for MILPs, as with the other solvers. The original constraints and the problem type are now read before solving, with getConss() and getNIntVars()/getNBinVars(). Reading the constraints afterwards needs getConss(transformed=False), which PySCIPOpt < 5 doesn't have, so every solve raised a TypeError there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
This branch has not been deployed
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.
Changes proposed in this Pull Request
We run SCIP through linopy's file interface in the solver benchmark. Two problems came up there.
On MILPs, linopy still asks SCIP for dual values. MILPs don't have any, so SCIP fills the log with
cannot get reduced costserrors, hundreds of them on some of our instances, and the duals linopy returns don't mean anything. We tracked this down in open-energy-transition/solver-benchmark#148.Separately, our older benchmark years use SCIP 8, which only works with PySCIPOpt 4.x. There, every solve fails because
getConss(False)doesn't exist yet.This PR reads the original constraints and checks whether the problem is a MILP before solving, so it works with any PySCIPOpt version, and it skips the duals for MILPs as the other solvers do. LP duals are unchanged.
Note
The following content was generated by AI.
When solving a problem file, the SCIP interface (
SCIP._run_file):cannot get reduced costs, because node LP is not processed(479 lines for the instance below), and the returned duals were meaningless;getConss(False), which PySCIPOpt < 5 doesn't accept, so every solve raisedTypeError: Model.getConss() takes no arguments (1 given).This reads the original constraints and the problem type before solving, with
getConss()andgetNIntVars()/getNBinVars(), which every PySCIPOpt version has. It leaves the duals empty for MILPs, with the same warning as the other solvers. LP duals are unchanged.Testing
test_scip_lp_returns_dualsandtest_scipmaster, the MILP test fails (a dual of 0 instead ofnone), and with PySCIPOpt 4.3.0 both fail with theTypeError.pytest test/test_solvers.py test/test_optimization.pCIP 8.0.3 + PySCIPOpt 4.3.0, SCIP 9.2.4 + PySCIPOpt5.7.1, and SCIP 10.0.0 + PySCIPOpt 6.0.0.ruffandmypy linopy/solvers.py` pass.TulipaEnergyModel_1_EU_investment_simple_24h(a MILodeling-benchmarks) with SCIP 9.2.4: 479 SCIP errorlines onmaster, none with this change, same objective.test/test_solvers.pyis skipped entirely when MOSEKits module-levelpytest.importorskip("mosek").Context: open-energy-transition/solver-benchmark#148
Checklist
AGENTS.md]doc.doc/release_notes.rstof the upcoming release is included.