home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-04-17 | 67.3 KB | 1,513 lines |
-
-
- REFERENCE MANUAL OF
- SSS - Simulation Subroutine Set.
- Version 1.00
-
- Copyright (C) M. A. Pollatschek 1990.
- All rights reserved.
-
-
-
-
- ╔════════════╗
- ║ CONTENTS ║
- ╚════════════╝
- Page
-
- HOW TO BENEFIT FROM THIS DOCUMENTATION.. ... ... ... 2
- ALPHABETIC LIST OF ROUTINES... ... ... ... ... ... 2
- TERMINOLOGY ... ... ... ... ... ... ... ... ... 2
- SIMULATION ROUTINE.. ... ... ... ... ... ... ... 4
- ERROR MASSAGES. ... ... ... ... ... ... ... ... 5
- CLARIFICATION OF ENTRIES IN DESCRIPTION. ... ... ... 6
- NOTES FOR EXAMPLES.. ... ... ... ... ... ... ... 6
- A(n), IDE(), SETA(n,v) SETIDE(i)... ... ... ... ... 7
- AIC(r,n), IDIC(r), NEIC(r), TIC(r). ... ... ... ... 8
- AIQ(m,r,n), IDIQ(m,r), PRIQ(m,r)... ... ... ... ... 9
- BE(W,U)... ... ... ... ... ... ... ... ... ...10
- BI(N,P), NP(M). ... ... ... ... ... ... ... ...10
- CD(X,V,N), DP(V,N).. ... ... ... ... ... ... ...11
- CLEARQ(m), QAVG(m), QMAX(m), QMIN(m), QNUM(m), QSTD(m).12
- CLEARS(j), TALLY(j,v) ... ... ... ... ... ... ...13
- CREATE(g,i) ... ... ... ... ... ... ... ... ...14
- DISPOS().. ... ... ... ... ... ... ... ... ...15
- ER(M,K), EX(M), GA(M,K) WE(M,U)... ... ... ... ...15
- INIQUE(q,b,s).. ... ... ... ... ... ... ... ...16
- INISTA(j,h,k,l,f,w). ... ... ... ... ... ... ...16
- NC(), NQ(m) ... ... ... ... ... ... ... ... ...18
- NCEN(), NEXTEV() ... ... ... ... ... ... ... ...19
- QDC(m), SETQDC(m,d). ... ... ... ... ... ... ...20
- QUEUE(m,p) ... ... ... ... ... ... ... ... ...21
- RA(), RL(M,S), RN(M,S), TR(I,B,C), UN(I,C)... ... ...22
- REMVFC(r), REMVFQ(m,r)... ... ... ... ... ... ...23
- SAVG(j), SMAX(j), SMIN(j), SNUM(j), SSTD(j).. ... ...24
- SCHED(g,e,i)... ... ... ... ... ... ... ... ...25
- SETANT(y), SETSEE(x) ... ... ... ... ... ... ...26
- SETDEB(o), SHOWQ(m). ... ... ... ... ... ... ...27
- SETT(g), T()... ... ... ... ... ... ... ... ...28
- SIMEND(g). ... ... ... ... ... ... ... ... ...29
- SIMERR().. ... ... ... ... ... ... ... ... ...30
- SUMRY(u).. ... ... ... ... ... ... ... ... ...31
-
- SSS Reference Page 2
-
-
- ╔══════════════════════════════════════════╗
- ║ HOW TO BENEFIT FROM THIS DOCUMENTATION ║
- ╚══════════════════════════════════════════╝
-
- Use a lister/editor's search facility to find out the meaning of
- terms. Each term is explained somewhere. Examine also the
- examples in files EX_*.*.
-
- Printed user guide with tutorials and/or source code is
- available. Write to: M. A. Pollatschek, Management, Technion,
- Haifa 32000 ISRAEL.
-
-
- ╔════════════════════════════════╗
- ║ ALPHABETIC LIST OF ROUTINES ║
- ║ and where they are described ║
- ╚════════════════════════════════╝
-
- for look for look for look for look
- routine under routine under routine under routine under
- A.......A IDIC....AIC QNUM....CLEARQ SETSEE..SETANT
- AIC.....AIC IDIQ....AIQ QSTD....CLEARQ SETT....SETT
- AIQ.....AIQ INIQUE..INIQUE QUEUE...QUEUE SHOWQ...SETDEB
- BE......BE INISTA..INISTA RA......RA SIMEND..SIMEND
- BI......BI NC......NC REMVFQ..REMVFQ SIMERR..SIMERR
- CD......CD NCEN....NCEN REMVFQ..REMVFQ SMAX....SAVG
- CLEARQ..CLEARQ NEIC....AIC RL......RA SMIN....SAVG
- CLEARS..CLEARS NEXTEV..NCEN RN......RA SNUM....SAVG
- CREATE..CREATE NP......BI SAVG....SAVG SSTD....SAVG
- DISPOS..DISPOS NQ......NC SCHED...SCHED SUMRY...SUMRY
- DP......CD PRIQ....AIQ SETA....A T.......SETT
- ER......ER QAVG....CLEARQ SETANT..SETANT TALLY...CLEARS
- EX......ER QDC.....QDC SETDEB..SETDEB TIC.....AIC
- GA......ER QMAX....CLEARQ SETIDE..A TR......RA
- IDE.....A QMIN....CLEARQ SETQDC..QDC UN......RA
- WE......ER
-
-
- ╔═══════════════╗
- ║ TERMINOLOGY ║
- ╚═══════════════╝
-
- attribute: is a numerical characteristic of the entities, e.g.
- size, color code in a floating point number. Attributes
- may differ among entities. They are updated/initiated for
- current entity to v by SETA(v). They can be accessed by
- A(n), AIC(r,n), AIQ(m,r,n).
-
- calendar: a list of scheduled or created, entities, that is
- entities whose events occure at some simulted time in the
- future. The calendar is created by calling INIQUE(q,b,s).
- Entities are put on the calendar by CREATE(g,i) or
- SCHED(g,e,i). Entities are removed from the calendar by
- NEXTEV() or REMVFC(r).
-
- SSS Reference Page 3
-
-
- current entity: the entity under present treatment. There must be
- at most one such entity at each time. Its number at any
- time is given by NCEN(). An entity becomes current after
- calling one of: NEXTEV(), REMVFC(r), REMVFQ(m,r)
- and stops being current after
- calling one of: DISPOS(), QUEUE(m,p), SCHED(g,e,i).
-
- discipline: the ordering of entities in a queue, may be one of:
- FIFO=first in first out, LIFO=first in last out,
- SVF=smallest value first, BVF=biggest value first.
-
- entity: the basic constituent of simulation which undergoes a few
- processes in time like a customer, a part, a pellet, etc.
-
- event: an occurrence of a specific operation at a certain time,
- like arrival, end of servicing, etc.
-
- id, identity: is used to differentiate between various kinds of
- entities, e.g. parts, pellets and transporters on a
- factory floor as integers. They are set to i by
- CREATE(g,i), SCHED(g,e,i), SETIDE(i).
-
- priority: a number which determines the rank of an entity in a
- queue having a BVF or SVF discipline - the entities are
- sorted by their priorities.
-
- returned value: the value returned by a (non void) function.
-
- simulated time: time that the simulator's clock shows, not
- related to real time or computation time.
-
- stochastic process: is a variable which changes at some points of
- time and we are interested in its time average rather
- than its simple average. An example is inventory: if
- first three days we have 5 units, and the fourth day only
- 3 then the time average is (5*3 + 3*1)/4 = 4.5 and while
- the simple average is (5 + 3)/2 = 4.
-
- subroutine: a procedure or function.
-
- time persistent statistic: a statistic about a stochastic
- process.
-
- SSS Reference Page 4
-
-
- ╔══════════════════════╗
- ║ SIMULATION ROUTINE ║
- ╚══════════════════════╝
-
- The simulation program has two parts:
- [1] setup - contains calls to INIQUE, INISTA, at least one call
- to CREATE and other initializations;
- [2] event loop - what to do when an event happens.
-
- A skeleton event loop looks as follows:
-
- ╔══════════════╦════════════╦═════════════════╦═════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠══════════════╬════════════╬═════════════════╬═════════════╣
- ║do ║do { ║9 e=NEXTEV() ║repeat ║
- ║e=NEXTEV ║e=NEXTEV() ║ if(e.gt.0) then║e:=NEXTEV ║
- ║if e>0 then ║if (e) ║ goto(1,2,...)e ║if e>0 then ║
- ║select case e ║switch(e) { ║1 continue ║begin ║
- ║case 1 ║case 1: ║C new entity ║case e of ║
- ║ 'new entity ║/*new entity║C arrival ║1:{new entity║
- ║ 'arrival ║ arrival */║ goto 9 ║ arrival} ║
- ║case 2 ║case 2: ║2 continue ║2: ║
- ║ 'etc ║ /* etc */ ║C etc ║ {etc} ║
- ║end select ║} ║ goto 9 ║end {case}; ║
- ║end if ║} ║ ... ║end {if}; ║
- ║loop while e>0║while(e); ║ endif ║until e=0; ║
- ╚══════════════╩════════════╩═════════════════╩═════════════╝
-
- (In FORTRAN the first column here is actually the 5th and the C's
- must be actually in the 1st column.)
-
- The cases 1, 2, etc (in FORTRAN the goto labels) are the event
- codes. The significance of e is:
-
- 0: either the calendar is empty or end of simulation, placed on
- calendar by SIMEND(g).
- 1: a new entity's arrival caused by calling CREATE(g,i) at some
- earlier simulated time.
- Other values (greater than 1) are non-arrival events scheduled by
- SCHED(g,e,i) like end of service etc.
-
- SSS Reference Page 5
-
-
- The codes following the cases are the things to perform at each
- event (like entering or inspecting a queue, starting or finishing
- an activity, etc). We suggest the following list covering most of
- the cases:
-
- ╔══════════╦════════════════════════════════════════════════════╗
- ║Symbol(=e)║ Things to do when this event becomes current: ║
- ╠══════════╬════════════════════════════════════════════════════╣
- ║ARRIVL(=1)║SCHEDuling next ARRIVaL, determination of Attributes║
- ║ ║and IDEntity of current entity as well as its first ║
- ║ ║activity ║
- ║ ║ ║
- ║NEXTAC(=2)║preparing NEXT ACtivity: whether it can start or ║
- ║ ║not, choosing of queues/servers if necessary ║
- ║ ║ ║
- ║STARTA(=3)║STARTing Activity: SCHEDuling its end ║
- ║ ║ ║
- ║ENDACT(=4)║ENDing ACTivity: determining what a server, who is ║
- ║ ║freed from current entity, and the current entity ║
- ║ ║should do next ║
- ║ ║ ║
- ║MATCH (=5)║MATCHing entities ║
- ╚══════════╩════════════════════════════════════════════════════╝
-
- The simulation is in a fact a proper interaction with the
- calendar. The important routines are: CREATE(g,i), NEXTEV() and
- SCHED(g,e,i).
-
- The calendar is fed with new entities by CREATE(g,i) and depleted
- by NEXTEV().
-
- SCHED(g,e,i) sends the current entity to its next event e after a
- delay of g units time from present simulated time. It acts as a
- kind of delayed "goto".
-
-
- ╔══════════════════╗
- ║ ERROR MASSAGES ║
- ╚══════════════════╝
-
- Most errors are explained under the routines that may raise them.
-
- There are two errors not covered under the routines:
-
- * There is no more space in memory or too many entities. Very
- unlikely, but may happen inside QuickBasic or QuickC
- environments. You may do one ore more of the following:
- [1] create less entities (if possible)
- [2] remove memory resident programs
- [3] add more physical memory (if possible)
- [4] in QuickBasic: consult end of SSSB.H for advice
- [5] in QuickBasic or QuickC: make compilation form CQ or QCL
-
- SSS Reference Page 6
-
-
- * There is a mathematical error (like division by 0 or square
- root from a negative number) inside a random number generator.
- Very unlikely, but if happens, please report the exact
- circumstances to the author. You can circumvent it by using an
- alternative strategy of generation (via CD, for example).
-
- See error codes and massages on page 30 as well as ways to
- control them.
-
-
- ╔══════════════════════════════════════════╗
- ║ CLARIFICATION OF ENTRIES IN DESCRIPTION ║
- ╚══════════════════════════════════════════╝
-
- Error: refers situations (invalid parameters or presence/absence
- of current entity) which give rise to errors
-
- Floating point number: double or real or real*8, see .H files
-
- Forbidden predecessor: a routine which must not be called prior
- to the routine under consideration unless one of the
- mandatory predecessors is called between them. For
- example, you cannot remove an entity from a queue (call
- REMVFQ(m,r)) unless there exists no current entity. But
- a current entity comes to existence as a result of
- calling NEXTEV(). NEXTEV() is therefore forbidden unless
- that entity is disposed (by calling DISPOS()) before
- calling REMVFQ(m,r). DISPOS() is mandatory here.
-
- Integer: 2 byte integer
-
- Notes: aspects concerning pecularities of languages
-
- Remarks: aspects concerning SSS or simulation or use
-
-
- ╔══════════════════════╗
- ║ NOTES FOR EXAMPLES ║
- ╚══════════════════════╝
-
- In BASIC examples:
- _ signifies that following line is actually a
- continuation of present line;
- sometimes closing quote (") is missing for lack of space.
-
- In FORTRAN examples:
- first FORTRAN column is actually 5th column of code;
- sometimes closing quote (') is missing for lack of space.
-
- SSS Reference Page 7
-
-
- ╔════════════════════════════════════╗
- ║ A(n), IDE(), SETA(n,v) SETIDE(i) ║
- ╚════════════════════════════════════╝
-
- Description: manages the data (attribute and identity) of the
- current entity. Attributes are floating point numbers.
- Identity is an integer, often set by last parameter of
- CREATE(g,i) or SCHED(g,e,i) when the present entity was
- CREATEd or SCHEDuled.
- A returns the n-th attribute (floating point number);
- IDE returns the identity (integer);
- SETA sets the n-th attribute's value to v;
- SETIDE sets identity to i.
-
- Arguments:
- n: (integer) attribute index, n = 1,...,max_atr where max_atr is
- second argument of INIQUE(q,max_atr,s).
- v: (floating point number) any value.
- i: (integer) any value.
-
- Mandatory predecessors: INIQUE(q,max_atr,s), and one of:
- NEXTEV(), REMVFC(r), REMVFQ(m,r).
-
- Forbidden predecessors: DISPOS(), QUEUE(m,p), SCHED(g,e,i).
-
- Recommanded predecessor for A: SETA(n,v), for IDE: one of -
- SETIDE(i), CREATE(g,i) or SCHED(g,e,i).
-
- Errors: if there is no current entity. For A and SETA also if
- n < 1 or n > max_atr.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 0,2,0 ║INIQUE(0,2,0);║ call INIQUE(0,2,0)║INIQUE(0,2,0);║
- ║CREATE 0,0 ║CREATE(0,0); ║ call CREATE(0,0) ║CREATE(0,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e = NEXTEV; ║
- ║SETA 2,7 ║SETA(2,7); ║ call SETA(2,7) ║SETA(2,7); ║
- ║SETIDE 99 ║SETIDE(99); ║ call SETIDE(99) ║SETIDE(99); ║
- ║print A(1),_ ║printf( ║ write (*,*) ║writeln( ║
- ║A(2),IDE ║"%f, %f %d\n",║+A(1),A(2),IDE() ║A(1),' ', ║
- ║ ║A(1),A(2), ║ ║A(2),' ',IDE);║
- ║ ║IDE()); ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A single entity is CREATEed and made current by
- NEXTEV. 1st attribute is not initialized, 2nd one is initialized
- to 7 and the identity to 99. Then all of them are printed out.
-
- SSS Reference Page 8
-
-
- ╔══════════════════════════════════════╗
- ║ AIC(r,n), IDIC(r), NEIC(r), TIC(r) ║
- ╚══════════════════════════════════════╝
-
- Description: returns data about the r-th entity in calendar
- (Attributes are like the latest current ones just prior
- SCHEDuling the entity.) -
- AIC returns the n-th attribute (as a floating point number);
- IDIC returns the identity code (last argument in CREATE or
- SCHED, an integer);
- NEIC returns the next event code (1 for CREATE, 2nd argument in
- SCHED, an integer);
- TIC returns the simulated time of the next event (first argument
- in CREATE/SCHED + simulated time when CREATE/SCHED was
- called, a floating point number).
-
- Arguments:
- r (integer) is the rank of entity in calendar, r = 1,...,NC(),
- where NC() is the number of entities in the calendar.
- n (integer) is the attribute index, n = 1,...,max_atr, where
- max_atr is second argument of INIQUE(q,max_atr,s).
-
-
- Mandatory predecessors: INIQUE(q,max_atr,s) and either
- CREATE(g,i) or SCHED(g,e,i).
-
- Recommended predecessor for AIC: SETA(n,v)
-
- Errors: if r < 1 or r > NC() or when calendar is empty or is not
- yet created. For AIC also when n < 1 or n > max_atr
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 0,2,0 ║INIQUE(0,2,0);║ call INIQUE(0,2,0)║INIQUE(0,2,0);║
- ║CREATE 0,0 ║CREATE(0,0); ║ call CREATE(0,0) ║CREATE(0,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e = NEXTEV; ║
- ║SETA 2,7 ║SETA(2,7); ║ call SETA(2,7) ║SETA(2,7); ║
- ║SCHED 9,2,0 ║SCHED(9,2,0); ║ call SCHED(9,2,0) ║SCHED(9,2,0); ║
- ║print _ ║printf( ║ write (*,*) ║writeln( ║
- ║AIC(1,2) _ ║"%f %f %d %d",║+AIC(1,2),TIC(1), ║AIC(1,2), ║
- ║TIC(1) _ ║AIC(1,2), ║+NEIC(1),IDIC(1) ║TIC(1),NEIC(1)║
- ║NEIC(1) ║TIC(1),NEIC(1)║ ║,IDIC(1)); ║
- ║IDIC(1) ║,IDIC(1)); ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A single entity is CREATEed and made current by
- NEXTEV. 1st attribute is not initialized, 2nd one is initialized
- to 7. After initialization the entity is SCHEDuled, thus put to
- the calendar. Since this is the only entity its rank in the
- calendar is 1. The data of the entity are printed out from the
- calendar.
-
- SSS Reference Page 9
-
-
- ╔════════════════════════════════════╗
- ║ AIQ(m,r,n), IDIQ(m,r), PRIQ(m,r) ║
- ╚════════════════════════════════════╝
-
- Description: returns data about the r-th entity in queue m.
- Attributes and id are like the latest current ones just
- prior placing the entity to the queue -
- AIQ returns the n-th attribute (as a floating point number);
- IDIQ returns the identity code (as an integer);
- PRIQ returns the priority (second argument in QUEUE which placed
- this entity to queue, a floating point number)
-
- Arguments:
- m (integer) is the queue index, m = 1,...,max_que, where max_que
- is the first argument in INIQUE(max_que,max_atr,s).
- r (integer) is the rank of entity in calendar, r = 1,...,NQ(m),
- where NQ(m) is the number of entities in queue m.
- n (integer0 is the attribute index, n = 1,...,max_atr, where
- max_atr is second argument of INIQUE(max_que,max_atr,s).
-
- Mandatory predecessors: INIQUE(max_que,max_atr,s) and QUEUE(m,p).
-
- Recommended predecessor: for AIQ: SETA(n,v)
-
- Errors: if m < 1 or m > max_que or r > NQ(m). For AIQ also if
- n < 1 or n > max_atr.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 3,2,0 ║INIQUE(3,2,0);║ call INIQUE(3,2,0)║INIQUE(3,2,0);║
- ║CREATE 0,0 ║CREATE(0,0); ║ call CREATE(0,0) ║CREATE(0,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e = NEXTEV; ║
- ║SETA 2,7 ║SETA(2,7); ║ call SETA(2,7) ║SETA(2,7); ║
- ║QUEUE 3,0 ║QUEUE(3,0); ║ call QUEUE(3,0) ║QUEUE(3,0); ║
- ║print _ ║printf("%f\n",║ write (*,*) ║writeln( ║
- ║AIQ(3,1,2) ║AIQ(3,1,2)); ║+AIQ(3,1,2) ║AIQ(3,1,2)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A single entity is CREATEed and made current by
- NEXTEV. 1st attribute is not initialized, 2nd one is initialized
- to 7. After initialization the entity is placed to queue #3.
- Since this is the only entity its rank in the queue is 1. The
- value of the attribute # 2 is printed out from the queue.
-
- SSS Reference Page 10
-
-
- ╔═══════════╗
- ║ BE(W,U) ║
- ╚═══════════╝
-
- Description: returns a continuous random beta variate (as a
- floating point number) whose mean is W/(U + W)
-
- Arguments:
- W (positive floating point number) is a shape parameter.
- U (positive floating point number) is a shape parameter.
-
- Errors: when U or W are not positive.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║BE(2,1) ║BE(2,1)); ║+BE(2,1) ║BE(2,1); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A random variate from BE(2,1) distribution is
- printed out. The probability density function of BE(2,1) is
- f(x) = 2x (0 < x < 1).
-
-
- ╔══════════════════╗
- ║ BI(N,P), NP(M) ║
- ╚══════════════════╝
-
- Description: returns a discrete random variate (as integer)
- according to the distribution law -
- BI binomial, number of successful trials out of N
- NP Poisson, binomial with many trials when probability of success
- in each trial is small.
-
- Arguments:
- N (positive integer) is the number of trials.
- P (a positive floating point number less than 1) is the
- probability of success in one trial.
- M (positive floating point number) is the mean number of
- successes.
-
- Errors: when N or P or M are not positive or P > 1.
-
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║BI(4,.2) ║BI(4,.2)); ║+BI(4,.2) ║BI(4,.2); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A random variate from BI(4,.2) distribution is
- printed out. This is the number of successes in 4 trials when the
- probability of success for each trial is 1/5.
-
- SSS Reference Page 11
-
-
- ╔══════════════════════╗
- ║ CD(X,V,N), DP(V,N) ║
- ╚══════════════════════╝
-
- Description: Returns a continuous/discrete random variate
- according to user defined distribution -
- CD for continuous case;
- DP for discrete case.
-
- Arguments:
- X (floating point array) is the ordinates.
- V (floating point array) is the cumulative probabilities.
- N (integer) is the number of elements in X and V.
-
- Notes on the arguments: The elements of X and V must constitute
- increasing sequences. The probability that a continuous
- random variable is X[i] or less is V[i], i=1,...,N (for
- FORTRAN & Pascal or i=0,...N-1 for BASIC & C). The
- probability that a discrete random variable is i-1 (for
- FORTRAN & Pascal or i for BASIC & C) or less is V[i].
-
- Note on starting index: it is the index of array natural to the
- language: 0 for BASIC and C, 1 for FORTRAN and Pascal.
-
- Note on BASIC: for each array we pass TWO integers, the first
- must be varptr(<array's first element>) while the second
- is varseg(<array's first element>). Take care to add # to
- X and V, the compiler cannot correct it as in other cases!
-
- Note on Pascal: the array's type is user_arr. This type is
- already defined in the Pascal unit or SSSP2.H.
-
- Examples:
- ╔════════════════╦══════════════╦════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠════════════════╬══════════════╬════════════════╬══════════════╣
- ║ ║ ║ real*8 x(3) ║ ║
- ║x#(0)=0:p#(0)=0 ║double x[3], ║ real*8 p(3) ║var ║
- ║x#(1)=3:p#(1)=.3║p[3]; ║ x(1)=0 ║x,p: user_arr;║
- ║x#(2)=4:p#(2)=1 ║x[0]=0;p[0]=0;║ x(2)=3 ║x[1]=0;p[1]=0;║
- ║ix=varptr(x#(0))║x[1]=3; ║ x(3)=4 ║x[2]=3; ║
- ║ip=varptr(p#(0))║p[1]=.3; ║ p(1)=0 ║p[2]=.3; ║
- ║sx=varseg(x#(0))║x[2]=4;p[2]=1;║ p(2)=.3 ║x[3]=4;p[3]=1;║
- ║sp=varseg(p#(0))║printf("%f ", ║ p(3)=1 ║writeln( ║
- ║print CD(ix,_ ║CD(x,p,3)); ║ write(*,*) ║CD(x,p,3), ║
- ║sx,ip,sp,3), ║printf("%f\n",║+CD(x,p,3), ║DP(p,3)); ║
- ║DP(ip,sp,3) ║DP(p,3)); ║+DP(p,3) ║ ║
- ╚════════════════╩══════════════╩════════════════╩══════════════╝
- Explanation: A continuous distribution is defined for which the
- probability of 2 or less is 0.2, the probability of 3.5 or less
- is 0.65, etc. A pseudo random variate is generated and printed
- out for this distribution. DP reflects a distribution function
- for which the probability for 1 is .3 and for 2 is .7.
-
- SSS Reference Page 12
-
-
- ╔══════════════════════════════════════════════════════════╗
- ║ CLEARQ(m), QAVG(m), QMAX(m), QMIN(m), QNUM(m), QSTD(m) ║
- ╚══════════════════════════════════════════════════════════╝
-
- Description: managing statistical information about size of queue
- m. Routines starting with Q return time persistent
- statistics (as floating point numbers) since the start of
- simulation or latest CLEARQ, whatever is later -
- CLEARQ clears statistic of a queue or of all queues;
- QAVG returns time average;
- QMAX returns maximum queue size;
- QMIN returns minimum queue size;
- QNUM returns length of period for which statistic is accumulated;
- QSTD returns standard deviation of queue size.
-
- Argument: (integer) is the queue index, m = 1,...,max_que, where
- max_que is the first argument in INIQUE(max_que,b,s).
- Only for CLEARQ m=0 is allowed, calling CLEARQ(0) clears
- the statistics of all the queues while if
- m = 1,...,max_que it clears statistics of queue m only.
-
- Mandatory predecessor: INIQUE(max_que,b,s) except for CLERQ(0).
-
- Recommanded predecessors: INIQUE(max_que,b,s), QUEUE(m,p) and
- REMVFQ(m,r)
-
- Errors: if m < 1 or m > max_que, except for CLEARQ(0).
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 3,0,0 ║INIQUE(3,0,0);║ call INIQUE(3,0,0)║INIQUE(3,0,0);║
- ║CREATE 0,0 ║CREATE(0,0); ║ call CREATE(0,0) ║CREATE(0,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e = NEXTEV; ║
- ║QUEUE 3,0 ║QUEUE(3,0); ║ call QUEUE(3,0) ║QUEUE(3,0); ║
- ║SETT(3) ║SETT(3); ║ call SETT(3) ║SETT(3); ║
- ║REMVFQ(3,1) ║REMVFQ(3,1); ║ call REMVFQ(3,1) ║REMVFQ(3,1); ║
- ║print _ ║printf("%f\n",║ write (*,*) ║writeln( ║
- ║QAVG(3) ║QAVG(3)); ║+QAVG(3) ║QAVG(3)); ║
- ║CLAERQ(3) ║CLEARQ(3); ║ CLEARQ(3) ║CLEARQ(3); ║
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║QAVG(3) ║QAVG(3)); ║+QAVG(3) ║QAVG(3)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A single entity is CREATEed and made current by
- NEXTEV. An entity is placed on QUEUE #3, the simulated time is
- increased to 3 (from initial 0 when the QUEUEing took place) and
- removed from QUEUE 3. The average queue size is printed out
- before and after CLEARing the Queue statistics of that queue.
-
- SSS Reference Page 13
-
-
- ╔═════════════════════════╗
- ║ CLEARS(j), TALLY(j,v) ║
- ╚═════════════════════════╝
-
- Description: managing statistics j -
- CLEARS clears statistics of a variable or of all the variables;
- TALLY collects observations (for a stochastic process it has to
- be called after each change of the variable).
-
- Arguments:
- j (integer) the variable's index, j = 1,...,max_sta (integer)
- where max_sta is the third argument in
- INIQUE(q,b,max_sta). Only for CLEARS j=0 is allowed,
- calling CLEARS(0) clears the all the statistics managed
- by the user, while if j = 1,...,max_sta it clears
- statistics of variable j only.
- v (floating point number) is a new observation of the variable.
-
- Mandatory predecessors: INIQUE(q,b,max_sta) and INISTA(j,h,k,l,w)
-
- Errors: if j < 1 or j > max_sta except for CLEARS(0).
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║x$="1st ║ ║ ║ ║
- ║INIQUE 0,0,1 ║INIQUE(0,0,1);║ call INIQUE(0,0,1)║INIQUE(0,0,1);║
- ║INISTA(1,_ ║INISTA(1, ║ call INISTA(1, ║INISTA(1, ║
- ║sadd(x$),0,_ ║"1st",0, ║+'1st ║'1st',0, ║
- ║0,0,0) ║0,0,0) ║+0,0,0,0) ║0,0,0) ║
- ║TALLY(1,4) ║TALLY(1,4); ║ call TALLY(1,4) ║TALLY(1,4); ║
- ║print _ ║printf("%f\n",║ write (*,*) ║writeln( ║
- ║SAVG(1) ║SAVG(1)); ║+SAVG(1) ║SAVG(1)); ║
- ║CLAERS(1) ║CLEARS(1); ║ CLEARS(1) ║CLEARS(1); ║
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║SAVG(1) ║SAVG(1)); ║+SAVG(1) ║SAVG(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One statistic collection is initialized by INIQUE
- and INISTA (see there particulars). One sample of one observation
- is recorded. The average is printed out before and after clearing
- the statistic.
-
- SSS Reference Page 14
-
-
- ╔═══════════════╗
- ║ CREATE(g,i) ║
- ╚═══════════════╝
-
- Description: Creates a new entity by placing it to the calendar
- with event code 1.
-
- Arguments:
- g (non-negative floating point number) is the simulated time
- duration between creation and entity's arrival.
- i (integer) is the identity code of that created entity.
-
- Remarks: A new entity can be entered to the system only by
- CREATE(g,i) and actually arrive only after NEXTEV() is
- called. Then the entity becomes current. CREATE(g,i) does
- not affect the current entity (if exists) in any way.
- (Current entity can be placed to the calendar by
- SCHED(g,e,i).) CREATE(g,i) takes care to "refill" the
- calendar with new entities as opposed to NEXTEV() which
- "depletes" it. It is essential to call it at least once
- before the event loop, otherwise NEXTEV() finds an empty
- calendar and no simulation takes place.
-
- Mandatory predecessor: INIQUE(q,b,s).
-
- Errors: calendar is not yet created.
-
- Note: if g is found negative, it is corrected to 0 automatically.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 0,2,0 ║INIQUE(0,2,0);║ call INIQUE(0,2,0)║INIQUE(0,2,0);║
- ║CREATE 0,0 ║CREATE(0,0); ║ call CREATE(0,0) ║CREATE(0,0); ║
- ║print IDIC(1)║printf("%f\n",║ write (*,*) ║writeln( ║
- ║ ║IDIC(1)); ║+IDIC(1) ║IDIC(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A single entity is CREATEed and its identity is
- printed out.
-
- SSS Reference Page 15
-
-
- ╔════════════╗
- ║ DISPOS() ║
- ╚════════════╝
-
- Description: disposes a current entity.
-
- Remarks: DISPOS() is called when an entity leaves the system.
- If there is no current entity, DISPOS has no effect.
- After DISPOS is called there is no current entity.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║INIQUE 0,0,1 ║INIQUE(0,0,1);║ call INIQUE(0,0,1)║INIQUE(0,0,1);║
- ║CREATE 2,0 ║CREATE(2,0); ║ call CREATE(2,0) ║CREATE(2,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║DISPOS ║DISPOS(); ║ call DISPOS ║DISPOS; ║
- ║DISPOS ║DISPOS(); ║ call DISPOS ║DISPOS; ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One entity is created which arrives at simulated
- time 2, and is immediately disposed. The second calling of DISPOS
- does not cause an error, but does nothing either.
-
-
- ╔════════════════════════════════════╗
- ║ ER(M,K), EX(M), GA(M,K) WE(M,U) ║
- ╚════════════════════════════════════╝
-
- Description: returns a continuous random variate (as a floating
- point number) according to distribution law -
- ER Erlang [with mean K*M]
- EX exponential
- GA gamma [with mean K*M]
- WE Weibull [X to power of U is exponential with mean M]
-
- Arguments:
- U (positive floating point number) is a shape parameter.
- M (positive floating point number) is the exponential mean
- K for ER (positive integer): is number of stages
- for GA (positive floating point number): is generalized number
- of stages.
-
- Errors: when U or K or M are not positive.
-
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║WE(1,2) ║WE(1,2)); ║+WE(1,2) ║WE(1,2); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A random variate from WE(1,2) distribution is
- printed out. The probability density function of WE(1,2) is
- f(x) = 2x * exp( - x*x).
-
- SSS Reference Page 16
-
-
- ╔═════════════════╗
- ║ INIQUE(q,b,s) ║
- ╚═════════════════╝
-
- Description: initiates the calendar, q queues, b attributes and
- s statistics. All the parameters are integers.
-
- Remark: Except for the random generators or T(), SETT(g), all the
- routines need INIQUE(q,b,s), so be sure to include it at
- the setup stage of simulation.
-
- Warnings: if q or b or s are higher than preset limits.
-
- Forbidden predecessor: INIQUE(q,b,s).
-
- Errors: if any of the parameters are negative or called more than
- once.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║INIQUE 3,2,1 ║INIQUE(3,2,1);║ call INIQUE(3,2,1)║INIQUE(3,2,1);║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: maximum 3 queues, 2 attribute and one variable's
- statistics collection by TALLY(j,v) are possible.
-
-
- ╔══════════════════════╗
- ║ INISTA(j,h,k,l,f,w) ║
- ╚══════════════════════╝
-
- Description: initialization of statistics collecting and standard
- report (by calling SUMRY(u)) for a variable.
-
- Arguments:
- j (integer) the variable's index, j = 1,...,max_sta (integer)
- where max_sta is the third argument in
- INIQUE(q,b,max_sta).
- h (str20, e.i. a string with 20 charcters maximum) is used as a
- headline in SUMRY when printing out results. See notes
- further.
- k (integer) is 1 for a stochastic process, 0 for an ordinary
- variable.
- l (integer) is number of cells in the observations' histogram
- printed in SUMRY(u). l=0 if no histogram is required.
- f (floating point number) is the lower bound of the first cell
- in the histogram.
- w (floating point number) is the width of a cell in the
- histogram.
-
- SSS Reference Page 17
-
-
- Remarks: a stochastic process is a random variable which changes
- at some points of time and we are interested in its time
- average rather than its simple average. An example is
- inventory: if first three days we have 5 units, and the
- fourth day only 3 then the time average is (5*3 + 3*1)/4
- = 4.5 and while the simple average is (5 + 3)/2 = 4.
- Thus, set third parameter (k) to 1 to get 4.5, while if
- k is 0, the result is 4. Independent of the value of l,
- no histogram is produced for a stochastic process. If no
- histogram is generated (either because k=1 or l=0), f
- and w can have any value.
-
- Note for BASIC: the second argument (headline) in BASIC should be
- sadd(x$) where x$ is a string defined prior to calling
- INISTA with 20 characters. If the length of headline is
- shorter, pad it with spaces.
-
- Note for FORTRAN: place the second argument (headline) as a
- string constant with 20 characters. If the length of
- headline is shorter, pad it with spaces.
-
- Mandatory predecessor: INIQUE(q,b,max_sta).
-
- Forbidden predecessor for INISTA(j,...): INISTA(j,...) with the
- same j.
-
- Errors: if j < 1 or j > max_sta or calling INISTA twice with
- first argument equal.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║x$="1st ║ ║ ║ ║
- ║INIQUE 0,0,1 ║INIQUE(0,0,1);║ call INIQUE(0,0,1)║INIQUE(0,0,1);║
- ║INISTA(1,_ ║INISTA(1, ║ call INISTA(1, ║INISTA(1, ║
- ║sadd(x$),0,_ ║"1st",0, ║+'1st ║'1st',0, ║
- ║0,0,0) ║0,0,0) ║+0,0,0,0) ║0,0,0) ║
- ║TALLY(1,4) ║TALLY(1,4); ║ call TALLY(1,4) ║TALLY(1,4); ║
- ║print _ ║printf("%f\n",║ write (*,*) ║writeln( ║
- ║SAVG(1) ║SAVG(1)); ║+SAVG(1) ║SAVG(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One statistic collection is initialized by INIQUE
- and INISTA (see there particulars). One sample of one observation
- is recorded. The average is printed out.
-
- SSS Reference Page 18
-
-
- ╔═══════════════╗
- ║ NC(), NQ(m) ║
- ╚═══════════════╝
-
- Description: returns number of entities (as integer) in -
- NC(): the calendar
- NQ(m): queue number m.
-
- Argument in NQ: m (integer) is the index of queue,
- m = 1,...max_que, where max_que is first argument in
- INIQUE(max_que,b,s).
-
- Mandatory predecessor: INIQUE(max_que,b,s).
-
- Error: for NC if calendar is not yet initialized by INIQUE(), for
- NQ if m < 1 or m > max_que.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║CREATE 2,0 ║CREATE(2,0); ║ call CREATE(2,0) ║CREATE(2,0); ║
- ║print NC ║printf("%d\n",║ write(*,*) NC() ║writeln(NC); ║
- ║ ║NC()); ║ ║ ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║QUEUE(1,0) ║QUEUE(1,0.0); ║ call QUEUE(1,0) ║QUEUE(1,0); ║
- ║print NQ(1) ║printf("%d\n",║ write(*,*) NQ(1) ║writeln( ║
- ║ ║NQ(1)); ║ ║NQ(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One entity is created (=placed on calendar) and
- number of entities in the calendar is printed out. Then the same
- entity is made current by NEXTEV, placed on queue #1 and the
- number of entities in that queue is printed out.
-
- SSS Reference Page 19
-
-
- ╔════════════════════╗
- ║ NCEN(), NEXTEV() ║
- ╚════════════════════╝
-
- Description:
- NCEN() returns 0 or 1 depending whether there is no current
- entity (=0) or there is one (=1). There cannot be more
- than one current entity. There must be a current entity
- before calling one of: A, IDE, QUEUE, SCHED, SETA, SETIDE.
- There must not be a current entity before calling one of:
- NEXTEV, REMVFC, REMVFQ.
- NEXTEV() removes the first entity from the calendar, makes it
- current, moves forward the simulated time if the event
- time of this entity is later and returns the event code
- of this entity as a non-negative integer.
-
- Remarks: NEXTEV() is the chief driver of the simulation. It is at
- the top of the event loop.
-
- Mandatory predecessors for NEXTEV(): one of INIQUE(q,b,s),
- SCHED(g,e,i), QUEUE(m,p).
-
- Forbidden predecessors for NEXTEV(): NEXTEV(), REMVFC(r),
- REMVFQ(m,r).
-
- Recommended predecessor for NEXTEV(): CREATE(g,i).
-
- Errors for NEXTEV(): if the calendar has not been initiated by
- INIQUE or there is a current entity.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 0,0,1 ║INIQUE(0,0,1);║ call INIQUE(0,0,1)║INIQUE(0,0,1);║
- ║print NCEN ║printf("%d\n",║ write(*,*)NCEN() ║writeln(NCEN);║
- ║ ║NCEN()); ║ ║ ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: The calendar is empty after initialized by INIQUE,
- therefore e is 0. Also NCEN returns 0 as there is no current
- entity.
-
- SSS Reference Page 20
-
-
- ╔═══════════════════════╗
- ║ QDC(m), SETQDC(m,d) ║
- ╚═══════════════════════╝
-
- Description: the discipline of queue number m is -
- QDC: returned as a character (one of: F, L, B, S)
- SETQDC: set (to one of FIFO, LIFO, BVF, SVF).
-
- Arguments:
- m (integer) is the index of queue, m = 1,...max_que where max_que
- is the first argument in INIQUE(max_que,b,s).
- d (str6, e.i. a string with 6 charcters maximum) is the
- discipline, one of: FIFO, LIFO, BVF, SVF. If d is any
- other string (like bvs or KKK), the first character
- counts. If it is L or B or S, the discipline is treated
- as LIFO or BVF or SVF respectively. If it is different
- (like b or K) it is treated as FIFO.
-
- Note for BASIC: the second argument of SETQDC (discipline) in
- BASIC should be sadd(x$) where x$ is a string defined
- prior to calling SETQDC with 6 characters. If the length
- of discipline is shorter, pad it with spaces.
-
- Note for FORTRAN: place the second argument of SETQDC
- (discipline) as a string constant with 6 characters. If
- the length of discipline is shorter, pad it with spaces.
-
- Mandatory predecessor: INIQUE(max_que,b,s).
-
- Errors: if m < 1 or m > max_que.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║x$="B " ║ ║ ║ ║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║SETQDC(1,_ ║SETQDC(1,"B");║ call SETQDC(1, ║SETQDC(1,'B');║
- ║sadd(x$)) ║ ║+'B ') ║ ║
- ║print QDC(1) ║printf("%c\n",║ write(*,*) QDC(1) ║writeln( ║
- ║ ║QDC(1)); ║ ║QDC(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: The discipline is set to "B", printed out. This
- discipline is interpreted as Biggest Value First.
-
- SSS Reference Page 21
-
-
- ╔══════════════╗
- ║ QUEUE(m,p) ║
- ╚══════════════╝
-
- Description: places the current entity in queue number m with
- priority p. According to queue discipline FIFO/LIFO/SVF/
- BVF which has been set most recently by SETQDC. (If none
- is set the default is FIFO.) After calling QUEUE there
- is no current entity.
-
- Arguments:
- m (integer) is the index of queue, m = 1,...max_que where max_que
- is first argument in INIQUE(max_que,b,s).
- p (floating point number) is the priority. Argument has effect
- only with disciplines SVF or BVF. The rank of the the
- entity in the queue is such that in SVF the entity with
- Smallest Value of p is First and in BVF the entity with
- Biggest Value of p is First.
-
- Mandatory predecessor: INIQUE(max_que,b,s) and one of: NEXTEV(),
- REMVFC(r), REMVFQ(m,r).
-
- Forbidden predecessors: DISPOS(), QUEUE(m,p), SCHED(g,e,i).
-
- Errors: if there is no current entity or m < 1 or m > max_que.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║CREATE 2,0 ║CREATE(2,0); ║ call CREATE(2,0) ║CREATE(2,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║QUEUE(1,0) ║QUEUE(1,0.0); ║ call QUEUE(1,0) ║QUEUE(1,0); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One entity is created (=placed on calendar) and is
- made current by NEXTEV. The current entity is placed on queue #1.
-
- SSS Reference Page 22
-
-
- ╔══════════════════════════════════════════════╗
- ║ RA(), RL(M,S), RN(M,S), TR(I,B,C), UN(I,C) ║
- ╚══════════════════════════════════════════════╝
-
- Description: returns a continuous random variate (as a floating
- point number) according to distribution law -
- RA uniform between 0 and 1
- RL log-normal, so that after taking natural logarithm, the
- resulting distribution is normal with mean M, standard
- deviation S (S > 0)
- RN normal with mean M, standard deviation S (S > 0)
- TR triangular between I and C with mode B
- UN uniform between I and C.
-
- Arguments are all floating point numbers.
-
- Errors: when C < B or B < I.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║RN(2,1) ║RN(2,1)); ║+RN(2,1) ║RN(2,1); ║
- ║print _ ║printf("%f\n",║ write(*,*) ║writeln( ║
- ║TR(0,3,4) ║TR(0,3,4)); ║+TR(0,3,4) ║TR0,3,4)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: A random normal variate is printed from a
- distribution with mean 2 and standard deviation 1. Then a
- random variate from TR(0,3,4) is printed out.
-
- SSS Reference Page 23
-
-
-
- ╔══════════════════════════╗
- ║ REMVFC(r), REMVFQ(m,r) ║
- ╚══════════════════════════╝
-
- Description: making an entity (which has had rank r) current by
- removing it from -
- REMVFC: calendar;
- REMVFQ: queue number m.
-
- Arguments:
- r (integer) is the rank of entity -
- for REMVFC: in calendar, r = 1,...,NC(), where NC() is
- number of entities in calendar;
- for REMVFQ: in queue m, r = 1,...,NQ(m), where NQ(m) is
- the number of entities in queue m.
- m (integer) is the index of queue, m = 1,...max_que, where
- max_que is first argument in INIQUE(max_que,b,s).
-
- Mandatory predecessors: INIQUE(q,b,s), for REMVFC also one of:
- CREATE(g,i), SCHED(g,e,i), for REMVFQ also QUEUE(m,p).
-
- Forbidden predecessor: NEXTEV(), REMVFC(r), REMVFQ(m,r).
-
- Errors: if prior to call there is a current entity or calendar
- is not initiated by INIQUE(max_que,b,s) or if
- m > max_queue or (for REMVFQ) r > NQ(m) or (for REMVFC)
- r > NC().
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║CREATE 0,1 ║CREATE(0,1); ║ call CREATE(0,1) ║CREATE(0,1); ║
- ║CREATE 2,2 ║CREATE(2,2); ║ call CREATE(2,2) ║CREATE(2,2); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║QUEUE 1,0 ║QUEUE(1,0.0); ║ call QUEUE(1,0) ║QUEUE(1,0); ║
- ║REMVFQ 1,1 ║REMVFQ(1,1); ║ call REMVFQ(1,1) ║REMVFQ(1,1); ║
- ║DISPOS ║DISPOS(); ║ call DISPOS ║DISPOS; ║
- ║REMVFC 1,1 ║REMVFC(1,1); ║ call REMVFC(1,1) ║REMVFC(1,1); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Two entities are created (=placed on calendar). The
- first is made current and placed to queue #1. Then the remaining
- one is removed from the calendar, disposed and the one in the
- queue is removed next. Note that without intermingled DISPOS this
- could cause an error.
-
- SSS Reference Page 24
-
-
- ╔═══════════════════════════════════════════════╗
- ║ SAVG(j), SMAX(j), SMIN(j), SNUM(j), SSTD(j) ║
- ╚═══════════════════════════════════════════════╝
-
- Description: returning statistics about about variable j as
- floating point numbers since the start of simulation or
- latest CLEARS, whatever is later -
- SAVG average (or time average for a stochastic process);
- SMAX maximum observed value;
- SMIN minimum observed value;
- SNUM sample size (for a stochastic process the length of period
- is returned for which statistics are accumulated);
- SSTD standard deviation of observed values calculated as the
- square root of the sum of deviations from SAVG devided by
- SNUM. Note that the demoninator is the sample size rather
- than the degrees of freedom!
-
- Argument:
- j (integer) the variable's index, j = 1,...,max_sta (integer)
- where max_sta is the third argument in
- INIQUE(q,b,max_sta).
-
- Mandatory predecessors: INIQUE(q,b,max_sta) and INISTA(j,h,k,l,w)
-
- Recommended predecessor: TALLY(j,v).
-
- Errors: if j < 1 or j > max_sta.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║x$="1st ║ ║ ║ ║
- ║INIQUE 0,0,1 ║INIQUE(0,0,1);║ call INIQUE(0,0,1)║INIQUE(0,0,1);║
- ║INISTA(1,_ ║INISTA(1, ║ call INISTA(1, ║INISTA(1, ║
- ║sadd(x$),0,_ ║"1st",0, ║+'1st ║'1st',0, ║
- ║0,0,0) ║0,0,0) ║+0,0,0,0) ║0,0,0) ║
- ║TALLY(1,4) ║TALLY(1,4); ║ call TALLY(1,4) ║TALLY(1,4); ║
- ║print _ ║printf("%f\n",║ write (*,*) ║writeln( ║
- ║SAVG(1) ║SAVG(1)); ║+SAVG(1) ║SAVG(1)); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: One statistic collection is initialized by INIQUE
- and INISTA (see there particulars). One sample of one observation
- is recorded. The average is printed out.
-
- SSS Reference Page 25
-
-
- ╔════════════════╗
- ║ SCHED(g,e,i) ║
- ╚════════════════╝
-
- Description: the current entity is placed on the calendar with
- identity i, event code e to be removed from there after g units
- of simulated time by NEXTEV. If the identity is to be preserved
- i = IDE().
-
- Arguments:
- g (non-negative floating point number) is the simulated time that
- elapses between present and the time that event e is
- executed;
- e (integer bigger than 1) is the event code;
- i (integer) is the identity.
-
- Remark: SCHED(g,e,i) "sends" the current entity to its next event
- e after a delay of g units time from present simulated
- time. It acts as a kind of delayed "goto". After calling
- SCHED(g,e,i) there will be no current entity. Therefore
- delay calling SCHED(g,e,i) to the latest moment
- consistent with your program.
-
- Mandatory predecessors: NEXTEV(), REMVFC(r), REMVFQ(m,r).
-
- Forbidden predecessors: DISPOS(), QUEUE(m,p), SCHED(g,e,i).
-
- Errors: if prior to call there is already a current entity or e
- is 0, 1 or negative.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║CREATE 0,1 ║CREATE(0,1); ║ call CREATE(0,1) ║CREATE(0,1); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║SCHED .5,2, _║SCHED(.5,2, ║ call SCHED(.5,2, ║SCHED(.5,2, ║
- ║IDE ║IDE()); ║+IDE()) ║IDE); ║
- ║print NEXTEV ║printf("%d\", ║ write(*,*)NEXTEV()║writeln( ║
- ║ ║NEXTEV()); ║ ║NEXTEV); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: An entity is created (=placed on calendar), made
- current, scheduled again for time .5 and its event code is
- printed out.
-
- SSS Reference Page 26
-
-
- ╔════════════════════════╗
- ║ SETANT(y), SETSEE(x) ║
- ╚════════════════════════╝
-
- Description: routines managing the random stream -
- SETANT sets(y=1)/resets(y=0) antithetic stream
- SETSEE sets the random seed to x
-
- Arguments:
- y is 0 or 1.
- x (positive odd integer) is the seed.
-
- Remarks: For other than the above arguments the routines have no
- effect.
-
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║SETSEE 777 ║SETSEE(777); ║ call SETSEE(777) ║SETSEE(777); ║
- ║SETANT 0 ║SETANT(0); ║ call SETANT(0) ║SETANT(0); ║
- ║print EX(1),_║printf( ║ write(*,*) EX(1), ║writeln( ║
- ║EX(1) ║"%f %f ", ║+EX(1) ║EX(1),EX(2)); ║
- ║ ║EX(1),EX(1)); ║ ║ ║
- ║SETSEE 777 ║SETSEE(777); ║ call SETSEE(777) ║SETSEE(777); ║
- ║SETANT 1 ║SETANT(1); ║ call SETANT(1) ║SETANT(1); ║
- ║print EX(1),_║printf( ║ write(*,*) EX(1), ║writeln( ║
- ║EX(1) ║"%f %f ", ║+EX(1) ║EX(1),EX(2)); ║
- ║ ║EX(1),EX(1)); ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Two pairs of antithetic exponential variates are
- printed. Note that the seed had to be reset to 777.
-
- SSS Reference Page 27
-
-
- ╔═══════════════════════╗
- ║ SETDEB(o), SHOWQ(m) ║
- ╚═══════════════════════╝
-
- Description: routines for debug -
- SETDEB sets switches which tell what to do after an error or when
- to print out calendar and/or queues
- SHOWQ shows contents of queue m or the calendar (m=0)
-
- Arguments:
- o (integer between 0 and 15) with following significance (3 is
- the default; stop means immediate stop):
- ╔══════════════════════════════════════════════════════════════╗
- ║o = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15║
- ║stop on error? N Y N Y N Y N Y N Y N Y N Y N Y║
- ║print error? N N Y Y N N Y Y N N Y Y N N Y Y║
- ║print calendar? N N N N Y Y Y Y N N N N Y Y Y Y║
- ║print queues? N N N N N N N N Y Y Y Y Y Y Y Y║
- ╚══════════════════════════════════════════════════════════════╝
- m (integer) is the index of queue, m = 1,...max_que, where
- max_que is first argument in INIQUE(max_que,b,s) or m=0
- for the calendar.
-
- Remarks: calendar and queue is printed just before removing an
- entity from them. Any other value for o does not have any
- affect. See further discussion on errors under SIMERR().
-
- Note for FORTRAN: If you write to screen before the calendar or
- queue, include an end of line in your write command,
- otherwise the calendar's or queues' first line will be on
- the last written line.
-
- Mandatory predecessor for SHOWQ(m): INIQUE(max_que,b,s).
-
- Errors for SHOWQ: if m > max_queue or m < 0.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║SETDEB 15 ║SETDEB(15); ║ call SETDEB(15) ║SETDEB(15); ║
- ║CREATE 0,1 ║CREATE(0,1); ║ call CREATE(0,1) ║CREATE(0,1); ║
- ║CREATE 2,2 ║CREATE(2,2); ║ call CREATE(2,2) ║CREATE(2,2); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║QUEUE 1,0 ║QUEUE(1,0.0); ║ call QUEUE(1,0) ║QUEUE(1,0); ║
- ║SHOWQ 1 ║SHOWQ(1); ║ call SHOWQ(1) ║SHOWQ(1); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Two entities are created (=placed on calendar). The
- first is made current and placed to queue #1. Printout should
- follow NEXTEV and SHOWQ.
-
- SSS Reference Page 28
-
-
- ╔════════════════╗
- ║ SETT(g), T() ║
- ╚════════════════╝
-
- Description: managing simulated time -
- SETT sets simulated time to g,
- T returns current simulated time (as a floating point number).
-
- g (floating point number) new absolute value of simulated time,
- g should not be less than T() prior to calling SETT.
-
- Remarks: At start of simulation simulated time is set to 0. If g
- is less than T() prior to calling SETT, SETT has no
- effect. Simulated time is managed in general by NEXTEV
- when it sets the time to next event's time. Next event's
- times are the first arguments in CREATE(g,i) or
- SCHED(g,e,i).
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║SETT 7.4 ║SETT(7.4); ║ call SETT(7.4) ║SETT(7.4); ║
- ║print T ║printf("%f\", ║ write(*,*) T() ║writeln(T); ║
- ║ ║T()); ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Time is set to 7.4 and printed out.
-
- SSS Reference Page 29
-
-
- ╔═════════════╗
- ║ SIMEND(g) ║
- ╚═════════════╝
-
- Description: Causes end of simulation at absolute simulated time
- g or immediately if g < T() prior calling SIMEND, where
- T() is the current simulated time.
-
- Argument: g (floating point number) is the absolute simulated
- time to finish simulation.
-
- Mandatory predecessor: INIQUE(q,b,s).
-
- Error: if calendar has been not initiated by INIQUE(q,b,s).
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║integer e ║int e; ║ integer e ║var e:integer;║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║SIMEND 9.5 ║SIMEND(9.5); ║ call SIMEND(9.5) ║SIMEND(9.5); ║
- ║CREATE 10,0 ║CREATE(10,0); ║ call CREATE(10,0) ║CREATE(10,0); ║
- ║e = NEXTEV ║e = NEXTEV(); ║ e = NEXTEV() ║e := NEXTEV; ║
- ║print e ║printf("%d\n",║ write(*,*) e ║writeln(e); ║
- ║ ║e); ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Two entities are created (=placed on calendar). The
- first is made current and placed to queue #1. Printout should
- follow NEXTEV and SHOWQ.
-
- SSS Reference Page 30
-
-
- ╔════════════╗
- ║ SIMERR() ║
- ╚════════════╝
-
- Description: Returns latest SSS error code as an integer and
- clears it (clear means 0).
-
- Remarks: SIMERR() is in effect only when o is EVEN in SETDEB(o),
- as for odd values of o the simulation stops on an error.
- If an error occurs, o is even and SIMERR() is not called
- then NEXTEV() returns 0 upon its next call, effectively
- stopping simulation. However, when SIMERR() is called
- just before NEXTEV(), SIMERR() clears the error and
- NEXTEV() will continue if possible. This gives to the
- experianced programmer more control on errors.
-
- Note on QuickBASIC v4.5 and similar integrated environments that
- exit to DOS upon an SSS error: in the beginning of the
- program include the line SETDEB(2).
-
- The meaning of SSS error codes are:
-
- ╔════╦══════════════════════════════════════════════════════════╗
- ║Code║ Meaning ║
- ╠════╬══════════════════════════════════════════════════════════╣
- ║ 1 ║ Attempt to make more than one entity current ║
- ║ 2 ║ Lack of space in memory ║
- ║ 3 ║ Too many entities ║
- ║ 4 ║ Queue index is too big or smaller than 1 ║
- ║ 5 ║ No entity exists with specified rank and/or queue number ║
- ║ 6 ║ There is no current entity when one is needed ║
- ║ 7 ║ INIQUE was not called ║
- ║ 8 ║ Statistics index is too big smaller than 1 ║
- ║ 9 ║ INISTA is called twice with same first argument ║
- ║ 10 ║ Summary file cannot be opened ║
- ║ 12 ║ Too large rank for queue or calendar ║
- ║ 13 ║ Parameters should be positive ║
- ║ 14 ║ In TR the parameters do not obay to min <= mode <= max ║
- ║ 15 ║ Attribute number is too big or smaller than 1 ║
- ║ 16 ║ Event code should be greater than 1 in SCHED ║
- ╚════╩══════════════════════════════════════════════════════════╝
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║CREATE 10,0 ║CREATE(10,0); ║ call CREATE(10,0) ║CREATE(10,0); ║
- ║print SIMERR ║printf("%d\n",║ write(*,*)SIMERR()║writeln( ║
- ║ ║SIMERR()); ║ ║ SIMERR); ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: CREATE without prior INIQUE raises error code 7
- which is printed. After printing error code is cleared.
-
- SSS Reference Page 31
-
-
- ╔════════════╗
- ║ SUMRY(u) ║
- ╚════════════╝
-
- Description: To write a standard report to screen (if u is an
- empty string) or to append to file with name u. The
- standard report is written for each call of INISTA and
- for each queue including sample size (duration of
- recording for time persistent statistics), average,
- (time average for time persistent statistics), standard
- deviation, minimum and maximum. If in INISTA(j,h,k,l,f,w)
- k = 0 and l > 0, a frequency table is also printed.
-
- Argument: u (string with an appended space in BASIC & FORTRAN)
- is either empty or a legitimate file name (path names are
- OK but not wild cards). Examples for u in FORTRAN: ' '
- for screen (SPACE between quotes is mandatory!), 'OUT '
- for file OUT (last space is mandatory!). Similar holds
- for BASIC (but notnecessary in C or Pascal).
-
- Note for BASIC: u should be sadd(x$) where x$ is a string defined
- prior to calling SUMRY(sadd(x$)).
-
- Note for FORTRAN: If you write on file u before calling SUMRY(u)
- place an end of line between, otherwise SUMRY will
- continue the previous line.
-
- Mandatory predecessors: INIQUE(q,b,s), INISTA(j,h,k,l,w,f).
-
- Recommended predecessors: QUEUE(m,p), TALLY(j,v).
-
- Errors: if no closed file can be found with name u or disk is
- write protected or diskette door is not closed or not
- enough disk space space to write to file u.
-
- Examples:
- ╔═════════════╦══════════════╦═══════════════════╦══════════════╗
- ║ BASIC ║ C ║ FORTRAN ║ Pascal ║
- ╠═════════════╬══════════════╬═══════════════════╬══════════════╣
- ║x$="1st ║ ║ ║ ║
- ║INIQUE 1,0,1 ║INIQUE(1,0,1);║ call INIQUE(1,0,1)║INIQUE(1,0,1);║
- ║INISTA(1,_ ║INISTA(1, ║ call INISTA(1, ║INISTA(1, ║
- ║sadd(x$),0,_ ║"1st",0, ║+'1st ║'1st',0, ║
- ║0,0,0) ║0,0,0) ║+0,0,0,0) ║0,0,0) ║
- ║x$=" " ║SUMRY(""); ║ call SUMRY(' ') ║SUMRY(''); ║
- ║SUMRY _ ║ ║ ║ ║
- ║sadd(x$) ║ ║ ║ ║
- ╚═════════════╩══════════════╩═══════════════════╩══════════════╝
- Explanation: Summary report is printed for "1st" variable and the
- queue.