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

8 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by