Skip to content

Wrapped the calls to Highs::calledOptimizeModel(), simplex, callSolveQp and MIP solver in try-catch blocks - #3168

Open
jajhall wants to merge 20 commits into
latestfrom
fix-2924+3150
Open

Wrapped the calls to Highs::calledOptimizeModel(), simplex, callSolveQp and MIP solver in try-catch blocks#3168
jajhall wants to merge 20 commits into
latestfrom
fix-2924+3150

Conversation

@jajhall

@jajhall jajhall commented Jul 26, 2026

Copy link
Copy Markdown
Member

Closes #2924 and #3150

Although the Highs::calledOptimizeModel() try-catch block is sufficient, the lower level try-catch blocks enable the particular solver causing the exception to be identified.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.11548% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.94%. Comparing base (187c624) to head (c8a8518).
⚠️ Report is 127 commits behind head on latest.

Files with missing lines Patch % Lines
highs/lp_data/HighsSolve.cpp 70.70% 46 Missing ⚠️
highs/qpsolver/QpAsmWrapper.cpp 88.88% 18 Missing ⚠️
highs/lp_data/Highs.cpp 73.77% 16 Missing ⚠️
highs/ipm/IpxWrapper.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #3168      +/-   ##
==========================================
+ Coverage   72.92%   72.94%   +0.01%     
==========================================
  Files         436      439       +3     
  Lines      106038   106165     +127     
  Branches    17071    17077       +6     
==========================================
+ Hits        77329    77437     +108     
- Misses      28433    28452      +19     
  Partials      276      276              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@filikat

filikat commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Looks good! However, if there is an exception thrown by the parallel scheduler (there shouldn't be, I hope I fixed all the bugs, but who knows), this will not be caught here, because it does not inherit from std::exception. To catch it, we would need a specific catch block with catch (const HighsTask::Interrupt&), or just catch(...), but then we cannot know what exception it is.

@jajhall

jajhall commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Looks good! However, if there is an exception thrown by the parallel scheduler (there shouldn't be, I hope I fixed all the bugs, but who knows), this will not be caught here, because it does not inherit from std::exception. To catch it, we would need a specific catch block with catch (const HighsTask::Interrupt&), or just catch(...), but then we cannot know what exception it is.

Thanks. I've done quite a bit of refactoring of the interface to the solves. Now

  • In the Highs class methods, there's minimal code relating to solvers - just the MIP solver for Highs::presolve(). The Highs class methods just identify which optimization problems are to be solved, using the incumbent model or its presolved instance
  • The QP solvers are fed a HighsQpSolverObject instance in the same way as the LP solvers, rather than drawing directly on data members of the Highs class. This will make it simple to solve presolved QP problems.
  • The active set QP solver has a wrapper
  • All solvers are chosen in HighsSolve, and called in a try... catch block, catching const std::exception& exception and const HighsTask::Interrupt&, with the LP and QP solvers using the same generic #define method.
  • All solver-specific code is in the corresponding wrapper - except for the MIP solver, where it's still in HighsSolve

Highs.cpp is now significantly smaller

All this means that there are a lot of diffs - mainly due to moving code. The most important changes are in HighsSolve.cpp

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.

2 participants