Created
October 24, 2012 12:53
-
-
Save haraldschilly/3945892 to your computer and use it in GitHub Desktop.
Shekel Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Shekel-(4,5) | |
function y = sh5(x) | |
% | |
% Shekel function | |
% Matlab Code by A. Hedar (Nov. 23, 2005). | |
% The number of variables n = 4 | |
% The parameter m should be adjusted m = 5,7,10. | |
% The default value of m = 10. | |
% | |
m = 5; | |
a = ones(10,4); | |
a(1,:) = 4.0*a(1,:); | |
a(2,:) = 1.0*a(2,:); | |
a(3,:) = 8.0*a(3,:); | |
a(4,:) = 6.0*a(4,:); | |
for j = 1:2; | |
a(5,2*j-1) = 3.0; a(5,2*j) = 7.0; | |
a(6,2*j-1) = 2.0; a(6,2*j) = 9.0; | |
a(7,j) = 5.0; a(7,j+2) = 3.0; | |
a(8,2*j-1) = 8.0; a(8,2*j) = 1.0; | |
a(9,2*j-1) = 6.0; a(9,2*j) = 2.0; | |
a(10,2*j-1)= 7.0; a(10,2*j)= 3.6; | |
end | |
c(1) = 0.1; c(2) = 0.2; c(3) = 0.2; c(4) = 0.4; c(5) = 0.4; | |
c(6) = 0.6; c(7) = 0.3; c(8) = 0.7; c(9) = 0.5; c(10)= 0.5; | |
s = 0.0; | |
for j = 1:m; | |
p = 0.0; | |
for i = 1:4 | |
p = p+(x(i)-a(j,i))^2; | |
end | |
s = s+1.0/(p+c(j)); | |
end | |
y = -s; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment