How to evaluate individual once at a time when using GA with parallel processing?

Hi, I'm doing a research using GA with parallel processing. I print out the variable everytime when the objective function is evaluated. I found out that sometimes the objective function took 2 sets of variables as the input argument. For example, I have a problem with 12 variables, and the command window will show:
Is there any way to make the objective function takes 1 set of variables as the input argument at a time?

 採用された回答

Matt J
Matt J 2023 年 3 月 20 日
編集済み: Matt J 2023 年 3 月 21 日

0 投票

The objective function will always evaluate one point at a time unless you are using the UseVectorized option.
As for your screen display, it is merely giving the illusion that a single call to the objective is processing more (or in some cases less!) than one point. Because the objective function calls are running in parallel, commands to print things to the screen are fulfilled in an unpredictable order.

1 件のコメント

Arthur Teng
Arthur Teng 2023 年 3 月 21 日
Really appreciate that, Matt. I found out the real problem is that I use some global variables as fixed parameters in the objective function and it seems to cause some sort of trouble when using parallel processing. I fixed it by turning all global variables into local ones.
Your answer still helps me, thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2023 年 3 月 20 日

編集済み:

2023 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by