Advanced Modelling Features

Res

The Model Class

   
 

In the description of the implementation, we will focus on the Res 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 and a Res object), and implement a constructor and the required methods description(), init() and doInitialSchedules() as well as a main() method. To be able to use the Res 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 Res object.

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

/**
 * This is the model class. It is the main class of a simple process-oriented
 * model of the quay of a container terminal using resources to represent berths.
 */
public class ResExample extends desmoj.core.simulator.Model {

   /** model parameter: the number of berths at the quay */
   static int NUM_BERTHS = 8;

   /** A Res construct used to model the berths	*/
   Res berths;

   // additional model attributes, e.g. distributions
   ...

   // constructor
   ...

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

      // initialise distributions
      ...

      // initialise the Res construct
      berths = new Res(this, "Berths", NUM_BERTHS, true, true);
   }


   // additional required methods
   ...

}

In this case the Res object receives a number of 8 initial resources which it can distribute to its customers. Remember, these resources are not consumable and it is not possible to add additional resources during the use of the object.



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