how to use 'OutputFcn' in GA
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear All,
I'm trying to use the next function to find some information about previous generation and I found difficulty with writing the state and the options
options = gaoptimset('OutputFcn', @outputfun);
[state,options,optchanged] = outputfun(options,state,flag)
I have this code which is work,
function [x,fval,exitflag,output,population,score] = optimGA(nvars,lb,PopulationSize_Data,Generations_Data,TolFun_Data,InitialPopulation_Data)
%%This is an auto generated MATLAB file from Optimization Tool.
could you please explain to me how to write it. or you may have better idea
Thank you in advance
0 commentaires
Réponses (1)
Alan Weiss
le 27 Août 2014
GA will pass in options, state, and flag. You should pass those exact same options and state to the output function output arguments, and set optchanged to false, unless for some reason you want to change the options during your output function call. See the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation
2 commentaires
Alan Weiss
le 27 Août 2014
function[state,options,optchanged] = outputfun(options, state, flag)
optchanged = false;
% DO NOT set options, state, or flag!
% Just write code to calculate whatever it is you want here.
% If you need to read an option, then read it, don't set it.
% Make sure that your options include @outputfun as your output function.
Alan Weiss
MATLAB mathematical toolbox documentation
Voir également
Catégories
En savoir plus sur Whos 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!