next up previous contents
Next: Types of nodes Up: Characteristics of the GLIDER Previous: Example of discrete simulation

Example of continuous simulation

.
  Plantation with periodic cuts.
  In a plantation the quantity of wood growths according to a
  logistic curve whose differential equation is:
                      w' = k * (1 - w / wm) * w
  When the quantity is greater than wm, a cutting process starts
  which decides the proportion of wood to be extracted according
  to a function of the actual price, p(TIME) and the mean price pm.
  The time for the cut process is negligible compared with the
  rates of growth.

  NETWORK
  Growth (C) :: w' := k * (1 - w / wmax) * w;
                        if w >= wm then ACT(Cut, 0);
        GRAPH(0, 50, BLACK; TIME: 7: 0, WHITE; W: 6: 0,Wood, 0, 10000, GREEN;
                                 price(TIME): 6: 0, Price, 0, 100, YELLOW);

  Cut    (A) :: w := w - MIN(0.3 * wm, MinCut + MAX(0, cc*(price(TIME) - pm)));

  INIT TSIM := 50; ACT(Growth, 0);
           k := 0.21; wm := 6000; MinCut := 500; cc := 40.2; pm := 24;
           w := 100; wmax := 9500;
           DT_Growth := 0.125;
           price := 0, 30 / 10, 20 / 20, 15 / 30, 25 / 40, 30 / 50, 42 /
                   55, 45;
  DECL VAR k, wm, wmax, MinCut, cc, pm: real; w: CONT;
             GFUNCTIONS price SPLINE (real): real: 8;
  END.
The type C node Growth solves the differential equation. When w >= wm the node Cut, of A type, is activated. This reduces the mass of wood by a quantity that is 30% of the wm at most, and MinCut at least. Within these limits it depends on the difference between actual price and average price pm of the wood. The variable w must be declared of CONT (continuous) type.

The time function price is given by the 7 pairs of values indicated in the INIT section. For the time 0, its value is 30; for the time 10, it is 20; etc. It is declared of real argument, real value and the interpolation is made by a SPLINE algorithm.

A graph is programmed to display, during the run, w and the price as a function of TIME.

In the INIT section, values to the parameters and to the initial value of the variable w are given. The integration interval DT_Growth is also set. All variables are declared in the DECL section.

In GLIDER programs the basic features are implemented in the following way:

The abbreviations EL and IL will be respectively used for Entry List and Internal List, with the plurals ELs and ILs.

In addition to the global variables and variables local to nodes, that are declared by the user, the system introduces global field variables for each field of each message structure declared by the user. The name of these variables is equal to the name of the field. When a message is processed, the values of the fields of the message are transferred to the field variables. So the user's code can use and change these values referring to them by its simple name. When the process of the message is over, the values of the field variables are passed to the fields of the message.

When messages of different structure have some fields with the same name, they correspond to the same field variable. This allows to deal with different entities sharing common properties.

The execution of the code of a node is called the activation of the node. At a point during the simulation it may be necessary to schedule the activation of certain nodes for the future. The schedule is kept in a list called FEL (Future Event List). Each element in the FEL represents a pending event. It contains a reference to the node to be activated and the time at which the activation must take place. This list is automatically processed by the system, but the user may also handle it through special GLIDER procedures.

The order of activation of the nodes is essential to the simulation. An event (activation fact) begins with the processing of the element of the FEL, that has the minimum time value. The node referred by this element is activated (executed) and this starts the event execution.

The code of the node may cause changes in the values of the variables, execution of procedures and message processing. In particular this execution may cause message exchanges. It can also change conditions that allow other nodes to move messages or change values of variables. All this must be done in these events. To perform all these changes it follows a scanning of all the nodes that could be affected by the execution of the node. These scanned nodes are then activated. The scanning is repeated cyclically until no further movements of messages are possible. The event processing is then ended and the following event from the FEL will be considered. During the execution of an event the state of the system changes and new future events are scheduled. The value of the simulation time do not change during the transformations produced in the event. When a new event is executed the time variable is updated to the time of the event indicated in the FEL. So the simulation process goes on until an end condition specified by the user finishes the simulation run. The user must be aware of the two ways in which a node can be activated: by an event that refers to the node, which starts a new event, or by scanning of the network during an event.


next up previous contents
Next: Types of nodes Up: Characteristics of the GLIDER Previous: Example of discrete simulation

Marta Sananes-Domingo
Fri Mar 17 10:05:26 PST 2000