LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Entry.m
1classdef Entry < LayeredNetworkElement
2 % An entry point of service for a Task.
3 %
4 % Copyright (c) 2012-2026, Imperial College London
5 % All rights reserved.
6
7 properties
8 parent;
9 replyActivity = {};
10 arrival; % Open arrival distribution
11 scheduling = [];
12 forwardingDests = {};
13 forwardingProbs = [];
14 type = 'PH1PH2'; % string, entry type (default: PH1PH2, can be NONE, etc.)
15 end
16
17 methods
18 %public methods, including constructor
19
20 %constructor
21 function self = Entry(model, name)
22 % SELF = ENTRY(MODEL, NAME)
23 name = char(name);
24 if nargin<2 %~exist('name','var')
25 line_error(mfilename,'Constructor requires to specify at least a name.');
26 end
27 self@LayeredNetworkElement(name);
28
29 if isa(model,'LayeredNetwork')
30 self.arrival = [];
31 model.entries{end+1} = self;
32 self.model = model;
33 elseif isa(model,'JLayeredNetwork')
34 % JLayeredNetwork support would go here if it exists
35 self.obj = jline.lang.layered.Entry(model.obj, name);
36 model.addEntry(self);
37 end
38 end
39
40 function self = on(self, parent)
41 % SELF = ON(SELF, PARENT)
42
43 parent.addEntry(self);
44 self.parent = parent;
45 end
46
47 function self = setArrival(self, arvDist)
48 % SETARRIVAL Sets the open arrival distribution for this entry
49 %
50 % Parameters:
51 % arvDist - Arrival distribution (e.g., Exp, Erlang, HyperExp)
52 %
53 % Examples:
54 % entry.setArrival(Exp(2.5)); % Exponential with rate 2.5
55 % entry.setArrival(Erlang(2, 0.4)); % Erlang-2 with rate 0.4
56
57 if ~isa(arvDist, 'Distribution')
58 line_error(mfilename, 'Arrival must be a Distribution object');
59 end
60 self.arrival = arvDist;
61 end
62
63 function self = setType(self, type)
64 % SELF = SETTYPE(self, TYPE)
65 % Set the entry type attribute (e.g., PH1PH2, NONE)
66
67 self.type = type;
68 end
69
70 function self = forward(self, dest, prob)
71 % SELF = FORWARD(SELF, DEST, PROB)
72 %
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.
76 %
77 % Parameters:
78 % dest - Destination entry object or entry name (string)
79 % prob - Probability of forwarding (0.0 to 1.0), default is 1.0
80 %
81 % Returns:
82 % self - This entry for method chaining
83
84 if nargin < 3
85 prob = 1.0;
86 end
87
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));
91 end
92
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));
97 end
98
99 % Get destination name
100 if isa(dest, 'Entry')
101 destName = dest.name;
102 elseif ischar(dest) || isstring(dest)
103 destName = char(dest);
104 else
105 line_error(mfilename, 'Destination must be an Entry object or a string');
106 end
107
108 % Add to forwarding lists
109 self.forwardingDests{end+1} = destName;
110 self.forwardingProbs(end+1) = prob;
111 end
112
113 % Getter methods for API consistency with Java/Python
114 function val = getParent(obj)
115 % GETPARENT Get the parent task
116 val = obj.parent;
117 end
118
119 function val = getReplyActivity(obj)
120 % GETREPLYACTIVITY Get the reply activities for this entry
121 val = obj.replyActivity;
122 end
123
124 function val = getArrival(obj)
125 % GETARRIVAL Get the arrival distribution
126 val = obj.arrival;
127 end
128
129 function val = getForwardingDests(obj)
130 % GETFORWARDINGDESTS Get the forwarding destinations
131 val = obj.forwardingDests;
132 end
133
134 function val = getForwardingProbs(obj)
135 % GETFORWARDINGPROBS Get the forwarding probabilities
136 val = obj.forwardingProbs;
137 end
138
139 end
140
141end