SORT.MOD

From Support

Jump to: navigation, search

Back to Model Library

See also: How to read .MOD pages

Contents

Description

In SORT.MOD, a SORT event will generate N random numbers (called X), placing them in decreasing order on a list. The SHOW event gets these numbers of the list sequentially and displays their values. This model is used as an example of using PUT and GET functions.

State Variables

State Variables in SORT.MOD
Variable Name Variable Description Size Type
X For tracing random numbers sorted on the edge 1 Real
I Counter 1 Integer
J Counting index for show event 1 Integer
ENT Attributes of the entity we are sorting 15 Integer
LINE Line where entities are put for sorting 1 Integer
RNK Rank list on this element of ENT 25 Integer
N Number of random numbers to sort 1 Integer
GETFLAG Set to 1 if GET{} function successful 1 Integer

Vertices

Vertices in SORT.MOD
Vertex Name Vertex Description State Changes
RUN The simulation is started LINE=4,RNK[LINE]=6
SORT Generation of entities sorted on the edge ENT[1]=I,ENT[6]=RND,X=ENT[6]
SHOW Sorted list (assignment of GET{} is dummy) GETFLAG=GET{FST;LINE},X=ENT[6],I=ENT[1]

Initialization Conditions

Initialization Conditions in in SORT.MOD
Variable Description
N Number of random numbers to sort

Event Relationship Graph

SORT.MOD
SORT.MOD

English Translation

An English translation is a verbal description of a model, automatically generated by SIGMA.

The SIGMA Model, SORT.MOD, is a discrete event simulation. 
It models SORTING OF N RANDOM NUMBERS USING PUT AND GET.
I. STATE VARIABLE DEFINITIONS.
For this simulation, the following state variables are defined:
ENT[15]: ATTRIBUTES OF THE ENTITY WE ARE SORTING  (real valued)
LINE: LINE WHERE ENTITIES ARE PUT FOR SORTING   (integer valued)
I: COUNTER   (integer valued)
RNK[25]: RANK LIST ON THIS ELEMENT OF ENT   (integer valued)
N: NUMBER OF RANDOM NUMBERS TO SORT   (integer valued)
X: FOR TRACING RANDOM NUMBERS SORTED ON THE EDGE  (real valued)
J: COUNTING INDEX FOR SHOW EVENT   (integer valued)
GETFLAG: SET TO 1 IF GET{} FUNCTION SUCCESSFUL   (integer valued)
II. EVENT DEFINITIONS.
Simulation state changes are represented by event vertices (nodes or balls) in a SIGMA graph.  
Event vertex parameters, if any, are given in parentheses. Logical and dynamic relationships 
between pairs of events are represented in a SIGMA graph by edges (arrows) between event vertices.  
Unless otherwise stated, vertex execution priorities, to break time ties, are equal to 5.
1. The RUN(N) event occurs when START OF THE RUN (STOP ON GET ERROR).
   Initial values for, N, are needed for each run.
   This event causes the following state change(s):
   LINE=4
   RNK[LINE]=6
   After every occurrence of the RUN event:
   Unconditionally, SET I EQUAL TO ZERO AND START SORTING;
   that is, schedule the SORT(I) event to occur without delay...using the parameter value(s) of 1.
2. The SORT(I) event occurs when GENERATION OF ENTITIES SORTED ON THE EDGE.
   This event causes the following state change(s):
   ENT[1]=I
   ENT[6]=RND
   X=ENT[6]
   After every occurrence of the SORT event:
   If PUT{DEC;LINE}!=0 and (I<N), then PUT ENTITY INTO SORTEST LIST AND INCREMENT;
   that is, schedule the SORT(I) event to occur in 1 time units...
   using the parameter value(s) of I+1.
   If I==N, then START SHOWING THE SORTED LIST;
   that is, immediately execute the SHOW(J) event...using the parameter value(s) of 1.
3. The SHOW(J) event occurs when SORTED LIST (ASSIGNMENT OF GET{} IS DUMMY).
   This event causes the following state change(s):
   GETFLAG=GET{FST;LINE}
   X=ENT[6]
   I=ENT[1]
   After every occurrence of the SHOW event:
   If J<N and (GETFLAG==1), then SHOW THE NEXT ELEMENT ON THE LIST;
   that is, schedule the SHOW(J) event to occur in 1
   time units...using the parameter value(s) of J+1.

Comments

Back to top

Back to Model Library

Personal tools
Navigation