LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ClosedSignal.m
1classdef ClosedSignal < ClosedClass
2 % ClosedSignal Signal class for closed queueing networks
3 %
4 % ClosedSignal is a specialized ClosedClass for modeling signals in closed
5 % queueing networks. Unlike regular customers, signals can have special
6 % effects on queues they visit, such as removing jobs (negative signals)
7 % or unblocking servers (reply signals).
8 %
9 % For open networks, use OpenSignal instead.
10 %
11 % ClosedSignal has zero population - signals are created dynamically
12 % through class switching from the target job class.
13 %
14 % Signal types:
15 % - SignalType.NEGATIVE: Removes a job from the destination queue
16 % - SignalType.REPLY: Unblocks servers waiting for a reply
17 %
18 % Example:
19 % @code
20 % model = Network('ClosedModel');
21 % delay = Delay(model, 'Think');
22 % queue1 = Queue(model, 'Client', SchedStrategy.FCFS);
23 % queue2 = Queue(model, 'Server', SchedStrategy.FCFS);
24 % jobClass = ClosedClass(model, 'Job', 5, delay);
25 % replySignal = ClosedSignal(model, 'Reply', SignalType.REPLY, delay).forJobClass(jobClass);
26 % @endcode
27 %
28 % Copyright (c) 2012-2026, Imperial College London
29 % All rights reserved.
30
31 properties
32 signalType % SignalType constant (NEGATIVE, REPLY)
33 targetJobClass % JobClass that this signal is associated with
34 removalDistribution % DiscreteDistribution for number of removals (empty = remove exactly 1)
35 removalPolicy % RemovalPolicy constant (RANDOM, FCFS, LCFS)
36 end
37
38 methods
39
40 function self = ClosedSignal(model, name, signalType, refstat, prio, removalDistribution, removalPolicy)
41 % CLOSEDSIGNAL Create a closed signal class instance
42 %
43 % @param model Network model to add the signal class to
44 % @param name String identifier for the signal class
45 % @param signalType SignalType constant (default: SignalType.NEGATIVE)
46 % @param refstat Reference station (should match target job class)
47 % @param prio Optional priority level (default: 0)
48 % @param removalDistribution Optional discrete distribution for batch removals (default: [])
49 % @param removalPolicy Optional RemovalPolicy constant (default: RemovalPolicy.RANDOM)
50 % @return self ClosedSignal instance
51
52 if nargin < 7 || isempty(removalPolicy)
53 removalPolicy = RemovalPolicy.RANDOM;
54 end
55 if nargin < 6
56 removalDistribution = [];
57 end
58 if nargin < 5 || isempty(prio)
59 prio = 0;
60 end
61 if nargin < 4
62 line_error(mfilename, 'ClosedSignal requires a reference station.');
63 end
64 if nargin < 3 || isempty(signalType)
65 signalType = SignalType.NEGATIVE;
66 end
67
68 % ClosedSignal has 0 population - signals are created by class switching
69 self@ClosedClass(model, name, 0, refstat, prio);
70 self.signalType = signalType;
71 self.targetJobClass = [];
72 self.removalDistribution = removalDistribution;
73 self.removalPolicy = removalPolicy;
74 end
75
76 function type = getSignalType(self)
77 % GETSIGNALTYPE Get the signal type
78 type = self.signalType;
79 end
80
81 function self = forJobClass(self, jobClass)
82 % FORJOBCLASS Associate this signal with a job class
83 %
84 % For REPLY signals, this specifies which job class's servers
85 % will be unblocked when this signal arrives.
86 %
87 % @param jobClass The JobClass to associate with this signal
88 % @return self The modified Signal instance (for chaining)
89
90 self.targetJobClass = jobClass;
91 if ~isempty(jobClass)
92 jobClass.replySignalClass = self;
93 end
94 end
95
96 function jobClass = getTargetJobClass(self)
97 % GETTARGETJOBCLASS Get the associated job class
98 jobClass = self.targetJobClass;
99 end
100
101 function idx = getTargetJobClassIndex(self)
102 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
103 if isempty(self.targetJobClass)
104 idx = -1;
105 else
106 idx = self.targetJobClass.index;
107 end
108 end
109
110 function dist = getRemovalDistribution(self)
111 % GETREMOVALDISTRIBUTION Get the removal distribution
112 dist = self.removalDistribution;
113 end
114
115 function self = setRemovalDistribution(self, dist)
116 % SETREMOVALDISTRIBUTION Set the removal distribution
117 self.removalDistribution = dist;
118 end
119
120 function policy = getRemovalPolicy(self)
121 % GETREMOVALPOLICY Get the removal policy
122 policy = self.removalPolicy;
123 end
124
125 function self = setRemovalPolicy(self, policy)
126 % SETREMOVALPOLICY Set the removal policy
127 self.removalPolicy = policy;
128 end
129
130 function b = isCatastrophe(self)
131 % ISCATASTROPHE Check if this is a catastrophe signal
132 %
133 % @return b true if signalType is SignalType.CATASTROPHE
134 b = (self.signalType == SignalType.CATASTROPHE);
135 end
136
137 function summary(self)
138 % SUMMARY()
139 line_printf('Signal (%s): <strong>%s</strong> [%s]', self.type, self.getName, self.signalType);
140 end
141
142 end
143
144end