Environment
- Grid2op version:
1.12.2
- System:
OL8
Bug description
pypowsybl==1.14 changed the order of the backend elements (now always sorted). This causes env failures for some test env.
How to reproduce
When running this code with pypowsybl 1.13 and 1.14 we get different results. Indeed the order of lines changed.
import logging
import warnings
import grid2op
import pypowsybl as pp
import pytest
from grid2op.Chronics import ChangeNothing
from grid2op.Opponent import get_kwargs_no_opponent
from pypowsybl2grid import PyPowSyBlBackend
env1 = grid2op.make(
"l2rpn_case14_sandbox",
test=True,
backend=PyPowSyBlBackend(
lf_parameters=lf_params,
check_isolated_and_disconnected_injections=True,
),
)
PP 1.14
env1
<abc.Environment_l2rpn_case14_sandboxPyPowSyBlBackend object at 0x7f5e669522d0>
env1.name_line
array(['0_1_0', '0_4_1', '11_12_13', '12_13_14', '1_2_2', '1_3_3',
'1_4_4', '2_3_5', '3_4_6', '3_6_15', '3_8_16', '4_5_17', '5_10_7',
'5_11_8', '5_12_9', '6_7_18', '8_13_11', '8_6_19', '8_9_10',
'9_10_12'], dtype='<U8')
env1.get_thermal_limit()
array([ 541., 450., 375., 636., 175., 285., 335., 657., 496.,
827., 442., 641., 840., 156., 664., 235., 119., 179.,
1986., 1572.], dtype=float32)
PP 1.13
env1.name_line
array(['0_1_0', '0_4_1', '1_2_2', '1_3_3', '1_4_4', '2_3_5', '3_4_6',
'5_10_7', '5_11_8', '5_12_9', '8_9_10', '8_13_11', '9_10_12',
'11_12_13', '12_13_14', '3_6_15', '3_8_16', '4_5_17', '6_7_18',
'8_6_19'], dtype='<U8')
env1.get_thermal_limit()
array([ 541., 450., 375., 636., 175., 285., 335., 657., 496.,
827., 442., 641., 840., 156., 664., 235., 119., 179.,
1986., 1572.], dtype=float32)
The issue comes from the definition of these env : they are defined using a vector instead of a dict
# Copyright (c) 2019-2020, 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.
"""
This file contains the settings (path to the case file, chronics converter etc.) that allows to make a simple
environment with a powergrid of only 5 buses, 3 laods, 2 generators and 8 powerlines.
"""
import os
import numpy as np
from pathlib import Path
file_dir = Path(__file__).parent.absolute()
grid2op_root = file_dir.parent.absolute()
grid2op_root = str(grid2op_root)
dat_dir = os.path.abspath(os.path.join(grid2op_root, "data"))
case_dir = "rte_case14_test"
grid_file = "case14_test.json"
case14_test_CASEFILE = os.path.join(dat_dir, case_dir, grid_file)
case14_test_CHRONICSPATH = os.path.join(dat_dir, case_dir, "chronics")
case14_test_TH_LIM = np.array(
[
352.8251645,
352.8251645,
183197.68156979,
183197.68156979,
183197.68156979,
12213.17877132,
183197.68156979,
352.8251645,
352.8251645,
352.8251645,
352.8251645,
352.8251645,
183197.68156979,
183197.68156979,
183197.68156979,
352.8251645,
352.8251645,
352.8251645,
2721.79412618,
2721.79412618,
]
)
Environment
1.12.2OL8Bug description
pypowsybl==1.14changed the order of the backend elements (now always sorted). This causes env failures for some test env.How to reproduce
When running this code with pypowsybl 1.13 and 1.14 we get different results. Indeed the order of lines changed.
PP 1.14
PP 1.13
The issue comes from the definition of these env : they are defined using a vector instead of a dict