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>
| "nb_units_on_opt", | ||
| "nb_units_max", |
There was a problem hiding this comment.
To use the same naming conventions as in the models libraries
| "nb_units_on_opt", | |
| "nb_units_max", | |
| "num_units_on_opt", | |
| "num_units_max", |
| "min_up_duration", | ||
| "min_down_duration", | ||
| }, | ||
| "outputs": {"minimum_nb_units_on"}, |
There was a problem hiding this comment.
| "outputs": {"minimum_nb_units_on"}, | |
| "outputs": {"minimum_num_units_on"}, |
| id: str | ||
| model_decomposition: Optional[ModelDecompositionConfig] = None | ||
| out_of_bounds_processing: Optional[OutOfBoundsProcessingConfig] = None | ||
| heuristic: List[HeuristicConfig] = Field(default_factory=list) |
There was a problem hiding this comment.
As we may have many of them
| heuristic: List[HeuristicConfig] = Field(default_factory=list) | |
| heuristics: List[HeuristicConfig] = Field(default_factory=list) |
| v_cfg.id: v_cfg.location | ||
| for v_cfg in model_config.model_decomposition.variables | ||
| } |
There was a problem hiding this comment.
| v_cfg.id: v_cfg.location | |
| for v_cfg in model_config.model_decomposition.variables | |
| } | |
| variable_config.id: variable_config.location | |
| for variable_config in model_config.model_decomposition.variables | |
| } |
| Model on 168 time steps with one thermal generation and one demand on a single node. | ||
| - Demand is constant to 2000 MW except for the 13th hour for which it is 2050 MW | ||
| - Thermal generation is characterized with: | ||
| - P_min = 700 MW | ||
| - P_max = 1000 MW | ||
| - Min up time = 3 | ||
| - Min down time = 10 | ||
| - Generation cost = 50€ / MWh | ||
| - Startup cost = 50 | ||
| - Fixed cost = 1 /h | ||
| - Number of unit = 3 | ||
| - Unsupplied energy = 1000 €/MWh | ||
| - Spillage = 0 €/MWh |
There was a problem hiding this comment.
Expose the system description only once in a comment at the begining of the file
| "num_units_on", | ||
| [ | ||
| 0.0, | ||
| 1.0, | ||
| 1.0, | ||
| 1.04, | ||
| 1.07, | ||
| 1.11, | ||
| 1.14, | ||
| 1.11, | ||
| 1.08, | ||
| 1.04, | ||
| 1.0, | ||
| 1.0, | ||
| 0.0, | ||
| ], |
There was a problem hiding this comment.
I am a bit surprised of this behavior, I would have expected to retrieve the MILP solution of turning on more units (but an integer number of them)
Or maybe this behavior is linked to the addition of ramp constraints ? Is the goal to show the inefficiency of the accurate heuristics in this case ?
|
|
||
| def test_accurate_heuristic() -> None: | ||
| """ | ||
| Check that find_nb_units_accurate produces the same nb_units_on as Antares. |
There was a problem hiding this comment.
remove Antares reference, just say the goal of the test is to retrieve the expected results stored in the repo
| # This file is part of the Antares project. | ||
|
|
||
| # Expected per-timestep outputs for thermal_heuristic_three_clusters tests. | ||
| # Extracted from Antares reference outputs (commit 38c4535). |
There was a problem hiding this comment.
Remove reference to Antares, just say these are reference results
| return series[:NUMBER_HOURS, SCENARIO].tolist() | ||
|
|
||
|
|
||
| def test_accurate_heuristic() -> None: |
There was a problem hiding this comment.
Move this file to the unittests directory, then what is the added value of having the previous file testing the fast heuristic ?
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. |
Process ID
Process:
Description
Impact Analysis
Checklist
pytest)mypy)black,isort)pyproject.tomlversion bumped if applicableAGENTS.mdreviewed for impact and updated if needed