Skip to content

Make the ILP solver backend configurable - #343

Merged
JoOkuma merged 2 commits into
royerlab:mainfrom
aliddell:feat/configurable-solver-backend
Oct 14, 2026
Merged

JoOkuma merged 2 commits into
royerlab:mainfrom
aliddell:feat/configurable-solver-backend

Conversation

@aliddell

@aliddell aliddell commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

ILPSolver chooses its solver backend with a fixed list. The method _solve() tries Preference.Gurobi, then Preference.Scip. A caller cannot change this order. This pull request adds a solver_preference parameter. The caller can now set the backend order. The default does not change.

Why

Some users have no Gurobi license. Gurobi then fails on a large model. The solver falls back to SCIP. SCIP is too slow for large graphs. ilpy >= 0.6.0 adds Preference.CuOpt. cuOpt has a native MILP solver under the Apache-2.0 license. It needs no license file. A configurable backend order lets a user put cuOpt between Gurobi and SCIP. A large model then completes without a Gurobi license.

What changed

  • ILPSolver.__init__ gains a keyword solver_preference. It accepts an ilpy Preference, a backend name as a string, or a sequence of either. A string matches a Preference by name, without case. Valid names are "gurobi", "scip", and "cuopt".
  • None keeps the current order: Gurobi, then SCIP. The change is backward compatible.
  • _solve() iterates the configured list instead of the fixed list.
  • The warning message no longer names SCIP. It names the backend that failed. It says it tries the next backend.
  • New tests cover the default order, a single value, a sequence, an unknown name, an empty sequence, an invalid type, the fallback loop across all backends, and a solve that selects SCIP.

Notes

  • This pull request does not change the ilpy version pin. It stays >= 0.5.1. The name "cuopt" needs ilpy >= 0.6.0. The code raises a clear error if the installed ilpy has no Preference.CuOpt.
  • The tests need no GPU and no Gurobi license. The solve test uses SCIP.

Test

pytest src/tracksdata/solvers passes. 35 tests pass with ilpy 0.6.0.

🤖 Generated with Claude Code

ILPSolver._solve() used a fixed list [Preference.Gurobi, Preference.Scip].
Add a solver_preference parameter that sets the backend order. It accepts a
Preference, a backend-name string, or a sequence of either. None keeps the
Gurobi-then-SCIP default, so the change is backward compatible.

This lets a caller add Preference.CuOpt (ilpy >= 0.6.0) between Gurobi and
SCIP, so a large model completes without a Gurobi license.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JoOkuma

JoOkuma commented Oct 7, 2026

Copy link
Copy Markdown
Member

@aliddell , LGTM, I'll merge once the CIs pass.

@aliddell

Copy link
Copy Markdown
Contributor Author

@JoOkuma are we happy with CI?

@JoOkuma
JoOkuma merged commit 1bdb8d3 into royerlab:main Oct 14, 2026
7 checks passed
@JoOkuma

JoOkuma commented Oct 14, 2026

Copy link
Copy Markdown
Member

@aliddell , yes, thank you for the ping. I forgot about this.

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.

2 participants