Class Queue
- All Implemented Interfaces:
Serializable,Copyable
- Direct Known Subclasses:
Delay
The Queue node is the fundamental service station in queueing networks. It models a system where jobs wait in a buffer and are processed by one or more servers according to a scheduling strategy. Common examples include CPU schedulers, disk I/O queues, network routers, and service desks.
Key features:
- Multiple scheduling strategies: FCFS, PS, LCFS, priority-based, etc.
- Single or multi-server configurations
- Load-dependent and class-dependent service rates
- Support for preemptive and non-preemptive policies
- Polling server capabilities with various polling types
- Switchover times between job classes
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<JobClass, Distribution> Delay-off time distributions for function tasks (teardown time).protected Map<JobClass, Distribution> Setup time distributions for function tasks (cold start time).Fields inherited from class jline.lang.nodes.ServiceStation
serviceProcessesFields inherited from class jline.lang.nodes.Station
balkingStrategies, balkingThresholds, batchRejectProb, cap, classCap, dropRule, impatienceTypes, lcdScaling, lcdScalingPeak, lldScaling, numberOfServers, orbitImpatienceDistributions, patienceDistributions, retrialDelayDistributions, retrialMaxAttempts, switchoverTimesFields inherited from class jline.lang.nodes.ServiceNode
schedPolicy, schedStrategy, schedStrategyParFields inherited from class jline.lang.nodes.Node
dropStrategy, input, model, nodeIndex, output, server, statefulIdx, stationIdx -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddServerType(ServerType serverType) Adds a server type to this queue for heterogeneous multiserver configuration.checkPermInvariance(double[] Nvec, double cap) Checks the order-independence (OI) condition on the service rate mu(c): the rate of the job in position j must depend only on the jobs at or ahead of it (positions 1..j) and not on those behind.booleancontainsJobClass(JobClass jobClass) Checks whether this queue has a service process configured for the specified job class.getDelayOffTime(JobClass jobClass) Gets the delay-off time distribution for a job class.Gets the scheduling policy for heterogeneous servers.Gets all heterogeneous service distributions for this queue.Gets the set of class indices with immediate feedback enabled.intGets the number of server types configured for this queue.Gets the scheduling policy type (preemptive or non-preemptive).Gets the scheduling strategy used by this queue.doublegetSchedStrategyPar(JobClass jobClass) Gets the scheduling strategy parameter for a specific job class.getServerType(int id) Gets a server type by its ID.getServerType(String name) Gets a server type by its name.Gets the list of server types configured for this queue.getService(JobClass jobClass) Gets the service time distribution for a specific job class.getService(JobClass jobClass, ServerType serverType) Gets the service time distribution for a specific job class and server type.Returns the mu(c) service rate function of a PAS queue, or null.getSetupTime(JobClass jobClass) Gets the setup time distribution for a job class.Returns the (nclasses x nclasses) swap graph of a PAS queue, or null.getSwitchover(JobClass jobClass) Gets the switchover time for a job class (POLLING scheduling strategy).getSwitchover(JobClass fromClass, JobClass toClass) Gets the switchover time from one job class to another.booleanChecks if immediate feedback is enabled for any class at this queue.booleanhasImmediateFeedback(int classId) Checks if immediate feedback is enabled for a specific class at this queue.booleanChecks if this queue has delay-off times enabled.booleanChecks if this queue is configured as a heterogeneous multiserver queue.booleanChecks if immediate feedback is enabled for all classes.voidPrints a summary of this queue's configuration to standard output.voidSets a class-dependent scaling function for service rates.voidsetClassDependence(SerializableFunction<Matrix, Matrix> beta, Matrix peakRatePerClass) Sets a class-dependent service-rate scaling and its required peak rate per class.voidsetDelayOff(JobClass jobClass, Distribution setupTime, Distribution delayoffTime) Sets the setup time and delay off time for a job class.voidSets the scheduling policy for heterogeneous servers.voidsetImmediateFeedback(boolean enabled) Enables or disables immediate feedback for all job classes at this queue.voidsetImmediateFeedback(JobClass jobClass) Enables immediate feedback for a specific job class at this queue.voidsetImmediateFeedbackForClasses(List<JobClass> jobClasses) Enables immediate feedback for multiple job classes at this queue.voidsetItemServiceRate(Cache cache, JobClass jobinClass, int item, double serviceRate) Override, at this queue, the retrieval service rate for a single item of the read class jobinClass in the given cache's retrieval system.voidsetLimit(int limit) Sets the maximum number of jobs for LPS scheduling.voidsetLoadDependence(Matrix alpha) Sets load-dependent service rate scaling factors.voidsetNumberOfServers(int numberOfServers) Sets the number of servers at this queueing station.voidsetPollingK(int k) Sets the K value for K-LIMITED polling (only valid for POLLING scheduling strategy with K-LIMITED type).voidsetPollingType(PollingType pollingType) Sets the polling type for this queue (only valid for POLLING scheduling strategy).voidsetPollingType(PollingType pollingType, int k) Sets the polling type for this queue with K value for K-LIMITED (only valid for POLLING scheduling strategy).voidsetSchedStrategyPar(JobClass jobClass, double weight) Sets the scheduling strategy parameter for a specific job class.voidsetService(JobClass jobClass, ServerType serverType, Distribution distribution) Sets the service time distribution for a specific job class and server type.voidsetService(SerializableFunction<Matrix, Double> muFun) Sets the total service rate function mu(c) of a pass-and-swap (PAS) queue.voidSets the total service rate function mu(c) of a pass-and-swap (PAS) queue.voidsetSwapGraph(Matrix graph) Sets the class compatibility/swap graph of a pass-and-swap (PAS) queue.voidsetSwitchover(JobClass fromClass, JobClass toClass, Distribution switchoverTime) Sets the switchover time from one job class to another (for general scheduling strategies).voidsetSwitchover(JobClass jobClass, Distribution switchoverTime) Sets the switchover time for a job class (only valid for POLLING scheduling strategy).booleanChecks if all job classes have at least one compatible server type.Methods inherited from class jline.lang.nodes.ServiceStation
getServiceProcess, removeJobClass, setService, setService, setServiceMethods inherited from class jline.lang.nodes.Station
getBalkingStrategy, getBalkingStrategyLocal, getBalkingThresholds, getBalkingThresholdsLocal, getBatchRejectProbability, getCap, getClassCap, getDropRule, getImpatienceType, getImpatienceTypeLocal, getLimitedClassDependence, getLimitedClassDependencePeak, getLimitedLoadDependence, getMaxRetrialAttempts, getMaxRetrialAttemptsLocal, getNumberOfServers, getOrbitImpatience, getOrbitImpatienceLocal, getPatience, getPatienceLocal, getRetrialDelayDistribution, getRetrialDelayDistributionLocal, getServiceRates, getSourceRates, getStrategyParam, getSwitchoverTime, hasBalking, hasBalkingLocal, hasFiniteCap, hasOrbitImpatience, hasPatience, hasPatienceLocal, hasRetrial, hasRetrialLocal, hasSwitchoverTime, isReferenceStation, isServiceDefined, isServiceDefined, isServiceDisabled, isServiceDisabled, setBalking, setBalking, setBatchRejectProbability, setCap, setCapacity, setChainCapacity, setClassCap, setDropRule, setLimitedClassDependence, setLimitedClassDependence, setLimitedLoadDependence, setOrbitImpatience, setPatience, setPatience, setRetrial, setRetrial, setStrategyParam, setSwitchoverTimeMethods inherited from class jline.lang.nodes.StatefulNode
clearState, getState, getStatefulIndex, getStatePrior, getStateSpace, resetStateSpace, setState, setState, setStatePrior, setStateSpaceMethods inherited from class jline.lang.nodes.Node
getAttribute, getDropStrategy, getInput, getModel, getNodeIndex, getOutput, getOutputStrategies, getRoutingStrategy, getSections, getServer, getStatefulIdx, getStationIdx, isStateful, reset, resetRouting, setKChoicesRouting, setModel, setNodeIdx, setProbRouting, setRLRouting, setRouting, setRouting, setStationIdx
-
Field Details
-
setupTimes
Setup time distributions for function tasks (cold start time). Maps job classes to their setup time distributions. -
delayOffTimes
Delay-off time distributions for function tasks (teardown time). Maps job classes to their delay-off time distributions.
-
-
Constructor Details
-
Queue
Creates a new queueing station with the specified scheduling strategy. Configures the appropriate server type based on the scheduling strategy. The queue is automatically added to the network model.- Parameters:
model- the network model to add this queue toname- the name for this queueing stationschedStrategy- the scheduling strategy to use (e.g., FCFS, PS, LCFS)- Throws:
RuntimeException- if the scheduling strategy is not supported
-
Queue
Creates a new queueing station with default processor sharing (PS) scheduling.- Parameters:
model- The network model to add this queue toname- The name for this queueing station
-
-
Method Details
-
containsJobClass
Checks whether this queue has a service process configured for the specified job class.- Parameters:
jobClass- The job class to check- Returns:
- true if a service process exists for this job class, false otherwise
-
getSchedPolicy
Gets the scheduling policy type (preemptive or non-preemptive).- Returns:
- The scheduling policy type (PR for preemptive, NP for non-preemptive)
-
setService
Sets the total service rate function mu(c) of a pass-and-swap (PAS) queue. An order-independent/PAS queue is parameterized by mu(c) as a whole, not by per-class service distributions; this overload of setService accepts the mu(c) function directly.- Parameters:
muFun- maps the ordered state vector c (1xN row Matrix of 0-based class indices, c(0) oldest) to the scalar total service rate
-
setServiceRateFunction
Sets the total service rate function mu(c) of a pass-and-swap (PAS) queue. Also derives a representative per-class rate mu([r]) (single class-r job) so the standard rate/process machinery stays consistent; the authoritative service description remains mu(c).- Parameters:
muFun- the mu(c) service rate function
-
getServiceRateFunction
Returns the mu(c) service rate function of a PAS queue, or null.- Returns:
- the mu(c) function
-
checkPermInvariance
Checks the order-independence (OI) condition on the service rate mu(c): the rate of the job in position j must depend only on the jobs at or ahead of it (positions 1..j) and not on those behind. Since the position-j rate is the prefix increment mu(c[:j]) - mu(c[:j-1]), tail-independence is structural; the substantive requirement is that this increment be independent of the order of the jobs ahead, which (by induction on prefix length) is equivalent to mu(c) being permutation- invariant. Enumerates the reachable multisets (per-class counts <= Nvec, total <= cap) when small, otherwise samples and sets partial=true. -
setSwapGraph
Sets the class compatibility/swap graph of a pass-and-swap (PAS) queue.- Parameters:
graph- (nclasses x nclasses) adjacency matrix; entry (r,s) nonzero iff, upon completion of a class-r job, a waiting class-s job may take its place. Undirected; self-loops allowed.
-
getSwapGraph
Returns the (nclasses x nclasses) swap graph of a PAS queue, or null.- Returns:
- the swap graph matrix
-
getSchedStrategy
Gets the scheduling strategy used by this queue.- Overrides:
getSchedStrategyin classStation- Returns:
- The scheduling strategy (e.g., FCFS, PS, LCFS, etc.)
-
getSchedStrategyPar
Gets the scheduling strategy parameter for a specific job class.For strategies like DPS (Discriminatory Processor Sharing) and GPS (Generalized Processor Sharing), this returns the weight or priority parameter for the job class.
- Overrides:
getSchedStrategyParin classServiceNode- Parameters:
jobClass- The job class to get the parameter for- Returns:
- The scheduling parameter value, or 0.0 if not set
-
getService
Gets the service time distribution for a specific job class.- Parameters:
jobClass- The job class to get the service distribution for- Returns:
- The service time distribution for this job class
-
setItemServiceRate
Override, at this queue, the retrieval service rate for a single item of the read class jobinClass in the given cache's retrieval system. The default (when not overridden) is the read class's own service distribution at this queue. item is 0-based.- Parameters:
cache- the cache whose retrieval system contains this queuejobinClass- the read class that creates the retrieval requestitem- the requested item (0-based)serviceRate- exponential service rate for the item at this queue
-
printSummary
public void printSummary()Prints a summary of this queue's configuration to standard output.The summary includes the queue name, service processes for each job class, their mean service times and squared coefficients of variation, number of servers, and output routing configuration.
- Overrides:
printSummaryin classNode
-
setClassDependence
Sets a class-dependent scaling function for service rates.The function takes a matrix representing the number of jobs of each class at the station and returns the service rate scaling. It may return either a 1x1 matrix, i.e. a chain-independent scaling beta_i(n) shared by every class, or a length-R row vector [beta_{i,1}(n), ..., beta_{i,R}(n)] giving each class its own rate at the same population, which expresses Sauer's chain-dependent service rates mu_{r,i}(n) (Sauer 1983, eq. (40)). This enables modeling of systems where service rates depend on the job mix.
- Parameters:
beta- A function that maps job class populations to a service rate scaling- Throws:
RuntimeException- if the scheduling strategy doesn't support class dependence
-
setClassDependence
Sets a class-dependent service-rate scaling and its required peak rate per class. Utilization at the station is reported as U = T*S/peak.- Parameters:
beta- maps the per-class population vector to a service-rate scalingpeakRatePerClass- 1x1 (broadcast) or 1xR peak rate scaling per class
-
setLoadDependence
Sets load-dependent service rate scaling factors.Each element alpha[n] specifies the service rate scaling when there are n jobs at the station. This enables modeling of systems where performance degrades under load.
- Parameters:
alpha- A matrix of scaling factors indexed by the number of jobs- Throws:
RuntimeException- if the scheduling strategy doesn't support load dependence
-
setNumberOfServers
public void setNumberOfServers(int numberOfServers) Sets the number of servers at this queueing station.For infinite server (IS) queues, this method has no effect as they always have unlimited servers.
- Overrides:
setNumberOfServersin classStation- Parameters:
numberOfServers- The number of parallel servers (must be positive)
-
setSchedStrategyPar
Sets the scheduling strategy parameter for a specific job class.For weighted scheduling strategies (DPS, GPS, etc.), this sets the weight or priority parameter that determines the job class's share of the service capacity.
- Parameters:
jobClass- The job class to set the parameter forweight- The scheduling parameter value (e.g., weight, priority)
-
setLimit
public void setLimit(int limit) Sets the maximum number of jobs for LPS scheduling. For LPS: limit is the max number of jobs that can execute in PS mode.- Parameters:
limit- the maximum number of concurrent jobs in PS mode- Throws:
RuntimeException- if called on non-LPS queue
-
setPollingType
Sets the polling type for this queue (only valid for POLLING scheduling strategy).- Parameters:
pollingType- the polling type (GATED, EXHAUSTIVE, or KLIMITED)
-
setPollingType
Sets the polling type for this queue with K value for K-LIMITED (only valid for POLLING scheduling strategy).- Parameters:
pollingType- the polling type (GATED, EXHAUSTIVE, or KLIMITED)k- the K value for K-LIMITED polling (ignored for other types)
-
setPollingK
public void setPollingK(int k) Sets the K value for K-LIMITED polling (only valid for POLLING scheduling strategy with K-LIMITED type).- Parameters:
k- the K value (must be greater than 0)
-
setSwitchover
Sets the switchover time for a job class (only valid for POLLING scheduling strategy).- Parameters:
jobClass- the job classswitchoverTime- the switchover time distribution
-
setSwitchover
Sets the switchover time from one job class to another (for general scheduling strategies).- Parameters:
fromClass- the job class to switch fromtoClass- the job class to switch toswitchoverTime- the switchover time distribution
-
getSwitchover
Gets the switchover time from one job class to another.- Parameters:
fromClass- the job class to switch fromtoClass- the job class to switch to- Returns:
- the switchover time distribution, or null if not set
-
getSwitchover
Gets the switchover time for a job class (POLLING scheduling strategy).- Parameters:
jobClass- the job class- Returns:
- the switchover time distribution, or null if not set
-
setDelayOff
Sets the setup time and delay off time for a job class. This is typically used for function-based tasks that have initialization overhead.- Parameters:
jobClass- the job classsetupTime- the setup time distributiondelayoffTime- the delay off time distribution
-
getSetupTime
Gets the setup time distribution for a job class.- Parameters:
jobClass- the job class- Returns:
- the setup time distribution, or null if not set
-
getDelayOffTime
Gets the delay-off time distribution for a job class.- Parameters:
jobClass- the job class- Returns:
- the delay-off time distribution, or null if not set
-
isDelayOffEnabled
public boolean isDelayOffEnabled()Checks if this queue has delay-off times enabled. Delay-off is considered enabled if any job class has both a setup time and a delay-off time distribution configured.- Returns:
- true if delay-off is enabled, false otherwise
-
addServerType
Adds a server type to this queue for heterogeneous multiserver configuration.When server types are added, the queue becomes a heterogeneous multiserver queue where different server types can have different service rates and serve different subsets of job classes.
The total number of servers at this queue becomes the sum of all server type counts.
- Parameters:
serverType- the server type to add- Throws:
IllegalArgumentException- if serverType is null or already added
-
getServerTypes
Gets the list of server types configured for this queue.- Returns:
- a new list containing the server types
-
getNumServerTypes
public int getNumServerTypes()Gets the number of server types configured for this queue.- Returns:
- the number of server types, or 0 if homogeneous
-
isHeterogeneous
public boolean isHeterogeneous()Checks if this queue is configured as a heterogeneous multiserver queue.- Returns:
- true if server types are defined, false for homogeneous queue
-
setHeteroSchedPolicy
Sets the scheduling policy for heterogeneous servers.This policy determines how jobs are assigned to server types when a job's class is compatible with multiple server types.
- Parameters:
policy- the heterogeneous scheduling policy- Throws:
IllegalArgumentException- if policy is null
-
getHeteroSchedPolicy
Gets the scheduling policy for heterogeneous servers.- Returns:
- the heterogeneous scheduling policy
-
setService
Sets the service time distribution for a specific job class and server type.This method is used for heterogeneous multiserver queues where different server types may have different service rates for the same job class.
- Parameters:
jobClass- the job classserverType- the server typedistribution- the service time distribution- Throws:
IllegalArgumentException- if any parameter is null or serverType is not in this queue
-
getService
Gets the service time distribution for a specific job class and server type.- Parameters:
jobClass- the job classserverType- the server type- Returns:
- the service time distribution, or null if not set
-
getHeteroServiceDistributions
Gets all heterogeneous service distributions for this queue.- Returns:
- the map of server type to job class to distribution
-
getServerType
Gets a server type by its ID.- Parameters:
id- the server type ID- Returns:
- the server type, or null if not found
-
getServerType
Gets a server type by its name.- Parameters:
name- the server type name- Returns:
- the server type, or null if not found
-
validateCompatibility
public boolean validateCompatibility()Checks if all job classes have at least one compatible server type.This validation is important because in heterogeneous queues, every job class must be able to be served by at least one server type.
- Returns:
- true if all job classes have at least one compatible server type
-
setImmediateFeedback
public void setImmediateFeedback(boolean enabled) Enables or disables immediate feedback for all job classes at this queue. When enabled, jobs that self-loop at this station stay in service instead of rejoining the queue.- Parameters:
enabled- true to enable immediate feedback for all classes, false to disable
-
setImmediateFeedback
Enables immediate feedback for a specific job class at this queue.- Parameters:
jobClass- the job class to enable immediate feedback for
-
setImmediateFeedbackForClasses
Enables immediate feedback for multiple job classes at this queue.- Parameters:
jobClasses- list of job classes to enable immediate feedback for
-
hasImmediateFeedback
public boolean hasImmediateFeedback()Checks if immediate feedback is enabled for any class at this queue.- Returns:
- true if immediate feedback is enabled for at least one class
-
hasImmediateFeedback
public boolean hasImmediateFeedback(int classId) Checks if immediate feedback is enabled for a specific class at this queue.- Parameters:
classId- the class index (0-based)- Returns:
- true if immediate feedback is enabled for the specified class
-
getImmediateFeedbackClasses
Gets the set of class indices with immediate feedback enabled.- Returns:
- set of class indices, or null if none are set
-
isImmediateFeedbackAll
public boolean isImmediateFeedbackAll()Checks if immediate feedback is enabled for all classes.- Returns:
- true if immediate feedback is enabled for all classes
-