Advanced Modelling Features

Res

The Model Trace

   
 

Finally, let us have a look into the model trace, to see how the ship processes interact with the Res object. We jump right to simulation time 15.9412, because it provides us with a perfect example of the behaviour of the Res construct.

ResExampleExperiment - Trace

time
event
entity
action(s)
0.0TraceOn#1----Trace switched on
... ......
15.9412 ShipGenerator#1activates 'Ship#9' now
holds for 3.8806 until 19.8218
Ship#9available berths: 0
awaits 2 of ' Berths '
19.8218 ShipGenerator#1activates 'Ship#10' now
holds for 0.3696 until 20.1915
Ship#10available berths: 0
awaits 2 of ' Berths '
20.1915 ShipGenerator#1activates 'Ship#11' now
holds for 0.5649 until 20.7564
Ship#11available berths: 0
awaits 1 of ' Berths '
20.6818 Ship#8releases 2 to 'Berths'
available berths: 2
Ship#8 terminates
Ship#9seizes 2 from 'Berths'
holds for 14.8057 until 35.4875
20.7564 ShipGenerator#1activates 'Ship#12' now
holds for 1.1599 until 21.9164
Ship#12available berths: 0
awaits 2 of ' Berths '
21.9164 ShipGenerator#1activates 'Ship#13' now

At simulation time 15.9412 Ship#9 enters the harbour where no more berths are available. It tries to acquire 2 berths and the Res object automatically inserts Ship#9 into its internal waiting queue and passivates the process. Control passes back to the scheduler which activates the next process on the event list, in this case the ship generator again. Since no resources have been released in the meantime, the new Ship#10 has to wait in the Res object's internal queue as well. The same holds true for the next ship, Ship#11.

At simulation time 20.6818 Ship#8 has finished unloading and releases its resources (2 berths) before it terminates, i.e. leaves the system. The Res object now automatically activates Ship#9, the first ship waiting in the internal queue, since its request of 2 berths can now be satisfied.

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



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