- Parent Category: Unconstrained
- Category: 2-Dimensions
- Hits: 7883
Sawtoothxy Function
I. Mathematical Expression:
$$f(X)=g(r) \cdot h(t)$$
where:
\(\bullet\) \(g(r)=\left[\sin(r)-\frac{\sin(2r)}{2}+\frac{\sin(3r)}{3}-\frac{\sin(4r)}{4}+4\right]\left(\frac{r^2}{r+1}\right)\)
\(\bullet\) \(h(t)=\frac{1}{2}\cos\left(2t-\frac{1}{2}\right)+\cos(t)+2\)
\(\bullet\) \(r=\sqrt{x^2_1+x^2_2}\)
\(\bullet\) \(t=\text{atan2}\left(x_2,x_1\right)\)
\(\bullet\) \(-20\leq x_i\leq 20\), \(i=1,2\)
\(\bullet\) \(f_{min}(X^*)=0\)
\(\bullet\) \(x^*_i=0\)
II. 2&3D-Plots:
III. Controllable 3D Model:
- In case you want to adjust the rendering mode, camera position, background color or/and 3D measurement tool, please check the following link
- In case you face any problem to run this model on your internet browser (it does not work on mobile phones), please check the following link
IV. MATLAB M-File:
% Sawtoothxy Function
% Range of initial points: -20 <= xj <= 20 , j=1,2
% Global minima: (x1,x2)=(0,0)
% f(x1,x2)=0
% Coded by: Ali R. Alroomi | Last Update: 24 March 2015 | www.al-roomi.org
clear
clc
warning off
x1min=-20;
x1max=20;
x2min=-20;
x2max=20;
R=1500; % steps resolution
x1=x1min:(x1max-x1min)/R:x1max;
x2=x2min:(x2max-x2min)/R:x2max;
for j=1:length(x1)
for i=1:length(x2)
[t r] = cart2pol(x1(j),x2(i)); % change to polar coordinates
h = cos(2*t - 1/2)/2 + cos(t) + 2;
g = (sin(r) - sin(2*r)/2 + sin(3*r)/3 - sin(4*r)/4 + 4)*r.^2./(r+1);
f(i) = g.*h;
end
f_tot(j,:)=f;
end
figure(1)
meshc(x1,x2,f_tot);colorbar;set(gca,'FontSize',12);
xlabel('x_2','FontName','Times','FontSize',20,'FontAngle','italic');
set(get(gca,'xlabel'),'rotation',25,'VerticalAlignment','bottom');
ylabel('x_1','FontName','Times','FontSize',20,'FontAngle','italic');
set(get(gca,'ylabel'),'rotation',-25,'VerticalAlignment','bottom');
zlabel('f(X)','FontName','Times','FontSize',20,'FontAngle','italic');
title('3D View','FontName','Times','FontSize',24,'FontWeight','bold');
figure(2)
mesh(x1,x2,f_tot);view(0,90);colorbar;set(gca,'FontSize',12);
xlabel('x_2','FontName','Times','FontSize',20,'FontAngle','italic');
ylabel('x_1','FontName','Times','FontSize',20,'FontAngle','italic');
zlabel('f(X)','FontName','Times','FontSize',20,'FontAngle','italic');
title('X-Y Plane View','FontName','Times','FontSize',24,'FontWeight','bold');
figure(3)
mesh(x1,x2,f_tot);view(90,0);colorbar;set(gca,'FontSize',12);
xlabel('x_2','FontName','Times','FontSize',20,'FontAngle','italic');
ylabel('x_1','FontName','Times','FontSize',20,'FontAngle','italic');
zlabel('f(X)','FontName','Times','FontSize',20,'FontAngle','italic');
title('X-Z Plane View','FontName','Times','FontSize',24,'FontWeight','bold');
figure(4)
mesh(x1,x2,f_tot);view(0,0);colorbar;set(gca,'FontSize',12);
xlabel('x_2','FontName','Times','FontSize',20,'FontAngle','italic');
ylabel('x_1','FontName','Times','FontSize',20,'FontAngle','italic');
zlabel('f(X)','FontName','Times','FontSize',20,'FontAngle','italic');
title('Y-Z Plane View','FontName','Times','FontSize',24,'FontWeight','bold');
V. References:
[1] MathWorks, "Global Optimization Toolbox," 2013, [Accessed April 25, 2013]. [Online]. Available: http://www.mathworks.com/products/global-optimization/index.html
[2] M. Aria, "Educational Simulator for Teaching of Particle Swarm Optimization in LabVIEW," TELEKONTRAN, vol. 1, no. 1, pp. 1-15, Jan. 2013.
[3] Ali R. Alroomi, "The Farm of Unconstrained Benchmark Functions," University of Bahrain, Electrical and Electronics Department, Bahrain, Oct. 2013. [Online]. Available: http://www.al-roomi.org/cv/publications