TEST FUNCTIONS for Unconstrained Global Optimization Ackley Function r Number of variables: n variables.

2 views (last 30 days)
i need solution this function with a main program
function y = ackley(x)
% % Ackley function.
% Matlab Code by A. Hedar (Sep. 29, 2005).
% The number of variables n should be adjusted below.
% The default value of n =2. % n = 2;
a = 20; b = 0.2; c = 2*pi;
s1 = 0; s2 = 0;
for i=1:n; s1 = s1+x(i)^2; s2 = s2+cos(c*x(i));
end
y = -a*exp(-b*sqrt(1/n*s1))-exp(1/n*s2)+a+exp(1);

Answers (0)

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!