基于SciPy的并行ODE集成

2024-10-03 17:20:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用SciPysintegrate.ode模块来集成一个大系统(~8000个方程)。因为我总是要用不同的参数来执行这些操作,所以我使用multiprocessing模块对其进行了并行化,这似乎运行得很好。但是,SciPy的文档说明:

Warning:

This integrator is not re-entrant. You cannot have two ode instances using the “vode” integrator at the same time.

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


Tags: 模块the文档参数is系统notintegrator
1条回答
网友
1楼 · 发布于 2024-10-03 17:20:47

如果在同一会话中两次尝试使用integrator,则会出现错误:

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`)

如果在多处理环境中没有得到这个错误,那么可以合理地假设您的结果是有效的。在

相关问题 更多 >