Skip to content

Refactor optimize model - #3766

Open
filikat wants to merge 68 commits into
latestfrom
refactor-optimize-model
Open

filikat wants to merge 68 commits into
latestfrom
refactor-optimize-model

Conversation

@filikat

@filikat filikat commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

calledOptimizeModel has become a very long and complicated function, doing many different things. This PR splits the function into various phases so that the solve path can be kept more organised and adding more features (eventually LP folding) becomes easier.

While doing this, many small fixes for pathological edge cases have been found (including #3756).

On top of the refactoring, this PR:

  • applies all modifications to the model in one place (apart from reformulation of semi-variables, which still happens inside the MIP solver).
  • introduces a single exit point from calledOptimizeModel, so that it is not needed to remember to call returnFromOptimizeModel on each exit path.
  • adds a helper object HighsUndoStack that allows to make modifications to the options, making sure that they are undone before returning.
  • fixes some issues with catching exceptions.

Most of the diff in Highs.cpp consists of code moving around without changes. OptimizeModelRefactor.md is a summary generated by Claude meant to facilitate the review of the changes and to find where a given feature has moved. It also lists all the small fixes and behaviour changes. It can be removed before merging the PR.

Checklist

  • I have read the contributing guidelines
  • This PR targets the latest branch
  • Tests are passing
  • Documentation was updated where relevant
  • This PR is not primarily AI-generated (per the AI contributions policy in CONTRIBUTING.md)

Related issue

Closes #3756

@filikat filikat self-assigned this Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.13559% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.02%. Comparing base (f592c92) to head (66e36bc).
⚠️ Report is 15 commits behind head on latest.

Files with missing lines Patch % Lines
highs/lp_data/HighsSolve.cpp 78.37% 8 Missing ⚠️
highs/lp_data/HighsInterface.cpp 79.31% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #3766      +/-   ##
==========================================
+ Coverage   75.99%   76.02%   +0.02%     
==========================================
  Files         467      468       +1     
  Lines      116562   116766     +204     
  Branches    18165    18181      +16     
==========================================
+ Hits        88578    88767     +189     
- Misses      27744    27759      +15     
  Partials      240      240              

☔ 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 marked this pull request as ready for review November 21, 2026 20:48
@filikat
filikat requested review from galabovaa and jajhall November 21, 2026 20:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant