Repository navigation
irregular: add a global nonlinear programming algorithm for continuous rotations - #815
Merged
Merged
Conversation
…s rotations The tree search on relative positions proves nothing when the items can be rotated by any angle. Add an exact algorithm for the 'Feasibility' objective with a single convex bin, including with continuous rotations: each item has a position and a rotation given by its cosine and its sine, each pair of convex parts of different items a separating line, and the nonconvex quadratically constrained program is solved to global optimality by the spatial branch-and-bound of SCIP. The allowed rotation ranges, the item-item and item-bin spacings, and the symmetries of identical items and of centrally symmetric bins are handled. As in the tree search on relative positions, the pairs of item types, then the increasing subsets of the largest items, are solved until a subset is proven infeasible. The solution with all the items is checked before being returned. It only solves small instances; it is a baseline for exact algorithms with continuous rotations. In the 'Exact' mode, it is selected if an item type has continuous rotations. It requires SCIP: add the CMake option 'PACKINGSOLVER_USE_SCIP', off by default since SCIP is built from source, and on in the Build workflow. Update mathoptsolverscmake to the version with SCIP.
The prebuilt static Ipopt libraries don't link on macOS: the gfortran runtime they include needs libgcc. SCIP only uses Ipopt in its NLP heuristics, not in its spatial branch-and-bound, so build it without. Without these heuristics, finding a packing of the two L-shapes and the square took 25 s: enlarge their bin so that the test stays fast.
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.
The tree search on relative positions proves nothing when items can be rotated by any angle. This PR adds an exact algorithm for the
Feasibilityobjective with a single convex bin, including with continuous rotations, as a baseline for future exact algorithms with continuous rotations.Model
Solved to global optimality by SCIP's spatial branch-and-bound (
src/irregular/global_nonlinear_programming.{hpp,cpp}):(x, y)and its rotation(c, s)withc² + s² = 1, so every point of an item is linear in its variables;wand middlemisc cos m + s sin m ≥ cos(w/2); with several ranges, binaries select one;(a, b, d), with bilinear constraints anda² + b² ≥ 1(= 1with an item-item spacing);As in the tree search on relative positions, the pairs of item types are solved first by decreasing area, then the growing subsets of the largest items, until a subset is proven infeasible. The solution with all the items is checked with the overlap check of the library before being returned.
Results are exact up to SCIP's feasibility tolerance (1e-6 relative to the bin size), which the documentation states. As in the literature (Cherri et al. 2018, Jones 2014), it handles only a few items: two quickly, three or more rarely.
Unsupported (throws): several bins, non-convex bins, defects, fixed items, mirrored rotations, circular arcs.
Selection and build
use_global_nonlinear_programming/--use-global-nonlinear-programming/ Python; selected automatically inExactmode when an item type has continuous rotations.PACKINGSOLVER_USE_SCIP, off by default since SCIP is built from source, on in the Build workflow. Without it, the algorithm throws and is never selected automatically.Tests
Parametrized test on five new fixtures, the expectation derived from whether a solution file exists:
Plus tests for an unsupported objective and a non-convex bin. The new tests run only with
PACKINGSOLVER_USE_SCIP=ON; locally, all 211 tests of the irregular test binary pass with it. Weakening the separating-line constraint makes the feasible multi-item cases fail.The documentation has a new page describing the model, and the algorithm selection page is updated.