フィルターのクリア

Vectorizing the fitness function of a genetic algorithm

1 回表示 (過去 30 日間)
Atamert Arslan
Atamert Arslan 2017 年 4 月 1 日
編集済み: Stephen23 2017 年 4 月 9 日
Dear MATLAB Community,
I am currently trying to solve a binary nonlinear problem through ga, but it just takes too long. I came across the following page (see vectorize for speed): https://www.mathworks.com/help/gads/vectorizing-the-fitness-function.html
I understand the logic, however; I have 6210 dimensions in the decision vector and I was wondering if there was another way to write the function in detail as expressed on that page.
My fitness function currently looks as follows:
A = abs(X-X_Stern);
y = c*A';
where X, X_Stern and c are vectors (1x6210).
Is there a way to vectorize for speed without having to write in open format?
I appreciate your time and answer.

採用された回答

Carl
Carl 2017 年 4 月 4 日
編集済み: Carl 2017 年 4 月 4 日
Hi Atamert, I believe the way you have it structured now should work fine. If pop is the population size, the input to your fitness function will be popx6210. The output of that calculation is a vector of length pop, which is what's required from a vectorized fitness function.
  1 件のコメント
Atamert Arslan
Atamert Arslan 2017 年 4 月 8 日
Thanks for the answer Carl! I had to convert the vectors into matrix depending on the size of the matrix ga each time passes (sometimes it indeed passes only a row vector and not a matrix for the whole population) so I implemented it dynamically and it works now!

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

その他の回答 (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