Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demand Response #661

Draft
wants to merge 107 commits into
base: dev_1.11.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
7a86cc7
Add: Changelog TODO
DEUCE1957 Nov 8, 2024
f6faeca
Add: actual/target_flex to BaseObservation
DEUCE1957 Nov 8, 2024
bdd7f1c
Update: Obs Test to expect Flex
DEUCE1957 Nov 8, 2024
8eeecd9
Test: Update obs size for attched_envs
DEUCE1957 Nov 8, 2024
02238f2
Test: Update obs size for test_Observation
DEUCE1957 Nov 8, 2024
66df043
Test: Remove actual/target flex from older obs
DEUCE1957 Nov 8, 2024
02cd7b3
Test: Update grid2op_compat to dev version
DEUCE1957 Nov 8, 2024
f72adae
Test: Update Obs Size and Str Contents
DEUCE1957 Nov 8, 2024
6e3e140
Test: Revert ActStr
DEUCE1957 Nov 8, 2024
c6962a1
Test: Update ObsDim gym_compat
DEUCE1957 Nov 8, 2024
ec7ab54
Add: Flexibility to Actions
DEUCE1957 Nov 11, 2024
9b71105
Add: Gym Compat
DEUCE1957 Nov 11, 2024
7d67067
Refact: Remove unused '_exc'
DEUCE1957 Nov 11, 2024
ddb6ea6
Refact: Remove Commented Code
DEUCE1957 Nov 11, 2024
56f0481
Test: Update ActStr to include flexibility
DEUCE1957 Nov 11, 2024
945e686
Test: Update gym_compat for flex act
DEUCE1957 Nov 11, 2024
0932ad0
Test: Update chain_converter
DEUCE1957 Nov 11, 2024
59532be
Test: res_tup update for chain_converter
DEUCE1957 Nov 11, 2024
e96acff
Test: Update res_disp in chain_converter
DEUCE1957 Nov 11, 2024
edd0e05
Test: res_tup in chain_converter
DEUCE1957 Nov 11, 2024
c2a6af5
Test: res_disp in chain_converter
DEUCE1957 Nov 11, 2024
a8e0650
Test: Update act space dim in gym_compat
DEUCE1957 Nov 11, 2024
ea9df85
Test: Update string of storage act
DEUCE1957 Nov 11, 2024
1e068d3
Test: Update str in test_alert_obs_act and curtailment
DEUCE1957 Nov 11, 2024
ef8e17e
Test: Update str in Test_curtailment
DEUCE1957 Nov 11, 2024
0e36baa
Test: Clean _aux_test_gym_compat
DEUCE1957 Nov 12, 2024
16aa4fb
Add: Flexibility in GridObject
DEUCE1957 Nov 12, 2024
f497e52
Test: Remove Redundant If-Statements in aux_test_gym_compat
DEUCE1957 Nov 12, 2024
fff65e5
Test: Update GridActions for flexibility is False
DEUCE1957 Nov 12, 2024
81078aa
Debug: Add fallback if load_size is not defined
DEUCE1957 Nov 12, 2024
a447120
Test: Add flex attrs to test_space_to_dict
DEUCE1957 Nov 12, 2024
90c6e75
Test: Fix Typo in Redispatch for Notebook6
DEUCE1957 Nov 12, 2024
b4bd4f4
Add: Load flex data method to backend base
DEUCE1957 Nov 12, 2024
6fc865b
Add: Flexibility to BaseEnv
DEUCE1957 Nov 12, 2024
13ad035
Add: Full Flex to BaseEnv
DEUCE1957 Nov 12, 2024
f1e0d0b
Debug: Fix Typo in BaseEnv
DEUCE1957 Nov 12, 2024
9a7d343
Add: _get_nw_load_setpoint
DEUCE1957 Nov 12, 2024
f5a5de3
Add: _get_already_modified_load
DEUCE1957 Nov 12, 2024
38b7df9
Debug: Fix Typo in prepare_redisp_and_flex call
DEUCE1957 Nov 12, 2024
14cf893
Debug: Remove flex relianc on handle_updown_times
DEUCE1957 Nov 12, 2024
e82850e
Debug: Add init_flex to step
DEUCE1957 Nov 12, 2024
3424792
Add: already_modified_load to internal_env_params
DEUCE1957 Nov 12, 2024
075361f
Add: load_demand_t to internal_env_params
DEUCE1957 Nov 12, 2024
b328bbe
Refact: load_redispacthing_data to load_redispatching_data
DEUCE1957 Nov 12, 2024
6697e4f
Add: Flexibility to BackendConverter
DEUCE1957 Nov 12, 2024
e04287e
Add: Load flex data to Environment
DEUCE1957 Nov 12, 2024
8e281fb
Add: Default Flex Values to GridObjects
DEUCE1957 Nov 12, 2024
1185e69
Add: Properly Convert Default Flex in GridObjects
DEUCE1957 Nov 12, 2024
3ef853e
Test: Add flex defaults to TestObs
DEUCE1957 Nov 13, 2024
9a9640c
Debug: Fix Wrong Variable Name in _Compute_Dispatch_And_Flex_Vect
DEUCE1957 Nov 15, 2024
25d0574
Refact: Reduce Smell
DEUCE1957 Nov 15, 2024
08b3295
Debug: Don't save None flex attrs to dict
DEUCE1957 Nov 16, 2024
98e90c7
Test: Modify AgentsFast
DEUCE1957 Nov 16, 2024
b768fe0
Doc: Improve Comments
DEUCE1957 Nov 20, 2024
d7ea563
Merge branch 'dev_1.11.0' of github.com:Grid2op/grid2op into dev_flex
DEUCE1957 Nov 20, 2024
7928bcb
Test: Remove Temporary Fix in test_1_random
DEUCE1957 Nov 20, 2024
88710cd
Debug: Correctly scale target_vals_mi_optim
DEUCE1957 Nov 20, 2024
b85d9ba
Debug: Change flex compat to use default arrays
DEUCE1957 Nov 20, 2024
156e36c
Debug: Fix flex box in test_print_alert for gym_compat
DEUCE1957 Nov 20, 2024
ca231b2
Test: Converet hard-coded GymAlertCompat string to gym object
DEUCE1957 Nov 20, 2024
e740c9c
Test: Make test_print_alert completely unreliant on hard-coded strings
DEUCE1957 Nov 20, 2024
c26b9e7
Test: Remove Old Values from test_issue_418
DEUCE1957 Nov 20, 2024
10e51df
Debug: Add Test Discovery support for VS Code through try-except on r…
DEUCE1957 Nov 20, 2024
0e2f8a4
Test: Add Version Check in Tests
DEUCE1957 Nov 20, 2024
b33466f
Test: Downgrade Checks
DEUCE1957 Nov 20, 2024
4e4d5b0
Test: Modify siz_th of obs spaac
DEUCE1957 Nov 20, 2024
0d8a337
Test: Bring back object comparison in test_print_alert
DEUCE1957 Nov 20, 2024
d791321
Test: Update ObsStr
DEUCE1957 Nov 20, 2024
8584673
Test: Fix package import in test_alert_trust_score
DEUCE1957 Nov 20, 2024
1697b2f
Debug: Add Print to test_alert_gym_compat
DEUCE1957 Nov 20, 2024
e24948e
Test: Fix Package Import in defaultgym_compat
DEUCE1957 Nov 20, 2024
2689c7d
Test: res_tup in chain_converter
DEUCE1957 Nov 11, 2024
139e805
Test: res_disp in chain_converter
DEUCE1957 Nov 11, 2024
edcd160
Test: Modify AgentsFast
DEUCE1957 Nov 16, 2024
fe50705
Test: Remove Temporary Fix in test_1_random
DEUCE1957 Nov 20, 2024
ef63eee
Test: Fix packagee import in RewardAlertCostScore
DEUCE1957 Nov 20, 2024
44b5140
Test: Remove Compat Processing for Flex
DEUCE1957 Nov 20, 2024
45244f8
Test: Remove actual/target flex for backwards compatibility
DEUCE1957 Nov 20, 2024
740a067
Test: Remove defaults in backwards compatibility
DEUCE1957 Nov 20, 2024
7c71260
Add: Flexibility in gym_compat spaces
DEUCE1957 Nov 20, 2024
e4aeb4e
Debug: Missing comma
DEUCE1957 Nov 20, 2024
8aa00b4
Add: Flex in serializable actSpace
DEUCE1957 Nov 20, 2024
8a0568c
Debug: Flex in multidiscrete
DEUCE1957 Nov 20, 2024
b34b913
Debug: Add flex to dicrete actspace
DEUCE1957 Nov 20, 2024
d4440c7
Debug: Remove _sample_flexibility if flexibility not available
DEUCE1957 Nov 21, 2024
e6c105b
Test: Update target/actual flex bound in test_print_alert
DEUCE1957 Nov 21, 2024
4f24a7e
Test: Update l2rpn_idf_2023 for larger BoxObs dim
DEUCE1957 Nov 22, 2024
4e5a0fd
Test: Remove Print
DEUCE1957 Nov 22, 2024
2ea8178
Test: Add Compatability Check in test_alert_gym_compat
DEUCE1957 Nov 22, 2024
312e92d
Test: Add Flex Check to Tests, Fix Import on gymnasium_compat
DEUCE1957 Nov 22, 2024
9d35530
Test: Add Flex Check in Test_Issue_418
DEUCE1957 Nov 22, 2024
683ab82
Test: Fix path in test_score_idf_2023_assistant
DEUCE1957 Nov 22, 2024
00976e1
Refact: Reduce Smell
DEUCE1957 Nov 22, 2024
6a2c869
Test: Bring Back BaseObs Flex Compat
DEUCE1957 Nov 22, 2024
d4cd827
Refact: Add type_attr as default_value to lambda
DEUCE1957 Nov 22, 2024
fa32f0f
Refact: Remove Commented Out expected_obs_str from test_gym_compat
DEUCE1957 Nov 22, 2024
35f279f
Test: Simplify Flex Compatibility check
DEUCE1957 Nov 22, 2024
3e47d8b
Test: Clean superfluous text
DEUCE1957 Nov 22, 2024
6210c77
Add: Flexibility Tests + Test Environment
DEUCE1957 Nov 22, 2024
887c408
Test: Replace np.where with np.nonzero in test_flexibility
DEUCE1957 Nov 23, 2024
89bb2f5
Refact: Reduce Cognitivee Complex of _compute_vect
DEUCE1957 Nov 23, 2024
91383c6
Refact: Reduce Complexity of baseEnv.reset
DEUCE1957 Nov 23, 2024
b01764e
Revert "Refact: Reduce Cognitivee Complex of _compute_vect"
DEUCE1957 Nov 23, 2024
fd2ba19
Debug: Revert Changes to RESET_OPTIONS_TYPING
DEUCE1957 Nov 23, 2024
dae2f92
Doc: Resolvee Codacy and CircleCI in README
DEUCE1957 Nov 23, 2024
aa9181d
Merge: Updates from dev_1.11.0
DEUCE1957 Dec 2, 2024
8f075be
Debug: Add target/actual flex to observation
DEUCE1957 Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 58 additions & 114 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,153 +1,97 @@
Work "in progress"
[TODO]
--------------------
- [???] use some kind of "env.get_state()" when simulating instead of recoding everything "by hand"
- [???] use "backend.get_action_to_set()" in simulate
- [???] model better the voltage, include voltage constraints
- [???] use the prod_p_forecasted and co in the "next_chronics" of simulate
- [???] in deepcopy of env, make tests that the "pointers" are properly propagated in the attributes (for example
`envcpy._game_rules.legal_action` should not be copied when building `envcpy._helper_action_env`)
- [???] add multi agent
- [???] make observation read only / immutable for all its properties (and not just for `prod_p`)
- [???] better logging
- [???] shunts in observation too, for real (but what to do when backend is not shunt compliant to prevent the
stuff to break)
- [???] model agent acting at different time frame
- [???] model delay in observations
- [???] model delay in action
- [???] Code and test the "load from disk" method
- [???] add a "plot action" method
- [???] in MultiEnv, when some converter of the observations are used, have each child process to compute
it in parallel and transfer the resulting data.
- [???] "asynch" multienv
- [???] properly model interconnecting powerlines

