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

Wrong observation's start date with the MultifolderWithCache chronic class and the l2rpn_wcci_2022 env #369

Closed
EBoguslawski opened this issue Sep 28, 2022 · 2 comments · Fixed by #383
Labels
bug Something isn't working

Comments

@EBoguslawski
Copy link
Contributor

Environment

  • Grid2op version: 1.7.2
  • System: Ubuntu 20.04.3 LTS

Bug description

When working with le l2rpn_wcci_2022 environment and the MultifolderWithCache chronic's class, it appears that the date of the first observation is 01/01/2019 for all the chronics. For this environment, the start date of a chronic can be found in its name and rarely (never) matches 01/01/2019.
Here is the bug : with the MultifolderWithCache chronic's class, the dates of the observations seems wrong.

How to reproduce

The following python code allows to compare the date of the first observation and the date in the chronic's name :

Code snippet

import grid2op
from grid2op.Chronics import MultifolderWithCache
import re

# Creation of the environment
env = grid2op.make("l2rpn_wcci_2022",
                    chronics_class=MultifolderWithCache) # No bug wihout the MultifolderWithCache argument here
env.chronics_handler.real_data.set_filter(lambda x: re.match(".*2050-02-07_0", x) is not None) # We test on a randomly chosen chronic for the example
env.chronics_handler.reset()

# Print the dates
obs=env.reset()
print("Date of the first observation (yyyy mm dd) :", obs.year, obs.month, obs.day)
print("Chronic name :", env.chronics_handler.get_name())

Current output

The date of the first observation and the date of the chronic's name are differents

Date of the observation (yyyy mm dd) : 2019 1 1
Chronic name : 2050-02-07_0

Expected output

The date of the first observation schould match the date of the chronic's name

Date of the observation (yyyy mm dd) : 2050 2 7 
Chronic name : 2050-02-07_0

Maybe an interesting clue

The date 01/01/2019 matches the default start_datetime argument in the grid2op.Chronics.MultifolderWithCache class :
https://grid2op.readthedocs.io/en/latest/chronics.html#grid2op.Chronics.MultifolderWithCache

@EBoguslawski EBoguslawski added the bug Something isn't working label Sep 28, 2022
@richardwth
Copy link

richardwth commented Sep 30, 2022

I also noticed this long ago. My fix:

from grid2op.Chronics import GridStateFromFileWithForecasts

class MyGridStateFromFileWithForecasts(GridStateFromFileWithForecasts):
    """ This class fixes a bug that the current chronix datatime is fixed to start at datetime(year=2019, month=1, day=1)
    """
    def next_chronics(self):
        self.current_datetime = self.start_datetime
        self.current_index = -1
        self.curr_iter = 0

and use it to create the env

env = grid2op.make(
      'l2rpn_wcci_2022', 
      ...,
      data_feeding_kwargs={'gridvalueClass': MyGridStateFromFileWithForecasts},
      ...,
      )

@BDonnot
Copy link
Collaborator

BDonnot commented Sep 30, 2022

Hello,

Thanks for providing us with this fix. It will save lots of time :-)

Benjamin

BDonnot added a commit to BDonnot/Grid2Op that referenced this issue Dec 2, 2022
@BDonnot BDonnot linked a pull request Dec 12, 2022 that will close this issue
@BDonnot BDonnot closed this as completed Dec 12, 2022
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.

3 participants