LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ClosedClass.m
1classdef ClosedClass < JobClass
2 % ClosedClass Job class with fixed population circulating in the network
3 %
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.
8 %
9 % @brief Job class with fixed population circulating within the network
10 %
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
18 %
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
26 %
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
33 %
34 % Example:
35 % @code
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
42 % @endcode
43 %
44 % Copyright (c) 2012-2026, Imperial College London
45 % All rights reserved.
46
47 properties
48 population;
49 end
50
51 methods
52
53 %Constructor
54 function self = ClosedClass(model, name, njobs, refstat, prio, deadline)
55 % CLOSEDCLASS Create a closed job class instance
56 %
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
65
66 self@JobClass(JobClassType.CLOSED, name);
67
68 %global GlobalConstants.CoarseTol
69
70 if nargin<5
71 prio = 0;
72 end
73 if nargin<6
74 deadline = Inf;
75 end
76
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));
82 end
83 self.priority = 0;
84 self.deadline = Inf;
85 if nargin>=5 %exist('prio','var')
86 self.priority = prio;
87 end
88 if nargin>=6
89 self.deadline = deadline;
90 end
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));
95 else
96 line_error(mfilename,sprintf('The parameter for the reference station of class %s is not a valid object.\n', name));
97 end
98 end
99 setReferenceStation(self, refstat);
100
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);
107 end
108 end
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);
113 end
114 setReferenceStation(self, refstat);
115 end
116 end
117
118 function setReferenceStation(class, source)
119 % SETREFERENCESTATION(CLASS, SOURCE)
120 setReferenceStation@JobClass(class, source);
121 end
122
123 function summary(self)
124 % SUMMARY()
125 line_printf('Class (%s): <strong>%s</strong> [%d jobs]',self.type,self.getName,self.population);
126 end
127 end
128
129end
130
Definition mmt.m:92