Next few releases
---------------------------------

General grid2op improvments:

- ill formed docstring in the BaseAction module
- remove pandapower dependency (have a way to install grid2op without pandapower)
- better logging
- have functions that automatically computes topo_vect and switch_state in the backend
(usefull for solver that will never disconnect or reconnect anything)
- bug on maintenance starting at midnight (they are not correctly handled in the observation)
- numpy 2 compat (need pandapower for that)
- TODO bug on maintenance starting at midnight (they are not correctly handled in the observation)
=> cf script test_issue_616
- A number of max buses per substation different for each substation
- in the runner, save multiple times the same scenarios
- add a "_cst_" or something for the `const` members of all the classes
- improve type annotation for all public functions
- properly document and type hint all public members of all the public classes
- properly implement the copy and "deepcopy" API
- in deepcopy of env, make tests that the "pointers" are properly propagated in the attributes (for example
`envcpy._game_rules.legal_action` should not be copied when building `envcpy._helper_action_env`)
- Make the redispatching data independent from the time step (eg instead of "in MW / step" have it in "MW / h")
- TODO A number of max buses per sub
- TODO in the runner, save multiple times the same scenario
- TODO improve type annotation for all public functions
- TODO add a "_cst_" or something for the `const` members of all the classes
- TODO properly document and type hint all public members of all the public classes
- TODO properly implement the copy and "deepcopy" API
- TODO Make the redispatching data independent from the time step (eg instead of "in MW / step" have it in "MW / h")
and have grid2op convert it to MW / step
- make observation read only / immutable for all its properties (and not just for `prod_p`)
- in parallel distribute the loading of the time series if using a `MultifolderWithCache`
- Code and test the "load from disk" method
- add a "plot action" method
- does not read every data of the backend if not used

