Skip to content

Fix #765: Upgrade 17 decision models to optimization (Group A + B)#771

Open
isPANN wants to merge 25 commits intomainfrom
upgrade-decision-to-optimization-765
Open

Fix #765: Upgrade 17 decision models to optimization (Group A + B)#771
isPANN wants to merge 25 commits intomainfrom
upgrade-decision-to-optimization-765

Conversation

@isPANN
Copy link
Collaborator

@isPANN isPANN commented Mar 25, 2026

Summary

  • Upgrade all 17 decision models from Value = Or + threshold to true optimization (Value = Max<T> / Min<T>)
  • Rewrite 7 ILP rules from feasibility to optimization (add objective function, remove threshold constraint)
  • Redesign config space for 3 models with variable-length outputs (padding encoding)
  • Update CLI create commands, canonical examples, paper entries, and all tests

Group A — single-threshold models (12)

Model Value ILP Config redesign
LongestCircuit Max<W::Sum>
OptimalLinearArrangement Min<usize>
RuralPostman Min<W::Sum>
MixedChinesePostman Min<W::Sum>
StackerCrane Min<i32>
MinimumCardinalityKey Min<i64>
SequencingToMinimizeMaximumCumulativeCost Min<i64>
MultipleCopyFileAllocation Min<i64>
ExpectedRetrievalCost Min<f64>
SumOfSquaresPartition Min<i64>
LongestCommonSubsequence Max<usize> ✓ padding
ShortestCommonSupersequence Min<usize> ✓ padding

Group B — constrained-optimization models (5)

Model Keep (constraint) Optimize Value ILP
MinimumCutIntoBoundedSets size_bound cut weight Min<W::Sum>
ShortestWeightConstrainedPath weight_bound path length Min<N::Sum>
CapacityAssignment delay_budget cost Min<u128>
MinMaxMulticenter k (centers) max distance Min<W::Sum> ✓ minimax
LengthBoundedDisjointPaths max_length # paths Max<usize>

Test plan

  • make check (fmt + clippy + test) passes
  • cargo test --lib --features example-db — 3206 passed
  • cargo test -p problemreductions-cli — 17 passed
  • cargo test --test main (integration + doc tests) — all passed
  • cargo clippy --all-targets — 0 warnings

Closes #765

🤖 Generated with Claude Code

isPANN and others added 19 commits March 25, 2026 12:26
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Min<usize>)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…::Sum>)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…<i64>)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…to optimization (Min<i64>)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… (Min<i64>) + ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…<f64>) + ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…<i64>) + ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Max<usize>) + ILP rewrite + config redesign

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n (Min<usize>) + config redesign

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove bound parameter from 8 model constructor calls in CLI create
- Remove associated bound parsing/validation code and CLI tests
- Fix SumOfSquaresPartition canonical example (optimal is 226, not 230)
- Fix StackerCrane example-db test assertion (no longer has bound field)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…(Min<W::Sum>)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ion (Min<N::Sum>) + ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…28>) + ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Sum>) + minimax ILP rewrite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… (Max<usize>) + config redesign

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@isPANN isPANN changed the title Fix #765: Upgrade 12 Group A decision models to optimization Fix #765: Upgrade 17 decision models to optimization (Group A + B) Mar 25, 2026
isPANN and others added 2 commits March 25, 2026 14:42
…ptimization-765

# Conflicts:
#	docs/paper/reductions.typ
… merge

- Convert 10 ILP rules from feasibility to optimization (remove bound, add objective)
- Fix SCS ILP: add contiguous padding constraint, fix alphabet_size field
- Mark OLA ILP<i32> tests as ignored (ILP solver too slow for integer variables)
- Fix sequencing ILP test to use ILPSolver instead of brute-force on ILP<i32>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zazabap zazabap self-requested a review March 25, 2026 08:29
isPANN and others added 3 commits March 25, 2026 16:42
…nces

