How to save GA optimization iteration data in to a file?

8 ビュー (過去 30 日間)
Harish Balaga
Harish Balaga 2013 年 1 月 22 日
編集済み: Daniel Frisch 2020 年 10 月 7 日
I use Genetic Algorithm (GA)part of the optimization toolbox for my work. The optimized values after each iteration will be displayed on the command window and a graph of the same will be updated. But i couldn't find any option to save those displayed values to a file to generate the same graph in future. I also need those values to for post processing. help me in this regard.
Is there any option to save the generated graph automatically once the optimization is over?

採用された回答

Matt J
Matt J 2013 年 1 月 22 日
  1 件のコメント
joshua Abam
joshua Abam 2019 年 6 月 25 日
Hi
I am having difficulties implimenting your response can you please help by using this example to illustrate to me how to use the output function to save every iteration of a GA to a file so I can have assese to it in the future.
function f = gaintobj(x)
f = rastriginsfcn([x(1)-6 x(2)-13]);
f = f + rastriginsfcn([x(3)-3*pi x(4)-5*pi]);
lb = [1 1 -30 -30];
ub = [20 20 70 70];
%%
% Set the integer variables and number of variables.
IntCon = [1 2];
nvar = 4;
%%
% Set options to call the custom output function, and to initially have
% little crossover.
options = optimoptions('ga','OutputFcn',@gaoutputfunround,'CrossoverFraction',0.2);
%%
% For reproducibility, set the random number generator.
rng(10)
%%
% Set the objective function and call the solver.
fun = @gaintobj;
[x,fval] = ga(fun,nvar,[],[],[],[],lb,ub,[],IntCon,options)

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

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