How does genetic algorithm derive the best fitness and average fitness values for each generation?

2 ビュー (過去 30 日間)
My Matlab version is R2021a. The help give the sample function is
The output parameters do not have fitness for each generation.
It gives the fitness in figure, but I want know the values.

採用された回答

Sam Chak
Sam Chak 2022 年 6 月 23 日
The output here in the "Output Argument", only gives basic information about the optimization process returned as a structure.
If you want to evaluate the fitness for each generation, then you must call the OutputFcn through specifying it the option
option = optimoptions('ga', 'OutputFcn', @gaoutfun)
[x, fval, exitflag, output] = ga(fun, nvars, A, b, Aeq, beq, lb, ub, nonlcon, options)
and then create the ga output function that must have the following calling syntax:
function [state, options, optchanged] = gaoutfun(options, state, flag)
% See example here:
% https://www.mathworks.com/help/gads/custom-output-function-for-genetic-algorithm.html
end
You have a lot of options to choose from the state structure for ga information about the current generation. Click here to see:
  2 件のコメント
Time N
Time N 2022 年 6 月 26 日
Thanks for your solution. It is helpful.
Sam Chak
Sam Chak 2022 年 6 月 27 日
You're welcome, @Time N. Good to know that it helps.

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

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