230 <strong>MATLAB</strong> CODE prob=((phmone(st,nxt).^a).*(vis(st,nxt).^b)). sum((phmone(st,nxt).^a).*(vis(st,nxt).^b)); rcity=rand; for iz=1:length(prob) if rcity
[tour,dist] figure(1) plot(xcity(tour(ind,:)),ycity(tour(ind,:)),xcity,ycity,’ o’) axis square figure(2);plot([1:maxit],dd(:,1),[1:maxit],dd(:,2),’–’) PROGRAM 9: TEST FUNCTIONS % Test functions for optimization % These are the test functions that appear in Appendix I. % Set funnum to the function you want to use. % funnum=17 is for a MOO function % Haupt & Haupt % 2003 function f=testfunction(x) funnum=16; PROGRAM 9: TEST FUNCTIONS 231 if funnum==1 %F1 f=abs(x)+cos(x); elseif funnum==2 %F2 f=abs(x)+sin(x); elseif funnum==3 %F3 f=x(:,1).^2+x(:,2).^2; elseif funnum==4 %F4 f=100*(x(:,2).^2-x(:,1)).^2+(1-x(:,1)).^2; elseif funnum==5 %F5 f(:,1)=sum(abs(x’)-10*cos(sqrt(abs(10*x’))))’; elseif funnum==6 %F6 f=(x.^2+x).*cos(x); elseif funnum==7 %F7 f=x(:,1).*sin(4*x(:,1))+1.1*x(:,2).*sin(2*x(:,2)); elseif funnum==8 %F8 f=x(:,2).*sin(4*x(:,1))+1.1*x(:,1).*sin(2*x(:,2)); elseif funnum==9 %F9 f(:,1)=x(:,1).^4+2*x(:,2).^4+randn(length(x(:,1)),1); elseif funnum==10 %F10 f(:,1)=20+sum(x’.^2-10*cos(2*pi*x’))’; elseif funnum==11 %F11 f(:,1)=1+sum(abs(x’).^2/4000)’-prod(cos(x’))’;