Skip to content

Fix silent LP solver failures: make LPWrapper status reliable and check it at all call sites - #9956

Merged
timosachsenberg merged 1 commit into
developfrom
claude/openms-issue-9944-fvzfg6
Aug 25, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
claude/openms-issue-9944-fvzfg6

Conversation

@timosachsenberg

Copy link
Copy Markdown
Contributor

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 is getStatus() — which in turn returned UNDEFINED unconditionally on the COIN-OR path. This PR makes getStatus() reliable and then uses it:

LPWrapper (normalisation inside the wrapper, as suggested in the issue):

  • COIN-OR: the solution status is captured while the CbcModel is alive (isProvenOptimal() → OPTIMAL, incumbent via bestSolution() → FEASIBLE, isProvenInfeasible()/isProvenDualInfeasible() → NO_FEASIBLE_SOL) and stored, so getStatus() now reports it instead of always UNDEFINED.
  • COIN-OR: the solution vector is cleared before storing (repeated 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.
  • HiGHS: getStatus() recognises an integer-feasible incumbent (via HighsInfo::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.
  • Documentation of solve()/getStatus() corrected (the old getStatus() 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) and ILPDCWrapper.cpp (computeSlice_, computeSliceOld_) now check getStatus() after solve() and throw Exception::FailedAPICall with the status instead of reading back an all-zero non-solution. Neither call path runs inside an OpenMP region (the pragma in ILPDCWrapper::compute() is commented out), so throwing is safe.
  • computeSliceOld_'s verbose status print compared the SolverStatus enum against 0, a value it can never take (" Status: " << (!build.getStatus() ? ...)), and therefore always printed " Not finished"; it now checks against OPTIMAL.

Tests:

  • LPWrapper_test no longer enshrines the broken COIN-OR behaviour (it asserted getStatus() == UNDEFINED after a successful solve); all backends now assert OPTIMAL.
  • New test: an infeasible problem must not report OPTIMAL/FEASIBLE on any backend.

Validation

  • Full local Linux build (Release, COIN-OR backend selected via LP_SOLVER=AUTO); LPWrapper_test, MRMFeatureSelector_test, ILPDCWrapper_test, FeatureDeconvolution_test, MetaboliteFeatureDeconvolution_test and MRMBatchFeatureSelector_test pass via ctest.
  • The changed 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 #9940 GLP_EBOUND scenario: glp_mip_status stays GLP_UNDEF, columns read 0) were verified with standalone programs against the real solver libraries.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DJYjGzaG1C6WEqN2RhR9hZ


Generated by Claude Code

…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
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 30 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a13b54a-0739-4285-932d-77ff8cda5f31

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd05a9 and f408bbc.

📒 Files selected for processing (7)
  • CHANGELOG
  • src/openms/include/OpenMS/DATASTRUCTURES/LPWrapper.h
  • src/openms/source/ANALYSIS/DECHARGING/ILPDCWrapper.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureSelector.cpp
  • src/openms/source/DATASTRUCTURES/LPWrapper.cpp
  • src/pyOpenMS/bindings/bind_datastructures.cpp
  • src/tests/class_tests/openms/source/LPWrapper_test.cpp

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@timosachsenberg
timosachsenberg merged commit 3184a1a into develop Aug 25, 2026
35 checks passed
@timosachsenberg
timosachsenberg deleted the claude/openms-issue-9944-fvzfg6 branch August 25, 2026 05:25
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
timosachsenberg added a commit that referenced this pull request Aug 28, 2026
[pyOpenMS] Remove the internal-only LPWrapper binding (follow-up to #9956 / #9944)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LPWrapper::solve() return status is discarded at every C++ call site, turning solver failures into silent all-zero results

2 participants