1classdef Signal < OpenClass
2 % Signal Job
class representing a signal (e.g., negative customer in G-networks)
4 % Signal
is a specialized OpenClass
for modeling signals in queueing networks.
5 % Unlike regular customers, signals can have special effects on queues they
6 % visit, such as removing jobs (negative signals).
8 % @brief Job
class for modeling signals in G-networks and related models
10 % Key characteristics:
11 % - Extends OpenClass with signal-specific behavior
12 % - Supports different signal types (NEGATIVE, REPLY)
13 % - NEGATIVE signals remove jobs from destination queues
14 % - Used in G-networks (Gelenbe networks)
17 % - SignalType.NEGATIVE: Removes a job from the destination queue
18 % - SignalType.REPLY: Triggers a reply action
22 % model = Network(
'GNetwork');
23 % source = Source(model,
'Source');
24 % sink = Sink(model,
'Sink');
25 % queue = Queue(model,
'Queue', SchedStrategy.FCFS);
26 % posClass = OpenClass(model,
'Positive'); % Normal customers
27 % negClass = Signal(model,
'Negative', SignalType.NEGATIVE); % Negative signals
28 % source.setArrival(posClass, Exp(1.0));
29 % source.setArrival(negClass, Exp(0.3));
32 % Reference: Gelenbe, E. (1991).
"Product-form queueing networks with
33 % negative and positive customers", Journal of Applied Probability
35 % Copyright (c) 2012-2026, Imperial College London
36 % All rights reserved.
39 signalType % SignalType constant (NEGATIVE, REPLY)
40 targetJobClass % JobClass that this signal
is associated with (for REPLY: the class to unblock)
46 function self = Signal(model, name, signalType, prio)
47 % SIGNAL Create a signal class instance
49 % @brief Creates a Signal class for G-network modeling
50 % @param model Network model to add the signal class to
51 % @param name String identifier for the signal class
52 % @param signalType SignalType constant (default: SignalType.NEGATIVE)
53 % @param prio Optional priority level (default: 0)
54 % @return self Signal instance ready for arrival specification
59 if nargin < 3 || isempty(signalType)
60 signalType = SignalType.NEGATIVE;
63 self@OpenClass(model, name, prio);
64 self.signalType = signalType;
65 self.targetJobClass = [];
67 if model.isJavaNative()
68 % Replace the OpenClass Java
object with a Signal
object
69 self.obj = jline.lang.Signal(model.obj, name, signalType, prio);
73 function type = getSignalType(self)
74 % GETSIGNALTYPE Get the signal type
76 % @
return type The SignalType of
this signal
class
77 type = self.signalType;
80 function self = forJobClass(self, jobClass)
81 % FORJOBCLASS Associate
this signal with a job
class
83 % self = FORJOBCLASS(self, jobClass) associates
this signal with
84 % the specified job
class. For REPLY signals,
this specifies which
85 % job
class's servers 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)
91 % replySignal = Signal(model, 'Reply
', SignalType.REPLY).forJobClass(reqClass);
93 self.targetJobClass = jobClass;
95 % Also update the JobClass to know about this signal (bidirectional link)
97 jobClass.replySignalClass = self;
101 function jobClass = getTargetJobClass(self)
102 % GETTARGETJOBCLASS Get the associated job class
104 % @return jobClass The JobClass associated with this signal
105 jobClass = self.targetJobClass;
108 function idx = getTargetJobClassIndex(self)
109 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
111 % @return idx Index of the associated JobClass, or -1 if none
112 if isempty(self.targetJobClass)
115 idx = self.targetJobClass.index;