Skip to content

Commit

Permalink
fix a bug in reset + seed + reset for MultiFolderWithCache
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jun 25, 2024
1 parent 8f093b2 commit 27a266b
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions grid2op/Chronics/multifolderWithCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ def reset(self):
Rebuilt the cache as if it were built from scratch.
This call might take a while to process.
This means that current data in cache will be discarded and that new data will
most likely be read from the hard drive.
This might take a while.
.. danger::
You NEED to call this function (with `env.chronics_handler.reset()`)
if you use the `MultiFolderWithCache` class in your experiments.
Expand All @@ -189,25 +194,9 @@ def reset(self):
# everything in "_order" need to be put in cache
path = self.subpaths[i]
data = self._get_nex_data(path)
# if issubclass(self.gridvalueClass, GridStateFromFile):
# data = self.gridvalueClass(
# time_interval=self.time_interval,
# sep=self.sep,
# path=path,
# max_iter=self.max_iter,
# chunk_size=None,
# )
# elif issubclass(self.gridvalueClass, FromHandlers):
# data = self.gridvalueClass(
# time_interval=self.time_interval,
# else:
# raise ChronicsError("Can only use MultiFolderWithCache with GridStateFromFile "
# f"or FromHandlers and not {self.gridvalueClass}")
if self.seed_used is not None:
# seed_chronics = self.space_prng.randint(max_int)
# self._cached_seeds[i] = seed_chronics

if self._cached_seeds is not None:
data.seed(self._cached_seeds[i])
data.regenerate_with_new_seed()

data.initialize(
self._order_backend_loads,
Expand All @@ -216,6 +205,10 @@ def reset(self):
self._order_backend_subs,
self._names_chronics_to_backend,
)

if self._cached_seeds is not None:
data.regenerate_with_new_seed()

self._cached_data[i] = data
self.cache_size += 1
if self.action_space is not None:
Expand Down

0 comments on commit 27a266b

Please sign in to comment.