【问题标题】:Parallel ODE integration using SciPy使用 SciPy 进行并行 ODE 集成
【发布时间】:2017-10-06 06:35:00
【问题描述】:

我正在使用 SciPys integrate.ode 模块来集成 ODE 的大型系统(约 8000 个方程)。因为我总是需要用不同的参数做几个,所以我使用multiprocessing 模块将它并行化,这似乎工作正常。但是,SciPy 的文档说:

警告:

此集成商不可重入。您不能同时使用“vode”积分器有两个 ode 实例。

所以现在我的问题是我是否可以相信并行运行的结果?或者这个Waring是否也适用于不同进程中的实例?

【问题讨论】:

  • 同时很可能适用于同一个 Python 会话。如果您在两个单独的会话中启动脚本两次,则它们之间不应有任何交互。这也是多处理中发生的情况;每个进程运行它自己的解释器。所以我认为你是安全的,但多做一些研究不会有什么坏处。
  • 使用multiprocessing 很好。例如,请参阅stackoverflow.com/questions/34291639/…

标签: python parallel-processing scipy integrator


【解决方案1】:

如果您尝试在同一会话中使用积分器两次,则会收到错误:

from scipy.integrate import ode

f = lambda x: x

a = ode(f)
b = ode(f)

a.set_integrator('vode')
b.set_integrator('vode')

a.integrate(0.1)
b.integrate(0.1)
a.integrate(0.1)

# IntegratorConcurrencyError: Integrator `vode` can be used to 
# solve only a single problem at a time. If you want to integrate 
# multiple problems, consider using a different integrator 
# (see `ode.set_integrator`)

如果您在多处理环境中没有收到此错误,那么假设您的结果是有效的似乎是合理的。

【讨论】:

    猜你喜欢
    • 2013-06-03
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    • 2014-09-07
    相关资源
    最近更新 更多