Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: plot genetic algorithm output
Replies: 2   Last Post: Jun 7, 2013 5:34 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alan Weiss

Posts: 1,255
Registered: 11/27/08
Re: plot genetic algorithm output
Posted: Jun 7, 2013 3:24 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 6/7/2013 2:31 PM, mado wrote:
> how to plot X or Kp against the number of generations on y axis ?
>
> clc
> clear
> %initialize genetic
> %___________________________________
> nvar=2;
> FitnessFcn = @PID_objfun_ITAE
> LB=[4 2 ];UB=[50 80 ];
> options = gaoptimset;
> options=gaoptimset(options,'populationsize',30,'Generations',6,'SelectionFcn',
> @selectionroulette) %options = gaoptimset(options,'InitialPop',
> final_pop); % to improve search
> options = gaoptimset(options,'MutationFcn' ,{ @mutationuniform 0.001 });
> options = gaoptimset(options,'CrossoverFcn',@crossoverarithmetic);
> options = gaoptimset(options,'PopInitRange' ,[4 2 ;50 80 ]);% bounds
> for ITAE
> %options = gaoptimset(options,'PopInitRange' ,[3 2 0;12 15
> 5]);%bounds for MSE
> options = gaoptimset(options,'PlotFcns', { @gaplotbestf
> @gaplotbestindiv });
>
> %start algorithm
> %______________________________________
> [x,fval,exitflag,output,final_pop]=ga(FitnessFcn,nvar,[],[],[],[],LB,UB,[],options)
>
> fprintf('Genetic Algorithm values :KP = %7.5f;KI = %7.4f ',x(1),x(2) )


You can write a custom plot function to plot whatever you like:
http://www.mathworks.com/help/gads/genetic-algorithm-options.html#f15210

Here is an example:
http://www.mathworks.com/help/gads/creating-a-custom-plot-function.html

Alan Weiss
MATLAB mathematical toolbox documentation



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.