nested parallel optimization and parfor loops
1 回表示 (過去 30 日間)
古いコメントを表示
I would like to run a code having this structure:
Parallel Optimization 1(Particle swarm):
--- Par for loop (length ~ 20):
--- --- Parallel Optimization 2(Particle swarm)
--- calculate a cost function based on the 20 results of the parfor loop and use it in the Parallel Optimization 1
Is it possible to connect to a cluster and make a such complicated nested parallel compuitation?
I am doing this:
Par for loop
Parallel Optimization 2(Particle swarm)
on my computer for now but i am not sure the particle swarms actually works in parallel.
Please tell me if it is doable. Thank you.
0 件のコメント
回答 (1 件)
Walter Roberson
2024 年 8 月 26 日
If you specify the UseParallel option as true, then https://www.mathworks.com/help/gads/particle-swarm-options.html#bued1yt-1 calculations will be carried out using parallel processing -- parfor.
Within a parfor worker, parfor (and other parallel requests such as parfeval) are carried out in serial.
It is not possible to parfor within a parfor. (Well, it is possible, but the inner parfor will be executed in serial.)
Note that if you do not specify UseParallel, and instead specify UseVectorized then "Your objective function should accept an M-by-N matrix, where each row represents one particle, and return an M-by-1 vector of objective function values.". Your code might potentially use parfor during handling of that M-by-N matrix.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!