@@ -215,7 +215,9 @@ def _aux_test_tau_from_list_topo(self, proxy=None):
215
215
proxy = ProxyLeapNet (attr_tau = ("line_status" , "topo_vect" ,),
216
216
topo_vect_to_tau = "given_list" ,
217
217
kwargs_tau = [(0 , (2 , 1 , 1 )), (0 , (1 , 2 , 1 )), (1 , (2 , 1 , 1 , 1 , 1 , 1 )),
218
- (12 , (2 , 1 , 1 , 2 )), (13 , (2 , 1 , 2 )), (13 , (1 , 2 , 2 ))]
218
+ (12 , (2 , 1 , 1 , 2 )), (13 , (2 , 1 , 2 )), (13 , (1 , 2 , 2 )),
219
+ (1 , (2 , 1 , 2 , 1 , 2 , 1 ))
220
+ ]
219
221
)
220
222
proxy .init ([self .obs ])
221
223
@@ -258,7 +260,7 @@ def _aux_test_tau_from_list_topo(self, proxy=None):
258
260
res = proxy .topo_vect_handler (obs )
259
261
assert np .sum (res ) == 0
260
262
261
- # test that everything on bys 2 and everything on bus 1 leads to the same result
263
+ # test that everything on bus 2 and everything on bus 1 leads to the same result
262
264
obs = env .reset ()
263
265
act = env .action_space ({"set_bus" : {"substations_id" : [(12 , (2 , 2 , 2 , 2 ))]}})
264
266
obs , reward , done , info = env .step (act )
@@ -271,7 +273,7 @@ def _aux_test_tau_from_list_topo(self, proxy=None):
271
273
res = proxy .topo_vect_handler (obs )
272
274
assert np .sum (res ) == 0
273
275
274
- # check the symmetry 2 <-> 1
276
+ # check cumulative "actions"
275
277
obs = env .reset ()
276
278
act = env .action_space ({"set_bus" : {"substations_id" : [(0 , (2 , 1 , 1 ))]}})
277
279
obs , reward , done , info = env .step (act )
@@ -282,7 +284,7 @@ def _aux_test_tau_from_list_topo(self, proxy=None):
282
284
assert res [0 ] == 1.
283
285
assert res [4 ] == 1.
284
286
285
- # test the symmetry (gain ...) why not
287
+ # test the symmetry (again ...) why not
286
288
obs = env .reset ()
287
289
act = env .action_space ({"set_bus" : {"substations_id" : [(0 , (2 , 2 , 2 ))]}})
288
290
obs , reward , done , info = env .step (act )
@@ -295,7 +297,30 @@ def _aux_test_tau_from_list_topo(self, proxy=None):
295
297
res = proxy .topo_vect_handler (obs )
296
298
assert np .sum (res ) == 1
297
299
assert res [2 ] == 1.
300
+
301
+ obs = env .reset ()
302
+ act = env .action_space ({"set_bus" : {"substations_id" : [(12 , (1 , 2 , 2 , 1 ))]}})
303
+ obs , reward , done , info = env .step (act )
304
+ res = proxy .topo_vect_handler (obs )
305
+ assert np .sum (res ) == 1
306
+ assert res [3 ] == 1.
298
307
308
+ # test that if a line is disconnected, we are still able to match the topologies
309
+ # see https://github.com/BDonnot/leap_net/pull/12/files
310
+ obs = env .reset ()
311
+ act = env .action_space ({"set_bus" : {"substations_id" : [(1 , (2 , 1 , - 1 , 1 , 2 , 1 ))]}}) # (2, 1, 2, 1, 2, 1)
312
+ obs , reward , done , info = env .step (act )
313
+ res = proxy .topo_vect_handler (obs )
314
+ assert np .sum (res ) == 1
315
+ assert res [6 ] == 1.
316
+
317
+ obs = env .reset ()
318
+ act = env .action_space ({"set_bus" : {"substations_id" : [(1 , (2 , - 1 , 2 , 1 , 2 , 1 ))]}}) # (2, 1, 2, 1, 2, 1)
319
+ obs , reward , done , info = env .step (act )
320
+ res = proxy .topo_vect_handler (obs )
321
+ assert np .sum (res ) == 1
322
+ assert res [6 ] == 1.
323
+
299
324
def test_tau_from_online_topo (self ):
300
325
self ._aux_test_tau_from_online_topo ()
301
326
0 commit comments