Swarm intelligence optimization algorithm test function matlab source code
Global M;creatematrix (2);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing Ackley Picture. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ackley x from[-5 5]% x=-5:0.01:5;% [X,y]=meshgrid (x);% temp1=x.^2+y.^2;% temp2= cos (2*pi*x) +cos (2*pi*y),% z=20+exp (1) -20*exp ( -0.2*SQRT (TEMP1/2))-exp (TEMP2/2);% axis ([ -5,5,-5,5]);% MESHC (x, y, z); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw the Ackley diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated Ackley x from[-5 5% x=-5:0.01:5;% [X,y]=meshgrid (x);% for i=1:size (x,1)% For J=1:size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% temp1=x.^2+y.^2;% Temp2=cos (2*pi *x) +cos (2*pi*y),% z=20+exp (1) -20*exp ( -0.2*SQRT (TEMP1/2))-exp (TEMP2/2);% axis ([ -5,5,-5,5]);% MESHC (x, y, z);%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Drawing cigar picture. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cigarx=-5:0.01:5; [X,y]=meshgrid (x); z=x.^2+ (10^4) *y.^2;axis ([ -5,5,-5,5]); MESHC (z/y);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Draw a cigar diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated cigar x from [-5 5]% x=-7:0.01:7;% [X,y]=meshgrid (x);% for I=1:size (x,1)% for J=1:size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% z=x.^2+ (10^4) *y.^2;% axis ([ -7,7 , -7,7]);% MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing ellipse. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ellipse x from [ -5-5]% x=-5:0.01:5;% [X,y]=meshgrid (x);% z=x.^2+10.^4* (y.^2);% Axis ([ -5,5,-5,5]); MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing Griewangk. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%griewangk% x=-600:1:600;% [X,y]=meshgrid (x);% temp1= (x.^2+y.^2)/4000;% temp2= cos (x) *cos (Y/SQRT (2)),% z=temp1-temp2+1;% axis ([ -600,600,-600,600]),% MESHC (z/y);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%% draw the Griewangk diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated griewangk% x=-600:1:600;% [X,y]=meshgrid (x);% for i=1:size (x,1)% for j=1 : Size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% temp1= (x.^2+y.^2)/4000;% temp2=cos (x) * Cos (Y/SQRT (2));% z=temp1-temp2+1;% axis ([ -600,600,-600,600]);% MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Painting Nocon_rastrigIn figure. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%nocon_rastrigin% x=-10:0.05:10;% [X,y]=meshgrid (x);% temp1=0;% temp2=0;% z=0;% If ABS (x) <1/2% temp1=x;% else% temp1=round (2.*x)/2;% end% if abs (y) <1/2% temp2=y;% else% temp2=round (2.*y)/2;% end% Z=z+temp1.^2-10*cos (2*PI.*TEMP1) +temp2.^2-10*cos (2*PI.*TEMP2) +20;% axis ([ -10,10,-10,10]);% MESHC (x, y, z);%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw the Nocon_rastrigin diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated nocon_rastrigin% x=-15:0.05:15;% [X,y]=meshgrid (x);% for I=1:size (x,1) % for J=1:size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% temp1=0;% temp2=0;% z=0;% if ABS (x ) <1/2% temp1=x;% else% temp1=round (2.*x)/2;% end% if abs (y) <1/2% temp2=y;% else% temp2=round (2.*y)/2;% end% Z=z+tem P1.^2-10*cos (2*PI.*TEMP1) +temp2.^2-10*cos (2*PI.*TEMP2) +20;% axis ([ -15,15,-15,15]);% MESHC (x, y, z);%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%% drawing Rastrigin picture. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rastrigin% x=-10:0.05:10;% [X,y]=meshgrid (x);% temp1=x.^2-10*cos (2*pi.*x);% Temp2=y.^2-10*cos (2*pi.*y);% z=temp1+temp2+20;% axis ([ -10,10,-10,10]); MESHC (x, y, z);%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw the Rastrigin diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated rastrigin% x=-15:0.05:15;% [X,y]=meshgrid (x);% for i=1:size (x,1)% for j= 1:size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% temp1=x.^2-10*cos (2*pi.*x);% temp2=y. ^2-10*cos (2*pi.*y);% z=temp1+temp2+20;% axis ([ -15,15,-15,15]);% MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Draw Rosenbrock Chart. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rosenbrock% x=-10:0.05:10;% [X,y]=meshgrid (x);% z=100* (y-x.^2). ^2+ (x-1). ^2;% Axis ([ -10,10,-10,10]); MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing Schwefel. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%schwefel% x=-10:0.05:10;% [X,y]=meshgrid (x);% z= (x-x.^2). ^2+ (x-1). ^2+ (x-y.^2 ). ^2+ (y-1). ^2;% axis ([ -10,10,-10,10]),% MESHC (x, Y, z),%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing rotated Schwefel diagram. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated schwefel% x=-15:0.05:15;% [X,y]=meshgrid (x);% for i=1:size (x,1)% for j=1:size (y,1)% p=[x (i,j), Y (i,j)] ';% x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) * p;% end% end% z= (x-x.^2). ^2+ (x-1). ^2+ (x-y.^2) ^2+ (y-1). ^2;% axis ([ -15,15,-15,15]); MESHC (x, y, z);%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% Drawing sphere picture. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%sphere% x=-10:0.05:10;% [X,y]=meshgrid (x);% z=x.^2+y.^2;% axis ([ -10,10,-10,10 ]);% MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing Sumcan. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%sumcan% x=-0.16:0.0005:0.16;% [X,y]=meshgrid (x);% z=1./(10.^ ( -5) +abs (x) +abs ( x+y));% z=log10 (z);% axis ([ -0.16,0.16,-0.16,0.16]);% mesh (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw a tablet chart. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%tablet% x=-10:0.05:10;% [X,y]=meshgrid (x);% z=10.^4*x.^2+y.^2;% axis ([ -10,10, -10,10]);% mesh (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drawing Weierstrass. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%weierstrass% x=-1:0.005:1;% [X,y]=meshgrid (x);% z=0;% for k=0:20% Z=z+0.5^k*cos (2*pi*3^k* (x+0.5)) +0.5^k*cos (2*pi*3^k* (y+0.5));% end% temp=0;% for k=0:20% Temp=temp+0.5^k*cos (2*pi*3^k*0.5);% end% z=z-2*temp;% axis ([ -1,1,-1,1]);% MESHC (x, y, z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% the Weierstrass diagram of the rotation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%rotated Weierstrass% x=-1.5:0.005:1.5;% [X,y]=meshgrid (x);% for i=1:size (x,1)% For J=1:size (y,1)% p=[x (i,j), Y (i,j)] '; percent x (i,j) =m (1,:) *p;% y (i,j) =m (2,:) *p;% end% end% z=0;% for k=0:20% Z=z+0.5^k*cos ( Pi*3^k* (x+0.5)) +0.5^k*cos (2*pi*3^k* (y+0.5));% end% temp=0;% for k=0:20% Temp=temp+0.5^k*cos (2*pi*3^k*0.5);% end% z= z-2*temp;% axis ([ -1.5,1.5,-1.5,1.5]);% MESHC (x, y, z);%xlabel (' x '); Ylabel (' Y '); Zlabel (' F (x, y) '); ColorMap jet;% Clear;%saveas (GCF, ' temp.jpg ')
Swarm intelligence Optimization algorithm-test function matlab Source code