Skip to content

Commit

Permalink
Fixed a bug in the calculator destructor (#168)
Browse files Browse the repository at this point in the history
* Fixed a bug in the calculator destructor

* Fixed problem with process pool destruction

* The design of the example is brought to a single sample
  • Loading branch information
LebedevIlyaG committed Nov 16, 2023
1 parent 46afc77 commit 17d4e58
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
6 changes: 1 addition & 5 deletions examples/GKLS_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from iOpt.output_system.listeners.static_painters import StaticPainterNDListener
from iOpt.output_system.listeners.console_outputers import ConsoleOutputListener


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


if __name__ == "__main__":
SolveSingleGKLS()
7 changes: 1 addition & 6 deletions examples/GKLS_timeout_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from iOpt.solver_parametrs import SolverParameters
from problems.GKLS import GKLS


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

# Решение задачи
solver.solve()


if __name__ == "__main__":
SolveSingleGKLS()
4 changes: 2 additions & 2 deletions iOpt/method/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self,
self.evaluate_method = evaluate_method
self.parameters = parameters
Calculator.worker_init(self.evaluate_method)
Calculator.pool = _ProcessPool(parameters.number_of_parallel_points,
self.pool = _ProcessPool(parameters.number_of_parallel_points,
initializer=Calculator.worker_init,
initargs=(self.evaluate_method,))

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

points_res = Calculator.pool.map(Calculator.worker, points_copy)
points_res = self.pool.map(Calculator.worker, points_copy)

for point, point_r in zip(points, points_res):
self.evaluate_method.copy_functionals(point, point_r)
Expand Down

0 comments on commit 17d4e58

Please sign in to comment.