-
Notifications
You must be signed in to change notification settings - Fork 3
[Rule] ThreeDimensionalMatching → ILP (direct) #1011
Description
Motivation
PR #1010 adds ThreeDimensionalMatching → ThreePartition, which creates an indirect ILP path:
3DM → ThreePartition → ResourceConstrainedScheduling → ILP
This chain has O(n^2) blowup: a 5-triple canonical example produces 114,075 binary ILP variables, causing HiGHS to hang and CI to time out (2+ hours).
A direct ThreeDimensionalMatching → ILP reduction produces 5 variables and 9 constraints for the same instance.
Source
ThreeDimensionalMatching
Target
ILP<bool>
Reference
Alexander Schrijver, Combinatorial Optimization: Polyhedra and Efficiency, Springer, 2003, Section 29.11. Book metadata: https://books.google.com/books?id=mqGeSQ6dJycC.
This is the standard textbook 0-1 ILP pattern for set packing / set covering / matching problems: use one binary variable per candidate set (here, per triple) and enforce incidence constraints so each required element is covered exactly once. The direct ThreeDimensionalMatching → ILP rule is exactly that formulation specialized to the three coordinate classes W, X, and Y.
Reduction Checklist
| # | Item | Value |
|---|---|---|
| 1 | Source | ThreeDimensionalMatching |
| 2 | Target | ILP<bool> |
| 3 | Reduction | Let k = universe_size, let the triples be t_0, ..., t_{n-1} where n = num_triples, and create one binary variable x_j for each j in {0, ..., n-1}. For each element value in each dimension W, X, and Y, add an equality constraint requiring exactly one selected triple to contain that value in that dimension. This is a feasibility reduction with an empty objective. |
| 4 | Solution extraction | Identity: x_j = 1 means triple t_j is selected |
| 5 | Correctness | The W constraints force each W element to appear exactly once, the X constraints force each X element to appear exactly once, and the Y constraints force each Y element to appear exactly once. Therefore feasible ILP solutions are exactly perfect 3-dimensional matchings, and vice versa. |
| 6 | Overhead | num_vars = "num_triples", num_constraints = "3 * universe_size" |
| 7 | Example | For universe_size = 3 and triples [(0,1,2),(1,0,1),(2,2,0),(0,0,0),(1,2,2)], the target ILP has variables x_0, ..., x_4 and the 9 equality constraints listed below. Its unique feasible solution is x = [1,1,1,0,0], corresponding to triples t_0, t_1, t_2. |
| 8 | Solving | Direct ILP via HiGHS |
| 9 | Reference | Schrijver (2003), Combinatorial Optimization: Polyhedra and Efficiency, Section 29.11 |
Implementation Pattern
Follow src/rules/exactcoverby3sets_ilp.rs — nearly identical structure (binary variable per subset, exact-cover constraints per element). The only difference is 3 groups of constraints (one per dimension W, X, Y) instead of 1.
Reduction Algorithm
Given a ThreeDimensionalMatching instance:
- let
k = universe_size - let the triple list be
M = {t_0, ..., t_{n-1}}, wheren = num_triples - write each triple as
t_j = (a_j, b_j, c_j)witha_j, b_j, c_j in {0, ..., k-1}
Construct an ILP<bool> instance as follows:
- Introduce one binary decision variable
x_j in {0,1}for each triple indexj in {0, ..., n-1}. - For each
a in {0, ..., k-1}, add theW-dimension exact-cover constraint
sum_{j : a_j = a} x_j = 1. - For each
b in {0, ..., k-1}, add theX-dimension exact-cover constraint
sum_{j : b_j = b} x_j = 1. - For each
c in {0, ..., k-1}, add theY-dimension exact-cover constraint
sum_{j : c_j = c} x_j = 1. - Use an empty objective with
ObjectiveSense::Minimize, since this is a pure feasibility problem. - Extract a source witness by selecting exactly those triples
t_jwithx_j = 1.
Size Overhead
| Target metric | Formula |
|---|---|
num_vars |
n = num_triples |
num_constraints |
3k = 3 * universe_size |
Validation Method
Validate the rule in three complementary ways:
- Closed-loop witness check on the canonical example: solve the source
ThreeDimensionalMatchinginstance by brute force, solve the reduced ILP instance with HiGHS, extract the selected triples, and confirm the extracted witness is a perfect 3-dimensional matching for the source. - Infeasible-instance check: use a small instance where some coordinate value cannot be covered exactly once and confirm that both the source problem and the reduced ILP instance are infeasible.
- Cross-check against the existing indirect path: on small brute-force-solvable instances, compare the direct
ThreeDimensionalMatching → ILPresult against the current indirect pathThreeDimensionalMatching → ThreePartition → ResourceConstrainedScheduling → ILPto ensure both produce the same yes/no answer while the direct path has strictly smaller exported overhead.
Example
1. Source instance
Let k = 3 and let the triples be
t_0 = (0,1,2)t_1 = (1,0,1)t_2 = (2,2,0)t_3 = (0,0,0)t_4 = (1,2,2)
So the source instance is:
ThreeDimensionalMatching::new(
3,
vec![(0,1,2), (1,0,1), (2,2,0), (0,0,0), (1,2,2)],
)
2. Construction
Create five binary ILP variables x_0, x_1, x_2, x_3, x_4, one for each triple.
The exact-cover constraints are:
W-dimension constraints
- value
0appears int_0andt_3:x_0 + x_3 = 1 - value
1appears int_1andt_4:x_1 + x_4 = 1 - value
2appears only int_2:x_2 = 1
X-dimension constraints
- value
0appears int_1andt_3:x_1 + x_3 = 1 - value
1appears only int_0:x_0 = 1 - value
2appears int_2andt_4:x_2 + x_4 = 1
Y-dimension constraints
- value
0appears int_2andt_3:x_2 + x_3 = 1 - value
1appears only int_1:x_1 = 1 - value
2appears int_0andt_4:x_0 + x_4 = 1
The ILP uses an empty objective because it is only checking feasibility.
3. Target instance
The resulting target problem is an ILP<bool> instance with:
num_vars = 5num_constraints = 9objective = []sense = ObjectiveSense::Minimize
Solving the constraints forces:
x_0 = 1from constraint 5x_1 = 1from constraint 8x_2 = 1from constraint 3x_3 = 0from constraints 1, 4, or 7x_4 = 0from constraints 2, 6, or 9
Hence the extracted witness is the triple set {t_0, t_1, t_2}, which covers each value in W, X, and Y exactly once, so it is a perfect 3-dimensional matching.
Files to Create/Modify
src/rules/threedimensionalmatching_ilp.rs— reduction implementationsrc/unit_tests/rules/threedimensionalmatching_ilp.rs— tests (closed-loop, structure, infeasible case)src/rules/mod.rs— addmod threedimensionalmatching_ilp;(feature-gatedilp-solver)src/example_db/rule_builders.rs— add canonical example builderdocs/paper/reductions.typ— addreduction-ruleentry- Run
cargo run --example export_graphandmake regenerate-fixtures
Priority
Blocks PR #1010 — without this, CI hangs for 2+ hours because model_specs_are_optimal tries the indirect 3-step path.
BibTeX
@book{schrijver2003combinatorial,
author = {Schrijver, Alexander},
title = {Combinatorial Optimization: Polyhedra and Efficiency},
publisher = {Springer},
year = {2003},
isbn = {9783540443896}
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status