From bbec4348ec6a4ed74e6c52a2d3e6e0029b6d2263 Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Tue, 19 Nov 2024 10:36:56 +0100 Subject: [PATCH] fixing an issue in the action Signed-off-by: DONNOT Benjamin --- CHANGELOG.rst | 1 + grid2op/Action/baseAction.py | 1 + grid2op/Backend/backend.py | 2 +- grid2op/Environment/baseEnv.py | 9 +++++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c04ddceb..2d42e76b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -103,6 +103,7 @@ Native multi agents support: when creating the data. - [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. - [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(...)` diff --git a/grid2op/Action/baseAction.py b/grid2op/Action/baseAction.py index 082b6e71..3bc564a8 100644 --- a/grid2op/Action/baseAction.py +++ b/grid2op/Action/baseAction.py @@ -1941,6 +1941,7 @@ def _digest_injection(self, dict_): elif len(el_ids) >= 2: raise AmbiguousAction(f"More than one element named {el_nm} for key {k} when trying to modify the injection") vals[el_ids[0]] = dt_float(el_val) + self._dict_inj[k] = vals else: self._dict_inj[k] = np.array(tmp_d[k]).astype(dt_float) # TODO check the size based on the input data ! diff --git a/grid2op/Backend/backend.py b/grid2op/Backend/backend.py index b71c8532..7302e1b5 100644 --- a/grid2op/Backend/backend.py +++ b/grid2op/Backend/backend.py @@ -1600,7 +1600,7 @@ def load_redispacthing_data(self, for el in mandatory_columns: if el not in df.columns: warnings.warn( - f"Impossible to load the redispatching data for this environment because" + f"Impossible to load the redispatching data for this environment because " f"one of the mandatory column is not present ({el}). Please check the file " f'"{name}" contains all the mandatory columns: {mandatory_columns}' ) diff --git a/grid2op/Environment/baseEnv.py b/grid2op/Environment/baseEnv.py index 69ff4bd6..8dd40cd3 100644 --- a/grid2op/Environment/baseEnv.py +++ b/grid2op/Environment/baseEnv.py @@ -301,7 +301,12 @@ def foo(manager): #: this are the keys of the dictionnary `options` #: that can be used when calling `env.reset(..., options={})` - KEYS_RESET_OPTIONS = {"time serie id", "init state", "init ts", "max step", "thermal limit"} + KEYS_RESET_OPTIONS = {"time serie id", + "init state", + "init ts", + "max step", + "thermal limit", + } def __init__( self, @@ -1882,7 +1887,7 @@ def _get_new_prod_setpoint(self, action): tmp = action._dict_inj["prod_p"] indx_ok = np.isfinite(tmp) new_p[indx_ok] = tmp[indx_ok] - + # modification of the environment always override the modification of the agents (if any) # TODO have a flag there if this is the case. if "prod_p" in self._env_modification._dict_inj: