Recover the best individual of each population in GA

9 ビュー (過去 30 日間)
Jaime Trivino
Jaime Trivino 2022 年 6 月 29 日
回答済み: Sam Chak 2022 年 6 月 29 日
The documentation ga doc especifies that the output arguments consider the final population only. Is there a way to recover the best individual of each generation?

採用された回答

Sam Chak
Sam Chak 2022 年 6 月 29 日
Yes, @Jaime Trivino, it is possible according to this section.
state.Score % gives you the scores of the current population
state.Best % gives you the vector containing the best score in each generation
To do this, 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 m-file 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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by