LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
StationReplicas.m
1classdef StationReplicas < opt.DecisionVariable
2 % StationReplicas Optimize the number of identical station copies. N
3 % replicas are represented as one multiserver station with N times the base
4 % server count, keeping topology and names fixed. Mirrors native-Python
5 % StationReplicas.
6
7 properties
8 station
9 minReplicas
10 maxReplicas
11 end
12
13 methods
14 function obj = StationReplicas(station, bounds, name)
15 if nargin < 3 || isempty(name)
16 name = [station.getName() '_replicas'];
17 end
18 obj@opt.DecisionVariable(name);
19 obj.station = station;
20 obj.minReplicas = round(bounds(1));
21 obj.maxReplicas = round(bounds(2));
22 end
23
24 function s = getStation(obj), s = obj.station; end
25 function b = getBounds(obj), b = opt.DecisionVariable.unitBounds(1); end
26
27 function v = decode(obj, x)
28 continuous = obj.minReplicas + x(1) * (obj.maxReplicas - obj.minReplicas);
29 v = min(max(round(continuous), obj.minReplicas), obj.maxReplicas);
30 end
31
32 function apply(obj, model, value)
33 nodes = model.getNodes();
34 for i = 1:numel(nodes)
35 if strcmp(nodes{i}.getName(), obj.station.getName())
36 base = nodes{i}.getNumberOfServers();
37 if ~isfinite(base) || base < 1
38 base = 1;
39 end
40 nodes{i}.setNumberOfServers(base * value);
41 return;
42 end
43 end
44 end
45
46 function t = getVariableType(obj), t = 'station_replicas'; end
47 end
48end
Definition fjtag.m:157
Definition Station.m:245