Parallel pool goes idle instantly in parallel GA

23 ビュー (過去 30 日間)
Rafal Szulejko
Rafal Szulejko 2022 年 1 月 7 日
コメント済み: Rafal Szulejko 2022 年 1 月 7 日
Hello,
I am working on a project, where a fitness function of GA executes a bash script, part of which is a OpenFOAM simulation run. (on Linux, Ubuntu 20.04). Below is the fragment of code where the GA is being launched:
options = optimoptions('ga', 'UseParallel', true, 'UseVectorized', false ,'MaxGenerations', 500, 'MaxStallGenerations', 500, 'Display', 'iter', 'CreationFcn', @initialValidPopulation);
ga_values = ga(@calculate_case, ...
2*n, [], [], [], [], zeros(2*n, 1), 0.5*ones(2*n, 1), ...
[], options);
The MATLAB recognizes UseParallel flag and starts the pool automatically, the bottom left corner icon goes green for a few seconds and then goes blue signalizing it's idle. Also only one fitness function is executed. The same happens if I create a parallel pool manually.
What could be a source of this behavior?
  2 件のコメント
Matt J
Matt J 2022 年 1 月 7 日
Describe your system.
Rafal Szulejko
Rafal Szulejko 2022 年 1 月 7 日
What do you mean? It's a fresh installation of Ubuntu 20.04 with R2021b, If I remember correctly, literally the only apps installed in the system are git, Matlab, matlab-support, default-jdk and OpenFOAM v8. Hardware-wise it's a Ryzen 3900X with 32 GB of RAM.

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

採用された回答

Matt J
Matt J 2022 年 1 月 7 日
編集済み: Matt J 2022 年 1 月 7 日
It sounds like you'll need to send your code to tech support in a bug report..
As a temporary workaround, set UseVectorized to true, instead. Then, use a parfor loop within your fitness function to process each row of the population matrix.
  3 件のコメント
Matt J
Matt J 2022 年 1 月 7 日
You are welcome, but if the answer works for you, please consider Accept-clicking it.
Rafal Szulejko
Rafal Szulejko 2022 年 1 月 7 日
I quickly refactored my code to use your workaround and while a bit dirty, it is working. Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by