Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted side-effect of grid2op.Action.baseAction.as_dict method #511

Closed
vinault opened this issue Aug 9, 2023 · 0 comments
Closed

Unwanted side-effect of grid2op.Action.baseAction.as_dict method #511

vinault opened this issue Aug 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@vinault
Copy link
Contributor

vinault commented Aug 9, 2023

Environment

  • Grid2op version: 1.9.3
  • System: Windows 10

Bug description

The as_dict method do not return the expected dictionnary for a specific action on the l2rpn_idf_2023 environment (see how to reproduce)

How to reproduce

import grid2op
from grid2op.Backend import PandaPowerBackend

env = grid2op.make(
    "l2rpn_idf_2023",
    backend=PandaPowerBackend(detailed_infos_for_cascading_failures=False),
)

act = {
    "set_bus": {
        "lines_or_id": [(0, 2)],
        "loads_id": [(0, 2)],
    },
}

topo_action = env.action_space(act)
print(topo_action.as_dict())

Current output

This returns :

{'set_bus_vect': {'nb_modif_objects': 2, '0': {'0': {'type': 'load', 'new_bus': 2}}, 'nb_modif_subs': 1, 'modif_subs_id': ['0']}}

Expected output

The expected return should look like

{'set_bus_vect': {'nb_modif_objects': 2, '0': {'0': {'type': 'load', 'new_bus': 2}, '??': {'type': 'line (origin)', 'new_bus': 2}}, 'nb_modif_subs': 1, 'modif_subs_id': ['0']}}

What I think is happening

When building the dictionnary in the as_dict method here

 '0': {'type': 'line (origin)', 'new_bus': 2}

is first inserted in

res["set_bus_vect"]["0"]

and then

 '0': {'type': 'load', 'new_bus': 2}

is inserted, thus overwriting the line information.

This comes from the fact that _obj_caract_from_topo_id (here) returns 0 as obj_id for both the line_or and the load, which is unfortunate.

Thank you very much for your help !

@vinault vinault added the bug Something isn't working label Aug 9, 2023
BDonnot referenced this issue in BDonnot/Grid2Op Aug 24, 2023
@BDonnot BDonnot mentioned this issue Aug 25, 2023
@BDonnot BDonnot closed this as completed Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants