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
14 type =
'PH1PH2'; % string, entry type (
default: PH1PH2, can be NONE, etc.)
18 %public methods, including constructor
21 function self = Entry(model, name)
22 % SELF = ENTRY(MODEL, NAME)
24 if nargin<2 %~exist(
'name',
'var')
25 line_error(mfilename,'Constructor requires to specify at least a name.');
27 self@LayeredNetworkElement(name);
29 if isa(model,'LayeredNetwork')
31 model.entries{end+1} = self;
33 elseif isa(model,
'JLayeredNetwork')
34 % JLayeredNetwork support would go here
if it exists
35 self.obj = jline.lang.layered.Entry(model.obj, name);
40 function self = on(self, parent)
41 % SELF = ON(SELF, PARENT)
43 parent.addEntry(self);
47 function self = setArrival(self, arvDist)
48 % SETARRIVAL Sets the open arrival distribution
for this entry
51 % arvDist - Arrival distribution (e.g., Exp, Erlang, HyperExp)
54 % entry.setArrival(Exp(2.5)); % Exponential with rate 2.5
55 % entry.setArrival(Erlang(2, 0.4)); % Erlang-2 with rate 0.4
57 if ~isa(arvDist,
'Distribution')
58 line_error(mfilename, 'Arrival must be a Distribution
object');
60 self.arrival = arvDist;
63 function self = setType(self, type)
64 % SELF = SETTYPE(self, TYPE)
65 % Set the entry type attribute (e.g., PH1PH2, NONE)
70 function self = forward(self, dest, prob)
71 % SELF = FORWARD(SELF, DEST, PROB)
73 % Add a forwarding call to another entry with a specified probability.
74 % Forwarding allows this entry to redirect the reply to another entry
75 % instead of replying directly to the original caller.
78 % dest - Destination entry
object or entry name (
string)
79 % prob - Probability of forwarding (0.0 to 1.0), default
is 1.0
82 % self - This entry for method chaining
88 % Validate probability
89 if prob < 0.0 || prob > 1.0
90 line_error(mfilename, sprintf('Forwarding probability must be between 0.0 and 1.0, got: %f', prob));
93 % Check sum of probabilities
94 currentSum = sum(self.forwardingProbs);
95 if currentSum + prob > 1.0 + 1e-6 % Small tolerance for floating point errors
96 line_error(mfilename, sprintf('Sum of forwarding probabilities would exceed 1.0 (current: %.6f, adding: %.6f)', currentSum, prob));
99 % Get destination name
100 if isa(dest, 'Entry')
101 destName = dest.name;
102 elseif ischar(dest) || isstring(dest)
103 destName =
char(dest);
105 line_error(mfilename, 'Destination must be an Entry
object or a
string');
108 % Add to forwarding lists
109 self.forwardingDests{end+1} = destName;
110 self.forwardingProbs(end+1) = prob;
113 % Getter methods
for API consistency with Java/Python
114 function val = getParent(obj)
115 % GETPARENT Get the parent task
119 function val = getReplyActivity(obj)
120 % GETREPLYACTIVITY Get the reply activities
for this entry
121 val = obj.replyActivity;
124 function val = getArrival(obj)
125 % GETARRIVAL Get the arrival distribution
129 function val = getForwardingDests(obj)
130 % GETFORWARDINGDESTS Get the forwarding destinations
131 val = obj.forwardingDests;
134 function val = getForwardingProbs(obj)
135 % GETFORWARDINGPROBS Get the forwarding probabilities
136 val = obj.forwardingProbs;