Api thermal heuristic - #238
Conversation
Cross-check each heuristic input/output declared in optim-config.yml against the model: the referenced id must exist and have the time-dependence the fast/accurate thermal heuristics expect (e.g. min_up_duration constant, generation_power per-timestep), catching mismatches at load time instead of a runtime crash mid-solve. nb_units_max and cluster_max_generation now accept either form, with the heuristics broadcasting a scalar internally. Also warn (instead of silently truncating) when min_up_duration/ min_down_duration resolve to a non-integer number of timesteps. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix solution retrieval, window size in fast heuristic bugs (b96b782)Follow-up commit addressing 4 issues surfaced by 1. Root cause: solution reads keyed by an ambiguous merged-variable name Fixed by adding 2. Heuristics/second solve ran before checking the first solve's status 3. Fast heuristic crashed on zero minimum durations 4. Minor: missing space in the solve-failure error message. Also updated the Verification: full suite green (605 passed, 1 xfailed), mypy clean on all touched files. |
The merged Variable rebuilt for split integer/binary variables was a detached xr.concat copy: setting .lower/.upper on it silently wrote to an orphaned copy instead of the solver, and its name/label_range were inherited from only one of the two groups. Now fails loudly and carries correct metadata. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Documents the new per-component integer relaxation strategy (exact/relaxed/heuristic) and the built-in fast/accurate thermal heuristics in optim-config.md, building.md, AGENTS.md, and the changelog. Also fixes a mypy error-code annotation in optimization.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| for mc in optim_config.models | ||
| for heuristic_config in (mc.heuristic or []) | ||
| } | ||
| heuristic_config_map = get_heuristic_config_map(optim_config) |
There was a problem hiding this comment.
This is weird to parse the optim config file into the runner. why not enriching the Optimconfig class with the heuristic config, then simply use the optim config object (or its heuristics attribute here) ?
There was a problem hiding this comment.
This will be treated in another PR.
|
It seems some problems are too large to use Xpress in CI... use highs instead |
Process ID
Process: GP-01
Description
Adds an
integer-strategyfield on components, letting a component choose how its model's integer/binary variables are built:exact(default, unchanged behavior) — kept as MILP.relaxed— relaxed to continuous.heuristic(+heuristic-id) — relaxed to continuous for a first solve, then refined by a built-in heuristic (fastoraccurate) that computes tighter bounds from that first solve, followed by an automatic second solve. Triggered transparently bySimulationSessionwhen at least one component usesinteger-strategy: heuristic.Each model declares what its chosen heuristic reads from and writes to via a new
models[].heuristicssection inoptim-config.yml(binding fixedheuristic-elementnames to the model's own parameter/variable ids and bound types).validate_optim_config()checksheuristic-id↔heuristicsconsistency, that every boundidexists on the model with the expected time-dependence, and thatheuristicis not combined withresolution.mode: benders-decomposition.This required a refactor of variable construction in
optimization.py: when a model's components are split across relaxed/exact strategy groups, variables are built per-group and then merged into a read-only_MergedGroupVariableview, while a new_linopy_vars_by_componentmap keeps a reference to each component's real registered linopyVariableso heuristic bound mutations (and solution retrieval, via the newget_component_variable/get_variable_solution) reach the solver correctly instead of silently landing on a detachedxr.concatcopy.Impact Analysis
Modules affected:
optim_config/(newHeuristicConfig,IntegerStrategyparsing/validation),study/(integer_strategyfield onComponentSchema,system.py),simulation/(optimization.pyvariable-building refactor, newheuristic_runner.pyandthermal_heuristic.py,SimulationSessiontwo-pass solve,simulation_table.py).Solver output values: Not expected to change for existing configs —
integer-strategydefaults toexact, which preserves current variable construction and the single-solve flow. Values only change for components that newly opt in torelaxedorheuristic, which is the intended effect of the feature.Checklist
pytest)mypy)black,isort)pyproject.tomlversion bumped if applicableAGENTS.mdreviewed for impact and updated if needed