How would I get Maximization curve in GA in Matlab?

12 ビュー (過去 30 日間)
SUMAN CHATTERJEE
SUMAN CHATTERJEE 2019 年 2 月 25 日
コメント済み: Mohammed Bakr 2020 年 11 月 25 日
In GA toolbox in Matlab we are getting fitness curve in form of minimization. How can I get maximization (fitness function) curve?
Can anyone help me in getting GA code for optimization?

採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 25 日
minimize the negative of the function.
[x, fvalp] = ga(@(x) -f(x), ....)
fval = -fvalp; %maximum value of the original function
  14 件のコメント
Walter Roberson
Walter Roberson 2020 年 11 月 25 日
You see in the Plot function section where you ask to plot best fitness? You would need to change that to a custom plot function that worked just like the plot function for best fitness but plotted the negative of the current value. See https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f15210
There is no built-in way to maximize values using the solver-based approach: all you can do is minimize the negative of the function and understand that what you will get out is the location of the maxima, and that you need to take the negative of any function value you get out of your @(x)-mofun(x) function in order to know what the value would be in your original @mofun space.
Mohammed Bakr
Mohammed Bakr 2020 年 11 月 25 日
thank you too much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOil, Gas & Petrochemical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by