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

16 visualizaciones (últimos 30 días)
Harish Balaga
Harish Balaga el 22 de En. de 2013
Editada: Daniel Frisch el 7 de Oct. de 2020
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?

Respuesta aceptada

Matt J
Matt J el 22 de En. de 2013
  1 comentario
joshua Abam
joshua Abam el 25 de Jun. de 2019
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)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by