How to save GA optimization iteration data in to a file?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Harish Balaga
le 22 Jan 2013
Modifié(e) : Daniel Frisch
le 7 Oct 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?
1 commentaire
Réponse acceptée
Matt J
le 22 Jan 2013
An Output Function is probably what you need
1 commentaire
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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!