# Tutorial

(Difference between revisions)
 Revision as of 23:22, 23 July 2008 (edit) (→Vertices)← Previous diff Revision as of 23:26, 23 July 2008 (edit) (undo) (→Edges)Next diff → Line 91: Line 91: [[image:tutorial5.png|thumb|494px|Edge Dialog Box from RUN Vertex to ENTER Vertex [[image:tutorial5.png|thumb|494px|Edge Dialog Box from RUN Vertex to ENTER Vertex Schedules the First Customer Arrival Schedules the First Customer Arrival + |center]] + + We see that this edge has the condition (1==1). As in the C programming language, == is a test for equality in SIGMA. Thus, this edge unconditionally (1==1) schedules the first customer to ENTER the system. There is no time delay between starting the RUN and the first customer ENTERing the system. Here no attribute values are passed, and the execution priority, used to break time ties between events scheduled to occur at the same clock time, is set to a neutral value of 5. (Attributes and priorities are important aspects of SIGMA; they allow simple models to represent complex systems. Both are discussed in greater detail in Chapter 6.) Click the Cancel button on this edge dialog box. + + Unconditional edges test the condition (1==1), which is always true. + + Double-click on the self-scheduling edge from the ENTER vertex to the ENTER vertex, which perpetuates customer arrivals. The most notable item in this dialog box is the delay time. Here, the Delay between successive customers ENTERing the system will be a time uniformly distributed between 3 and 8 minutes. This is done by making the delay time for this edge equal to the expression, 3+5*RND. RND is a SIGMA function providing a fraction that behaves like a random number between 0 and 1. Thus, 5*RND will be a number somewhere between 0 and 5; adding 3 will shift the range of this number to between 3 and 8. Close this dialog box. + + Open the dialog box between the ENTER vertex and the START vertex. The item of interest on this edge is Condition: SERVER>0. This means that a customer ENTERing the system will START service without delay only if that customer finds that the server is available, i.e., if the condition SERVER>0 is true. Close this dialog box. + + Double-click on the edge between the START vertex and the LEAVE vertex. Note that this edge is a double edge: with one edge from the START vertex to the LEAVE vertex and another edge in the reverse direction, from LEAVE to START. The dialog box for this multiple edge is shown in Figure 3.7. + + [[image:tutorial6.png|thumb|494px|Multiple Edge Dialog Box between START and LEAVE Vertices |center]] |center]] [[Main Page|Back to Main Page]] [[Main Page|Back to Main Page]]

# A Tutorial on the Basics of SIGMA

An overview of the SIGMA software environment is presented in this chapter in tutorial format. All primary elements of event relationship graph modeling are explained. Technical details are presented in later sections.

## Starting a SIGMA Session

Double click on SIGMA.EXE to begin a SIGMA modeling session. SIGMA does not automatically load a model, but they can easily be recalled using the File/Recall menu command.

## The SIGMA Modeling Environment

A simulation graph window similar to the one in Figure 3.1 will appear when a SIGMA session begins. This is the primary window for a SIGMA modeling session. Linked to this modeling session are simulation plot windows and output windows. Note: Several SIGMA modeling sessions may run simultaneously; thus, several simulation graph windows representing different models may be open at one time.

SIGMA's Simulation Graph Window

There are three regions in the simulation graph window: the model creation area (the region in the center of the window), the menu bar (located along the top of the window), and the toolbar (located along the right side of the window).

The various push buttons in the toolbar are identified in Figure 3.2. The Start Run and End Run tools allow you to start or stop a simulation run; the Select or Edit, Create Process, and Create Single Edge tools let you quickly create a model; the Single Step tool allows you to watch the simulation as each event is executed; and the Run Time Information and Show SIGMA Version tools provide you with additional information. In addition, fifteen User Tool buttons allow you to add previously created models to a new modeling session.

 Select or Edit Create Process Create Single Edge Show SIGMA Verion Start Run End Run Single Step User Tool

A window is activated when the mouse pointer is clicked anywhere on it. As the various windows are activated, the menu bar changes. The menu bar for the simulation graph window contains the following menus: File, Edit, Run, Variables, Zoom, Window, and Help. The simulation plot window contains the File, Edit, Options, Window, and Help menus; the output window contains the File, Edit, Search, Window, and Help menus.

When a SIGMA session is started, the mouse pointer is normally in Create Process mode (*). It is in this mode that the graphical components of a simulation model are created. If you click the right mouse button, the mouse pointer will change to Select or Edit mode (*). This mode is used to add or change information related to specific vertices or edges. Just double-click on a vertex or edge, and an Edit Edge or Edit Vertex dialog box will appear. Add information or make changes by clicking on the appropriate box and entering the data from the keyboard. Clicking the right mouse button will cause the mouse to alternate between the Create Process mode and Select or Edit mode. Pressing the appropriate push buttons on the tool bar will also activate the Create Process mode or the Select or Edit mode.

## Exploring Our Carwash Model

We will use a previously created model, CARWASH.MOD, to examine the components of a SIGMA model. To begin, start a SIGMA session. Open CARWASH.MOD by pressing the File\Open command, pressing Event Graph, and then double-clicking on CARWASH.MOD from the list of previously created models in the dialog box.. This model is represented in Figure 3.3.

An Event Graph for a Single Server Queue, CARWASH.MOD

