Skip to content

Commit

Permalink
fix a bug in sim2real and storage units
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jul 28, 2023
1 parent 48bb590 commit 6178dff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Change Log
this might cause an issue if you install `grid2op[chronix2grid]` for the short thermal
- [BREAKING] force key-word arguments in `grid2op.make` except for the first one (env name), see
[rte-france#503](https://github.com/rte-france/Grid2Op/issues/503)
- [FIXED] a bug preventing to use storage units in "sim2real" environment (when the
grid for forecast is not the same as the grid for the environment)
- [ADDED] a CI to test package can be installed and loaded correctly on windows, macos and line_ex_to_sub_pos
for python 3.8, 3.9, 3.10 and 3.11
- [ADDED] possibility to change the "soft_overflow_threshold" in the parameters (like
Expand Down
2 changes: 1 addition & 1 deletion grid2op/Observation/observationSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _create_obs_env(self, env):
def _aux_create_backend(self, env, observation_bk_class, observation_bk_kwargs, path_grid_for):
if observation_bk_kwargs is None:
observation_bk_kwargs = env.backend._my_kwargs
observation_bk_class_used = observation_bk_class.init_grid(env.backend)
observation_bk_class_used = observation_bk_class.init_grid(type(env.backend))
self._backend_obs = observation_bk_class_used(**observation_bk_kwargs)
self._backend_obs.set_env_name(env.name)
self._backend_obs.load_grid(path_grid_for)
Expand Down
14 changes: 10 additions & 4 deletions grid2op/Space/GridObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ class GridObjects:
alertable_line_names = [] # name of each line to produce an alert on # TODO
alertable_line_ids = []

# test
_IS_INIT = False

def __init__(self):
"""nothing to do when an object of this class is created, the information is held by the class attributes"""
pass
Expand Down Expand Up @@ -663,7 +666,7 @@ def _clear_class_attribute(cls):
cls.attr_nan_list_set = set()

# class been init
# __is_init = False
cls._IS_INIT = False

# name of the objects
cls.env_name = "unknown"
Expand Down Expand Up @@ -1255,8 +1258,9 @@ def _init_class_attr(self, obj=None):
setattr(cls, attr_nm, attr)

def _compute_pos_big_topo(self):
# TODO move the object attribute as class attribute !
self._init_class_attr()
# move the object attribute as class attribute !
if not type(self)._IS_INIT:
self._init_class_attr()
cls = type(self)
cls._compute_pos_big_topo_cls()

Expand Down Expand Up @@ -2702,7 +2706,9 @@ def init_grid(cls, gridobj, force=False, extra_name=None, force_module=None):
else:
# i am the original class from grid2op
res_cls._INIT_GRID_CLS = cls


res_cls._IS_INIT = True

res_cls._compute_pos_big_topo_cls()
res_cls.process_shunt_satic_data()
if res_cls.glop_version != grid2op.__version__:
Expand Down

0 comments on commit 6178dff

Please sign in to comment.