|
ah great thanks.
"Donn Shull" <donn.shull.no_spam@aetoolbox.com> wrote in message <g9ub86$kjp$1@fred.mathworks.com>...
> Try following your plot statement with a drawnow statement.
>
> Donn
>
> "Dave Brackett" <davebrackett@hotmail.com> wrote in message <g9uald$ekt$1@fred.mathworks.com>...
> > I have a ga which is hybridised with fminunc:
> >
> > hybrid_options=optimset('OutputFcn',@fminuncOut,'Display','iter','MaxFunEvals',1000,'MaxIter',1000,'TolFun',1e-6,'TolX',1e-6);
> >
> > options=gaoptimset('HybridFcn',{@fminunc,hybrid_options},'UseParallel','always','PopInitRange',variable_range,'PopulationSize',25,'CrossoverFraction',0.5,'Generations',10,'StallGenLimit',50,'StallTimeLimit',40,'SelectionFcn',@selectionstochunif,'MutationFcn',{@mutationuniform,0.7},'CrossoverFcn',@crossoverscattered,'PlotFcns',@gaplotbestf},'PlotInterval',1);
> >
> > [x,fval,exitflag,output,final_pop]=ga(fitness_fcn,no_variables,[],[],[],[],lower_bound,upper_bound,[],options);
> >
> >
> > I have used fminuncOut.m as an output function from the matlab ga toolbox webinar with this intention of getting this:
> > http://www.mathworks.com/company/newsletters/digest/sept04/images/results5b_wl.jpg
> >
> > This then produces a plot of the GA history followed by the fminunc history. However, it only updates the figure once the optimisation has ended whereas I want it to update after each iteration. Does anyone know how I can make it do so? Thanks.
> >
> >
> > fminuncOut.m consists of the following code (with the annotation part removed):
> >
> > function stop = fminuncOut(x,optimvalues,state)
> >
> > persistent fig gaIter
> > stop = false;
> >
> > switch state
> >
> > case 'init'
> > fig = findobj(0,'type','figure','name','Genetic Algorithm');
> > limits = get(gca,'XLim');
> > gaIter = limits(2);
> > hold on;
> > case 'iter'
> > set(gca,'Xlim', [1 optimvalues.iteration + gaIter]);
> > fval = optimvalues.fval;
> > iter = gaIter + optimvalues.iteration;
> > plot(iter,fval,'dr')
> > title(['Best function value: ',num2str(fval)],'interp','none')
> > case 'done'
> > fval = optimvalues.fval;
> > iter = gaIter + optimvalues.iteration;
> > hold off
> > end
> >
> >
>
|