- model_specs_are_optimal now tries brute-force first for instances with
  search space ≤ 2^20, avoiding HiGHS hangs on ILP<i32> reductions
- Hardcode OLA and Sequencing ILP canonical example solutions (avoid
  calling ILPSolver at example-db build time for ILP<i32> targets)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root cause: ILP<i32> variables default to domain [0, 2^31], causing HiGHS
to hang on even tiny instances. Two fixes:

1. ILP solver: derive tighter per-variable upper bounds from single-variable
   ≤ constraints before passing to HiGHS (covers x and p variables)
2. OLA ILP: add z_e ≤ n-1 bound (max position difference)
3. Sequencing ILP: add z ≤ Σ|costs| bound (max cumulative cost)

Restores ILPSolver calls in canonical rule examples (removes hardcoded
solutions) and reverts model_specs_are_optimal to ILP-first strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lver test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 99.30716% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.82%. Comparing base (88fb8f7) to head (b70a7fd).

Files with missing lines Patch % Lines
src/models/graph/rural_postman.rs 75.00% 4 Missing ⚠️
...c/models/graph/shortest_weight_constrained_path.rs 88.23% 2 Missing ⚠️
src/models/graph/mixed_chinese_postman.rs 94.11% 1 Missing ⚠️
src/models/misc/longest_common_subsequence.rs 96.87% 1 Missing ⚠️
...t_tests/rules/shortestweightconstrainedpath_ilp.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #771    +/-   ##
========================================
  Coverage   97.82%   97.82%            
========================================
  Files         588      588            
  Lines       66422    66198   -224     
========================================
- Hits        64976    64760   -216     
+ Misses       1446     1438     -8     

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

@isPANN
Copy link
Collaborator Author

isPANN commented Mar 25, 2026

Finding: ILP solver hangs due to unbounded variable domains

During this PR, we discovered that ILP<i32> reductions can cause HiGHS to hang indefinitely, even on tiny instances (e.g., 4 vertices / 23 variables).

Root cause

The ILP solver sets variable upper bounds from V::DIMS_PER_VAR:

v = v.max((V::DIMS_PER_VAR - 1) as f64);  // i32 → 2,147,483,647

For ILP<i32>, every variable gets domain [0, 2^31]. Even though constraints like x_{v,p} <= 1 or p_v <= n-1 logically bound variables to small ranges, HiGHS receives the full [0, 2^31] domain and its branch-and-bound becomes extremely slow.

This particularly affects auxiliary variables that lack explicit single-variable <= C constraints:

  • z variables in minimax formulations (OLA z_e, Sequencing z)
  • position/order variables only bounded via linking constraints (p_v = Σ p·x_{v,p})

Fix (3 parts)

  1. ILP solver (src/solvers/ilp/solver.rs): Before passing to HiGHS, scan constraints for single-variable x_i <= C patterns and use the tighter bound instead of DIMS_PER_VAR
  2. OLA ILP: Added z_e <= n-1 (max position difference)
  3. Sequencing ILP: Added z <= Σ|costs| (max cumulative cost)

Impact

Before fix: model_specs_are_optimal hangs (OLA canonical example triggers OLA→ILP reduction path, HiGHS never returns).
After fix: all example-db tests pass in ~2 seconds.

Recommendation for future ILP rules

Always add explicit var <= upper_bound constraints for non-binary variables. This ensures HiGHS gets tight bounds regardless of DIMS_PER_VAR. See #772 for remaining hardcoded examples that should be converted.

…verage

- Remove #[ignore] from OLA ILP tests (HiGHS is fast now with z bounds)
- Add rural_postman tests: wrong config length, is_weighted, solver aggregate
- Add SWCP test: weight bound exceeded
- Covers codecov gaps in rural_postman, shortest_weight_constrained_path,
  and optimallineararrangement_ilp

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Upgrade 17 decision models to optimization versions

1 participant