Skip to content

Commit 4ed5d73

Browse files
authored
Merge pull request #694 from BDonnot/bd_dev
Bd dev
2 parents 066f782 + b1dde84 commit 4ed5d73

29 files changed

+599
-209
lines changed

CHANGELOG.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ General grid2op improvments:
2525
- Code and test the "load from disk" method
2626
- add a "plot action" method
2727
- does not read every data of the backend if not used
28+
- backend converter: now test it properly with pandapower / lightsim2grid and pypowsybl2grid
2829

2930
Better multi processing support:
3031

@@ -96,6 +97,8 @@ Native multi agents support:
9697

9798
- cf ad-hoc branch (dev-multiagents)
9899
- properly model interconnecting powerlines
100+
- add detachment
101+
- add change_bus / set_bus
99102

100103
[1.11.0] - 202x-yy-zz
101104
-----------------------
@@ -112,6 +115,15 @@ Native multi agents support:
112115
- [BREAKING] the way actions is serialized has been changed with respect to the `from_vect` /
113116
`to_vect` method. This might introduce some issues when loading previously saved actions
114117
with this methods.
118+
- [BREAKING] first kwargs of `backend.apply_action` method is now spelled `backend_action`
119+
(instead of backendAction)
120+
- [BREAKING] (not yet) rationalization of the backend public / private API part. The
121+
environment (and simulator, forecast env etc.) will always call the method `_public`
122+
for example `load_grid_public`, `reset_public`, `copy_public` and `apply_action_public`.
123+
These function of the base `Backend` should NOT be overriden, and will internally call
124+
the functions `load_grid`, `reset`, `copy` and `apply_action` which were part of the public
125+
API. These last member functions will be renamed (in a later version) `_load_grid`,
126+
`_reset`, `_copy` and `_apply_action` to reflect this change. NOT for this version however !
115127
- [FIXED] issue https://github.com/Grid2op/grid2op/issues/657
116128
- [FIXED] missing an import on the `MaskedEnvironment` class
117129
- [FIXED] a bug when trying to set the load_p, load_q, gen_p, gen_v by names.
@@ -143,6 +155,7 @@ Native multi agents support:
143155
- [FIXED] a powerflow is run when the environment is first created even before the initial "env.step"
144156
function is called. This is to ensure proper behaviour if env is used without being reset.
145157
- [FIXED] no error was catched if the backend could not properly apply the action sent by the environment.
158+
- [FIXED] an issue in the AAA tests: when backend does not support storages, some tests were skipped not correctly
146159
- [ADDED] possibility to set the "thermal limits" when calling `env.reset(..., options={"thermal limit": xxx})`
147160
- [ADDED] possibility to retrieve some structural information about elements with
148161
with `gridobj.get_line_info(...)`, `gridobj.get_load_info(...)`, `gridobj.get_gen_info(...)`
@@ -187,7 +200,8 @@ Native multi agents support:
187200
that allows not to recompute it over and over again (this is internal API please do not change
188201
it... unless you know what you are doing)
189202
- [IMPROVED] `ForecastEnv` is now part of the public API.
190-
203+
- [IMPROVED] no need to call `self._compute_pos_big_top()` at the end of the implementation of `backend.load_grid()`
204+
191205
[1.10.5] - 2025-03-07
192206
------------------------
193207
- [FIXED] force pandapower < 3 otherwise pandapower backend does not work and

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'Benjamin Donnot'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '1.11.0.dev4'
25+
release = '1.11.0.dev5'
2626
version = '1.11'
2727

2828

grid2op/Action/_backendAction.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,12 @@ def __init__(self):
522522
self._lines_or_bus = None
523523
self._lines_ex_bus = None
524524
self._storage_bus = None
525+
526+
#: .. versionadded: 1.11.0
527+
self._is_cached = False
528+
self._injections_cached = None
529+
self._topo_cached = None
530+
self._shunts_cached = None
525531

526532
def __deepcopy__(self, memodict={}) -> Self:
527533

@@ -818,7 +824,8 @@ def __iadd__(self, other : BaseAction) -> Self:
818824
The updated state of `self` after the new action `other` has been added to it.
819825
820826
"""
821-
827+
self._is_cached = False # TODO speed here: if no modification does not invalidate the cache
828+
822829
set_status = 1 * other._set_line_status
823830
switch_status = other._switch_line_status
824831
set_topo_vect = 1 * other._set_topo_vect
@@ -944,20 +951,24 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back
944951
position in the `topo_vect` vector)
945952
946953
"""
954+
if self._is_cached:
955+
return self.activated_bus, self._injections_cached, self._topo_cached, self._shunts_cached
956+
947957
self._assign_0_to_disco_el()
948-
injections = (
958+
self._injections_cached = (
949959
self.prod_p,
950960
self.prod_v,
951961
self.load_p,
952962
self.load_q,
953963
self.storage_power,
954964
)
955-
topo = self.current_topo
956-
shunts = None
965+
self._topo_cached = self.current_topo
966+
self._shunts_cached = None
957967
if type(self).shunts_data_available:
958-
shunts = self.shunt_p, self.shunt_q, self.shunt_bus
968+
self._shunts_cached = self.shunt_p, self.shunt_q, self.shunt_bus
959969
self._get_active_bus()
960-
return self.activated_bus, injections, topo, shunts
970+
self._is_cached = True
971+
return self.activated_bus, self._injections_cached, self._topo_cached, self._shunts_cached
961972

962973
def get_loads_bus(self) -> ValueStore:
963974
"""

grid2op/Action/actionSpace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ActionSpace(SerializableActionSpace):
2121
:class:`ActionSpace` should be created by an :class:`grid2op.Environment.Environment`
2222
with its parameters coming from a properly
2323
set up :class:`grid2op.Backend.Backend` (ie a Backend instance with a loaded powergrid.
24-
See :func:`grid2op.Backend.Backend.load_grid` for
24+
See :func:`grid2op.Backend.Backend.load_grid_public` for
2525
more information).
2626
2727
It will allow, thanks to its :func:`ActionSpace.__call__` method to create valid :class:`BaseAction`. It is the

0 commit comments

Comments
 (0)