For Genetic Algorithm Optimization, how to save the variables(that are optimized) in workspace for every generations and how to plot the graph for each variable value change vs no. of generation like the default bestfitness vs no. of generation???
Show older comments
the main problem that i am having is to save the values of the variables in workspace...suppose i have three variables that i am optimizing...for every generations there is a particular number of iterations...i dont need the values for each iterations..i need the optimized value for each generations...and i need to plot them...i have used the following code and i get values for each iterations and not the best value after each generation...i need to save the values for each generation in workspace...and also i need to know how to plot them... options = gaoptimset; lb= [20 8 7]; ub= [30 12 9]; rng(0, 'twister'); [xbest, fbest, exitflag,output] = ga(@simplefunction1, 3,[],[],[],[],lb,ub,[],[], options); display(xbest) display (fbest) fprintf('\n best function returned by ga = %g\n', fbest) display(x)
pls help me with saving the datas and plotting the curve...few examples would be a great help...
Answers (1)
Alan Weiss
on 29 Oct 2015
0 votes
In MATLAB documentation look at the example of a nested output function. You can write an output function for ga in a different syntax, but using the same idea.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!