-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAckley.m
More file actions
29 lines (27 loc) · 720 Bytes
/
Ackley.m
File metadata and controls
29 lines (27 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
classdef Ackley < Problem
properties(Constant)
c = 2*pi;
b = 0.2;
a = 20;
LB = [-32.768 -32.768];
UB = [32.768 32.768];
end
methods
function obj = Ackley()
obj = obj@Problem("Ackley");
end
function out = evaluate(obj, x)
d = length(x);
sum1 = 0;
sum2 = 0;
for ii = 1:d
xi = x(ii);
sum1 = sum1 + xi^2;
sum2 = sum2 + cos(obj.c*xi);
end
term1 = -obj.a * exp(-obj.b*sqrt(sum1/d));
term2 = -exp(sum2/d);
out = term1 + term2 + obj.a + exp(1);
end
end
end