Skip to content

Apply the leftover post-process to the other objectives - #888

Merged
fontanf merged 2 commits into
masterfrom
leftover-post-process
Nov 24, 2026
Merged

fontanf merged 2 commits into
masterfrom
leftover-post-process

Conversation

@fontanf

@fontanf fontanf commented Nov 24, 2026

Copy link
Copy Markdown
Owner

The leftover post-process re-optimizes the bins of the best solution as single-bin BinPackingWithLeftovers instances, and keeps a re-optimized bin if its leftovers are better. It was only applied for the BinPackingWithLeftovers objective. This PR applies it to BinPacking, VariableSizedBinPacking, VariableSizedBinPackingWithLeftovers and Knapsack too, in the not-anytime modes (rectangle, box, boxstacks, irregular).

  • The last bin post-process (tree search on the last bin) remains specific to BinPackingWithLeftovers: for the other objectives, no bin plays the role of the last bin.
  • For the other objectives, all the bins are re-optimized (reoptimize_all_bins_leftovers), whatever leftover_all_bins.
  • The post-processed solution has the same value as the best solution. It replaces it in the solution pool if its leftovers are better (AlgorithmFormatter::update_solution_leftovers, SolutionPool::replace_best, Solution::leftovers_better).
  • The post-process isn't stopped when the best solution is proven optimal, since the leftovers are not part of the proven objective.
  • Empty bins are not re-optimized.
  • The sub-calls of optimize (knapsack/bin packing sub-instances, Benders decomposition, large item first) disable the post-process, so that it only runs once, on the final solution.
  • The re-optimization functions are renamed to make clear that they re-optimize the leftovers: reoptimize_bin_leftovers, reoptimize_non_last_bins_leftovers, reoptimize_all_bins_leftovers.
  • The leftovers documentation page gets a "Post-process" section.

The PR also contains a small fix of the description of the VariableSizedBinPackingWithLeftovers objective in common.hpp, which was left over from #887.

Tests: new rectangle tests (ReoptimizeAllBinsLeftovers, UpdateSolutionLeftovers, LeftoverPostProcessBinPacking). The whole test suite passes. The only noticeable running time increase is on the irregular fixed_items_several_bins test (0.5 s → 4 s).

The leftover post-process re-optimizes the bins of the best solution as
single-bin BinPackingWithLeftovers instances, and keeps a re-optimized bin
if its leftovers are better. It was only applied for the
BinPackingWithLeftovers objective. It is now also applied for the
BinPacking, VariableSizedBinPacking, VariableSizedBinPackingWithLeftovers and
Knapsack objectives, in the not-anytime modes:

- The last bin post-process remains specific to BinPackingWithLeftovers.
- For the other objectives, all the bins are re-optimized
  ('reoptimize_all_bins_leftovers'), whatever 'leftover_all_bins'.
- The post-processed solution has the same value as the best solution: it
  replaces it in the solution pool if its leftovers are better
  ('AlgorithmFormatter::update_solution_leftovers',
  'SolutionPool::replace_best', 'Solution::leftovers_better').
- The post-process isn't stopped when the best solution is proven optimal,
  since the leftovers are not part of the proven objective.
- Empty bins are not re-optimized.

The re-optimization functions are renamed to make clear that they
re-optimize the leftovers: 'reoptimize_bin_leftovers',
'reoptimize_non_last_bins_leftovers' and 'reoptimize_all_bins_leftovers'.
@fontanf
fontanf merged commit 3ff7abc into master Nov 24, 2026
8 checks passed
@fontanf
fontanf deleted the leftover-post-process branch November 24, 2026 19:59
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.

1 participant