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 end
15
16 methods
17 %public methods, including constructor
18
19 %constructor
20 function self = Entry(model, name)
21 % SELF = ENTRY(MODEL, NAME)
22 name = char(name);
23 if nargin<2 %~exist('name','var')
24 line_error(mfilename,'Constructor requires to specify at least a name.');
25 end
26 self@LayeredNetworkElement(name);
27
28 if isa(model,'LayeredNetwork')
29 self.arrival = [];
30 model.entries{end+1} = self;
31 self.model = model;
32 elseif isa(model,'JLayeredNetwork')
33 % JLayeredNetwork support would go here if it exists
34 self.obj = jline.lang.layered.Entry(model.obj, name);
35 model.addEntry(self);
36 end
37 end
38
39 function self = on(self, parent)
40 % SELF = ON(SELF, PARENT)
41
42 parent.addEntry(self);
43 self.parent = parent;
44 end
45
46 function self = setArrival(self, arvDist)
47 % SETARRIVAL Sets the open arrival distribution for this entry
48 %
49 % Parameters:
50 % arvDist - Arrival distribution (e.g., Exp, Erlang, HyperExp)
51 %
52 % Examples:
53 % entry.setArrival(Exp(2.5)); % Exponential with rate 2.5
54 % entry.setArrival(Erlang(2, 0.4)); % Erlang-2 with rate 0.4
55
56 if ~isa(arvDist, 'Distribution')
57 line_error(mfilename, 'Arrival must be a Distribution object');
58 end
59 self.arrival = arvDist;
60 end
61
62 function self = forward(self, dest, prob)
63 % SELF = FORWARD(SELF, DEST, PROB)
64 %
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.
68 %
69 % Parameters:
70 % dest - Destination entry object or entry name (string)
71 % prob - Probability of forwarding (0.0 to 1.0), default is 1.0
72 %
73 % Returns:
74 % self - This entry for method chaining
75
76 if nargin < 3
77 prob = 1.0;
78 end
79
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));
83 end
84
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));
89 end
90
91 % Get destination name
92 if isa(dest, 'Entry')
93 destName = dest.name;
94 elseif ischar(dest) || isstring(dest)
95 destName = char(dest);
96 else
97 line_error(mfilename, 'Destination must be an Entry object or a string');
98 end
99
100 % Add to forwarding lists
101 self.forwardingDests{end+1} = destName;
102 self.forwardingProbs(end+1) = prob;
103 end
104
105 end
106
107end