LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
OpenSignal.m
1classdef OpenSignal < OpenClass
2 % OpenSignal Signal class for open queueing networks
3 %
4 % OpenSignal is a specialized OpenClass for modeling signals in open
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 closed networks, use ClosedSignal instead.
10 %
11 % Signal types:
12 % - SignalType.NEGATIVE: Removes a job from the destination queue
13 % - SignalType.REPLY: Unblocks servers waiting for a reply
14 %
15 % Example:
16 % @code
17 % model = Network('OpenModel');
18 % source = Source(model, 'Source');
19 % sink = Sink(model, 'Sink');
20 % queue = Queue(model, 'Queue', SchedStrategy.FCFS);
21 % reqClass = OpenClass(model, 'Request');
22 % replySignal = OpenSignal(model, 'Reply', SignalType.REPLY).forJobClass(reqClass);
23 % @endcode
24 %
25 % Copyright (c) 2012-2026, Imperial College London
26 % All rights reserved.
27
28 properties
29 signalType % SignalType constant (NEGATIVE, REPLY)
30 targetJobClass % JobClass that this signal is associated with
31 removalDistribution % DiscreteDistribution for number of removals (empty = remove exactly 1)
32 removalPolicy % RemovalPolicy constant (RANDOM, FCFS, LCFS)
33 end
34
35 methods
36
37 function self = OpenSignal(model, name, signalType, prio)
38 % OPENSIGNAL Create an open signal class instance
39 %
40 % @param model Network model to add the signal class to
41 % @param name String identifier for the signal class
42 % @param signalType SignalType constant (default: SignalType.NEGATIVE)
43 % @param prio Optional priority level (default: 0)
44 % @return self OpenSignal instance
45
46 if nargin < 4
47 prio = 0;
48 end
49 if nargin < 3 || isempty(signalType)
50 signalType = SignalType.NEGATIVE;
51 end
52
53 self@OpenClass(model, name, prio);
54 self.signalType = signalType;
55 self.targetJobClass = [];
56 self.removalDistribution = [];
57 self.removalPolicy = RemovalPolicy.RANDOM;
58
59 if model.isJavaNative()
60 % Replace the OpenClass Java object with a Signal object
61 self.obj = jline.lang.Signal(model.obj, name, signalType, prio);
62 end
63 end
64
65 function type = getSignalType(self)
66 % GETSIGNALTYPE Get the signal type
67 type = self.signalType;
68 end
69
70 function self = forJobClass(self, jobClass)
71 % FORJOBCLASS Associate this signal with a job class
72 %
73 % For REPLY signals, this specifies which job class's servers
74 % will be unblocked when this signal arrives.
75 %
76 % @param jobClass The JobClass to associate with this signal
77 % @return self The modified Signal instance (for chaining)
78
79 self.targetJobClass = jobClass;
80 if ~isempty(jobClass)
81 jobClass.replySignalClass = self;
82 end
83 end
84
85 function jobClass = getTargetJobClass(self)
86 % GETTARGETJOBCLASS Get the associated job class
87 jobClass = self.targetJobClass;
88 end
89
90 function idx = getTargetJobClassIndex(self)
91 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
92 if isempty(self.targetJobClass)
93 idx = -1;
94 else
95 idx = self.targetJobClass.index;
96 end
97 end
98
99 function b = isCatastrophe(self)
100 % ISCATASTROPHE Check if this is a catastrophe signal
101 %
102 % @return b true if signalType is SignalType.CATASTROPHE
103 b = (self.signalType == SignalType.CATASTROPHE);
104 end
105
106 function dist = getRemovalDistribution(self)
107 % GETREMOVALDISTRIBUTION Get the removal distribution
108 dist = self.removalDistribution;
109 end
110
111 function self = setRemovalDistribution(self, dist)
112 % SETREMOVALDISTRIBUTION Set the removal distribution
113 self.removalDistribution = dist;
114 end
115
116 function policy = getRemovalPolicy(self)
117 % GETREMOVALPOLICY Get the removal policy
118 policy = self.removalPolicy;
119 end
120
121 function self = setRemovalPolicy(self, policy)
122 % SETREMOVALPOLICY Set the removal policy
123 self.removalPolicy = policy;
124 end
125
126 end
127
128end