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
14 function obj = StationReplicas(station, bounds, name)
15 if nargin < 3 || isempty(name)
16 name = [station.getName()
'_replicas'];
18 obj@opt.DecisionVariable(name);
19 obj.station = station;
20 obj.minReplicas = round(bounds(1));
21 obj.maxReplicas = round(bounds(2));
24 function s = getStation(obj), s = obj.station; end
25 function b = getBounds(obj), b = opt.DecisionVariable.unitBounds(1); end
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);
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
40 nodes{i}.setNumberOfServers(base * value);
46 function t = getVariableType(obj), t =
'station_replicas'; end