Skip to content

[Rule] ThreeDimensionalMatching → ILP (direct) #1011

@GiggleLiu

Description

@GiggleLiu

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}}, where n = num_triples
  • write each triple as t_j = (a_j, b_j, c_j) with a_j, b_j, c_j in {0, ..., k-1}

Construct an ILP<bool> instance as follows:

  1. Introduce one binary decision variable x_j in {0,1} for each triple index j in {0, ..., n-1}.
  2. For each a in {0, ..., k-1}, add the W-dimension exact-cover constraint
    sum_{j : a_j = a} x_j = 1.
  3. For each b in {0, ..., k-1}, add the X-dimension exact-cover constraint
    sum_{j : b_j = b} x_j = 1.
  4. For each c in {0, ..., k-1}, add the Y-dimension exact-cover constraint
    sum_{j : c_j = c} x_j = 1.
  5. Use an empty objective with ObjectiveSense::Minimize, since this is a pure feasibility problem.
  6. Extract a source witness by selecting exactly those triples t_j with x_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:

  1. Closed-loop witness check on the canonical example: solve the source ThreeDimensionalMatching instance 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.
  2. 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.
  3. Cross-check against the existing indirect path: on small brute-force-solvable instances, compare the direct ThreeDimensionalMatching → ILP result against the current indirect path ThreeDimensionalMatching → ThreePartition → ResourceConstrainedScheduling → ILP to 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

  1. value 0 appears in t_0 and t_3: x_0 + x_3 = 1
  2. value 1 appears in t_1 and t_4: x_1 + x_4 = 1
  3. value 2 appears only in t_2: x_2 = 1

X-dimension constraints

  1. value 0 appears in t_1 and t_3: x_1 + x_3 = 1
  2. value 1 appears only in t_0: x_0 = 1
  3. value 2 appears in t_2 and t_4: x_2 + x_4 = 1

Y-dimension constraints

  1. value 0 appears in t_2 and t_3: x_2 + x_3 = 1
  2. value 1 appears only in t_1: x_1 = 1
  3. value 2 appears in t_0 and t_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 = 5
  • num_constraints = 9
  • objective = []
  • sense = ObjectiveSense::Minimize

Solving the constraints forces:

  • x_0 = 1 from constraint 5
  • x_1 = 1 from constraint 8
  • x_2 = 1 from constraint 3
  • x_3 = 0 from constraints 1, 4, or 7
  • x_4 = 0 from 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 implementation
  • src/unit_tests/rules/threedimensionalmatching_ilp.rs — tests (closed-loop, structure, infeasible case)
  • src/rules/mod.rs — add mod threedimensionalmatching_ilp; (feature-gated ilp-solver)
  • src/example_db/rule_builders.rs — add canonical example builder
  • docs/paper/reductions.typ — add reduction-rule entry
  • Run cargo run --example export_graph and make 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

No one assigned

    Labels

    GoodAn issue passed all checks.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions