Automatic Translation of SIGMA Model

From Support

Jump to: navigation, search

SIGMA automatically translates a SIGMA model into both English and C code.

English Translation

SIGMA’s automatic English translation feature is very useful for checking errors (use with a printed graph), verifying a model with persons not familiar with simulation, or supplementing physical animations.

This feature exploits SIGMA's graph structure to produce an English description of your simulation. Basically the two vertices on an edge act as the subject and object of a sentence while the edge conditions and delay times form prepositional phrases; the predicate is almost always "schedule" or "cancel."

To see the English translation of the carwash model, open CARWASH.MOD. Activate the English translation option by clicking the Translate command in the File menu and selecting English from the alternatives. A dialog box will appear with the active file highlighted in the File Name text box. Press the OK command button to see the English translation, press Yes to replace an existing file, and Yes again to view the file now.

The following English description of our basic carwash model was obtained using the Translate command on the graphical model.

The SIGMA Model, CARWASH.MOD, is a discrete event simulation. It models an automatic carwash.
I. STATE VARIABLE DEFINITIONS.
For this simulation, the following state variables are defined:
QUEUE:	number of cars in line	(integer valued)
SERVER: machine is idle/busy = 1/0    (integer valued)
II. EVENT DEFINITIONS.
1. The RUN(QUEUE) event models the initialization of the simulation. Initial values for, QUEUE, are
   needed for each run. This event causes the following state change(s):
   SERVER=1
   After every occurrence of the RUN event: 
   Unconditionally, the car will enter the line; 
   that is, schedule the ENTER() event to occur without delay.
2. The ENTER() event models the car entering the line.
   This event causes the following state change(s):
   QUEUE=QUEUE+1
   After every occurrence of the ENTER event:
   If SERVER>0, then start service with the idle machine;
   that is, schedule the START() event to occur without delay.
   Unconditionally, the next customer enters in 3 to 8 minutes;
   that is, schedule the ENTER() event to occur in 3+5*RND time units.
3. The START() event models the start of service.
   This event causes the following state change(s):
   SERVER=0
   QUEUE=QUEUE-1
   After every occurrence of the START event:
   Unconditionally, the car will be in service for 5 minutes;
   that is, schedule the LEAVE() event to occur in 5 time units.
4. The LEAVE() event models the end of service.
   This event causes the following state change(s):
   SERVER=1
   After every occurrence of the LEAVE event:
   If QUEUE>0, then start service for the next car in line;
   that is, schedule the START() event to occur without delay.

You can see that if you completed the sentences in the Description line in all of the dialog boxes for the vertices and edges in a simulation, the English translation of your model should be quite readable. Close this file.

Translate to C

Once you have verified the logic of your model, you can automatically generate a simulation program in the C Programming language using the same Translate feature discussed above. You specify the model (e.g., CARWASH.MOD) you wish to have translated and select a C as the target language; the rest is automatic.

To translate a model into C, activate the simulation graph window, click on the Translate command in the File menu, and click on C. A dialog box will appear with the file name highlighted (e.g., CARWASH.C). Click the OK button to confirm the file name. Respond Yes if you are asked to replace an existing file and Yes when asked to see the translation now. Use the scroll bars to view the entire file.


Back to Building Models

Personal tools
Navigation