Advanced Modelling Features

WaitQueue

The Model Class

   
 

In the description of the implementation, we will focus on the WaitQueue construct and its use. As usual, we derive our own model class from desmoj.core.simulator.Model, define the necessary attributes (in this case: distributions, a counter for the number of serviced ships, a WaitQueue object, and a ProcessCoop object to use with the wait queue), and implement a constructor and the required methods description(), init() and doInitialSchedules() as well as a main() method. To be able to use the WaitQueue construct we will have to import the desmoj.core.advancedModellingFeatures package.

The following code snippet shows only the parts of the model class relevant to the WaitQueue object

import desmoj.core.simulator.*;
import desmoj.core.dist.*;
import desmoj.core.advancedModellingFeatures.*;

/**
 * This is the model class. It is the main class of a simple process-oriented
 * model of a busy seaport loading coal from trains onto ships using direct
 * process synchronisation via the WaitQueue construct.
 */
 public class WaitQueueExample extends Model {

   /** A wait queue used to synchronise trains and ships */
   protected WaitQueue<Ship,Train> transferPoint;
   /** The transfer of coal from train to ship (a process cooperation)*/
   protected CoalTransfer coalTransfer;

   // additional model attributes: distributions and data collectors
   ...

   // constructor
   ...

   /**
    * initialises static model components like distributions and queues.
    */
   public void init() {

	// initialise distributions and data collectors
	...

	// initialise wait queue
	transferPoint = new WaitQueue<Ship,Train>(this, "coal transfer", true, true);

	// initialise the process cooperation
	coalTransfer = new CoalTransfer(this);
   }


   // additional required methods
   ...

}

The first statement shown in the init() method initialises the WaitQueue. Trains will enter this wait queue as slaves, ships as masters, specifying the common task (in this case: unloading the train and loading the coal onto the ship) as a process cooperation. This process cooperation is instantiated by the last statement. Because cooperations are specific to models, a model designer has to implement their own process cooperation classes. In this case, we derive a subclass named CoalTransfer from DESMO-J's abstract ProcessCoop class.

But first we will take a look at the two dynamic model components that use the wait queue. Let us start with the train.



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