Repository navigation
fix: compensate the load injections of an action in the dispatch (#777) - #790
Conversation
…d2op#777) The change of load_p made by an action through its injection key is now declared to the dispatch as a new load source of imbalance. The generators compensate it within pmax and ramps, and the episode ends with ImpossibleRedispatching if they cannot follow. Adds a regression test and a changelog entry. Fixes Grid2op#777 Signed-off-by: Engr. Muhammad Fahad <muhammadfahadx2.0@gmail.com>
Not up to standards ⛔
|
|
Hello, Thanks for helping me fix this issue 😊 I'll review and check why a bit complains. Best Benjamin |
BDonnot
left a comment
There was a problem hiding this comment.
If feasible I think supporting the forecasts (ob's.simulate and ob's.get_forecast_env()) would je really nice.
Also I would like to see runner and env.copy tested on the python tests.
Let me know if something is blocking.
Thanks
| """ | ||
| Loads that have a new active consumption in the time series this step. | ||
|
|
||
| NB this is overidden in _ObsEnv where the consumption of all the loads is read from the |
There was a problem hiding this comment.
So this feature of changing the load does not work in obs.simulate(...) ?
| from grid2op.Exceptions import ImpossibleRedispatching | ||
|
|
||
|
|
||
| class TestIssue777LoadInjectionDispatch(unittest.TestCase): |
There was a problem hiding this comment.
Overall for this whole file, the obs.simulate is not tested.
It would also be good to include small test for:
- copied environment: for example make a load change before,m the copy, copy, then a) a normal action behaves normally b) another reduce the load action behaves normally. Another example would be to make sure that after a copy a load modification is properly implemented in the new env. Properly implemented here means "lead to the same results as in the environment not copied". Another test is also to make sure the initial env and the copy are not sharing any load modification data
- runner (here it's pretty simple: make a runner, an agent that does some load modification at each step and check the results are correct with the same agent on the same env)
- obs.get_forecast_env() (check the env behaves normally, you might need l2rpn_idf_2023 for this test otherwise the forecast env is pretty limited (only one step) )
Beside that it looks well covered.
Thanks
There was a problem hiding this comment.
Thanks, I added tests for all the cases you listed:
- obs.simulate: increase, decrease, too large change (ImpossibleRedispatching), the real env is not modified by a simulate, and a real injection followed by a simulated do nothing step.
- env.copy(): load change before the copy, then a normal action and a reduce load action give the same results as in the original env, a new load change gives the same result, a too large change ends the copy, and the injection data is not shared (modified in one, unchanged in the other).
- Runner: an agent that changes a load at each step; the dispatch follows the load change at each step, and the results (rewards, dispatch) are the same as a loop on the env.
- obs.get_forecast_env() on l2rpn_idf_2023: same checks, plus the dispatch coming back after the injection stops.
Please tell me if you want other cases.
…injections (Grid2op#777) Load injections also work in obs.simulate, in copied environments, with the Runner and in the forecast environment. Clarify the comments about simulate and add the tests asked in the review. Signed-off-by: Engr. Muhammad Fahad <muhammadfahadx2.0@gmail.com>
Fixes #777
What was wrong
An action that sets
load_pthrough its"injection"key changed the grid, but the change was never declared to the dispatch. The slack generator silently took it, without any pmax or ramp check, and without an error.What this PR does
"load"source todispatch_contributions(new fieldload_injection_mwinRedispatchState).LoadInjectionModulecomputes it from the difference between the loads set by the action and the loads of the time series. Like storage and detachment, the solver gets the change since the previous step, so the generators come back to normal when the injection stops.load_injection_excess).nanentries (not modified) are ignored._ObsEnvtreats all loads as set by the forecasts.FeasibilityGuardalso counts this source.ImpossibleRedispatching.Behavior notes (questions for the maintainers)
prod_pinjections are out of scope.[1.12.7]section because the top section is already dated. Please tell me if it should go elsewhere.Tests
test_issue_777.py(14 tests): the reproduction of the issue, increase and decrease, ramp and pmax limits, too large increase ends the episode, dispatch returns to zero, persistent injection, detached load.test_redispatch_solver.pyis updated for the new source.