Error using PARFOR: Index exceeds the number of array elements

14 ビュー (過去 30 日間)
Sherwin
Sherwin 2021 年 2 月 27 日
コメント済み: Walter Roberson 2021 年 2 月 27 日
Hi,
I'm using a parfor loop in my GA algorithm. After some time of running this error pops up:
Error using distcomp.remoteparfor/getCompleteIntervals
Index exceeds the number og array elements (0)
Can someone please help me fix it?
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 27 日
Does your algorithm use global variables?
Sherwin
Sherwin 2021 年 2 月 27 日
yes, it does.

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 27 日
global variables are not copied to workers when you use Parallel Computing Toolbox, and setting the variable on one worker does not affect the others.
You can in some circumstances use parpool constant. Or you can use parfevalOnAll to run an initialization function on all the workers.
  2 件のコメント
Sherwin
Sherwin 2021 年 2 月 27 日
編集済み: Sherwin 2021 年 2 月 27 日
Thank you so much for your answer, however, I guess this is a time-related issue. My GA is slow and it probably has to make more than 25000 iterations to converge. This error only came up after more than 16000 iterations which had took one and a half day of running.
Walter Roberson
Walter Roberson 2021 年 2 月 27 日
I could hypothesize that it was not until that point that one of your nonlinear constraints happened to try to access the (empty) global variable. You should rewrite to not use global variables.
I would also recommend that you put in an OutputFcn that saves the current population from time to time -- not necessarily every iteration as that could be too expensive. Enough iterations to be (say) roughly 10 minutes. Using a different file for each worker. The idea would be that if you had a failure you would be able to reconstruct a recent population and start running from that.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by