-
Notifications
You must be signed in to change notification settings - Fork 0
/
RWalks.m
58 lines (46 loc) · 957 Bytes
/
RWalks.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function [RWs]=RWalks(Dim,max_iter,lb, ub,antlion,current_iter)
if size(lb,1) ==1 && size(lb,2)==1
lb=ones(1,Dim)*lb;
ub=ones(1,Dim)*ub;
end
if size(lb,1) > size(lb,2)
lb=lb';
ub=ub';
end
I=1;
if current_iter>max_iter/10
I=1+1*(current_iter/max_iter);
end
if current_iter>max_iter/2
I=1+5*(current_iter/max_iter);
end
if current_iter>max_iter*(3/4)
I=1+10*(current_iter/max_iter);
end
if current_iter>max_iter*(0.9)
I=1+20*(current_iter/max_iter);
end
if current_iter>max_iter*(0.95)
I=1+50*(current_iter/max_iter);
end
lb=lb/(I);
ub=ub/(I);
if rand<0.5
lb=lb+antlion;
else
lb=-lb+antlion;
end
if rand>=0.5
ub=ub+antlion;
else
ub=-ub+antlion;
end
for i=1:Dim
X = [0 cumsum(2*(rand(max_iter,1)>0.5)-1)'];
a=min(X);
b=max(X);
c=lb(i);
d=ub(i);
X_norm=((X-a).*(d-c))./(b-a)+c;
RWs(:,i)=X_norm;
end