python中的并行/多线程差分进化 [英] parallel/multithread differential evolution in python

查看:300
本文介绍了python中的并行/多线程差分进化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对生化过程进行建模,并且将我的问题构造为一个优化问题,我可以使用scipy中的differential_evolution来解决.
到目前为止,一切都很好,我非常满意使用15-19个参数的简化模型的实现.
我扩展了模型,现在带有32个参数的模型花费的时间太长了.并非完全出乎意料,但仍然是一个问题,因此是个问题.

I'm trying to model a biochemical process, and I structured my question as an optimization problem, that I solve using differential_evolution from scipy.
So far, so good, I'm pretty happy with the implementation of a simplified model with 15-19 parameters.
I expanded the model and now, with 32 parameters, is taking way too long. Not totally unexpected, but still an issue, hence the question.

我看过:
-关于R 并行差分进化
-和github问题 https://github.com/scipy/scipy/issues/4864关于主题

I've seen:
- an almost identical question for R Parallel differential evolution
- and a github issue https://github.com/scipy/scipy/issues/4864 on the topic

但是它希望保留在python中(该模型在python管道中),尽管提出了一些选择,但是pull请求尚未导致并正式接受解决方案.

but it would like to stay in python (the model is within a python pipeline), and the pull request did not lead to and officially accepted solution yet, although some options have been suggested.

此外,我无法并行化要优化的函数中的代码,因为这是一系列顺序计算,每个计算都需要上一步的结果.理想的选择是拥有可以并行评估某些个体并将其返回给总体的东西.

Also, I can't parallelize the code within the function to be optimised because is a series of sequential calculations each requiring the result of the previous step. The ideal option would be to have something that evaluates some individuals in parallel and return them to the population.

总结:
-scipy中是否有任何选项可以并行化我愚蠢忽略的differential_evolution? (理想的解决方案)
-是否建议在scipy中使用一种替代算法,该算法在串行方式上(方式)更快,或者可以并行化?
-是否有其他好的程序包可以提供并行化的差分演化功能?还是其他适用的优化方法?
-健全性检查:我是否要用32参数重载DE,我需要从根本上改变方法?

Summing up:
- Is there any option within scipy that allows parallelization of differential_evolution that I dumbly overlooked? (Ideal solution)
- Is there a suggestion for an alternative algorithm in scipy that is either (way) faster in serial or possible to parallelize?
- Is there any other good package that offers parallelized differential evolution funtions? Or other applicable optimization methods?
- Sanity check: am I overloading DE with 32 parameter and I need to radically change approach?

PS
我是一名生物学家,正规的数学/统计学并不是我真正的强项,任何将公式转换为英语的翻译都将受到极大的欢迎:)

PS
I'm a biologist, formal math/statistics isn't really my strenght, any formula-to-english translation would be hugely appreciated :)

PPS
作为一种极端的选择,我可以尝试迁移到R,但是我不能编写C/C ++或其他语言的代码.

PPS
As an extreme option I could try to migrate to R, but I can't code C/C++ or other languages.

推荐答案

感谢@ jp2011指向pygmo

Thanks to @jp2011 for pointing to pygmo

首先,值得注意的是与pygmo 1的区别,因为google上的拳头链接仍然指向较旧的版本.

First, worth noting the difference from pygmo 1, since the fist link on google still directs to the older version.

第二个多处理岛仅适用于python 3.4 +

Second, Multiprocessing island are available only for python 3.4+

第三,有效.当我第一次提出问题时,我开始的过程仍在运行,而pygmo群岛在不到3小时的时间内对saDE中存在的所有18种可能的DE变异进行了广泛的测试.如此处可能会更早完成.开头语.

Third, it works. The processes I started when I first asked the question are still running while I write, the pygmo archipelago running an extensive test of all the 18 possible DE variations present in saDE made in less than 3h. The compiled version using Numba as suggested here https://esa.github.io/pagmo2/docs/python/tutorials/coding_udp_simple.html will probably finish even earlier. Chapeau.

鉴于需要建立一个新类(相对于scipy中的signle函数)来定义问题,我个人认为它不如scipy版本直观,但可能只是个人喜好.同样,对突变/交叉参数的定义也不太清楚,对于初次接触DE的人来说可能有点晦涩难懂.
但是,由于scipy中的串行DE不能满足要求,因此欢迎pygmo(2).

I personally find it a bit less intuitive than the scipy version, given the need to build a new class (vs a signle function in scipy) to define the problem but is probably just a personal preference. Also, the mutation/crossing over parameters are defined less clearly, for someone approaching DE for the first time might be a bit obscure.
But, since serial DE in scipy just isn't cutting it, welcome pygmo(2).

此外,我还发现了其他一些声称可以并行化DE的选项.我自己没有对它们进行测试,但是对于在此问题上绊脚石的人可能有用.

Additionally I found a couple other options claiming to parallelize DE. I didn't test them myself, but might be useful to someone stumbling on this question.

鸭嘴兽,专注于多目标进化算法 https://github.com/Project-Platypus/Platypus

Platypus, focused on multiobjective evolutionary algorithms https://github.com/Project-Platypus/Platypus

Yabox
https://github.com/pablormier/yabox

Yabox
https://github.com/pablormier/yabox

关于DE的详细但恕我直言的清晰解释 https://pablormier.github .io/2017/09/05/a-tutorial-on-differential-evolution-with-python/

from Yabox creator a detailed, yet IMHO crystal clear, explaination of DE https://pablormier.github.io/2017/09/05/a-tutorial-on-differential-evolution-with-python/

这篇关于python中的并行/多线程差分进化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