Repository navigation
Fix silent LP solver failures: make LPWrapper status reliable and check it at all call sites - #9956
Merged
Merged
Conversation
…ck it at all call sites LPWrapper::solve() returns a status code that every C++ call site discarded, so a solver that declined to solve was indistinguishable from one returning an all-zero optimum: any solver failure (infeasible model, bad bounds as in #9940, resource limits) silently produced empty feature selections / charge assignments. Checking the raw return value would not even suffice: COIN-OR (CbcModel::status()) and HiGHS (HighsStatus) both report a completed run (0) for a proven-infeasible model. The portable signal is getStatus() - which returned UNDEFINED unconditionally on the COIN-OR path. Therefore: LPWrapper: - COIN-OR: capture the solution status while the CbcModel is alive (OPTIMAL / FEASIBLE via incumbent / NO_FEASIBLE_SOL / UNDEFINED) and store it, so getStatus() reports the real status - COIN-OR: clear the solution vector before storing it (repeated solve() used to append and return stale values), only store it when a solution exists, and bounds-check getColumnValue() like on the HiGHS path - HiGHS: getStatus() recognizes an integer feasible incumbent (via HighsInfo::primal_solution_status) when the run stopped early - solve() logs a warning whenever no feasible solution was produced - fix solve()/getStatus() docs (also in the pyOpenMS docstrings): the getStatus() doc listed wrong enum values Call sites: - MRMFeatureSelectorScore/QMIP::optimize and ILPDCWrapper:: computeSlice_/computeSliceOld_ now check getStatus() after solve() and throw Exception::FailedAPICall instead of reading back the all-zero non-solution - computeSliceOld_'s verbose status print compared the status enum against 0, which it can never be; compare against OPTIMAL Tests: - LPWrapper_test asserted the broken behavior (UNDEFINED after a successful COIN-OR solve); all backends now assert OPTIMAL - new test: an infeasible problem must not report OPTIMAL/FEASIBLE on any backend Fixes #9944 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DJYjGzaG1C6WEqN2RhR9hZ
Contributor
|
Warning Review limit reachedNext included review available in 30 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
timosachsenberg
commented
Aug 25, 2026
timosachsenberg
left a comment
Contributor
Author
There was a problem hiding this comment.
Looks good
This was referenced Aug 26, 2026
timosachsenberg
pushed a commit
that referenced
this pull request
Aug 28, 2026
The core #9944 fix (reliable LPWrapper::getStatus() + checks at all C++ call sites) landed on develop via #9956; this keeps only the pyOpenMS change: remove the LPWrapper binding entirely. LPWrapper is an internal LP/MILP backend wrapper (GLPK/COIN-OR/HiGHS) used only by C++ algorithms (MRMFeatureSelector, ILPDCWrapper). It has no Python consumers anywhere in pyOpenMS, and its solve()/getStatus() contract is easy to misuse (the footgun behind #9944). Python users should use the high-level algorithms instead. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01YJd4Z757KjAMqLuCG5zP3x
5 tasks done
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.
Description
Fixes #9944:
LPWrapper::solve()returns a status code that every C++ call site discarded, so a solver that declined to solve was indistinguishable from one that returned an all-zero optimum — solver failures (infeasible model, bad bounds as in #9940, resource limits) silently became empty feature selections / empty charge assignments.Checking the raw return value at the call sites would not even have been enough: verified empirically, COIN-OR (
CbcModel::status()) and HiGHS (HighsStatus) both report a completed run (0) for a proven-infeasible model. The reliable, portable signal isgetStatus()— which in turn returnedUNDEFINEDunconditionally on the COIN-OR path. This PR makesgetStatus()reliable and then uses it:LPWrapper(normalisation inside the wrapper, as suggested in the issue):CbcModelis alive (isProvenOptimal()→OPTIMAL, incumbent viabestSolution()→FEASIBLE,isProvenInfeasible()/isProvenDualInfeasible()→NO_FEASIBLE_SOL) and stored, sogetStatus()now reports it instead of alwaysUNDEFINED.solve()on the same object used to append and return stale values) and is only populated when a solution exists;getColumnValue()is bounds-checked like on the HiGHS path instead of indexing out of range after a failed solve.getStatus()recognises an integer-feasible incumbent (viaHighsInfo::primal_solution_status) when the run stopped for a non-terminal reason (e.g. time limit).solve()logs a warning whenever the backend reports no feasible solution, so even callers that ignore the status get an actionable message instead of silent zeros.solve()/getStatus()corrected (the oldgetStatus()doc listed wrong enum values;solve()'s "solver dependent (todo: fix)" now explains the contract), also in the pyOpenMS docstrings.Call sites (all four from the issue):
MRMFeatureSelector.cpp(MRMFeatureSelectorScore::optimize,MRMFeatureSelectorQMIP::optimize) andILPDCWrapper.cpp(computeSlice_,computeSliceOld_) now checkgetStatus()aftersolve()and throwException::FailedAPICallwith the status instead of reading back an all-zero non-solution. Neither call path runs inside an OpenMP region (the pragma inILPDCWrapper::compute()is commented out), so throwing is safe.computeSliceOld_'s verbose status print compared theSolverStatusenum against 0, a value it can never take (" Status: " << (!build.getStatus() ? ...)), and therefore always printed " Not finished"; it now checks againstOPTIMAL.Tests:
LPWrapper_testno longer enshrines the broken COIN-OR behaviour (it assertedgetStatus() == UNDEFINEDafter a successful solve); all backends now assertOPTIMAL.OPTIMAL/FEASIBLEon any backend.Validation
LP_SOLVER=AUTO);LPWrapper_test,MRMFeatureSelector_test,ILPDCWrapper_test,FeatureDeconvolution_test,MetaboliteFeatureDeconvolution_testandMRMBatchFeatureSelector_testpass via ctest.LPWrapper.cpp/test compile against all three backends (GLPK 5.0, COIN-OR Cbc 2.10, HiGHS v1.14.0 — the FetchContent-pinned version) and a runtime driver exercising feasible/infeasible/re-solve scenarios passes on all three; backend status semantics (incl. the [FIX] File::writable(): stop destroying files and reporting false negatives #9940GLP_EBOUNDscenario:glp_mip_statusstaysGLP_UNDEF, columns read 0) were verified with standalone programs against the real solver libraries.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01DJYjGzaG1C6WEqN2RhR9hZ
Generated by Claude Code