Learn R Programming

simEd (version 2.0.1)

ssqvis: Single-Server Queue Simulation Visualization

Description

A modified ssq implementation that illustrates event-driven details, including the event calendar, inversion for interarrival and service time variate generation, the simulation clock, the status of the queueing system, and statistics collection. The function plots step-by-step in either an interactive mode or time-delayed automatic mode.

Usage

ssqvis(
  maxArrivals = Inf,
  seed = NA,
  interarrivalType = "M",
  serviceType = "M",
  maxTime = Inf,
  maxDepartures = Inf,
  maxEventsPerSkyline = 15,
  saveAllStats = FALSE,
  saveInterarrivalTimes = FALSE,
  saveServiceTimes = FALSE,
  saveWaitTimes = FALSE,
  saveSojournTimes = FALSE,
  saveNumInQueue = FALSE,
  saveNumInSystem = FALSE,
  saveServerStatus = FALSE,
  showOutput = TRUE,
  showSkyline = NULL,
  showSkylineQueue = TRUE,
  showSkylineSystem = TRUE,
  showSkylineServer = TRUE,
  showTitle = TRUE,
  jobImage = NA,
  plotDelay = -1
)

Value

The function returns a list containing:

  • the number of arrivals to the system (customerArrivals),

  • the number of customers processed (customerDepartures),

  • the ending time of the simulation (simulationEndTime),

  • average wait time in the queue (avgWait),

  • average time in the system (avgSojourn),

  • average number in the system (avgNumInSystem),

  • average number in the queue (avgNumInQueue), and

  • server utilization (utilization).

of the queue as computed by the simulation. When requested via the ``save...'' parameters, the list may also contain:

  • a vector of interarrival times (interarrivalTimes),

  • a vector of wait times (waitTimes),

  • a vector of service times (serviceTimes),

  • a vector of sojourn times (sojournTimes),

  • two vectors (time and count) noting changes to number in the system (numInSystemT, numInSystemN),

  • two vectors (time and count) noting changes to number in the queue (numInQueueT, numInQueueN), and

  • two vectors (time and status) noting changes to server status (serverStatusT, serverStatusN).

Arguments

maxArrivals

maximum number of customer arrivals allowed to enter the system

seed

initial seed to the random number generator (NA uses current state of random number generator; NULL seeds using system clock)

interarrivalType

string representation of desired interarrival process. Options are "M" -- exponential with rate 1; "G" -- uniform(0,2), having mean 1; and "D" -- deterministic with constant value 1. Default is "M".

serviceType

string representation of desired service process . Options are "M" -- exponential with rate 10/9; "G" -- uniform(0, 1.8), having mean 9/10; and "D" -- deterministic with constant value 9/10. Default is "M".

maxTime

maximum time to simulate

maxDepartures

maximum number of customer departures to process

maxEventsPerSkyline

maximum number of events viewable at a time in the skyline plot. A large value for this parameter may result in plotting delays. This parameter does not impact the final plotting, which will show all end-of-simulation results.

saveAllStats

if TRUE, returns all vectors of statistics (see below) collected by the simulation

saveInterarrivalTimes

if TRUE, returns a vector of all interarrival times generated

saveServiceTimes

if TRUE, returns a vector of all service times generated

saveWaitTimes

if TRUE, returns a vector of all wait times (in the queue) generated

saveSojournTimes

if TRUE, returns a vector of all sojourn times (time spent in the system) generated

saveNumInQueue

if TRUE, returns a vector of times and a vector of counts for whenever the number in the queue changes

saveNumInSystem

if TRUE, returns a vector of times and a vector of counts for whenever the number in the system changes

saveServerStatus

if TRUE, returns a vector of times and a vector of server status (0:idle, 1:busy) for whenever the status changes

showOutput

if TRUE, displays summary statistics upon completion

showSkyline

If NULL (default), defers to each individual showSkyline... parameter below; otherwise, supersedes individual showSkyline... parameter values. If TRUE, displays full skyline plot; FALSE suppresses skyline plot. Can alternatively be specified using chmod-like octal component specification: use 1, 2, 4 for system, queue, and server respectively, summing to indicate desired combination (e.g., 7 for all). Can also be specified as a binary vector (e.g., c(1,1,1) for all).

showSkylineQueue

logical; if TRUE, includes number in queue as part of skyline plot. Value for showSkyline supersedes this parameter's value.

showSkylineSystem

logical; if TRUE, includes number in system as part of skyline plot. Value for showSkyline supersedes this parameter's value.

showSkylineServer

logical; if TRUE, includes number in server as part of skyline plot. Value for showSkyline supersedes this parameter's value.

showTitle

if TRUE, display title at the top of the main plot

jobImage

a vector of URLs/local addresses of images to use as jobs. Requires package 'magick'.

plotDelay

a positive numeric value indicating seconds between plots. A value of -1 enters 'interactive' mode, where the state will pause for user input at each step. A value of 0 will display only the final end-of-simulation plot.

Author

Barry Lawson (blawson@bates.edu),
Larry Leemis (leemis@math.wm.edu),
Vadim Kudlay (vkudlay@nvidia.com)

Details

Animates the details of an event-driven implementation of a single-server queue simulation.

The event calendar, inversion for interarrival and service time variates, and an abbreviated (current) timeline are animated in the top pane of the window. In this pane, blue corresponds to the arrival process, orange corresponds to the service process, and purple corresponds to uniform variates used in inversion. Yellow is used to highlight recent updates.

The state of the queueing system is animated in the middle pane of the window. In this pane, red indicates an idle server, orange indicates that a new customer has just arrived to the server and a corresponding service time is being generated, and green indicates a busy server. By default, customers are depicted as black rectangles and identified by increasing arrival number, but this depiction can be overridden by the jobImage parameter.

Statistics are displayed in the bottom pane of the window. Time-persistent statistics are shown as "skyline functions" in the left portion of this pane. Both time-persistent and based-on-observation statistics are shown in respective tables in the right portion of this pane. In the tables, yellow is used to highlight recent updates.

The seed parameter can take one of three valid argument types:

  • NA (default), which will use the current state of the random number generator without explicitly setting a new seed (see examples);

  • a positive integer, which will be used as the initial seed passed in an explicit call to set.seed; or

  • NULL, which will be passed in an explicit call to to set.seed, thereby setting the initial seed using the system clock.

See Also

Examples

Run this code

 # Visualizing ssq with a set seed, infinite queue capacity, 4 arrivals,
 # and showing skyline with number in system, queue, and server.
 ssqvis(seed = 1234, maxArrivals = 4, showSkyline = 7, plotDelay = 0.01)

Run the code above in your browser using DataLab