discopt.llm.reformulation#
Auto-reformulation engine.
Feature 3C: LLM identifies WHICH reformulations to apply; deterministic code executes them (correctness guaranteed).
Supported reformulations: - Big-M tightening - McCormick substitution for bilinear terms - Symmetry breaking constraints - Variable bound tightening from constraint structure
Attributes#
Classes#
A suggested reformulation with before/after description. |
Functions#
|
Analyze a model and suggest reformulations. |
|
Apply deterministic bound tightening to the model. |
Module Contents#
- discopt.llm.reformulation.logger#
- class discopt.llm.reformulation.ReformulationSuggestion#
A suggested reformulation with before/after description.
- category: str#
- description: str#
- impact: str#
- auto_applicable: bool = False#
- details: dict#
- discopt.llm.reformulation.analyze_reformulations(model: discopt.modeling.core.Model, llm: bool = False, llm_model: str | None = None) list[ReformulationSuggestion]#
Analyze a model and suggest reformulations.
Combines deterministic analysis (always runs) with optional LLM-powered analysis (when llm=True).
- Parameters:
model (Model) – The model to analyze.
llm (bool, default False) – Enable LLM-powered analysis.
llm_model (str, optional) – LLM model string.
- Returns:
Ordered by expected impact (highest first).
- Return type:
list of ReformulationSuggestion
- discopt.llm.reformulation.apply_bound_tightening(model: discopt.modeling.core.Model) int#
Apply deterministic bound tightening to the model.
Derives tighter variable bounds from constraint structure. This is safe — it only tightens bounds, never loosens them.
- Parameters:
model (Model) – The model to tighten (modified in place).
- Returns:
Number of bounds tightened.
- Return type:
int