Skip to content

Conversation

jajhall
Copy link
Member

@jajhall jajhall commented Jul 31, 2025

If the MIP solver is given a knapsack problem, it solves it by DP. Stats on the occurrence of knapsack problems are accumulated and logged. Tested by unit test knapsack.

@jajhall jajhall changed the base branch from master to latest July 31, 2025 21:18
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 94.75309% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.60%. Comparing base (ebd83e1) to head (d84a6b6).
⚠️ Report is 120 commits behind head on latest.

Files with missing lines Patch % Lines
highs/mip/HighsPrimalHeuristics.cpp 90.90% 10 Missing ⚠️
highs/mip/HighsMipSolver.cpp 86.11% 5 Missing ⚠️
highs/mip/MipTimer.h 0.00% 1 Missing ⚠️
highs/presolve/HPresolve.cpp 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #2482      +/-   ##
==========================================
+ Coverage   79.55%   79.60%   +0.04%     
==========================================
  Files         346      346              
  Lines       85401    85710     +309     
==========================================
+ Hits        67942    68229     +287     
- Misses      17459    17481      +22     

☔ View full report in Codecov by Sentry.
📢 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.

@jajhall
Copy link
Member Author

jajhall commented Jul 31, 2025

Also tested by unit test read-miplib-solution

@jajhall
Copy link
Member Author

jajhall commented Aug 1, 2025

Now incorporated integral scaling into mipIsKnapsack, but still not found any knapsack sub-problems in 100 easy MIPLIB 2017

@jajhall jajhall requested review from fwesselm and Opt-Mucca and removed request for fwesselm August 1, 2025 12:02
Copy link
Collaborator

@Opt-Mucca Opt-Mucca left a comment

Choose a reason for hiding this comment

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

The changes look good! I've left a comment or two, but they're for minor things.

I think I screwed up the language when talking about knapsacks and sub-milps. I was referring to some higher dimensional generalisations (an example MIPLIB benchmark instance: https://miplib.zib.de/instance_details_mik-250-20-75-4.html).
If we want some instances of (what I believe are normal knapsacks) then we can use: https://matilda.unimelb.edu.au/matilda/problems/opt/knapsack#knapsack (although off memory they are all rather trivial for current solvers)

" permitted reductions\n",
postsolve_stack.numReductions(), reductionLimit);
"\nPresolve: Performed %" PRId64 " of %" PRId64
" permitted true reductions\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it being worded differently to something like x reductions (y from scaling) or x reductions and y scaling reductions.
That would avoid using ambiguous like "true reductions".

lp.offset_ - sense * knapsack_optimal_objective_value;

// Compute the objective directly as a check
double check_objective = lp.offset_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this check be removed if we merge this?

num_item + 1, std::vector<double>(capacity + 1, -1));
// Set up the item use array, indicating that items are not used
std::vector<std::vector<bool>> use_item(
num_item + 1, std::vector<bool>(capacity + 1, false));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the downside here is that this vector can be huge?

@jajhall
Copy link
Member Author

jajhall commented Aug 26, 2025

No value in having a knapsack solver in HiGHS

@jajhall jajhall closed this Aug 26, 2025
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