Skip to content

Commit

Permalink
Merge pull request #520 from BDonnot/bd_dev
Browse files Browse the repository at this point in the history
fixing issue rte-france#518
  • Loading branch information
BDonnot authored Sep 14, 2023
2 parents 5c5b6b3 + a91b44e commit e2eacfb
Show file tree
Hide file tree
Showing 35 changed files with 3,752 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ test_malte.py
example_gym_act.py
test_to_fix.txt
doc_raise_alert.py
_profiling/profile.html
_profiling/profile.json
actspace_converter.py
grid2op/data_test/input_data_local/
test_sim2real_battery.py

# profiling files
**.prof
2 changes: 1 addition & 1 deletion _profiling/profiler_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from utils_benchmark import run_env, str2bool, ProfileAgent

try:
from lightsim2grid.LightSimBackend import LightSimBackend
from lightsim2grid import LightSimBackend
light_sim_avail = True
except ImportError:
light_sim_avail = False
Expand Down
4 changes: 2 additions & 2 deletions _profiling/utils_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def __init__(self,
self.action_space.all_actions = all_actions

# add the action "reset everything to bus 1"
self.action_space.all_actions.append(action_space({"set_bus": np.ones(action_space.dim_topo, dtype=np.int),
self.action_space.all_actions.append(action_space({"set_bus": np.ones(action_space.dim_topo, dtype=int),
"set_line_status": np.ones(action_space.n_line,
dtype=np.int)}))
dtype=int)}))


