Skip to content

Replace greedy solver with OR-Tools MIP#188

Open
Redliana wants to merge 1 commit intolanl:mainfrom
Redliana:feat/ortools-mip-solver
Open

Replace greedy solver with OR-Tools MIP#188
Redliana wants to merge 1 commit intolanl:mainfrom
Redliana:feat/ortools-mip-solver

Conversation

@Redliana
Copy link
Copy Markdown

Summary

  • Add cmm_ortools_solver.py with a CBC-based Mixed-Integer Program (continuous allocation flow, binary supplier activation, unmet demand slack) handling demand, capacity, max-share, and linearized composition constraints
  • Refactor cmm_supply_chain_optimization_tool.py to extract _build_output() and add _try_ortools() wrapper — OR-Tools is tried first, greedy heuristic becomes the fallback when OR-Tools is not installed
  • Add 7 new unit tests for the OR-Tools solver path and relax existing test assertions to be solver-agnostic

Test plan

  • uv run pytest tests/tools/test_cmm_supply_chain_optimization_tool.py -v — 4/4 passing
  • uv run pytest tests/tools/test_cmm_ortools_solver.py -v — 7/7 passing
  • Greedy fallback verified with _HAS_ORTOOLS mocked to False
  • Verify uv sync --extra opt installs ortools on CI

🤖 Generated with Claude Code

Add cmm_ortools_solver.py with a CBC-based Mixed-Integer Program
(continuous allocation flow, binary supplier activation, unmet demand
slack) that handles demand, capacity, max-share, and linearized
composition constraints. The existing greedy heuristic becomes a
fallback when OR-Tools is not installed.

Extract _build_output() so both paths produce an identical output
schema, and add _try_ortools() wrapper with lazy import.

Co-Authored-By: Claude Opus 4.6 <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.

2 participants