I am having some problems with writing an output function for genetic algorithm in Matlab global optimization toolbox.
I want to create a function that stores all state.Population
(each individual) of each generation.
Here is what i know:
Output functions are functions that the genetic algorithm calls at each generation.
The output function has the following calling syntax.
[state,options,optchanged] = myfun(options,state,flag,interval)
From http://www.mathworks.com/help/releases/R2010b/toolbox/gads/f6174dfi10.html#f17837
Where state contains useful data of the current generation.
Here is what i've tried:
Create a function with a different output than [state,options,optchanged]
. The output is a global matrix that stores every state.Population
The recommended way to do this would be to use a nested output function like in the example here: http://www.mathworks.com/help/matlab/math/output-functions.html#bsgpq6q-31
Note that this example uses the calling syntax for an fminsearch output function, so you'd need to update it for a ga output function.