Я пытаюсь использовать workers
параметр дифференциальной эволюции scipy al go.
Когда я задаю его как 1, мой сценарий запускается без проблем. Если я добавлю что-то другое, произойдет сбой со следующей трассировкой:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/_lib/_util.py", line 419, in __call__
return self._mapfunc(func, iterable)
File "/usr/lib/python3.6/multiprocessing/pool.py", line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/usr/lib/python3.6/multiprocessing/pool.py", line 644, in get
raise self._value
File "/usr/lib/python3.6/multiprocessing/pool.py", line 424, in _handle_tasks
put(task)
File "/usr/lib/python3.6/multiprocessing/connection.py", line 206, in send
self._send_bytes(_ForkingPickler.dumps(obj))
File "/usr/lib/python3.6/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
TypeError: cannot serialize '_io.TextIOWrapper' object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/optimize/_differentialevolution.py", line 878, in _calculate_population_energies
parameters_pop[0:nfevs]))
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/_lib/_util.py", line 422, in __call__
raise TypeError("The map-like callable must be of the"
TypeError: The map-like callable must be of the form f(func, iterable)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main_parallel.py", line 323, in <module>
optimizer(args.asset_class, udl, tenor, args.criteria, params_decay, params, couch_server, args.num_workers)
File "main_parallel.py", line 269, in optimizer
maxiter=5, workers=num_workers, mutation=(0.5, 1.5), recombination=0.8)
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/optimize/_differentialevolution.py", line 306, in differential_evolution
ret = solver.solve()
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/optimize/_differentialevolution.py", line 745, in solve
self.population[self.feasible]))
File "/home/ubuntu/.local/lib/python3.6/site-packages/scipy/optimize/_differentialevolution.py", line 883, in _calculate_population_energies
raise RuntimeError("The map-like callable must be of the"
RuntimeError: The map-like callable must be of the form f(func, iterable), returning a sequence of numbers the same length as 'iterable'
Может кто-нибудь помочь объяснить, как использовать этот параметр (указать c целевая функция? Другие ограничения?)?
Также приветствуется пример простой python дифференциальной эволюционной оптимизации с использованием нескольких ядер.