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 % Only a REPLY signal establishes the synchronous-call link:
81 % for a NEGATIVE or CATASTROPHE signal forJobClass merely names the
82 % victim class, and setting replySignalClass there made
83 % sn.syncreply >= 0, so the state layer reserved a held-server
84 % counter and rejected every non-FCFS station.
85 if ~isempty(jobClass) && self.signalType == SignalType.REPLY
86 jobClass.replySignalClass = self;
87 end
88 end
89
90 function jobClass = getTargetJobClass(self)
91 % GETTARGETJOBCLASS Get the associated job class
92 jobClass = self.targetJobClass;
93 end
94
95 function idx = getTargetJobClassIndex(self)
96 % GETTARGETJOBCLASSINDEX Get the index of the associated job class
97 if isempty(self.targetJobClass)
98 idx = -1;
99 else
100 idx = self.targetJobClass.index;
101 end
102 end
103
104 function b = isCatastrophe(self)
105 % ISCATASTROPHE Check if this is a catastrophe signal
106 %
107 % @return b true if signalType is SignalType.CATASTROPHE
108 b = (self.signalType == SignalType.CATASTROPHE);
109 end
110
111 function dist = getRemovalDistribution(self)
112 % GETREMOVALDISTRIBUTION Get the removal distribution
113 dist = self.removalDistribution;
114 end
115
116 function self = setRemovalDistribution(self, dist)
117 % SETREMOVALDISTRIBUTION Set the removal distribution
118 self.removalDistribution = dist;
119 end
120
121 function policy = getRemovalPolicy(self)
122 % GETREMOVALPOLICY Get the removal policy
123 policy = self.removalPolicy;
124 end
125
126 function self = setRemovalPolicy(self, policy)
127 % SETREMOVALPOLICY Set the removal policy
128 self.removalPolicy = policy;
129 end
130
131 end
132
133end
Definition Station.m:245