【发布时间】:2022-01-05 16:56:51
【问题描述】:
我想同时使用不同的随机种子运行模拟。运行模拟的顺序代码是:
def run_multiple_simulations(n=10,T=T,p=p):
A,B,C,D,E=[],[],[],[],[]
for i in range(n):
a,b,c,d,e= do_simulation(T,p=p,seed=i)
A.append([a])
B.append([b])
C.append([c])
D.append([d])
E.append([e])
return A,B,C,D,E
有没有办法像run_multiple_simulations() 的返回语句那样得到结果(a,b,c,d 和 e 是数组)。
【问题讨论】:
-
请添加最低可运行代码和您的预期结果。
-
是的,这是可能的。签出 joblib 或 multiprocessing 模块,但为了帮助您,我们将需要一个最小的代码示例来重现该行为!只为一个模拟编写一个片段,给它一个 id 值并将其放入多处理中!
标签: python multithreading multiprocessing return