问题描述
我正在尝试使用 python/pyfmi 和多处理并行模拟多个 Modelica FMU.但是,一旦 FMU 被初始化,我就无法从子进程返回任何 pyfmi FMI 对象.似乎 pyfmi FMI 对象(例如 pyfmi.fmi.FMUModelCS2 或 pyfmi.fmi.FMUState2)不可选择.我也试过用莳萝腌制,这对我不起作用.使用莳萝,对象是可腌制的,这意味着没有错误,但如果我之后尝试重新加载它们,就会以某种方式损坏.有谁知道如何解决这个问题?谢谢!
I am trying to simulate multiple Modelica FMUs in parallel using python/pyfmi and multiprocessing. However I am not able to return any pyfmi FMI objects from the subprocesses once the FMUs are initialized. It seems that pyfmi FMI objects (e.g. pyfmi.fmi.FMUModelCS2 or pyfmi.fmi.FMUState2) are not pickable. I also tried dill to pickle, which doesn't work for me eather. With dill the objects are picklable though, meaning no error, but somehow corrupted if I try to reload them afterwards. Does anyone have an idea of how to solve this issue? Thanks!
推荐答案
我在创建 EstimationPy 时遇到了类似的问题.我最终创建了一个包装器,用于使用多个进程运行同一 FMU 的并行仿真.
I faced a similar problem when I created EstimationPy. I ended up creating a wrapper for running parallel simulation of the same FMU using multiple processes.
我建议你看这里的实现https://github.com/lbl-srg/EstimationPy/blob/master/estimationpy/fmu_utils/fmu_pool.py
对于示例 http:///lbl-srg.github.io/EstimationPy/modules/examples/first_order.html#run-multiple-simulations
这篇关于使用 pyfmi 和多处理模拟 Modelica FMU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!