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

Action space sampling returns invalid actions #527

Closed
nicow-elia opened this issue Sep 15, 2023 · 1 comment
Closed

Action space sampling returns invalid actions #527

nicow-elia opened this issue Sep 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@nicow-elia
Copy link

Environment

  • Grid2op version: 1.9.3
  • System: ubuntu16.04
  • Additional system information

Bug description

When sampling from the action space and converting these actions into serializable dicts so they can be loaded from disc later, we will occasionally get results from the sort {"change_bus": {}} which is a do-nothing action and should be {}. Since grid2op 1.9, this type of action is not supported as input to the environment and raises an exception

How to reproduce

import grid2op

def test_action_space_sampling() -> None:
    env = grid2op.make("l2rpn_case14_sandbox")
    for _ in range(10000):
        act_dict = env.action_space.sample().as_serializable_dict()
        env.action_space(act_dict)

Current output

The test raises an exception

Expected output

The test succeeds.
@nicow-elia nicow-elia added the bug Something isn't working label Sep 15, 2023
BDonnot added a commit to BDonnot/Grid2Op that referenced this issue Sep 15, 2023
@BDonnot
Copy link
Collaborator

BDonnot commented Sep 15, 2023

Hello,

Thanks for spotting this. I fixed the issue in two different ways:

  1. the as_serializable_dict() method will now discard the keys associated with "do nothing" (when nothing is modified for example)
  2. the action will be nicer and accept "weird" do nothing actions such as env.action_space({"change_bus": {}})

I expect to release a new grid2op version next Monday (it's always a bad idea to release anything at all on Fridays)

BDonnot added a commit that referenced this issue Sep 18, 2023
@BDonnot BDonnot closed this as completed Sep 19, 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