Skip to content

Commit

Permalink
Merge pull request #69 from BDonnot/bd-1.0.0
Browse files Browse the repository at this point in the history
Bd 1.0.0
  • Loading branch information
BDonnot authored Jun 19, 2020
2 parents 0394a64 + d011bb3 commit d35680f
Show file tree
Hide file tree
Showing 170 changed files with 3,220 additions and 852 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ test_multiproc2.py
getting_started/saved_agent2_DDDQN_1500/
getting_started/saved_agent2_DDDQN_1500_results/
getting_started/saved_agent_DDDQN_1000_results/

getting_started/saved_agent_DDDQN_100_multi/
getting_started/saved_agent_DDDQN_100_multi_results_multi/

# profiling files
**.prof
8 changes: 6 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Change Log
- [BREAKING] `MultiEnv` has been renamed `SingleEnvMultiProcess`
- [BREAKING] `MultiEnv` has been abstracted to `BaseMultiProcessEnv` and the backwards compatible interface is now
`SingleProcessMultiEnv`
- [FIXED] `BaseAction.__iadd__` fixed a bug with change actions `+=` operator reported in `Issue #116 <https://github.com/rte-france/Grid2Op/issues/116>`_
- [FIXED] `BaseAction.__iadd__` fixed a bug with change actions `+=` operator reported in
`Issue #116 <https://github.com/rte-france/Grid2Op/issues/116>`_
- [FIXED] `obs.simulate` post-initialized reward behaves like the environment
- [FIXED] `LinesReconnectedReward` fixes reward inverted range
- [FIXED] the `get_all_unitary_topologies_change` now counts only once the "do nothing" action.
Expand All @@ -44,10 +45,13 @@ Change Log
grid and an arbitrary number of processes for each of these.
- [UPDATED] Behaviour of "change_bus" and "set_bus": it is no more possible to affect the bus of a powerline
disconnected.
- [UPDATED] More control about the looping strategy of the `ChronicsHandler` that has been refactored, and can now be
more easily cached (no need to do an expensive reading of the data at each call to `env.reset`)

[0.9.4] - 2020-06-12
---------------------
- [FIXED] `Issue #114 <https://github.com/rte-france/Grid2Op/issues/114>`_ the issue concerning the bug for the maintenance.
- [FIXED] `Issue #114 <https://github.com/rte-france/Grid2Op/issues/114>`_ the issue concerning the
bug for the maintenance.


[0.9.3] - 2020-05-29
Expand Down
137 changes: 5 additions & 132 deletions _profiling/profiler_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
import os

from grid2op import make
from grid2op.Agent import AgentWithConverter
from grid2op.Parameters import Parameters
from grid2op.Converter import IdToAct
from grid2op.Rules import AlwaysLegal
from grid2op.Backend import PandaPowerBackend
import cProfile

from utils_benchmark import run_env, str2bool
from utils_benchmark import run_env, str2bool, ProfileAgent

try:
from lightsim2grid.LightSimBackend import LightSimBackend
Expand All @@ -39,137 +38,11 @@
MAX_TS = 1000


class TestAgent(AgentWithConverter):
class TestAgent(ProfileAgent):
def __init__(self, action_space, env_name, action_space_converter=IdToAct, **kwargs_converter):
AgentWithConverter.__init__(self, action_space, action_space_converter=action_space_converter, **kwargs_converter)
self.action_space.all_actions = []

# do nothing
all_actions_tmp = [action_space()]

# powerline switch: disconnection
for i in range(action_space.n_line):
if env_name == "rte_case14_realistic":
if i == 18:
continue
elif env_name == "rte_case5_example":
pass
elif env_name == "rte_case118_example":
if i == 6:
continue
if i == 26:
continue
if i == 72:
continue
if i == 73:
continue
if i == 80:
continue
if i == 129:
continue
if i == 140:
continue
if i == 176:
continue
if i == 177:
continue
elif env_name == "l2rpn_wcci_2020":
if i == 2:
continue
all_actions_tmp.append(action_space.disconnect_powerline(line_id=i))

# other type of actions
all_actions_tmp += action_space.get_all_unitary_topologies_set(action_space)
# self.action_space.all_actions += action_space.get_all_unitary_redispatch(action_space)

