1classdef ClosedSignal < ClosedClass
2 % ClosedSignal Signal
class for closed queueing networks
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).
9 % For open networks, use OpenSignal instead.
11 % ClosedSignal has zero population - signals are created dynamically
12 % through
class switching from the target job class.
15 % - SignalType.NEGATIVE: Removes a job from the destination queue
16 % - SignalType.REPLY: Unblocks servers waiting
for a reply
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);
28 % Copyright (c) 2012-2026, Imperial College London
29 % All rights reserved.
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)
40 function self = ClosedSignal(model, name, signalType, refstat, prio, removalDistribution, removalPolicy)
41 % CLOSEDSIGNAL Create a closed signal class instance
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
52 if nargin < 7 || isempty(removalPolicy)
53 removalPolicy = RemovalPolicy.RANDOM;
56 removalDistribution = [];
58 if nargin < 5 || isempty(prio)
62 line_error(mfilename,
'ClosedSignal requires a reference station.');
64 if nargin < 3 || isempty(signalType)
65 signalType = SignalType.NEGATIVE;
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;
76 function type = getSignalType(self)
77 % GETSIGNALTYPE Get the signal type
78 type = self.signalType;
81 function self = forJobClass(self, jobClass)
82 % FORJOBCLASS Associate
this signal with a job
class
84 % For REPLY signals,
this specifies which job
class's servers
85 % will be unblocked when this signal arrives.
87 % @param jobClass The JobClass to associate with this signal
88 % @return self The modified Signal instance (for chaining)
90 self.targetJobClass = jobClass;
92 jobClass.replySignalClass = self;
96 function jobClass = getTargetJobClass(self)
97 % GETTARGETJOBCLASS Get the associated job class
98 jobClass = self.targetJobClass;
101 function idx = getTargetJobClassIndex(self)
102 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
103 if isempty(self.targetJobClass)
106 idx = self.targetJobClass.index;
110 function dist = getRemovalDistribution(self)
111 % GETREMOVALDISTRIBUTION Get the removal distribution
112 dist = self.removalDistribution;
115 function self = setRemovalDistribution(self, dist)
116 % SETREMOVALDISTRIBUTION Set the removal distribution
117 self.removalDistribution = dist;
120 function policy = getRemovalPolicy(self)
121 % GETREMOVALPOLICY Get the removal policy
122 policy = self.removalPolicy;
125 function self = setRemovalPolicy(self, policy)
126 % SETREMOVALPOLICY Set the removal policy
127 self.removalPolicy = policy;
130 function b = isCatastrophe(self)
131 % ISCATASTROPHE Check if this is a catastrophe signal
133 % @return b true if signalType is SignalType.CATASTROPHE
134 b = (self.signalType == SignalType.CATASTROPHE);
137 function summary(self)
139 line_printf('Signal (%s): <strong>%s</strong> [%s]
', self.type, self.getName, self.signalType);