1classdef Entry < LayeredNetworkElement
2 % An entry point of service
for a Task.
4 % Copyright (c) 2012-2026, Imperial College London
10 arrival; % Open arrival distribution
17 %
public methods, including constructor
20 function self = Entry(model, name)
21 % SELF = ENTRY(MODEL, NAME)
23 if nargin<2 %~exist(
'name',
'var')
24 line_error(mfilename,'Constructor requires to specify at least a name.');
26 self@LayeredNetworkElement(name);
28 if isa(model,'LayeredNetwork')
30 model.entries{end+1} = self;
32 elseif isa(model,
'JLayeredNetwork')
33 % JLayeredNetwork support would go here
if it exists
34 self.obj = jline.lang.layered.Entry(model.obj, name);
39 function self = on(self, parent)
40 % SELF = ON(SELF, PARENT)
42 parent.addEntry(self);
46 function self = setArrival(self, arvDist)
47 % SETARRIVAL Sets the open arrival distribution
for this entry
50 % arvDist - Arrival distribution (e.g., Exp, Erlang, HyperExp)
53 % entry.setArrival(Exp(2.5)); % Exponential with rate 2.5
54 % entry.setArrival(Erlang(2, 0.4)); % Erlang-2 with rate 0.4
56 if ~isa(arvDist,
'Distribution')
57 line_error(mfilename, 'Arrival must be a Distribution
object');
59 self.arrival = arvDist;
62 function self = forward(self, dest, prob)
63 % SELF = FORWARD(SELF, DEST, PROB)
65 % Add a forwarding call to another entry with a specified probability.
66 % Forwarding allows this entry to redirect the reply to another entry
67 % instead of replying directly to the original caller.
70 % dest - Destination entry
object or entry name (
string)
71 % prob - Probability of forwarding (0.0 to 1.0), default
is 1.0
74 % self - This entry for method chaining
80 % Validate probability
81 if prob < 0.0 || prob > 1.0
82 line_error(mfilename, sprintf('Forwarding probability must be between 0.0 and 1.0, got: %f', prob));
85 % Check sum of probabilities
86 currentSum = sum(self.forwardingProbs);
87 if currentSum + prob > 1.0 + 1e-6 % Small tolerance for floating point errors
88 line_error(mfilename, sprintf('Sum of forwarding probabilities would exceed 1.0 (current: %.6f, adding: %.6f)', currentSum, prob));
91 % Get destination name
94 elseif ischar(dest) || isstring(dest)
95 destName =
char(dest);
97 line_error(mfilename, 'Destination must be an Entry
object or a
string');
100 % Add to forwarding lists
101 self.forwardingDests{end+1} = destName;
102 self.forwardingProbs(end+1) = prob;