irregular: fix the local search on infeasible sub-instances - #628
Merged
Merged
Conversation
fontanf
force-pushed
the
irregular-fix-local-search-lp
branch
from
October 3, 2026 09:15
2ebade4 to
edc4b9b
Compare
With 'use_local_search', BinPackingWithLeftovers (through
'sequential_feasibility') solves Feasibility sub-instances with bins
narrower than needed. On such a sub-instance, 'pack_item' kept solving
the shrinkage LP until the time limit; the LP then interrupted by the
time limit had no solution, which made 'linear_programming_minimize_shrinkage'
throw ('wrong LP solution').
- 'linear_programming_minimize_shrinkage' and 'linear_programming_anchor'
stop and keep the current solution when the time limit is reached. If
the LP isn't solved to optimality otherwise, they throw with the model
status ('exit(1)' on an infeasible LP is removed).
- 'pack_item' gives up if the item fits in no bin of the sub-instance, or
if the selected bin has no free space left (the item used to be placed
inside another one, which made 'find_best_edge_separator' throw).
- In the non-anytime modes, 'pack_item' also gives up after
'OptimizeParameters::not_anytime_local_search_maximum_number_of_iterations_without_improvement'
(100) iterations without increasing the sum of the scale factors of the
items. In anytime mode, it keeps trying until the time limit.
- The bin bounds were scaled twice in 'linear_programming_minimize_shrinkage'
('aabb_scaled * scale_value'), so they didn't restrict the items, and
mixed scaled and original units in 'linear_programming_anchor'.
- Remove debugging leftovers: the files written in the working directory
('initial_solution.txt' at each LP, 'infeasible.mps', 'tmp.json') and the
outputs printed on the standard output.
fontanf
force-pushed
the
irregular-fix-local-search-lp
branch
from
October 3, 2026 09:30
edc4b9b to
626c013
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
use_local_search=True(off by default), BinPackingWithLeftovers threwlinear_programming_minimize_shrinkage(...): wrong LP solution, even for a single 5x5 square in a 10x10 bin, with or without the reduction:sequential_feasibility, the local search solves Feasibility sub-instances whose bin gets narrower at each iteration. Here, one asked for the 5-wide square in a 4.95-wide bin.pack_itemhad no iteration limit and no progress check. It solved about 23,000 shrinkage LPs until the time limit.Once that loop stopped, a second bug showed up on
data/irregular/tests/multiple_bins.json. When the selected bin had no free space left,assign_item_to_binplaced the new item at the bin centre, inside another item.find_best_edge_separatorthen threw (violated separation constraint). This also happens onmaster, but there the time-limit crash came first.Also found while investigating:
linear_programming_minimize_shrinkage, the bin bounds wereaabb_scaled * scale_value, scaled twice, so they didn't restrict the items.linear_programming_anchormixed scaled and original units in the same way.initial_solution.txtwas written in the working directory at each LP, andinfeasible.mpsplusexit(1)on an infeasible LP, which would kill a Python process.tmp.jsonwas written, and traces printed to the standard output, before the internal errors.Fix
linear_programming_minimize_shrinkageandlinear_programming_anchorcheckparameters.timer.needs_to_end().linear_programming_anchorwould have taken an empty solution as the new positions.pack_itemgives up, and the local search stops on that sub-instance:optimize_item_types_fitonly checks the original instance, and the bins of these sub-instances are narrower;OptimizeParameters::not_anytime_local_search_maximum_number_of_iterations_without_improvement(default 100) iterations without the sum of the items' scale factors increasing. In anytime mode, it keeps trying until the time limit.optimize()would never return.--not-anytime-local-search-maximum-number-of-iterations-without-improvement).Testing
test_local_search_bin_packing_with_leftovers: 1 and 4 squares, with and without the reduction. It also checks that no file is written in the working directory.test_local_search_full_bin:multiple_bins.json.test_parameterscovers the new parameter.data/irregular/testsno longer throws.needs_to_end()was then true.test_knapsack_hole, fixed by irregular: keep the holes of item types copied from another instance #627).Not fixed
On some BinPackingWithLeftovers instances,
sequential_feasibilitywith the local search still runs until the time limit, e.g. three 5x5 and two 4x4 squares in a 20x10 bin. It keeps solving narrower sub-instances after its first solution. This isn't new: onmasterthe same instance also reached the time limit, then threw.