Advanced Modelling Features

WaitQueue

The Model Trace

   
 

Let us now take a look at the trace output of this example to see how the simulation processes interact via the WaitQueue construct.

WaitQueueExampleExperiment - Trace

time
event
entity
action(s)
0.0TraceOn#1----Trace switched on
0.0----Train#1activates 'Train#2' at 1.3117
waits in 'coal transfer_S'
Ship#1activates 'Ship#2' at 19.0933
cooperates 'Train#1' from 'coal transfer_S'
holds for 62.4310 until 62.4310
1.3117 Train#2activates 'Train#3' at 59.9158
waits in 'coal transfer_S'
19.0933 Ship#2activates 'Ship#3' at 21.0152
cooperates 'Train#2' from 'coal transfer_S'
holds for 135.6634 until 154.7567
21.0152 Ship#3activates 'Ship#4' at 113.6750
waits in 'coal transfer_M'
59.9158 Train#3activates 'Train#4' at 86.4204
waits in 'coal transfer_S'
Ship#3cooperates 'Train#3' from 'coal transfer_S'
holds for 147.9702 until 207.8861
62.4310 Ship#1activates 'Train#1' after 'Ship#1'
waits in 'coal transfer_M'
Train#1Train#1 terminates
86.4204 Train#4activates 'Train#5' at 135.1555
waits in 'coal transfer_S'
Ship#1cooperates 'Train#4' from 'coal transfer_S'
holds for 156.7804 until 243.2008
113.6750 Ship#4activates 'Ship#5' at 181.4499
waits in 'coal transfer_M'
135.1555 Train#5activates 'Train#6' at 135.6200
waits in 'coal transfer_S'
Ship#4cooperates 'Train#5' from 'coal transfer_S'
holds for 168.2988 until 303.4544
135.6200 Train#6activates 'Train#7' at 156.2915
waits in 'coal transfer_S'
154.7567 Ship#2activates 'Train#2' after 'Ship#2'
cooperates 'Train#6' from 'coal transfer_S'
holds for 84.8666 until 239.6234
Train#2Train#2 terminates

The first train arrives at the harbour, schedules the arrival of the next train for simulation time 1.3117, and then waits in the internal slave queue (coal transfer_S) of the wait queue for ships to arrive. The first ship also schedules the arrival of its successor and then proceeds to cooperate with Train#1. The transfer of coal from Train#1 to Ship#1 will take until simulation time 62.4310. The same happens for the second train and ship, they are paired off by the wait queue and their cooperation will be finished at simulation time 154.7567. When Ship#3 arrives at 21.0152 though, there is no train available so it has to wait in the internal master queue (coal transfer_M) until Train#3 arrives at 59.9158.

At simulation time 62.4310 the (un)loading of Train#1 and Ship#1 is completed which results in the slave process (Train#1) being scheduled for activation after the master process (Ship#1). The master process gains control and, since ships need two train loads of coal, requests another cooperation, which results in Ship#1 being enqueued in the wait queue and automatically passivated. Now Train#1 (the former slave) is activated to leave the system. Trains and ships then continue to arrive and wait on each other to transfer coal.

You may download the full source code of this example if you want to try it out yourself.



   
  http://desmoj.sourceforge.net/tutorial/advanced/waitqueue6.html