Better multi processing support:

- automatic read from local dir also on windows !
- doc for the "new" feature of automatic "experimental_read_from_local_dir"
- extend this feature (automatic "experimental_read_from_local_dir") to work also on windows based OS
- finish the test in automatic_classes
- "asynch" multienv
- in MultiEnv, when some converter of the observations are used, have each child process to compute
it in parallel and transfer the resulting data.
- TODO doc for the "new" feature of automatic "experimental_read_from_local_dir"
- TODO extend this feature to work also on windows based OS
- TODO finish the test in automatic_classes


Features related to gymnasium compatibility:

- put the `Grid2opEnvWrapper` (of the notebooks) directly in grid2op as GymEnv
- faster gym_compat (especially for DiscreteActSpace and BoxGymObsSpace)
- Notebook for tf_agents
- Notebook for acme
- Notebook using "keras rl" (see https://keras.io/examples/rl/ppo_cartpole/)
- example for MCTS https://github.com/bwfbowen/muax et https://github.com/google-deepmind/mctx
- done and truncated properly handled in gym_compat module (when game over
- TODO put the Grid2opEnvWrapper directly in grid2op as GymEnv
- TODO faster gym_compat (especially for DiscreteActSpace and BoxGymObsSpace)
- TODO Notebook for tf_agents
- TODO Notebook for acme
- TODO Notebook using "keras rl" (see https://keras.io/examples/rl/ppo_cartpole/)
- TODO example for MCTS https://github.com/bwfbowen/muax et https://github.com/google-deepmind/mctx
- TODO done and truncated properly handled in gym_compat module (when game over
before the end it's probably truncated and not done)
- when reset, have an attribute "reset_infos" with some infos about the
- TODO when reset, have an attribute "reset_infos" with some infos about the
way reset was called.
- on CI: test only gym, only gymnasium and keep current test for both gym and gymnasium
- refactor the gym_compat module to have a "legacy" stuff exactly like today
- TODO on CI: test only gym, only gymnasium and keep current test for both gym and gymnasium
- TODO refactor the gym_compat module to have a "legacy" stuff exactly like today
and the current class only supporting gymnasium (with possibly improved speed)
- in the gym env, make the action_space and observation_space attribute
- TODO in the gym env, make the action_space and observation_space attribute
filled automatically (see ray integration, it's boring to have to copy paste...)
- closer integration with `gymnasium` especially the "register env", being able to
- [???] closer integration with `gymnasium` especially the "register env", being able to
create an env from a string etc.

Grid2op extended features:

- ForecastEnv in MaskedEnv ! (and obs.simulate there too !)
- in multi-mix increase the reset options with the mix the user wants
- L2RPN scores as reward (sum loads after the game over and have it in the final reward)
- work on the reward class (see https://github.com/Grid2Op/grid2op/issues/584)
- jax everything that can be: create a simple env based on jax for topology manipulation, without
- TODO ForecastEnv in MaskedEnv ! (and obs.simulate there too !)
- TODO in multi-mix increase the reset options with the mix the user wants
- TODO L2RPN scores as reward (sum loads after the game over and have it in the final reward)
- TODO work on the reward class (see https://github.com/Grid2Op/grid2op/issues/584)
- TODO jax everything that can be: create a simple env based on jax for topology manipulation, without
redispatching or rules
- backend in jax, maybe ?

The "simulate" function :

- use some kind of "env.get_state()" when simulating instead of recoding everything "by hand"
- use "backend.get_action_to_set()" in simulate
- use the prod_p_forecasted and co in the "next_chronics" of simulate

Better handling of the voltages:

- model better the voltage, include voltage constraints
- shunts in observation too, for real (but what to do when backend is not shunt compliant to prevent the
stuff to break)
- model action on "shunts":
- either continuous (by default, if no config file)
- or discrete (more realistic, need a config file)
- model action related to transformer ratio:
- either continuous (by default, if no config file)
- or discrete (more realistic, need a config file)

Other modeling issues:

- model agent acting at different time frame
- model delay in observations
- model delay in action
- model action / observation on phase shifters
- model action / observation on HDVC powerlines
- TODO backend in jax, maybe ?

Native multi agents support:

- cf ad-hoc branch (dev-multiagents)
- properly model interconnecting powerlines

[1.11.0] - 202x-yy-zz
-----------------------
- [BREAKING] Change for `FromMultiEpisodeData` that disables the caching by default
when creating the data.
- [BREAKING] deprecation of `backend.check_kirchoff` in favor of `backend.check_kirchhoff`
(fix the typo in the name)
- [BREAKING] change the name of the generated classes: now by default the backend class
name is added. This behaviour can be turned off by passing `_add_cls_nm_bk=False`
when calling `grid2op.make(...)`. If you develop a new Backend, you can also
customize the added name by overloading the `get_class_added_name` class method.
- [FIXED] issue https://github.com/Grid2op/grid2op/issues/657
- [FIXED] missing an import on the `MaskedEnvironment` class
- [FIXED] a bug when trying to set the load_p, load_q, gen_p, gen_v by names.
- [FIXED] the `obs.get_forecast_env` : in some cases the resulting first
observation (obtained from `for_env.reset()`) did not have the correct
topology.
- [ADDED] possibility to set the "thermal limits" when calling `env.reset(..., options={"thermal limit": xxx})`
- [ADDED] possibility to retrieve some structural information about elements with
with `gridobj.get_line_info(...)`, `gridobj.get_load_info(...)`, `gridobj.get_gen_info(...)`
or , `gridobj.get_storage_info(...)`
- [ADDED] codacy badge on the readme
- [ADDED] a method to check the KCL (`obs.check_kirchhoff`) directly from the observation
(previously it was only possible to do it from the backend). This should
be used for testing purpose only
- [IMPROVED] possibility to set the injections values with names
to be consistent with other way to set the actions (*eg* set_bus)
- [IMPROVED] error messages when creating an action which changes the injections
- [IMPROVED] (linked to https://github.com/Grid2op/grid2op/issues/657) the way the
"chronics_hander" in the ObsEnv behaves (it now fully implements the public interface of
a "real" chronic_handler)
- [IMPROVED] error message in the `FromNPY` class when the backend is checked
- [IMRPOVED] the `FromMultiEpisodeData` class with the addition of the `caching`
kwargs to allow / disable caching (which was default behavior in previous version)
- [IMPROVED] the `FromMultiEpisodeData` class that now returns also the path of the data
- [IMPROVED] the classes inherited from `GreedyAgent` with the added possibility to
do the `obs.simulate` on a different time horizon (kwarg `simulated_time_step`)
- [IMPROVED] some type hints for some agent class
- [IMPROVED] the `backend.update_from_obs` function to work even when observation
does not have shunt information but there are not shunts on the grid.
- [IMPROVED] consistency of `MultiMixEnv` in case of automatic_classes (only one
class is generated for all mixes)

[1.10.4] - 2024-10-15
-------------------------
- [FIXED] new pypi link (no change in code)
- [FIXED] mybinder environment
- [FIXED] update all the links in the README.md (for the new grid2op location)
<<<<<<< HEAD
- [FIXED] update all the links in the docs and the grid2op source files
(to match new location: Grid2op/grid2op.git)
- [FIXED] the link in the `make_env` and `update_env` to point to
https://api.github.com/repos/Grid2Op/grid2op-datasets/
=======
>>>>>>> 0a04e162 (fixing the url to point to Grid2op/grid2op instead of rte-france/grid2op [skip ci])
- [IMPROVED] clarity of the "work in progress" in this CHANGELOG

[1.10.4] - 2024-10-14
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ If you want to contribute but are not sure were to start you can, for example:

- tackle an opened issue tagged as `good first issue`
- try to solve an opened issue marked with `helps wanted`
<<<<<<< HEAD
- there are also some contribution ideas written in the `Work "in progress"` section of the `CHANGELOG.rst`
=======
- there are also some contribution ideas written in the `[TODO]` and `Next few releases` of the `CHANGELOG.rst`
>>>>>>> 0a04e162 (fixing the url to point to Grid2op/grid2op instead of rte-france/grid2op [skip ci])
at the top level of the github repo.

In any case, if you are not sure about what is written here, feel free to ask in the grid2op [github discussion](https://github.com/orgs/Grid2op/discussions),
Expand Down
4 changes: 2 additions & 2 deletions getting_started/06_Redispatching_Curtailment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"source": [
"By default, some environments do not specify the cost of generators, their maximum and minimum production values, etc. In this case it is not possible to redispatch in grid2op.\n",
"\n",
"To know more about what is needed for using redispatching, it is advised to look at this help online : https://grid2op.readthedocs.io/en/latest/space.html#grid2op.Space.GridObjects.redispatching_unit_commitment_availble for the most recent documentation. When this notebook was created, the following were needed:\n",
"To know more about what is needed for using redispatching, it is advised to look at this help online : https://grid2op.readthedocs.io/en/latest/space.html#grid2op.Space.GridObjects.redispatching_unit_commitment_available for the most recent documentation. When this notebook was created, the following were needed:\n",
"\n",
"- \"gen_type\": the type of generator\n",
"- \"gen_pmin\": the minimum value a generator can produce\n",
Expand Down Expand Up @@ -147,7 +147,7 @@
"env_name = \"l2rpn_case14_sandbox\"\n",
"env = grid2op.make(env_name, test=True, backend=bk_cls())\n",
"\n",
"print(\"Is this environment suitable for redispatching: {}\".format(env.redispatching_unit_commitment_availble))"
"print(f\"Is this environment suitable for redispatching: {env.redispatching_unit_commitment_available}\")"
]
},
{
Expand Down
8 changes: 8 additions & 0 deletions grid2op/Action/_backendAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,14 @@ def set_redispatch(self, new_redispatching):
This is called by the environment, do not alter.
"""
self.prod_p.change_val(new_redispatching)

def set_flexibility(self, new_flexibility):
"""
.. warning:: /!\\\\ Internal, do not use unless you know what you are doing /!\\\\

This is called by the environment, do not alter.
"""
self.load_p.change_val(new_flexibility)

def _aux_iadd_inj(self, dict_injection):
"""
Expand Down
Loading