function y=funcion(d)
y=(2*(pi*(d(1)^2)/4))+(d(2)*(pi*(d(3)^2)/4))
%d(1)=[ 6 8 10 12], d(3)=[ 6 8 10 12], round(d(2))
y=570;
end
fit=@(d)funcion(d)
nvars=3;
[d,fval]=ga(fit,nvars)
How to solve a function through ga algortihm, if you have 3 variables, and two of them must be choosen between the numbers of a vector, and the third variable must be entire number?

 採用された回答

Stephan
Stephan 2019 年 2 月 12 日

0 投票

Hi,
check this example in the documentation:
It is about integer variables and in the second section there is shown how to choose values for variables from a vector of given discrete values.
Best regards
Stephan

2 件のコメント

J.J
J.J 2019 年 2 月 12 日
Thanks, but I don't understand how to write it in options of ga, the way to choose values for variables from a vector, in other words, I don't understand how I must write the function, because for example d(1) and d(3) must be choosen between [6 8 10 12] and d(2) must be an entire number, and with these features y must be near to 570.
How can I do it this?
Thank you.
Stephan
Stephan 2019 年 2 月 12 日

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

J.J
2019 年 2 月 12 日

コメント済み:

2019 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by