1classdef ClosedClass < JobClass
2 % ClosedClass Job
class with fixed population circulating in the network
4 % ClosedClass represents a job
class with a fixed number of jobs that
5 % perpetually circulate within the network. Jobs never leave the system
6 % and the total population remains constant. This
is essential
for modeling
7 % systems with limited resources or finite user populations.
9 % @brief Job
class with fixed population circulating within the network
11 % Key characteristics:
12 % - Fixed finite population of jobs
13 % - Jobs never enter or leave the network
14 % - Constant total network population
15 % - Reference station
for performance metrics
16 % - Priority-based service differentiation
17 % - Think time modeling
for user behavior
19 % Closed
class features:
20 % - Fixed population constraint enforcement
21 % - Reference station designation for metrics
22 % - Think time specification for user delays
23 % - Priority assignment for service
24 % - Circulation-based performance analysis
25 % - Saturation and throughput modeling
27 % ClosedClass
is used for:
28 % - Terminal-based computer systems
29 % - Time-sharing system modeling
30 % - Manufacturing systems with fixed workpieces
31 % - Batch processing systems
32 % - Systems with resource constraints
36 % model = Network('ClosedSystem');
37 % cpu = Queue(model, 'CPU', SchedStrategy.PS);
38 % disk = Queue(model, 'Disk', SchedStrategy.FCFS);
39 % think = Delay(model, 'ThinkTime');
40 % users = ClosedClass(model, 'Users', 20, think, 1); % 20 users
41 % think.setService(users, Exp(0.1)); % Think time
44 % Copyright (c) 2012-2026, Imperial College London
45 % All rights reserved.
54 function self = ClosedClass(model, name, njobs, refstat, prio, deadline)
55 % CLOSEDCLASS Create a closed job class instance
57 % @brief Creates a ClosedClass with fixed population circulating in network
58 % @param model Network model to add the closed class to
59 % @param name String identifier for the job class
60 % @param njobs Number of jobs in the class (fixed population)
61 % @param refstat Reference station for performance measurement
62 % @param prio Optional priority level (default: 0)
63 % @param deadline Optional relative deadline from arrival (default: Inf, no deadline)
64 % @return self ClosedClass instance with specified population
66 self@JobClass(JobClassType.CLOSED, name);
68 %global GlobalConstants.CoarseTol
77 if model.isMatlabNative()
78 self.type = JobClassType.CLOSED;
79 self.population = njobs;
80 if abs(njobs-round(njobs))>GlobalConstants.CoarseTol
81 line_warning(mfilename,sprintf('The number of jobs in class %s should be an integer, some solvers might fail.\n', name));
85 if nargin>=5 %exist('prio','var')
89 self.deadline = deadline;
91 model.addJobClass(self);
92 if ~isa(refstat, 'Station')
93 if isa(refstat, 'Node')
94 line_error(mfilename,sprintf('The reference station of class %s needs to be a station, not a node.\n', name));
96 line_error(mfilename,sprintf('The parameter for the reference station of class %s is not a valid object.\n', name));
99 setReferenceStation(self, refstat);
101 % set default scheduling for this class at all
nodes
102 for i=1:length(model.nodes)
103 model.
nodes{i}.setRouting(self, RoutingStrategy.RAND);
104 if isa(model.nodes{i},
'Join')
105 model.
nodes{i}.setStrategy(self, JoinStrategy.STD);
106 model.nodes{i}.setRequired(self, -1);
109 elseif model.isJavaNative()
110 self.index = model.obj.getNumberOfClasses + 1;
111 if ~isa(self,
'SelfLoopingClass')
112 self.obj = jline.lang.ClosedClass(model.obj, name, njobs, refstat.obj, prio, deadline);
114 setReferenceStation(self, refstat);
118 function setReferenceStation(class, source)
119 % SETREFERENCESTATION(CLASS, SOURCE)
120 setReferenceStation@JobClass(class, source);
123 function summary(self)
125 line_printf('Class (%s): <strong>%s</strong> [%d jobs]',self.type,self.getName,self.population);