Recall that CARWASH.MOD has only two state variables: QUEUE, the number of cars waiting in line, and SERVER, the status of the machine, 0=BUSY and 1=IDLE.. Four events are represented by the four vertices in the carwash model. The RUN vertex starts the simulation, the ENTER vertex models customers entering the carwash, the START vertex occurs when a car starts service in the washing bay, and the LEAVE vertex occurs when a car finishes service and leaves the washing bay. The time intervals between successive customer arrivals to the carwash are independent and random.

### Network Users

```WARNING: You should not use a floppy drive or a write-protected network drive as your default drive.
```

[[this text must be rephrased]]

NETWORK USERS: If you are running SIGMA from a network server, your default drive is probably write-protected. Thus, you will get a system error message if you run the simulation as described in Step 4. You must add a drive letter before the output file name in the Run Options dialog box. For example, you should change UNTITLED.OUT to C:\UNTITLED.OUT so you can write the output to your C: drive. (Click on the Options command under the Run menu. In the Run Options dialog box, add the drive letter to the name of the file in the Output File text box. Next, click on the OK button and proceed to Step 4.) You should not use a floppy drive as your default drive as this will slow the running of your simulation considerably.

### State Variables

Click the mouse on the Create/Edit Variables command under the Variables menu to see the list of state variables for this model in the State Variable Editor dialog box. Any state variables you define can be used anywhere in your SIGMA model. We refer to them as state variables to emphasize that they are accessible to all parts of the model. Clicking on one of the state variables in this dialog box will cause the details associated with that state variable to be displayed in the input boxes above (as in Figure 3.4.)

The State Variable Editor Dialog Box

The dialog box for state variables, like other SIGMA dialog boxes, has a line for a brief description of the object. These descriptions are important; they appear as comments in your SIGMA-generated simulation source code and make your model much easier to understand. Click on the Cancel command button to close the state variable dialog box and return to the simulation graph seen in Figure 3.3.

We will further explore this model by clicking the mouse on elements in the event graph. Make sure that the mouse pointer is in Select or Edit mode. Read the description in each dialog box as we

### Vertices

Double-click on the RUN vertex. This vertex, whose dialog box is shown in Figure 3.5, was the first vertex created in this model. SIGMA calls the first vertex created vertex number 1; it will always be executed first when the model is run. (This first vertex is colored green on the screen.)

The RUN vertex has a parameter: the state variable, QUEUE. When CARWASH.MOD is run, you will be asked to provide an initial value for the number of customers in the QUEUE when the system opens for service. All SIGMA state variables are initialized to be equal to zero. The only state change associated with the RUN vertex is to make the SERVER available (SERVER=1). To exit, click your mouse on the Cancel command button.

The Dialog Box for the RUN Vertex

The ENTER vertex is where customers join the line. Open the dialog box for the ENTER vertex. This vertex simply increments the number of customers waiting in line (QUEUE=QUEUE+l). Note that QUEUE has been entered as a display variable, so its value will be shown while the simulation is running. Close this dialog box and then double-click on the START vertex.

The START service vertex is where the server is made busy (SERVER=O) and the number of customers waiting in line is decremented (QUEUE=QUEUE-1). Close the START vertex dialog box and open the LEAVE dialog box.

The LEAVE vertex makes the server available to serve other customer (SERVER=1). Note that if the variable, QUEUE, were defined as the number of customers in the total system (in service as well as in line), QUEUE would be decremented in the LEAVE vertex rather than in the START vertex. Close this dialog box.

The event vertices are relatively straightforward in discrete event models. The complexity of the models comes at the edges of the event graph, where the dynamic and logical relationships between events are specified.

### Edges

Next, we will examine each of the edges in our model. Figure 3.6 is the edge dialog box that you should see if you double-clicked on the edge between the RUN vertex and the ENTER vertex.

Edge Dialog Box from RUN Vertex to ENTER Vertex Schedules the First Customer Arrival

We see that this edge has the condition (1==1). As in the C programming language, == is a test for equality in SIGMA. Thus, this edge unconditionally (1==1) schedules the first customer to ENTER the system. There is no time delay between starting the RUN and the first customer ENTERing the system. Here no attribute values are passed, and the execution priority, used to break time ties between events scheduled to occur at the same clock time, is set to a neutral value of 5. (Attributes and priorities are important aspects of SIGMA; they allow simple models to represent complex systems. Both are discussed in greater detail in Chapter 6.) Click the Cancel button on this edge dialog box.

```Unconditional edges test the condition (1==1), which is always true.
```

Double-click on the self-scheduling edge from the ENTER vertex to the ENTER vertex, which perpetuates customer arrivals. The most notable item in this dialog box is the delay time. Here, the Delay between successive customers ENTERing the system will be a time uniformly distributed between 3 and 8 minutes. This is done by making the delay time for this edge equal to the expression, 3+5*RND. RND is a SIGMA function providing a fraction that behaves like a random number between 0 and 1. Thus, 5*RND will be a number somewhere between 0 and 5; adding 3 will shift the range of this number to between 3 and 8. Close this dialog box.

Open the dialog box between the ENTER vertex and the START vertex. The item of interest on this edge is Condition: SERVER>0. This means that a customer ENTERing the system will START service without delay only if that customer finds that the server is available, i.e., if the condition SERVER>0 is true. Close this dialog box.

Double-click on the edge between the START vertex and the LEAVE vertex. Note that this edge is a double edge: with one edge from the START vertex to the LEAVE vertex and another edge in the reverse direction, from LEAVE to START. The dialog box for this multiple edge is shown in Figure 3.7.

Multiple Edge Dialog Box between START and LEAVE Vertices