next up previous contents
Next: Example of continuous simulation Up: Characteristics of the GLIDER Previous: Characteristics of the GLIDER

Example of discrete simulation

. Railroad Systemgif.
  In a simple railroad system, trains, with a number of coaches equal
  to a random number from 16 to 20,  depart from a station each 45
  minutes. After 25 minutes of travel, the trains reach their destination.
  The program writes the time of arrival and the number of coaches.
  For clarity, in all the manual, GLIDER and Pascal reserved words are in 
  upper case letters; user identifications are in lower cases with normally 
  the first letter in upper case. 

  NETWORK
   Depart   (I) Railroad      :: Coaches := UNIFI(16,20); IT := 45;
   Railroad (R) Destination   :: STAY := 25;
   Destination (E)            :: WRITELN('A train arrives at time:',
                                    TIME, 'Its length is', Coaches);
                                 PAUSE;

  INIT TSIM := 1300; ACT(Depart, 0);

  DECL MESSAGES Depart(Coaches: INTEGER);
             STATISTICS ALLNODES;
  END.
The program has the following sections:

It follows a description of the NETWORK section and its functions: After each node name follows a letter between parenthesis indicating its type and the successor node to which messages can be sent. Depart is a node of I (Input) type. When executed, it generates a message and sends it to the successor node Railroad. The message in this example represents a train. It has an integer type field called Coaches, that indicates the number of coaches. In the code of the node (after the separator ::) this field is set to a value given by a GLIDER function UNIFI that produces a random integer number, in this case between 16 and 20. A new activation of the Depart node is scheduled after an Interval Time of 45 time units.

The node Railroad is of R (Resource) type. When executed, it processes the message and it stores it temporarily in an internal list (IL). The code sets, by means of the GLIDER instruction STAY, that the message must remain in the node for a time equal to 25. When the message is released. it is sent to the node Destination.

The node Destination is of E (Exit) type. It takes the message, executes the instruction of the code (it writes, for instance: "A train arrives at 140. Its length is 17") and it deletes the message. See that the value (17) is transported by the message in the variable Coaches. After writing, the program stops (instruction PAUSE) and when any key is pressed the simulation continues. New trains are generated in Depart each 45 units time, then they pass to Railroad, and so on.

The above source program is the input to the compiler system that translates it and runs the simulation. The simulation time is not the real processing time. It takes the value at each event. At the beginning is 0, when the first train arrives is 25, when the second train departs is 45, when the second train arrives it is 70, when the third train departs it is 90, etc.


next up previous contents
Next: Example of continuous simulation Up: Characteristics of the GLIDER Previous: Characteristics of the GLIDER

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