-
Notifications
You must be signed in to change notification settings - Fork 2
/
CarromTableGlobalOptimization.m
71 lines (57 loc) · 1.19 KB
/
CarromTableGlobalOptimization.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
59
60
61
62
63
64
65
66
67
68
69
70
71
function [xbest,all_best, ybest, funceval, allybest]=CarromTableGlobalOptimization(n,m,s,eps,a,b)
all_best=ones(7);
allybest=[];
% ally=[];
x0=ones(1,n);
for i=1:n
r=a(i)+(b(i)-a(i))*rand;
x0(i)=r;
end
[y0,y1,y2,y3,y4,y5,y6]=WCPP(x0);
z0=[x0 y0];
k=0;
xk=x0;
yk=y0;
zk=[xk yk];
funceval=1;
while (k<m)
za=zeros(1,n+1);
xbest=xk;
ybest=yk;
all_best=[y0,y1,y2,y3,y4,y5,y6];
zk=[xk yk];
z=zeros(1,n+1);
flag=1;
for i=1:n
r=a(i)+(b(i)-a(i))*rand;
if (r==a(i))||(r==b(i))
flag=0;
end
z(i)=r;
end
if flag==0
z(n+1)=ybest*rand;
end
for j=0:s-1
t=j/(s-1);
zt=t.*zk+(1-t).*z;
xt=zt(1:n);
yt=zt(n+1);
[w,y1,y2,y3,y4,y5,y6]=WCPP(xt);
funceval=funceval+1;
if (w<yt)&(w<ybest)
xbest=xt;
ybest=w;
all_best=[w,y1,y2,y3,y4,y5,y6];
allybest=[allybest ybest];
break;
end
if (w==ybest)
break;
end
end
k=k+1;
zk=[xbest ybest];
xk=zk(1:n);
yk=zk(n+1);
end