-
Notifications
You must be signed in to change notification settings - Fork 112
/
test_dc_isolated_elements.py
56 lines (50 loc) · 2.46 KB
/
test_dc_isolated_elements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (c) 2023, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.
import grid2op
import numpy as np
import unittest
import itertools
import warnings
class TestIsolatedLoad(unittest.TestCase):
def setUp(self) -> None:
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
self.env = grid2op.make("l2rpn_case14_sandbox", test=True, _add_to_name=type(self).__name__)
param = self.env.parameters
param.ENV_DC = True # force the computation of the powerflow in DC mode
param.MAX_LINE_STATUS_CHANGED = 99999
param.MAX_SUB_CHANGED = 99999
param.NO_OVERFLOW_DISCONNECTION = True
self.env.change_parameters(param)
self.env.change_forecast_parameters(param)
time_series_id = 0
self.env.set_id(time_series_id)
self.obs = self.env.reset()
self.obs_start, *_ = self.env.step(self.env.action_space({}))
self.tol = 3e-5
return super().setUp()
def test_specific_action_load(self):
act = self.env.action_space({'set_bus': {'loads_id': [(0, 1), (1, 2)],
'generators_id': [(0, 2), (1, 1)],
'lines_or_id': [(2, 2), (3, 1), (4, 2), (5, -1)],
'lines_ex_id': [(0, 1), (2, 1), (5, -1)]}}
)
obs, reward, done, info = self.env.step(act)
assert done
assert info["exception"]
def test_specific_action_gen(self):
act = self.env.action_space({'set_bus': {'loads_id': [(0, 1), (1, 2)],
'generators_id': [(0, 2), (1, 1)],
'lines_or_id': [(2, 2), (3, 1), (4, 2), (5, -1)],
'lines_ex_id': [(0, 1), (2, 1), (5, -1)]}}
)
obs, reward, done, info = self.env.step(act)
assert done
assert info["exception"]
if __name__ == "__main__":
unittest.main()