-
Notifications
You must be signed in to change notification settings - Fork 5
/
NetworkOptimizer.m
71 lines (66 loc) · 1.82 KB
/
NetworkOptimizer.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
classdef NetworkOptimizer < handle
%UNTITLED5 Summary of this class goes here
% Detailed explanation goes here
properties (Abstract, SetAccess = protected)
options Dictionary;
end
properties (Access = {?NetworkOptimizer, ?PhysicalNetwork})
runtime = 0;
iterations = 1;
end
properties (SetAccess = protected)
hn;
end
%% Constructor
methods
function this = NetworkOptimizer(net, options)
defaultopts = Dictionary(...
'NonzeroTolerance', 10^-3, ...
'PostProcessing', 'round', ...
'ConstraintTolerance', 10^-3, ...
'Form', 'normal', ...
'Threshold', 'min', ...
'InterSlicePenalty', 0.1, ...
'OptimizationTool', 'matlab' ... % {matlab|cvx}
);
if nargin >= 2
this.options = structupdate(defaultopts, options);
else
this.options = defaultopts;
end
if isfield(options, 'IntraSlicePenalty')
this.options.IntraSlicePenalty = options.IntraSlicePenalty;
end
this.hn = net;
end
end
methods (Abstract)
end
methods (Access = {?NetworkOptimizer,?PhysicalNetwork})
slice_data = updateSliceData(this, slice_data, options);
function prices = initPrice(this, slices, unitcost, options)
if isfield(options, 't1')
t1 = options.t1;
else
t1 = 1; % {0.1|0.8|1}
end
unitcost = this.hn.convertParameter(unitcost, 'vector');
if nargin >= 4 && isfield(options, 'InitPrice')
Ne = this.hn.NumberLinks;
res_usage = false(Ne+this.hn.NumberDataCenters,1);
for i = 1:length(slices)
res_usage(slices(i).Links.PhysicalLink) = true;
res_usage(Ne+slices(i).getDCPI()) = true;
end
init_price = convertParameter(options.InitPrice, 'vector');
if find(init_price(res_usage)==0,1)
prices = t1* unitcost;
else
prices = init_price;
end
else
prices = t1* unitcost;
end
end
end
end