I. M. Sobol – The Monte Carlo Method – Section 05 – Simulation of a Mass Servicing System

Question: Consider one of the simplest systems of mass servicing. This system consists of n lines (or channels, or servicing stations) each of which can “serve on the customers”. The system receives requests arriving at random moments of time. Each request arrives at the N1 line. If the arrival time of the k-th request ( let us call it Tk ) finds this line free, the line starts servicing the request; this takes tb minutes (tb is the holding time of the line). If N1 line is busy at the moment Tb the request is immediately transferred to the N2 line. And so on … Finally, if all n lines are busy at the moment Tk , the system rejects the request. The problem is, what will be the (average) number of requests serviced by the system during the period T and how many rejections will be given?


The images would be a beautiful insight into the mass servicing. Note the following before moving on

  • Firstly, it is a very long list of images (several pages long)
  • Each image has a label on the top of it showing
    • λs the rate of arrival rate of the customers and the times of the arrival are exponentially distributed
    • λs the rate of service for the customers and the service times are exponentially distributed as well
  • The chart for each of the server has as blue line, which is binary in nature
    • the server is busy when the blue line is above the x axis &
    • the server is free when the blue line is on the x axis
  • As you scroll down the images, you will see that the pattern of the images is changing as in, which server is busy over the lifetime of the experiment
  • Notice how the “busyness” of the servers that are in sequence is highly dependent on the rate of the service
    • when the rate of the service is comparable or lesser than the rate of the arrival, the servers at the end also get some tasks as the first ones are taking a long time to finish what they have started and the servers next in line are free to server the incoming customers
    • when the rate of the service is very high compared the to the rate of arrival, the servers at the beginning of the queue are busy for most of the lifetime and the ones at the end do not even get to see any customers

Simulation Images

























































ClearAll[status, currentStatus];
status[list_List, time_] :=
    Boole[Or @@ (Min[#] < time <= Max[#] & /@ list)]
currentStatus[list_List, time_] := ! Min[#] < time <= Max[#] &[

Module[{servers = 10, serverStatus, nCustomers = 120,
  arrivals, \[Lambda]a = 5, \[Lambda]s = #, firstFree, plot},
  arrivals =
        RandomVariate[ExponentialDistribution[\[Lambda]a], nCustomers]];
  serverStatus = ConstantArray[{{0, 0}}, servers];

    firstFree =
          currentStatus[#, arrivals[[r]]] & /@ serverStatus,
    If[firstFree =!= Null,
      firstFree = First[firstFree][[1]];
      serverStatus[[firstFree]] =
          serverStatus[[firstFree]] ~
              Join ~ {{arrivals[[r]],
            arrivals[[r]] +
      Print["No server free"]]
    , {r, 1, Length@arrivals}];

  plot =
            Plot[status[#1, r], {r, 1, 100}, Exclusions -> None,
              ExclusionsStyle -> Red, ImageSize -> 788,
              AspectRatio -> 0.1, Frame -> True,
              PlotRange -> {{0, Max@arrivals}, {0, 1.1}},
              PlotLabel -> "Server " <> #2, FrameTicks -> False,
              FrameLabel -> {None,
                Style["NotBusy-Busy", Bold]}] &, {serverStatus,
              ToString /@ Range[Length@serverStatus]}]],
        "\!\(\*SubscriptBox[\(\[Lambda]\), \(a\)]\) = " <>
            ToString[\[Lambda]a] <>
            " : \!\(\*SubscriptBox[\(\[Lambda]\), \(s\)]\) = " <>
            ToString[\[Lambda]s], Top];

      ".nb" ->
          "_rates_" <> ToString[\[Lambda]a] <> "_" <>
              ToString[\[Lambda]s] <> ".png"], plot, ImageSize -> 788,
    ImageResolution -> 1000]
] & /@ Range[0.1, 5, 0.1]

End of the post 😉