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

1. KeyError using state_of storage; 2. cannot sum curtail_actions #340

Closed
richardwth opened this issue Jun 28, 2022 · 3 comments · Fixed by #355
Closed

1. KeyError using state_of storage; 2. cannot sum curtail_actions #340

richardwth opened this issue Jun 28, 2022 · 3 comments · Fixed by #355
Labels
bug Something isn't working

Comments

@richardwth
Copy link

richardwth commented Jun 28, 2022

Environment

  • Grid2op version: 1.7.1
  • lightsim2grid version: 0.7.0
  • System: Ubuntu 18.04.4 LTS

Bug description

Two issues:

  1. KeyError when using obs.state_of to get the state of a storage.
  2. Adding two curtailment actions returns the second one.

How to reproduce

Issue 1

import grid2op

env = grid2op.make('l2rpn_wcci_2022')
obs = env.reset()
obs.state_of(storage_id=0)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/envs/deeprl37/lib/python3.7/site-packages/grid2op/Observation/baseObservation.py", line 831, in state_of
    res["origin"]["theta"] = self.storage_theta[storage_id]
KeyError: 'origin'

Issue 2

import grid2op

env = grid2op.make('l2rpn_wcci_2022')
obs = env.reset()
curtail_actions = env.action_space.get_all_unitary_curtail(env.action_space)
print(curtail_actions[0])  # Limit unit "gen_3_0" to 50.0% of its Pmax (setpoint: 0.500) 
print(curtail_actions[10])  # Limit unit "gen_3_1" to 50.0% of its Pmax (setpoint: 0.500)
print(curtail_actions[0]+curtail_actions[10])  # Limit unit "gen_3_1" to 50.0% of its Pmax (setpoint: 0.500)

This happens because Grid2Op BaseAction Line 1262 implements = instead of +=

self._curtail[ok_ind] = curtailment[ok_ind]  # curtailment = other._curtail

Now I'd expect the addition of two curtail actions on different generators to affect both generators. If this rule (curtail_action1 + curtail_action2 -> curtail_action2) is intended, it should be reflected in the documentation (or did I miss it?).

@richardwth richardwth added the bug Something isn't working label Jun 28, 2022
@BDonnot
Copy link
Collaborator

BDonnot commented Jun 28, 2022

Hello

Thanks for raising this bugs to our attention.

It seems you are totally correct in your understanding and that these are indeed grid2op bugs. I'll fix them ASAP.

The fix (for these bugs and possibly following ones) will be used for the Validation and Test phases of the L2RPN 2022 competitions. (I will not release a new grid2op version just yet because of possibly different bugs that people might find in the future)

@BDonnot
Copy link
Collaborator

BDonnot commented Jun 28, 2022

In the mean time

issue 1

You can call

obs.storage_theta[storage_id] instead of the code you do. It's the same value

Issue 2

You can do (which is a bit more verbose...), but again it's just before the validation and test phase competition start:

sum = curtail_actions[0].copy()
sum += curtail_actions[10]  # usefull only if you have more "component" of the action (eg set_powerline_status, or change_bus) but not in this case
effective_cutail = curtail_actions[10].curtail >= 0.
sum.curtail = [(gen_id, curtailment) for gen_id, curt in enumerate(curtail_actions[10].curtail) if effective_cutail[gen_id]]

BDonnot referenced this issue in BDonnot/Grid2Op Jun 28, 2022
BDonnot referenced this issue in BDonnot/Grid2Op Jun 28, 2022
Fix issues in rte-france#340
@BDonnot
Copy link
Collaborator

BDonnot commented Jun 28, 2022

Just to mention that you can use the "pre release" version of grid2op if you want to with

pip install Grid2Op==1.7.2rc1 --pre

This should install the first "release candidate" for the 1.7.2 grid2op version, that includes some fix for the bugs you spotted :-)

@BDonnot BDonnot linked a pull request Jul 5, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants