我正在使用 SciPys integrate.ode 模块来集成一个大型 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.
所以现在我的问题是我是否可以相信并行运行的结果?或者这个 Waring 是否也适用于不同进程中的实例?
请您参考如下方法:
如果您尝试在同一个 session 中两次使用积分器,则会出现错误:
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`)
如果您在多处理环境中没有收到此错误,则假设您的结果有效似乎是合理的。
