Skip to content

Commit

Permalink
adressing feature request rte-france#217
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jun 7, 2021
1 parent b0748de commit bce0c37
Show file tree
Hide file tree
Showing 6 changed files with 1,796 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Change Log
- [ADDED] some handy argument in the `action_space.get_all_unitary_redispatch` and
`action_space.get_all_unitary_curtail` (see doc)
- [IMPROVED] prevent the use of the same instance of a backend in different environments
- [IMPROVED] `Issue#217 <https://github.com/rte-france/Grid2Op/issues/217>`_ : no more errors when trying to
load a grid with unsupported elements (eg. 3w trafos or static generators) by PandaPowerBackend

[1.5.2] - 2021-05-10
-----------------------
Expand Down
7 changes: 5 additions & 2 deletions grid2op/Space/GridObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ def assert_grid_correct_cls(cls):
raise IncorrectNumberOfSubstation("The number of substation is not consistent in "
"self.sub_info (size \"{}\")"
"and self.n_sub ({})".format(len(cls.sub_info), cls.n_sub))
if np.sum(cls.sub_info) != cls.n_load + cls.n_gen + 2*cls.n_line + cls.n_storage:
if np.sum(cls.sub_info) != cls.n_load + cls.n_gen + 2 * cls.n_line + cls.n_storage:
err_msg = "The number of elements of elements is not consistent between self.sub_info where there are "
err_msg += "{} elements connected to all substations and the number of load, generators and lines in " \
"the _grid ({})."
Expand Down Expand Up @@ -1745,7 +1745,10 @@ def assert_grid_correct_cls(cls):

# no empty bus: at least one element should be present on each bus
if np.any(cls.sub_info < 1):
raise BackendError("There are {} bus with 0 element connected to it.".format(np.sum(cls.sub_info < 1)))
# raise BackendError("There are {} bus with 0 element connected to it.".format(np.sum(cls.sub_info < 1)))
warnings.warn(f"There are {np.sum(cls.sub_info < 1)} substations where no 'controlable' elements "
f"are connected. These substations will be used in the computation of the powerflow "
f"(by the backend) but you will NOT be able to control anything on them.")

# redispatching / unit commitment
if cls.redispatching_unit_commitment_availble:
Expand Down
19 changes: 19 additions & 0 deletions grid2op/data_test/5bus_modif_grid/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from grid2op.Action import TopologyAction
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

config = {
"backend": PandaPowerBackend,
"action_class": TopologyAction,
"observation_class": None,
"reward_class": L2RPNReward,
"gamerules_class": DefaultRules,
"chronics_class": Multifolder,
"grid_value_class": GridStateFromFileWithForecasts,
"volagecontroler_class": None,
"thermal_limits": None,
"names_chronics_to_grid": None
}
Loading

0 comments on commit bce0c37

Please sign in to comment.