Skip to content

Knapsack presolve - #3807

Open
Opt-Mucca wants to merge 36 commits into
latestfrom
knapsack-presolve
Open

Opt-Mucca wants to merge 36 commits into
latestfrom
knapsack-presolve

Conversation

@Opt-Mucca

@Opt-Mucca Opt-Mucca commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR introduces a knapsack specific presolve file and many new knapsack specific presolve techniques. I've taken plenty of them from SCIP in cons_knapsack.c and have come up with some others myself. Each technique has a large comment with a knapsack that gets strengthened via the technique. Over my test set the change is 1% performance improving over all and 3% over affected (I expect this to be an under-estimator as I've removed a lot of pure binary problems from the test set).

The two general things I'm still unsure of:

  • Is there a better way to modify the rows?
  • How frequently should this code be called and where should it be placed? I put it before probing because there's a chance that it might create some clique rows (helps with clique extraction), and I found that calling it once was better than calling it every presolve round, however calling it every round solved 5 more instances and had some large wins (just slower on average). There's got to be some middle ground that captures the best of both worlds.

@fwesselm I'm opening the PR to see if you find any clear issues and save me from any useless performance runs or if you've got any good ideas for the second point. Currently I only see this PR changing via a couple of lines, i.e., where exactly the technique in Hpresolve.cpp is called and how many times it's called.

Additional note: The changes in HighsLpUtils were made because the number of rows are printed as --5 if they increased by 5. I spent a while trying to disaggregate some knapsacks and eventually gave up (great for some instances but catastrophic for others and I couldn't find a balance).

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)

@Opt-Mucca
Opt-Mucca requested a review from fwesselm November 26, 2026 10:34
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.11%. Comparing base (3a864cc) to head (21bedd1).
⚠️ Report is 193 commits behind head on latest.

Files with missing lines Patch % Lines
highs/presolve/HPresolveKnapsack.cpp 87.81% 63 Missing ⚠️
highs/lp_data/HighsLpUtils.cpp 81.81% 2 Missing ⚠️
highs/lp_data/HighsModelUtils.cpp 0.00% 1 Missing ⚠️
highs/presolve/PresolveTimer.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #3807      +/-   ##
==========================================
+ Coverage   75.98%   76.11%   +0.12%     
==========================================
  Files         467      469       +2     
  Lines      116543   117524     +981     
  Branches    18163    18333     +170     
==========================================
+ Hits        88555    89452     +897     
- Misses      27748    27832      +84     
  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.

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

Labels

Enhancement New feature or request MIP Presolve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants