Skip to content

Commit

Permalink
Ml fix dc (#41)
Browse files Browse the repository at this point in the history
* Fixing DC data generation

* configurations updated with new DoNothing section for powergrid
  • Loading branch information
Mleyliabadi authored Jun 23, 2024
1 parent 77e48ae commit 3ce9e0c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
11 changes: 11 additions & 0 deletions configurations/powergrid/benchmarks/l2rpn_idf_2023.ini
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ eval_params = {
"verify_theta": True}
}

[DoNothing]
attr_x = ("prod_p", "prod_v", "load_p", "load_q")
attr_tau = ("line_status", "topo_vect")
attr_y = ("a_or", "a_ex", "p_or", "p_ex", "q_or", "q_ex", "prod_q", "load_v", "v_or", "v_ex", "theta_or", "theta_ex")
attr_physics = ("YBus", "SBus", "PV_nodes", "slack")
dataset_create_params = {
"train": {},
"test": {},
"test_ood": {}
}

[Benchmark_competition]
attr_x = ("prod_p", "prod_v", "load_p", "load_q")
attr_tau = ("line_status", "topo_vect")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,17 @@ eval_dict = {
eval_params = {
"inf_batch_size": 59000} # #pas_de_temps=100 x #ligne=20 x #topo=7

[DoNothing]
attr_x = ("prod_p", "prod_v", "load_p", "load_q")
attr_tau = ("line_status", "topo_vect")
attr_y = ("a_or", "a_ex", "p_or", "p_ex", "q_or", "q_ex", "prod_q", "load_v", "v_or", "v_ex", "theta_or", "theta_ex")
attr_physics = ("YBus", "SBus", "PV_nodes", "slack")
dataset_create_params = {
"train": {},
"test": {},
"test_ood": {}
}

[Benchmark_competition]
attr_x = ("prod_p", "prod_v", "load_p", "load_q")
attr_tau = ("line_status", "topo_vect")
Expand Down
11 changes: 11 additions & 0 deletions configurations/powergrid/benchmarks/l2rpn_wcci_2022.ini
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,14 @@ eval_params = {
"VOLTAGE_EQ": {"tolerance": 1e-4,
"verify_theta": True}
}

[DoNothing]
attr_x = ("prod_p", "prod_v", "load_p", "load_q")
attr_tau = ("line_status", "topo_vect")
attr_y = ("a_or", "a_ex", "p_or", "p_ex", "q_or", "q_ex", "prod_q", "load_v", "v_or", "v_ex", "theta_or", "theta_ex")
attr_physics = ("YBus", "SBus", "PV_nodes", "slack")
dataset_create_params = {
"train": {},
"test": {},
"test_ood": {}
}
4 changes: 3 additions & 1 deletion lips/dataset/powergridDataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,13 @@ def _store_physics(self, current_size: int, obs, grid, is_lightSimBackend: bool,
pv_nodes = np.zeros(shape=(n_bus_bars), dtype=bool)

#get admittance matrix and injection vector values from LightSim2Grid
Sbus = grid.get_Sbus()

if is_dc:
YBus = grid.get_dcYbus()
Sbus = grid.get_dcSbus()
else:
YBus = grid.get_Ybus()
Sbus = grid.get_Sbus()

#fill data structures with expected dimensions
admittance_matrix[np.ix_(unique_bus, unique_bus)] = YBus.todense()
Expand Down
14 changes: 11 additions & 3 deletions lips/physical_simulator/grid2opSimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def __init__(self,
self._timer_solver = 0
self._timer_preproc = 0
self._timer_postproc = 0

self.is_dc = self._simulator.parameters.ENV_DC

try:
from lightsim2grid import LightSimBackend
Expand Down Expand Up @@ -249,8 +251,9 @@ def _reset_simulator(self, fast_forward: bool = True):
# exclude the already selected time stamps from which the scenario should started
remaining_timesteps = set(np.arange(self._max_episode_duration)) - set(self._visited_ts)
# randomly skip a given number of steps in the first day (to improve the randomness)
nb_ff = self._simulator.space_prng.choice(list(remaining_timesteps))
if nb_ff > 0:
if len(remaining_timesteps) > 0:
nb_ff = self._simulator.space_prng.choice(list(remaining_timesteps))
#if nb_ff > 0:
self._simulator.fast_forward_chronics(nb_ff)
self._obs = self._simulator.get_obs()
self._visited_ts.append(nb_ff)
Expand Down Expand Up @@ -338,7 +341,12 @@ def __any_isolated_nodes(self, env):
"""
check = False
grid = env.backend._grid
Sbus = grid.get_Sbus()

if self.is_dc:
Sbus = grid.get_dcSbus()
else:
Sbus = grid.get_Sbus()

if len(Sbus) < env.n_sub:
check = True
return check
Expand Down

0 comments on commit 3ce9e0c

Please sign in to comment.