Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

queueTrace

Trace Data for Single-Server Queue Simulation


Description

This data set contains the arrival and service times for 1000 jobs arriving to a generic single-server queue.

Usage

data(queueTrace)

Format

A list of two vectors, arrivalTimes and serviceTimes.

Details

This trace data could be used as input for the ssq function, but not directly. That is, ssq expects interarrival and service functions as input, not vectors of arrival times and service times. Accordingly, the user will need to write functions to extract the interarrival and service times from this trace, which can then be passed to ssq. See examples below.

Examples

data(queueTrace)
  interarrivalTimes   <- c(queueTrace$arrivalTimes[1], diff(queueTrace$arrivalTimes))
  serviceTimes        <- queueTrace$serviceTimes

  avgInterarrivalTime <- mean(interarrivalTimes)
  avgServiceTime      <- mean(serviceTimes)

  # functions to use this trace data for the ssq() function;
  # note that the functions below destroy the global values of the copied 
  # interarrivalTimes and serviceTimes vectors along the way...
  #
  interarrivalTimes <- NULL
  serviceTimes      <- NULL
  getInterarr <- function(...)
  {
      if (length(interarrivalTimes) == 0) { 
            interarrivalTimes <<- c(queueTrace$arrivalTimes[1], 
                                    diff(queueTrace$arrivalTimes))
      }
      nextInterarr <- interarrivalTimes[1]
      interarrivalTimes <<- interarrivalTimes[-1] # remove 1st element globally
      return(nextInterarr)
  }
  getService <- function(...)
  {
      if (length(serviceTimes) == 0) { 
          serviceTimes <<- queueTrace$serviceTimes
      }
      nextService <- serviceTimes[1]
      serviceTimes <<- serviceTimes[-1]  # remove 1st element globally
      return(nextService)
  }
  ssq(maxArrivals = 1000, interarrivalFcn = getInterarr, serviceFcn = getService)

simEd

Simulation Education

v2.0.0
GPL (>= 2)
Authors
Barry Lawson [aut, cre], Larry Leemis [aut], Vadim Kudlay [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.