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

7 vues (au cours des 30 derniers jours)
Harish Balaga
Harish Balaga le 22 Jan 2013
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?

Réponse acceptée

Matt J
Matt J le 22 Jan 2013
  1 commentaire
joshua Abam
joshua Abam le 25 Juin 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)

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by