-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun_test3.m
127 lines (121 loc) · 5.07 KB
/
run_test3.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
%% Physical Network Speification for SD_RAN
% This program used to test if the parameters are properly set.
% NOTE: link utilization ratio is lower, since not all links will be used for DC-2-DC
% traffic.
%% Specification of VNFs and Network Slices
% |StaticCostOption| is not set, the default value is |None|;
% |RandomSeed|: the first seed is for random static cost, the second is for process
% efficiency.
clear variables global;
link_opt.RandomSeed = 20170421;
link_opt.DelayModel = LinkDelayOption.Random;
link_opt.CostUnit = 0.2;
node_opt.CostUnit = 0.1;
net_opt.AdmitPolicy = 'reject-flow';
net_opt.PricingFactor = 2; % 1 | 2 | 3 ,
net_opt.Threshold = 'average';
VNF_opt.Number = 6; % number of VNF type
VNF_opt.Model = VNFIntegrateModel.AllInOne;
VNF_opt.RandomSeed = [20161101 0];
opopt.Form = 'compact';
%% control variables
b_static = true;
b_optimal = true;
b_repeat = true;
%% Construct Network
% 13 23 33
slice_type = 33;
%%
if b_optimal
net_opt.SlicingMethod = SlicingMethod.SingleNormal;
PN = SimpleCloudAccessNetwork(node_opt, link_opt, VNF_opt, net_opt);
PN.slice_template = Slice.loadSliceTemplate(slice_type);
link_capacity = PN.readLink('Capacity');
node_capacity = PN.readDataCenter('Capacity');
seed = floor(now);
slice_opt = PN.slice_template(1);
fprintf('\nSingle Slice Optimization:\n');
fprintf('\tAverage unit link cost: %.2G, average unit node cost: %.2G.\n', ...
mean(PN.readLink('UnitCost')), ...
mean(PN.readDataCenter('UnitCost')));
fprintf('\t\t(Ratio of unit node cost to unit link cost: %.2G.)\n\n',...
mean(PN.readDataCenter('UnitCost'))/mean(PN.readLink('UnitCost')));
PN.getOptimizer(opopt);
N = 5;
while true && N > 0
slice_opt.RandomSeed = seed;
seed = seed + 1;
PN.AddSlice(slice_opt);
% output = PN.singleSliceOptimization();
output = PN.singleSliceOptimization(struct('bCompact', false));
fprintf('\tNumber of slices: %d.\n', PN.NumberSlices);
fprintf('\tOptimal net social welfare (without pricing) is %.4e.\n', ...
output.WelfareOptimal);
fprintf('\tOptimal net social welfare (with pricing) is %.4e.\n', output.Welfare);
fprintf('\tnet profit of each slice:\n');
fprintf('\t\t%f\n',output.Profit(1:(end-1),:));
fprintf('\tnet profit of substrate network:\n');
fprintf('\t\t%f\n',output.Profit(end,:));
fprintf('\tNetwork utilization ratio %f.\n',PN.utilizationRatio);
fprintf('\t\t(Node utilization: %.2G)\n', sum(PN.readDataCenter('Load')/sum(node_capacity)));
fprintf('\t\t(Link utilization: %.2G)\n\n', sum(PN.readLink('Load')/sum(link_capacity)));
if ~b_repeat
break;
else
N = N - 1;
end
for i = 1:PN.NumberSlices
PN.slices{i}.initialize;
end
end
end
%%
if b_static
net_opt.SlicingMethod = SlicingMethod.StaticPricing;
PN_static = SimpleCloudAccessNetwork(node_opt, link_opt, VNF_opt, net_opt);
PN_static.slice_template = Slice.loadSliceTemplate(slice_type);
link_capacity = PN_static.readLink('Capacity');
node_capacity = PN_static.readDataCenter('Capacity');
link_price = PN_static.getLinkCost * (1 + net_opt.PricingFactor);
node_price = PN_static.getNodeCost * (1 + net_opt.PricingFactor);
PN_static.writeLink('Price', link_price);
PN_static.writeDataCenter('Price', node_price);
slice_opt = PN_static.slice_template(1);
if b_repeat
slice_opt.AdmitPolicy = 'reject-slice';
fprintf('\nStatic Slicing Repeat:\n');
else
fprintf('\nStatic Slicing:\n');
end
PN.getOptimizer(opopt);
seed = floor(now);
while true
slice_opt.RandomSeed = seed;
seed = seed + 1;
sl = PN_static.AddSlice(slice_opt);
if isempty(sl)
break;
end
output = PN_static.staticSlicing(sl);
fprintf('\tNumber of slices: %d.\n', PN_static.NumberSlices);
fprintf('\tOptimal net social welfare (with pricing) is %.4e.\n', output.Welfare);
fprintf('\tnet profit of each slice:\n');
fprintf('\t\t%f\n',output.Profit(1:(end-1),:));
fprintf('\tnet profit of substrate network:\n');
fprintf('\t\t%f\n',output.Profit(end,:));
fprintf('\tNetwork utilization ratio %f.\n',PN_static.utilizationRatio);
fprintf('\t\t(Node utilization: %.2G)\n', ...
sum(PN_static.readDataCenter('Load')/sum(node_capacity)));
fprintf('\t\t(Link utilization: %.2G)\n\n', ...
sum(PN_static.readLink('Load')/sum(link_capacity)));
if ~b_repeat
break;
end
end
fprintf('\tAverage unit link cost: %.2G, average unit node cost: %.2G.\n', ...
mean(PN_static.readLink('UnitCost')), ...
mean(PN_static.readDataCenter('UnitCost')));
fprintf('\t\t(Ratio of unit node cost to unit link cost: %.2G.)\n\n',...
mean(PN_static.readDataCenter('UnitCost'))/...
mean(PN_static.readLink('UnitCost')));
end