if env_name == "rte_case14_realistic":
# remove action that makes the powerflow diverge
breaking_acts = [action_space({"set_bus": {"lines_or_id": [(7,2), (8,1), (9,1)],
"lines_ex_id": [(17,2)],
"generators_id": [(2,2)],
"loads_id": [(4,1)]}}),
action_space({"set_bus": {"lines_or_id": [(10, 2), (11, 1), (19,2)],
"lines_ex_id": [(16, 2)],
"loads_id": [(5, 1)]}}),
action_space({"set_bus": {"lines_or_id": [(5, 1)],
"lines_ex_id": [(2, 2)],
"generators_id": [(1, 2)],
"loads_id": [(1, 1)]}}),
action_space({"set_bus": {"lines_or_id": [(6, 2), (15, 2), (16, 1)],
"lines_ex_id": [(3, 2), (5, 2)],
"loads_id": [(2, 1)]}}),
action_space({"set_bus": {"lines_or_id": [(18, 1)],
"lines_ex_id": [(15, 2), (19, 2)],
}})
]
elif env_name == "rte_case118_example":
breaking_acts = [action_space({"set_bus": {"lines_or_id": [(100, 2), (129, 1), (173, 2)],
# "lines_ex_id": [(17,2)],
"generators_id": [(2, 2)],
"loads_id": [(6, 1)]
}}),
action_space({"set_bus": {"lines_or_id": [(100, 2), (129, 1), (173, 2)],
# "lines_ex_id": [(17,2)],
"generators_id": [(2, 2)],
"loads_id": [(6, 2)]
}}),
action_space({"set_bus": {"lines_or_id": [(100, 2), (129, 1), (173, 2)],
# "lines_ex_id": [(17,2)],
"generators_id": [(2, 1)],
"loads_id": [(6, 1)]
}}),
action_space({"set_bus": {"lines_or_id": [(140, 1)],
"lines_ex_id": [(129, 2)],
# "generators_id": [(2, 1)],
# "loads_id": [(6, 1)]
}}),
action_space({"set_bus": {"lines_or_id": [(57, 2), (80, 1), (83, 2)],
"lines_ex_id": [(2, 2), (13, 2), (24, 2), (35, 2)],
"generators_id": [(6, 2)],
"loads_id": [(8, 2)]
}}),
action_space({"set_bus": {"lines_or_id": [(57, 2), (80, 1), (83, 2)],
"lines_ex_id": [(2, 2), (13, 2), (24, 2), (35, 2)],
"generators_id": [(6, 2)],
"loads_id": [(8, 1)]
}}),
action_space({"set_bus": {"lines_or_id": [(57, 2), (80, 1), (83, 2)],
"lines_ex_id": [(2, 2), (13, 2), (24, 2), (35, 2)],
"generators_id": [(6, 1)],
"loads_id": [(8, 2)]
}}),
action_space({"set_bus": {"lines_or_id": [(57, 2), (80, 1), (83, 2)],
"lines_ex_id": [(2, 2), (13, 2), (24, 2), (35, 2)],
"generators_id": [(6, 1)],
"loads_id": [(8, 1)]
}}),
]

elif env_name == "l2rpn_wcci_2020":
breaking_acts = [action_space({"set_bus": {"lines_or_id": [(5, 2), (6, 2)],
"lines_ex_id": [(1, 2), (2, 1), (4, 2), (55, 2)],
# "generators_id": [(2, 2)],
# "loads_id": [(6, 1)]
}}),
]
else:
breaking_acts = [action_space({"set_bus": {"lines_or_id": [(0,2), (1,2), (2,2), (3,1)],
"generators_id": [(0,1)],
"loads_id": [(0,1)]}}),
]

# filter out actions that break everything
all_actions = []
for el in all_actions_tmp:
if not el in breaking_acts:
all_actions.append(el)

# set the action to the action space
self.action_space.all_actions = all_actions

# add the action "reset everything to 1 bus"
self.action_space.all_actions.append(action_space({"set_bus": np.ones(action_space.dim_topo, dtype=np.int),
"set_line_status": np.ones(action_space.n_line, dtype=np.int)}))
ProfileAgent.__init__(self, action_space, env_name=env_name,
action_space_converter=action_space_converter, **kwargs_converter)

self.nb_act_done = 0
self.act_this = True

Expand Down
Loading

0 comments on commit d35680f

Please sign in to comment.