|
7 | 7 | import h5py
|
8 | 8 | import numpy as np
|
9 | 9 | import simplekml
|
10 |
| -from multiprocess import JoinableQueue, Lock, Process |
| 10 | +from multiprocess import Lock, Process |
11 | 11 | from multiprocess.managers import BaseManager
|
12 | 12 |
|
13 | 13 | from rocketpy import Function
|
@@ -296,12 +296,12 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
|
296 | 296 | -------
|
297 | 297 | None
|
298 | 298 | """
|
| 299 | + parallel_start = time() |
299 | 300 | processes = []
|
300 | 301 |
|
301 | 302 | if n_workers is None:
|
302 | 303 | n_workers = os.cpu_count()
|
303 | 304 |
|
304 |
| - parallel_start = time() |
305 | 305 |
|
306 | 306 | with MonteCarloManager() as manager:
|
307 | 307 | # initialize queue
|
@@ -353,7 +353,7 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
|
353 | 353 | pass # initialize file
|
354 | 354 |
|
355 | 355 | # Initialize simulation counter
|
356 |
| - sim_counter = manager.SimCounter(idx_i, self.number_of_simulations) |
| 356 | + sim_counter = manager.SimCounter(idx_i, self.number_of_simulations, parallel_start) |
357 | 357 |
|
358 | 358 | print("\nStarting monte carlo analysis", end="\r")
|
359 | 359 | print(f"Number of simulations: {self.number_of_simulations}")
|
@@ -1168,19 +1168,18 @@ class MonteCarloManager(BaseManager):
|
1168 | 1168 | def __init__(self):
|
1169 | 1169 | super().__init__()
|
1170 | 1170 | self.register('Lock', Lock)
|
1171 |
| - self.register('JoinableQueue', JoinableQueue) |
1172 | 1171 | self.register('SimCounter', SimCounter)
|
1173 | 1172 | self.register('StochasticEnvironment', StochasticEnvironment)
|
1174 | 1173 | self.register('StochasticRocket', StochasticRocket)
|
1175 | 1174 | self.register('StochasticFlight', StochasticFlight)
|
1176 | 1175 |
|
1177 | 1176 |
|
1178 | 1177 | class SimCounter:
|
1179 |
| - def __init__(self, initial_count, n_simulations): |
| 1178 | + def __init__(self, initial_count, n_simulations, parallel_start): |
1180 | 1179 | self.count = initial_count
|
1181 | 1180 | self.n_simulations = n_simulations
|
1182 | 1181 | self._last_print_len = 0 # used to print on the same line
|
1183 |
| - self.initial_time = time() |
| 1182 | + self.initial_time = parallel_start |
1184 | 1183 |
|
1185 | 1184 | def increment(self):
|
1186 | 1185 | if self.count >= self.n_simulations:
|
|
0 commit comments