Skip to content

Fix #97: Add BinPacking to ILP reduction#597

Merged
GiggleLiu merged 4 commits intomainfrom
issue-97-binpacking-to-ilp
Mar 13, 2026
Merged

Fix #97: Add BinPacking to ILP reduction#597
GiggleLiu merged 4 commits intomainfrom
issue-97-binpacking-to-ilp

Conversation

@zazabap
Copy link
Copy Markdown
Collaborator

@zazabap zazabap commented Mar 12, 2026

Summary

Add reduction rule from BinPacking to ILP using the standard assignment-based formulation (Martello & Toth, 1990).

Fixes #97

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.59%. Comparing base (9b82206) to head (6e1ef0a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #597      +/-   ##
==========================================
+ Coverage   96.57%   96.59%   +0.01%     
==========================================
  Files         214      216       +2     
  Lines       29155    29278     +123     
==========================================
+ Hits        28157    28280     +123     
  Misses        998      998              

☔ 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.

zazabap and others added 2 commits March 12, 2026 11:59
Add the standard assignment-based formulation (Martello & Toth, 1990)
for reducing Bin Packing to Integer Linear Programming.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@zazabap
Copy link
Copy Markdown
Collaborator Author

zazabap commented Mar 12, 2026

Implementation Summary

Changes

  • src/rules/binpacking_ilp.rs — New reduction rule implementing BinPacking -> ILP via the standard assignment formulation (Martello & Toth, 1990). Variables: n^2 + n binary (x_{ij} assignment + y_j bin-open). Constraints: assignment (equality) + capacity/linking (inequality).
  • src/rules/mod.rs — Register binpacking_ilp module under #[cfg(feature = "ilp-solver")]
  • src/unit_tests/rules/binpacking_ilp.rs — 8 unit tests: closed-loop with BruteForce/ILP solver, structure validation, edge cases (single item, same weights, exact fill), solution extraction, solve_reduced
  • examples/reduction_binpacking_to_ilp.rs — Example with 5 items (weights [6,5,5,4,3], capacity 10), uses ILPSolver since ILP has 30 binary vars
  • tests/suites/examples.rs — Register example test
  • docs/paper/reductions.typ — Add reduction-rule entry with construction, correctness proof, and solution extraction

Deviations from Plan

  • Example uses ILPSolver instead of BruteForce since the ILP has 2^30 configurations (too many for brute force enumeration)

Open Questions

  • None

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reduction from BinPacking to ILP using the standard assignment-based formulation (Martello & Toth, 1990), with binary variables for item-bin assignments and bin usage indicators.

Changes:

  • New reduction rule (binpacking_ilp.rs) implementing the BinPacking → ILP formulation with n²+n variables and 2n constraints
  • Comprehensive unit tests and an example demonstrating the reduction on a 5-item instance
  • Documentation in reductions.typ describing the mathematical formulation and correctness argument

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/rules/binpacking_ilp.rs Core reduction implementation with variable layout, constraints, and solution extraction
src/rules/mod.rs Registers the new module under the ilp-solver feature
src/unit_tests/rules/binpacking_ilp.rs 7 unit tests covering structure, closed-loop solving, edge cases, and solution extraction
examples/reduction_binpacking_to_ilp.rs Example demonstrating the reduction with JSON export
tests/suites/examples.rs Registers the example as an integration test
docs/paper/reductions.typ Mathematical description of the reduction rule

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GiggleLiu GiggleLiu merged commit 176919b into main Mar 13, 2026
5 checks passed
@GiggleLiu GiggleLiu deleted the issue-97-binpacking-to-ilp branch April 12, 2026 00:53
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.

[Rule] BinPacking to ILP

3 participants