@@ -36,6 +36,7 @@ def _aux_add_data(reward, env, episode,
3636 )
3737 return reward
3838
39+
3940def _aux_one_process_parrallel (
4041 runner ,
4142 episode_this_process ,
@@ -46,7 +47,8 @@ def _aux_one_process_parrallel(
4647 max_iter = None ,
4748 add_detailed_output = False ,
4849 add_nb_highres_sim = False ,
49- init_states = None
50+ init_states = None ,
51+ reset_options = None ,
5052):
5153 """this is out of the runner, otherwise it does not work on windows / macos"""
5254 # chronics_handler = ChronicsHandler(
@@ -75,7 +77,11 @@ def _aux_one_process_parrallel(
7577 init_state = init_states [i ]
7678 else :
7779 init_state = None
78-
80+
81+ if reset_options is not None :
82+ reset_option = reset_options [i ]
83+ else :
84+ reset_option = None
7985 tmp_ = _aux_run_one_episode (
8086 env ,
8187 agent ,
@@ -87,7 +93,8 @@ def _aux_one_process_parrallel(
8793 agent_seed = agt_seed ,
8894 detailed_output = add_detailed_output ,
8995 use_compact_episode_data = runner .use_compact_episode_data ,
90- init_state = init_state
96+ init_state = init_state ,
97+ reset_option = reset_option
9198 )
9299 (name_chron , cum_reward , nb_time_step , max_ts , episode_data , nb_highres_sim ) = tmp_
93100 id_chron = env .chronics_handler .get_id ()
@@ -114,7 +121,8 @@ def _aux_run_one_episode(
114121 max_iter = None ,
115122 detailed_output = False ,
116123 use_compact_episode_data = False ,
117- init_state = None
124+ init_state = None ,
125+ reset_option = None ,
118126):
119127 done = False
120128 time_step = int (0 )
@@ -123,18 +131,33 @@ def _aux_run_one_episode(
123131
124132 # set the environment to use the proper chronic
125133 # env.set_id(indx)
134+ if reset_option is None :
135+ reset_option = {}
136+
137+ if "time serie id" in reset_option :
138+ warnings .warn ("You provided both `episode_id` and the key `'time serie id'` is present "
139+ "in the provided `reset_options`. In this case, grid2op will ignore the "
140+ "`time serie id` of the `reset_options` and keep the value in `episode_id`." )
141+ reset_option ["time serie id" ] = indx
126142
127- options = {"time serie id" : indx }
128143 # handle max_iter
129144 if max_iter is not None :
130- options ["max step" ] = max_iter
145+ if "max step" in reset_option :
146+ warnings .warn ("You provided both `max_iter` and the key `'max step'` is present "
147+ "in the provided `reset_options`. In this case, grid2op will ignore the "
148+ "`max step` of the `reset_options` and keep the value in `max_iter`." )
149+ reset_option ["max step" ] = max_iter
131150
132151 # handle init state
133152 if init_state is not None :
134- options ["init state" ] = init_state
153+ if "init state" in reset_option :
154+ warnings .warn ("You provided both `init_state` and the key `'init state'` is present "
155+ "in the provided `reset_options`. In this case, grid2op will ignore the "
156+ "`init state` of the `reset_options` and keep the value in `init_state`." )
157+ reset_option ["init state" ] = init_state
135158
136159 # reset it
137- obs = env .reset (seed = env_seed , options = options )
160+ obs = env .reset (seed = env_seed , options = reset_option )
138161
139162 # reset the number of calls to high resolution simulator
140163 env ._highres_sim_counter ._HighResSimCounter__nb_highres_called = 0
0 commit comments