Chapter 5

A SimScript implementation of the airport model (page 82–92)

To run this model, you must have a copy of SimScript. Make a directory, e.g. airport, below the SimLab main directory, and store all the code segments on this web page in different files in this directory.

Important declarations in the preamble (page 87–88)

Save this to the file preamble.sim:

 
preamble
  processes include generator and passenger
  resources include InformationDesk, CheckInCounter, 
    and Gate
  accumulate AVG.InformationDesk.Queue.Length as the 
    average and MAX.InformationDesk.Queue.Length as the 
    maximum of N.Q.InformationDesk
  accumulate AVG.CheckInCounter.Queue.Length as the 
    average and MAX.CheckInCounter.Queue.Length as the 
    maximum of N.Q.CheckInCounter
  accumulate AVG.Gate.Queue.Length as the average
    and MAX.Gate.Queue.Length as the maximum
    of N.Q.Gate
  accumulate InformationDesk.Utilization as the average 
    of N.X.InformationDesk
  accumulate CheckInCounter.Utilization as the average 
    of N.X.CheckInCounter
  accumulate Gate.Utilization as the average of 
    N.X.Gate
'' several definitions needed for graphic output 
'' omitted
  define ServedCounter as an integer, 1-dimensional 
    array
  define .First to mean 1
  define .Business to mean 2
  define .Economy to mean 3
end

The main module (page 88–89)

Store this in the file main.sim:

 
main
  reserve ServedCounter(*) as 5
'' an array is declared to hold the number of  
'' passengers served by each resource
  create every InformationDesk(1)
  let U.InformationDesk(1) = 1
  create every CheckInCounter(3)
'' we need three different kinds of check-in counters  
  let U.CheckInCounter(.First) = 1
  let U.CheckInCounter(.Business) = 2
  let U.CheckInCounter(.Economy) = 4
'' two Business and four Economy counters are created
  create every Gate(1)
  let U.Gate = 1
'' all resources are ready 
  activate a generator now
  start simulation
'' The print statement starts here and extends to the end
'' of this code segment. `thus ...' is a template for the
'' printed oputput.
  print 14 lines with AVG.InformationDesk.Queue.Length(1),
    MAX.InformationDesk.Queue.Length(1),
    InformationDesk.Utilization(1) 
    * 100./U.InformationDesk(1),
    ServedCounter(1),
    AVG.CheckInCounter.Queue.Length(.First),
    MAX.CheckInCounter.Queue.Length(.First),
    CheckInCounter.Utilization(.First) 
    * 100./U.CheckInCounter(.First),
    ServedCounter(2),
    AVG.CheckInCounter.Queue.Length(.Business),
    MAX.CheckInCounter.Queue.Length(.Business),
    CheckInCounter.Utilization(.Business) 
    * 100./U.CheckInCounter(.Business),
    ServedCounter(3),
    AVG.CheckInCounter.Queue.Length(.Economy),
    MAX.CheckInCounter.Queue.Length(.Economy),
    CheckInCounter.Utilization(.Economy) 
    * 100./U.CheckInCounter(.Economy),
    ServedCounter(4),
    AVG.Gate.Queue.Length(1),
    MAX.Gate.Queue.Length(1),
    Gate.Utilization(1) * 100./U.Gate(1),
    ServedCounter(5)
    thus
Airport with different check-in counters
  average queue waiting for information desk is ***.*** passengers
  maximum queue waiting for information desk is **** passengers
  information desk was busy **.** per cent of the time, served **** 
  passengers
 
  The queue for the check-in counters were as follows:
  type     average     maximum    utilization   passengers served
  First    *.***       *          *.** per cent ****
  Business *.***       *          *.** per cent ****
  Economy  *.***       *          *.** per cent ****
 
  average queue waiting for the gate is ***.*** passengers
  maximum queue waiting for the gate is **** passengers
  gate was busy **.** per cent of the time, served **** passengers.
end

The generator module (page 89–90)

Store this in the file generato.sim:

 
process generator
  for i = 1 to 1000,
  do
    activate a passenger now
    wait exponential.f(1.5, 1) minutes
  loop
end

The passenger module (page 90-91)

Store this in the file passenge.sim:

 
process passenger
  define luggage as an integer variable
  define randLugg as a real variable
  define grade as an integer variable
  define randPass as a real variable
'' determine the class the passenger is booked on  
  let randPass = random.f(3)
  if randPass < 0.10     '' ten per cent of all passengers    
    let grade = .First   '' fly first class
    if randLugg < 0.70   '' 70 per cent of first class 
      let luggage = 1    '' passengers have luggage
    else 
      let luggage = 0
    always '' this is the end of the if clause
  else 
    if randPass < 0.40 '' another 30 per cent fly business  
      let grade = .Business
      if randLugg < 0.30 '' 30 per cent of business 
        let luggage = 1  '' passengers have luggage
      else
        let luggage = 0
      always
    else '' and the rest, 60 per cent, fly economy
      let grade = .Economy
      if randLugg < 0.70  '' 70 per cent of economy 
        let luggage = 1   '' passengers have luggage
      else
        let luggage = 0
      always
    always
  always
'' now the passenger is ready to enter the airport
  request 1 InformationDesk(1)
  work exponential.f(1.0, 2) minutes
  let ServedCounter(1) = ServedCounter(1) + 1
  relinquish 1 InformationDesk(1)
  wait uniform.f(5.0, 8.0, 2) minutes
  request 1 CheckInCounter(grade)
  if luggage = 1
    work uniform.f(5.0, 20.0, 2) minutes
  else
    work uniform.f(2.0, 4.0, 2) minutes
  always
  let ServedCounter(grade+1) = ServedCounter(grade+1) + 1
  relinquish 1 CheckInCounter(grade)
  wait uniform.f(10.0, 20.0, 2) minutes
  request 1 Gate
  work uniform.f(1.0, 2.0, 2) minutes
  let ServedCounter(5) = ServedCounter(5) + 1
  relinquish 1 Gate
end

The SimProcess version

The SimProcess version is only machine-readable. It can be downloaded from here.


This code is © Nigel Gilbert and Klaus G. Troitzsch 2005

It may be freely reproduced and incorporated into other software provided that reasonable acknowledgement of its source is given.


 

Send email to the authors Program code Sample chapter