diff --git a/examples/GKLS_example.py b/examples/GKLS_example.py index f762348..dce7144 100644 --- a/examples/GKLS_example.py +++ b/examples/GKLS_example.py @@ -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 """ @@ -32,6 +31,3 @@ def SolveSingleGKLS(): # Решение задачи solver.solve() - -if __name__ == "__main__": - SolveSingleGKLS() diff --git a/examples/GKLS_timeout_example.py b/examples/GKLS_timeout_example.py index 98a209c..ba04546 100644 --- a/examples/GKLS_timeout_example.py +++ b/examples/GKLS_timeout_example.py @@ -3,8 +3,7 @@ from iOpt.solver_parametrs import SolverParameters from problems.GKLS import GKLS - -def SolveSingleGKLS(): +if __name__ == "__main__": """ Минимизация тестовой функции из GKLS генератора с номером 39 """ @@ -25,7 +24,3 @@ def SolveSingleGKLS(): # Решение задачи solver.solve() - - -if __name__ == "__main__": - SolveSingleGKLS() diff --git a/iOpt/method/calculator.py b/iOpt/method/calculator.py index 49980df..581d402 100644 --- a/iOpt/method/calculator.py +++ b/iOpt/method/calculator.py @@ -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,)) @@ -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)