Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
Code:
% goplotpso.m % default plotting script used in PSO functions % % this script is not a function, % it is a plugin for the main PSO routine (pso_Trelea_vectorized) % so it shares all the same variables, be careful with variable names % when making your own plugin
% Brian Birge % Rev 2.0 % 3/1/06
% setup figure, change this for your own machine clf set(gcf,'Position',[651 31 626 474]); % this is the computer dependent part %set(gcf,'Position',[743 33 853 492]); set(gcf,'Doublebuffer','on');
% particle plot, upper right subplot('position',[.7,.6,.27,.32]); set(gcf,'color','k')
plot3(pos(:,1),pos(:,D),out,'b.','Markersize',7)
hold on plot3(pbest(:,1),pbest(:,D),pbestval,'g.','Markersize',7); plot3(gbest(1),gbest(D),gbestval,'r.','Markersize',25);
% text box in lower right % doing it this way so I can format each line any way I want subplot('position',[.62,.1,.29,.4]); clear titstr if trelea==0 PSOtype = 'Common PSO'; xtraname = 'Inertia Weight : '; xtraval = num2str(iwt(length(iwt)));
elseif trelea==3 PSOtype = (['Clerc Type 1"']); xtraname = '\chi value : '; xtraval = num2str(chi);
end if isnan(errgoal) errgoalstr='Unconstrained'; else errgoalstr=num2str(errgoal); end if minmax==1 minmaxstr = ['Maximize to : ']; elseif minmax==0 minmaxstr = ['Minimize to : ']; else minmaxstr = ['Target to : ']; end
if rstflg==1 rststat1 = 'Environment Change'; rststat2 = ' '; else rststat1 = ' '; rststat2 = ' '; end
text(.1,1,[titstr{1,1},titstr{1,2}],'color','g','fontweight','bold'); hold on text(.1,.9,[titstr{2,1},titstr{2,2}],'color','m'); text(.1,.8,[titstr{3,1},titstr{3,2}],'color','m'); text(.1,.7,[titstr{4,1}],'color','w'); text(.55,.7,[titstr{4,2}],'color','m'); text(.1,.6,[titstr{5,1},titstr{5,2}],'color','m'); text(.1,.5,[titstr{6,1},titstr{6,2}],'color','w','fontweight','bold'); text(.1,.4,[titstr{7,1},titstr{7,2}],'color','r','fontweight','bold');
% if we are training a neural net, show a few more parameters if strcmp('pso_neteval',functname) % net is passed from trainpso to pso_Trelea_vectorized in case you are % wondering where that structure comes from hiddlyrstr = []; for lyrcnt=1:length(net.layers) TF{lyrcnt} = net.layers{lyrcnt}.transferFcn; Sn(lyrcnt) = net.layers{lyrcnt}.dimensions; hiddlyrstr = [hiddlyrstr,', ',TF{lyrcnt}]; end hiddlyrstr = hiddlyrstr(3:end);