@@ -89,7 +89,7 @@ def create_pulse_func(idx):
89
89
self ._result = Result (
90
90
objectives = objectives ,
91
91
time_interval = time_interval ,
92
- start_local_time = time .localtime (), # initial optimization time
92
+ start_local_time = time .time (), # initial optimization time
93
93
n_iters = 0 , # Number of iterations(episodes) until convergence
94
94
iter_seconds = [], # list containing the time taken for each iteration(episode) of the optimization
95
95
var_time = True , # Whether the optimization was performed with variable time
@@ -99,7 +99,7 @@ def create_pulse_func(idx):
99
99
self ._backup_result = Result ( # used as a backup in case the algorithm with shorter_pulses does not find an episode with infid<target_infid
100
100
objectives = objectives ,
101
101
time_interval = time_interval ,
102
- start_local_time = time .localtime (),
102
+ start_local_time = time .time (),
103
103
n_iters = 0 ,
104
104
iter_seconds = [],
105
105
var_time = True ,
@@ -180,7 +180,7 @@ def _save_episode_info(self):
180
180
"terminated" : self .terminated ,
181
181
"truncated" : self .truncated ,
182
182
"steps_used" : self ._current_step ,
183
- "elapsed_time" : time .mktime ( time . localtime () ),
183
+ "elapsed_time" : time .time ( ),
184
184
}
185
185
self ._episode_info .append (episode_data )
186
186
@@ -256,7 +256,7 @@ def reset(self, seed=None):
256
256
time_diff = self ._episode_info [- 1 ]["elapsed_time" ] - (
257
257
self ._episode_info [- 2 ]["elapsed_time" ]
258
258
if len (self ._episode_info ) > 1
259
- else time . mktime ( self ._result .start_local_time )
259
+ else self ._result .start_local_time
260
260
)
261
261
self ._result .iter_seconds .append (time_diff )
262
262
self ._current_step = 0 # Reset the step counter
@@ -281,7 +281,7 @@ def _save_result(self):
281
281
self ._backup_result ._final_states = self ._result ._final_states .copy ()
282
282
self ._backup_result .infidelity = self ._result .infidelity
283
283
284
- result_obj .end_local_time = time .localtime ()
284
+ result_obj .end_local_time = time .time ()
285
285
result_obj .n_iters = len (self ._result .iter_seconds )
286
286
result_obj .optimized_params = self ._actions .copy () + [
287
287
self ._result .total_seconds
@@ -296,20 +296,20 @@ def result(self):
296
296
"""
297
297
if self ._use_backup_result :
298
298
self ._backup_result .start_local_time = time .strftime (
299
- "%Y-%m-%d %H:%M:%S" , self ._backup_result .start_local_time
300
- ) # Convert to a string
299
+ "%Y-%m-%d %H:%M:%S" , time . localtime ( self ._backup_result .start_local_time )
300
+ )
301
301
self ._backup_result .end_local_time = time .strftime (
302
- "%Y-%m-%d %H:%M:%S" , self ._backup_result .end_local_time
303
- ) # Convert to a string
302
+ "%Y-%m-%d %H:%M:%S" , time . localtime ( self ._backup_result .end_local_time )
303
+ )
304
304
return self ._backup_result
305
305
else :
306
306
self ._save_result ()
307
307
self ._result .start_local_time = time .strftime (
308
- "%Y-%m-%d %H:%M:%S" , self ._result .start_local_time
309
- ) # Convert to a string
308
+ "%Y-%m-%d %H:%M:%S" , time . localtime ( self ._result .start_local_time )
309
+ )
310
310
self ._result .end_local_time = time .strftime (
311
- "%Y-%m-%d %H:%M:%S" , self ._result .end_local_time
312
- ) # Convert to a string
311
+ "%Y-%m-%d %H:%M:%S" , time . localtime ( self ._result .end_local_time )
312
+ )
313
313
return self ._result
314
314
315
315
def train (self ):
0 commit comments