Skip to content

Commit 17d4e58

Browse files
authored
Fixed a bug in the calculator destructor (#168)
* Fixed a bug in the calculator destructor * Fixed problem with process pool destruction * The design of the example is brought to a single sample
1 parent 46afc77 commit 17d4e58

3 files changed

Lines changed: 4 additions & 13 deletions

File tree

examples/GKLS_example.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from iOpt.output_system.listeners.static_painters import StaticPainterNDListener
66
from iOpt.output_system.listeners.console_outputers import ConsoleOutputListener
77

8-
9-
def SolveSingleGKLS():
8+
if __name__ == "__main__":
109
"""
1110
Минимизация тестовой функции из GKLS генератора с номером 39
1211
"""
@@ -32,6 +31,3 @@ def SolveSingleGKLS():
3231
# Решение задачи
3332
solver.solve()
3433

35-
36-
if __name__ == "__main__":
37-
SolveSingleGKLS()

examples/GKLS_timeout_example.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from iOpt.solver_parametrs import SolverParameters
44
from problems.GKLS import GKLS
55

6-
7-
def SolveSingleGKLS():
6+
if __name__ == "__main__":
87
"""
98
Минимизация тестовой функции из GKLS генератора с номером 39
109
"""
@@ -25,7 +24,3 @@ def SolveSingleGKLS():
2524

2625
# Решение задачи
2726
solver.solve()
28-
29-
30-
if __name__ == "__main__":
31-
SolveSingleGKLS()

iOpt/method/calculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self,
3030
self.evaluate_method = evaluate_method
3131
self.parameters = parameters
3232
Calculator.worker_init(self.evaluate_method)
33-
Calculator.pool = _ProcessPool(parameters.number_of_parallel_points,
33+
self.pool = _ProcessPool(parameters.number_of_parallel_points,
3434
initializer=Calculator.worker_init,
3535
initargs=(self.evaluate_method,))
3636

@@ -78,7 +78,7 @@ def calculate_functionals_for_items(self, points: list[SearchDataItem]) -> list[
7878
discrete_value_index=point.get_discrete_value_index())
7979
points_copy.append(sd)
8080

81-
points_res = Calculator.pool.map(Calculator.worker, points_copy)
81+
points_res = self.pool.map(Calculator.worker, points_copy)
8282

8383
for point, point_r in zip(points, points_res):
8484
self.evaluate_method.copy_functionals(point, point_r)

0 commit comments

Comments
 (0)