-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathServerincrease2.m
176 lines (173 loc) · 7.97 KB
/
Serverincrease2.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
Usernum=100;
Servernum=1;
Num=50;
Avgdeleymin=zeros(1,Num);
Avgdeleyminton=zeros(1,Num);
Computetotal=200;
Tasknum=zeros(1,Usernum)+10;
Nummax=max(Tasknum);
Tasktotal=Nummax;
Taskgraph=zeros(Nummax,Nummax,Usernum);
%Taskgraph(:,:,1)=[0,-1,-1,-1,-1,-1,0,0,0,0;1,0,0,0,0,0,0,-1,-1,0;1,0,0,0,0,0,-1,0,0,0;1,0,0,0,0,0,0,-1,-1,0;1,0,0,0,0,0,0,0,-1,0;1,0,0,0,0,0,0,-1,0,0;0,0,1,0,0,0,0,0,0,-1;0,1,0,1,0,1,0,0,0,-1;0,1,0,1,1,0,0,0,0,-1;0,0,0,0,0,0,1,1,1,0]';
Taskgraph(:,:,1)=Graphgenerateparalel(Nummax,Nummax,Nummax-2);
for p=2:Usernum
Taskgraph(:,:,p)=Taskgraph(:,:,1);
end
%Taskgraph(:,:,2)=[0,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,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-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2];
Transdata=(zeros(Nummax,Nummax,Usernum)+0.3)*10;
%Computecost=zeros(Nummax,Num+1,Usernum)+Computetotal/Nummax;
Computecost=zeros(Nummax,Num+1,Usernum);
Computecost(1:Nummax,1:Num,:)=zeros(Nummax,Num,Usernum)+Computetotal/Tasktotal/10;
Computecost(1:Nummax,Num+1,:)=zeros(Nummax,Usernum)+Computetotal/Tasktotal;
Transferrate=(zeros(Num+1,Num+1,Usernum)+0.3)*300;
for r1=1:Usernum
for r2=1:Num
for r3=1:Num
Transferrate(r2,r3,r1)=Transferrate(r2,r3,r1)*Inf;
end
end
end
for p=1:Usernum
for a=1:Num+1
for b=1:Num+1
if a<=b
Transferrate(b,a,p)=Transferrate(a,b,p);
end
end
end
end
Comstartup=(zeros(1,Usernum+Num)+0.1)*1;
Computenergy=zeros(1,Usernum)+0.5;
Transmitpower=zeros(1,Usernum)+0.2;
alfa=zeros(1,Usernum)+0.5;
Size=zeros(Usernum,Nummax)+1000;
Avgdeley=zeros(1,Num);
Totalconsumption=zeros(1,Num);
while Servernum<=Num
Computecosttemp=zeros(Nummax,Servernum+1,Usernum);
Computecosttemp(1:Nummax,1:Servernum,:)=Computecost(1:Nummax,1:Servernum,:);
Computecosttemp(1:Nummax,Servernum+1,:)=Computecost(1:Nummax,Num+1,:);
Local=zeros(1,Usernum)+Servernum+1;
Transferratetemp=zeros(Servernum+1,Servernum+1,Usernum);
Transferratetemp(1:Servernum,1:(Servernum+1),:)=Transferrate(1:Servernum,1:(Servernum+1),:);
Transferratetemp(Servernum+1,1:(Servernum+1),:)=Transferrate(Servernum+1,1:(Servernum+1),:);
for p=1:Servernum
Transferratetemp(Servernum+1,p,:)=Transferrate(Num+1,p,:);
Transferratetemp(p,Servernum+1,:)=Transferratetemp(Servernum+1,p,:);
end
[Scheduletotal,Computeconsumption,Transmitconsumption]=globecomedgenetworks2(Usernum,Servernum,Local,Taskgraph,Tasknum,Transdata,Computecosttemp,Transferratetemp,Comstartup,Computenergy,Transmitpower,alfa,Size);
basesearch=0;
deley=0;
for t=1:Usernum
Startsearch(1,t)=basesearch;
basesearch=basesearch+Tasknum(1,t);
end
for i=1:Usernum
deley=deley+Scheduletotal(2,Startsearch(1,i)+Tasknum(1,i),Servernum+i)-Scheduletotal(1,Startsearch(1,i)+1,Servernum+i);
end
Avgdeley(1,Servernum)=deley/Usernum;
Totalconsumption(1,Servernum)=sum(Computeconsumption+Transmitconsumption);
Servernum=Servernum+1;
end
%single server
Servernum=1;
Avgdeleyonedge=zeros(1,Num);
Totalconsumptiononedge=zeros(1,Num);
while Servernum<=Num
Computecosttemp=zeros(Nummax,Servernum+1,Usernum);
Computecosttemp(1:Nummax,1:Servernum,:)=Computecost(1:Nummax,1:Servernum,:);
Computecosttemp(1:Nummax,Servernum+1,:)=Computecost(1:Nummax,Num+1,:);
Local=zeros(1,Usernum)+Servernum+1;
Transferratetemp=zeros(Servernum+1,Servernum+1,Usernum);
Transferratetemp(1:Servernum,1:(Servernum+1),:)=Transferrate(1:Servernum,1:(Servernum+1),:);
Transferratetemp(Servernum+1,1:(Servernum+1),:)=Transferrate(Servernum+1,1:(Servernum+1),:);
for p=1:Servernum
Transferratetemp(Servernum+1,p,:)=Transferrate(Num+1,p,:);
Transferratetemp(p,Servernum+1,:)=Transferratetemp(Servernum+1,p,:);
end
[Scheduletotal,Computeconsumption,Transmitconsumption]=globecomonedge(Usernum,Servernum,Local,Taskgraph,Tasknum,Transdata,Computecosttemp,Transferratetemp,Comstartup,Computenergy,Transmitpower,alfa,Size);
basesearch=0;
deley=0;
for t=1:Usernum
Startsearch(1,t)=basesearch;
basesearch=basesearch+Tasknum(1,t);
end
for i=1:Usernum
deley=deley+Scheduletotal(2,Startsearch(1,i)+Tasknum(1,i),Servernum+i)-Scheduletotal(1,Startsearch(1,i)+1,Servernum+i);
end
Avgdeleyonedge(1,Servernum)=deley/Usernum;
Totalconsumptiononedge(1,Servernum)=sum(Computeconsumption+Transmitconsumption);
Servernum=Servernum+1;
end
consumptiontemp=0;
for i=1:Usernum
consumptiontemp=consumptiontemp+Computenergy(1,i)*(Computecost(1,Local(1,i),i)+Computecost(Tasknum(1,i),Local(1,i),i));
end
%ton
Avgdeleyton=zeros(1,Num);
Totalconsumptionton=zeros(1,Num);
Servernum=1;
Tasknum=zeros(1,Usernum)+3;
Size(:,1)=0;
Size(:,3)=0;
Nummax=max(Tasknum);
Taskgraph=zeros(Nummax,Nummax,Usernum);
for k=1:Usernum
Taskgraph(:,:,k)=Graphgenerateparalel(3,Nummax,1);
end
Computecost=zeros(Nummax,Num+1,Usernum);
Computecost(1:Nummax,1:Num,:)=zeros(Nummax,Num,Usernum)+Computetotal/10;
Computecost(1:Nummax,Num+1,:)=zeros(Nummax,Usernum)+Computetotal;
% Computecost(1:Nummax,1:Servernum,:)=rand(Nummax,Servernum,Usernum)*Computetotal/5;
% Computecost(1:Nummax,Servernum+1,:)=rand(Nummax,Usernum)*2*Computetotal;
Computecost(1,:,:)=0;
Computecost(3,:,:)=0;
Transdata=zeros(Nummax,Nummax,Usernum);
for u=1:Usernum
Transdata(1,2,u)=25;
Transdata(2,3,u)=5;
end
while Servernum<=Num
Computecosttemp=zeros(Nummax,Servernum+1,Usernum);
Computecosttemp(1:Nummax,1:Servernum,:)=Computecost(1:Nummax,1:Servernum,:);
Computecosttemp(1:Nummax,Servernum+1,:)=Computecost(1:Nummax,Num+1,:);
Local=zeros(1,Usernum)+Servernum+1;
Transferratetemp=zeros(Servernum+1,Servernum+1,Usernum);
Transferratetemp(1:Servernum,1:(Servernum+1),:)=Transferrate(1:Servernum,1:(Servernum+1),:);
Transferratetemp(Servernum+1,1:(Servernum+1),:)=Transferrate(Servernum+1,1:(Servernum+1),:);
for p=1:Servernum
Transferratetemp(Servernum+1,p,:)=Transferrate(Num+1,p,:);
Transferratetemp(p,Servernum+1,:)=Transferratetemp(Servernum+1,p,:);
end
[Scheduletotal,Computeconsumption,Transmitconsumption]=globecomedgenetworks2(Usernum,Servernum,Local,Taskgraph,Tasknum,Transdata,Computecosttemp,Transferratetemp,Comstartup,Computenergy,Transmitpower,alfa,Size);
basesearch=0;
deley=0;
for t=1:Usernum
Startsearch(1,t)=basesearch;
basesearch=basesearch+Tasknum(1,t);
end
for i=1:Usernum
deley=deley+Scheduletotal(2,Startsearch(1,i)+Tasknum(1,i),Servernum+i)-Scheduletotal(1,Startsearch(1,i)+1,Servernum+i);
end
Avgdeleyton(1,Servernum)=deley/Usernum;
Totalconsumptionton(1,Servernum)=sum(Computeconsumption+Transmitconsumption);
Servernum=Servernum+1;
end
% plot(1:Num,Totalconsumption-consumptiontemp);
% hold on;
% plot(1:Num,Totalconsumptiononedge-consumptiontemp,'--');
% hold on;
plot(1:Num,Totalconsumption);
hold on;
plot(1:Num,Totalconsumptiononedge,'--');
hold on;
plot(1:Num,Totalconsumptionton);
hold on;
plot(1:Num,Avgdeley-2*Computetotal/Tasktotal);
hold on;
plot(1:Num,Avgdeleyton,'--');
hold on;
plot(1:Num,Avgdeleyonedge-2*Computetotal/Tasktotal);