Parallel ODE solve using parfor-loop

12 ビュー (過去 30 日間)
Danila Zharenkov
Danila Zharenkov 2013 年 5 月 11 日
Hello, I've got the ODE system and want to solve it using the cluster. I've been trying to use parfor-loop, but the initial condition must be changed for every new call of ode-solver. And the results I received isn't correct. Maybe there are some build-in tools for such problem? Here is my attemp to parallel ode solving
parfor i=1:100
[T,X]=ode45(@rightpart,[i*500-499 i*500],X0,options);
%each worker will calculate values for T from 1-500,501-1000 and so on
Tt=cat(1,Tt,T);
Xt=cat(1,Xt,X);
%here I accumulate final value vectors
end
  1 件のコメント
Ryan G
Ryan G 2013 年 5 月 13 日
PARFOR works by sending independent calls of the loop to each member of the pool. If your next call to the solver is dependent on a previous call, this will not work.
The cat function here will randomly order the data based on whenever the next iteration comes in. I would recommend indexing here instead.

サインインしてコメントする。

採用された回答

Jan
Jan 2013 年 5 月 14 日
Do all integrations start at the same X0? If not, is the final value of the former integration the initial value of the current interval? If so, the job cannot be parallelized.
As Pyan G has explained in his comment, concatenating the output inside the PARFOR loop will cause a random order: The output depends on the exact timining of the single jobs. This could be fixed by storing the partial results in a cell like C{i}.
  1 件のコメント
Danila Zharenkov
Danila Zharenkov 2013 年 5 月 17 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by