LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Signal.m
1classdef Signal < OpenClass
2 % Signal Job class representing a signal (e.g., negative customer in G-networks)
3 %
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).
7 %
8 % @brief Job class for modeling signals in G-networks and related models
9 %
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)
15 %
16 % Signal types:
17 % - SignalType.NEGATIVE: Removes a job from the destination queue
18 % - SignalType.REPLY: Triggers a reply action
19 %
20 % Example:
21 % @code
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));
30 % @endcode
31 %
32 % Reference: Gelenbe, E. (1991). "Product-form queueing networks with
33 % negative and positive customers", Journal of Applied Probability
34 %
35 % Copyright (c) 2012-2026, Imperial College London
36 % All rights reserved.
37
38 properties
39 signalType % SignalType constant (NEGATIVE, REPLY)
40 targetJobClass % JobClass that this signal is associated with (for REPLY: the class to unblock)
41 end
42
43 methods
44
45 %Constructor
46 function self = Signal(model, name, signalType, prio)
47 % SIGNAL Create a signal class instance
48 %
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
55
56 if nargin < 4
57 prio = 0;
58 end
59 if nargin < 3 || isempty(signalType)
60 signalType = SignalType.NEGATIVE;
61 end
62
63 self@OpenClass(model, name, prio);
64 self.signalType = signalType;
65 self.targetJobClass = [];
66
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);
70 end
71 end
72
73 function type = getSignalType(self)
74 % GETSIGNALTYPE Get the signal type
75 %
76 % @return type The SignalType of this signal class
77 type = self.signalType;
78 end
79
80 function self = forJobClass(self, jobClass)
81 % FORJOBCLASS Associate this signal with a job class
82 %
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.
86 %
87 % @param jobClass The JobClass to associate with this signal
88 % @return self The modified Signal instance (for chaining)
89 %
90 % Example:
91 % replySignal = Signal(model, 'Reply', SignalType.REPLY).forJobClass(reqClass);
92
93 self.targetJobClass = jobClass;
94
95 % Also update the JobClass to know about this signal (bidirectional link)
96 if ~isempty(jobClass)
97 jobClass.replySignalClass = self;
98 end
99 end
100
101 function jobClass = getTargetJobClass(self)
102 % GETTARGETJOBCLASS Get the associated job class
103 %
104 % @return jobClass The JobClass associated with this signal
105 jobClass = self.targetJobClass;
106 end
107
108 function idx = getTargetJobClassIndex(self)
109 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
110 %
111 % @return idx Index of the associated JobClass, or -1 if none
112 if isempty(self.targetJobClass)
113 idx = -1;
114 else
115 idx = self.targetJobClass.index;
116 end
117 end
118
119 end
120
121end