I'm trying to minimise my __optimisation_function
in parallel setting workers=-1
when calling differential_evolution
with scipy=1.10.1 and Python 3.9.7 (macOS Ventura 13.4), but I'm getting the error below.
Any idea how to make this work in parallel?
df_1
and df_2
are pandas DataFrames.
Removing the workers=-1
from differential_evolution
make it work just fine.
from scipy.optimize import differential_evolution
class Optimisation():
def __optimisation_function(self, x, *args) -> float:
a, b, c, d, e = x
df_1 = args[0]
df_2 = args[1]
return something
def run_optimisation(self):
optimisation_result = differential_evolution(
func=self.__optimisation_function,
bounds=bounds,
constraints=constraints,
args=(df_1, df_2),
workers=-1
)
Error
.../python3.9/site-packages/scipy/optimize/_differentialevolution.py:382: UserWarning: differential_evolution: the 'workers' keyword has overridden updating='immediate' to updating='deferred'
with DifferentialEvolutionSolver(func, bounds, args=args,
Process SpawnPoolWorker-2:
Traceback (most recent call last):
File ".../python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File ".../python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File ".../python3.9/multiprocessing/pool.py", line 114, in worker
task = get()
File ".../python3.9/multiprocessing/queues.py", line 368, in get
return _ForkingPickler.loads(res)
AttributeError: 'Optimisation' object has no attribute '__optimisation_function'
Process SpawnPoolWorker-1:
Traceback (most recent call last):
File ".../python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File ".../python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File ".../python3.9/multiprocessing/pool.py", line 114, in worker
task = get()
File ".../python3.9/multiprocessing/queues.py", line 368, in get
return _ForkingPickler.loads(res)
AttributeError: 'Optimisation' object has no attribute '__optimisation_function'