def print_res(env_klu, env_pp,
Expand Down
2 changes: 1 addition & 1 deletion grid2op/Chronics/fromOneEpisodeData.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class FromOneEpisodeData(GridValue):
parameters (see example below)
.. seealso::
:class:`grid2op.Chronics.FromMultiEpisodeData`if you want to use multiple episode data
:class:`grid2op.Chronics.FromMultiEpisodeData` if you want to use multiple episode data
Examples
---------
Expand Down
4 changes: 2 additions & 2 deletions grid2op/Environment/_obsEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def _init_backend(

from grid2op.Observation import ObservationSpace
from grid2op.Reward import FlatReward
ob_sp_cls = ObservationSpace.init_grid(backend)
self._observation_space = ob_sp_cls(backend,
ob_sp_cls = ObservationSpace.init_grid(type(backend))
self._observation_space = ob_sp_cls(type(backend),
env=self,
with_forecast=False,
rewardClass=FlatReward,
Expand Down
4 changes: 2 additions & 2 deletions grid2op/Observation/observationSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(
self._ObsEnv_class._INIT_GRID_CLS = _ObsEnv # otherwise it's lost
setattr(sys.modules[_ObsEnv.__module__], self._ObsEnv_class.__name__, self._ObsEnv_class)
if _with_obs_env:
self._create_obs_env(env)
self._create_obs_env(env, observationClass)
self.reward_helper.initialize(self.obs_env)
for k, v in self.obs_env.other_rewards.items():
v.reset(self.obs_env)
Expand Down Expand Up @@ -174,7 +174,7 @@ def set_real_env_kwargs(self, env):
if "observation_bk_kwargs" in self._real_env_kwargs:
del self._real_env_kwargs["observation_bk_kwargs"]

def _create_obs_env(self, env):
def _create_obs_env(self, env, observationClass):
other_rewards = {k: v.rewardClass for k, v in env.other_rewards.items()}
self.obs_env = self._ObsEnv_class(
init_env_path=None, # don't leak the path of the real grid to the observation space
Expand Down
2 changes: 1 addition & 1 deletion grid2op/Space/GridObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ def init_grid(cls, gridobj, force=False, extra_name=None, force_module=None):
# with shunt and without shunt, then
# there might be issues
name_res += "_noshunt"

if name_res in globals():
if not force:
# no need to recreate the class, it already exists
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2019-01-11 23:55
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00:05
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2019-01-12 23:55
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00:05
42 changes: 42 additions & 0 deletions grid2op/data_test/educ_case14_storage_diffgrid_diff_obs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from grid2op.Action import PowerlineChangeDispatchAndStorageAction
from grid2op.Reward import L2RPNReward
from grid2op.Rules import DefaultRules
from grid2op.Chronics import Multifolder
from grid2op.Chronics import GridStateFromFileWithForecasts
from grid2op.Backend import PandaPowerBackend
from grid2op.l2rpn_utils import ActionIDF2023, ObservationIDF2023

config = {
"backend": PandaPowerBackend,
"action_class": PowerlineChangeDispatchAndStorageAction,
"observation_class": ObservationIDF2023,
"action_class": ActionIDF2023,
"reward_class": L2RPNReward,
"gamerules_class": DefaultRules,
"chronics_class": Multifolder,
"grid_value_class": GridStateFromFileWithForecasts,
"volagecontroler_class": None,
"thermal_limits": [
541.0,
450.0,
375.0,
636.0,
175.0,
285.0,
335.0,
657.0,
496.0,
827.0,
442.0,
641.0,
840.0,
156.0,
664.0,
235.0,
119.0,
179.0,
1986.0,
1572.0,
],
"names_chronics_to_grid": None,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"0": {
"NO_OVERFLOW_DISCONNECTION": true,
"NB_TIMESTEP_OVERFLOW_ALLOWED": 9999,
"NB_TIMESTEP_COOLDOWN_SUB": 0,
"NB_TIMESTEP_COOLDOWN_LINE": 0,
"HARD_OVERFLOW_THRESHOLD": 9999,
"NB_TIMESTEP_RECONNECTION": 0,
"IGNORE_MIN_UP_DOWN_TIME": true,
"ALLOW_DISPATCH_GEN_SWITCH_OFF": true,
"ENV_DC": false,
"FORECAST_DC": false,
"MAX_SUB_CHANGED": 1,
"MAX_LINE_STATUS_CHANGED": 1
},
"1": {
"NO_OVERFLOW_DISCONNECTION": false,
"NB_TIMESTEP_OVERFLOW_ALLOWED": 6,
"NB_TIMESTEP_COOLDOWN_SUB": 0,
"NB_TIMESTEP_COOLDOWN_LINE": 0,
"HARD_OVERFLOW_THRESHOLD": 3.0,
"NB_TIMESTEP_RECONNECTION": 1,
"IGNORE_MIN_UP_DOWN_TIME": true,
"ALLOW_DISPATCH_GEN_SWITCH_OFF": true,
"ENV_DC": false,
"FORECAST_DC": false,
"MAX_SUB_CHANGED": 1,
"MAX_LINE_STATUS_CHANGED": 1
},
"2": {
"NO_OVERFLOW_DISCONNECTION": false,
"NB_TIMESTEP_OVERFLOW_ALLOWED": 3,
"NB_TIMESTEP_COOLDOWN_SUB": 1,
"NB_TIMESTEP_COOLDOWN_LINE": 1,
"HARD_OVERFLOW_THRESHOLD": 2.5,
"NB_TIMESTEP_RECONNECTION": 6,
"IGNORE_MIN_UP_DOWN_TIME": true,
"ALLOW_DISPATCH_GEN_SWITCH_OFF": true,
"ENV_DC": false,
"FORECAST_DC": false,
"MAX_SUB_CHANGED": 1,
"MAX_LINE_STATUS_CHANGED": 1
},
"competition": {
"NO_OVERFLOW_DISCONNECTION": false,
"NB_TIMESTEP_OVERFLOW_ALLOWED": 3,
"NB_TIMESTEP_COOLDOWN_SUB": 3,
"NB_TIMESTEP_COOLDOWN_LINE": 3,
"HARD_OVERFLOW_THRESHOLD": 2.0,
"NB_TIMESTEP_RECONNECTION": 12,
"IGNORE_MIN_UP_DOWN_TIME": true,
"ALLOW_DISPATCH_GEN_SWITCH_OFF": true,
"ENV_DC": false,
"FORECAST_DC": false,
"MAX_SUB_CHANGED": 1,
"MAX_LINE_STATUS_CHANGED": 1
}
}
Loading

0 comments on commit e2eacfb

Please sign in to comment.