home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol265 / gasp.doc < prev    next >
Encoding:
Text File  |  1986-05-19  |  21.6 KB  |  526 lines

  1. 
  2. [GASP.DOC of JUGPDS Vol.7]
  3.  
  4.   -----------------------------------------------------------------
  5.   !                                  !
  6.   !   Simulation with GASP (General Activity Simulation Program)  !
  7.   !                                  !
  8.   !                               by                  !
  9.   !                                  !
  10.   !           Makoto Yamagiwa (JUG-CP/M No.61)    June 16, 1984        !
  11.   !           Phone: 0424-61-5440 (evenings)          !
  12.   -----------------------------------------------------------------
  13.  
  14.                     Abstract
  15.  
  16.      GASP is a Fortran program package for general purpose simulation.  A
  17. user defined main program in Microsoft FORTRAN-80 or SSS FORTRAN-86 serves
  18. as a chassis into which subroutines are the building blocks.  All simula-
  19. tion models are virtually machine independent.  Thus, you can also use this 
  20. package under MS-Fortran.
  21.      The user must provide the main and key routines.  However, all other 
  22. low-level subroutines have been included in the package as the GASP library
  23. so that you can link them with the main program.
  24.  
  25.  
  26.  
  27.                               Contents
  28.  
  29. 1.  Introduction                    page 1
  30. 2.  The GASP II Programming language            page 1
  31. 3.  Statement of the sample models            page 4
  32. 4.  GASP Data Format                    page 5
  33. 5.  Data Format for Example 1                page 8
  34. 6.  How to Use GASP                    page 9
  35.  
  36.  
  37.  
  38.   
  39.  
  40. 1.  Introduction
  41.  
  42.      The GASP (General Activity Simulation Program) is a simulator for 
  43. Discrete Event Simulation models.  GASP II [1] was developed at Arizona State
  44. University from the original GASP developed at U. S. Steel and RAND Corpora-
  45. tion [2].  GASP II was written in FORTRAN-IV for IBM 1130 Computer with the
  46. limitation of 8K words of storage (16-bit per word).  Further updated version
  47. of GASP is available [3].
  48.  
  49.      The present version of GASP is based on GASP II and has been written for
  50. Microsoft FORTRAN-80 (CP/M-80), SSS FORTRAN-86 and ai-Fortran86 (CP/M-86). 
  51.  
  52.  
  53. 2. The GASP II Programming Language
  54.  
  55. 2.1 Functional Breakdown of GASP II
  56.  
  57.      A functional breakdown of the GASP II subprograms is shown in Table 1.
  58. A brief description is given here.  The GASP executive controls a simula-
  59. tion by updating simulation time (TNOW) from event to event and calling 
  60. programmer-written events through subroutine EVNTS.  Subroutine DATAN
  61. initializes all GASP II variables and reads from disk all initial events 
  62. and entities into filing array NSET.
  63.  
  64.      The storage of information is accomplished by subroutine FILEM.  This
  65. routine inserts the values contained in the buffer storage vector ATRIB into
  66. the first available column of the filing array NSET and calls subroutine SET,
  67. which updates the pointing system to insert the entry into subroutine RMOVE.
  68. This routine removes an entry from NSET,  and stores its row values in the
  69. buffer storage array ATRIB, then calls subroutine SET to update the file by
  70. altering the pointing system.  To find specific entries in a file to locate
  71. an entry whose attributes satisfy stated conditions. The various conditions
  72. for which search can be performed in subroutine FIND.
  73.  
  74.      Monitoring and error reporting are performed through the use of sub-
  75. routines MONTR and ERROR.  These subroutines have been designed to assist the
  76. programmer in debugging a simulation program.  Subroutine MONTR can also be
  77. used to obtain intermediate results during the course of a simulation run.
  78.  
  79.      The routines involved in data collection, statistical computations and
  80. reporting, random variable generation, and other support functions are 
  81. listed in Table 1.
  82.  
  83.  
  84.         Table 1  Functional Breakdown of the GASP Subprograms
  85. ----------------------------------------------------------------------
  86.   Function              !        Subprogram
  87. ----------------------------------------------------------------------
  88. GASP Executive          !       Subroutine GASP(NSET)
  89. Initialization          !       Subroutine DATAN(NSET)
  90. Information Storage    !    Subroutine SET(JQ,NSET)
  91. and Retrieval           !    Subroutine FILEM(JQ,NSET)
  92.                         !       Subroutine RMOVE(KCOL,JQ,NSET)
  93.                         !       Subroutine FIND(XVAL,MCODE,JQ,
  94.                         !                    JATT,KCOL,NSET)
  95. Data Collection         !       Subroutine COLCT(X,N,NSET)
  96.                         !       Subroutine TMST(X,T,N,NSET)
  97.                         !       Subroutine HISTO(X1,A,W,N)
  98. Statistic Computations  !    Subroutine PRNTQ(JQ,NSET)
  99. and Reporting         !       Subroutine ERROR (J,NSET)
  100. Random Deviate        !    Subroutine DRAND(ISEED,RNUM)
  101. Generators              !       Subroutine RANDU(IY,YFL)
  102.                         !       Function UNFRM(A,B)
  103.                         !       Function RNORM(J)
  104.                         !       Function RLOGN(J)
  105.                         !       Function ERLNG(J)
  106. ---------------------------------------------------------------------
  107.  
  108. 2.2 A Typical GASP Program in Fortran
  109.  
  110.      Table 2 and Fig.1 are the basic idea of Single Server Queueing System.
  111. While Listing 1 shows a prototype (skeleton) program for the main and sub-
  112. routine EVNTS of the service system.  Note that the main and EVNTS programs
  113. are user defined and normally follow the format given here.  In subroutine 
  114. EVNTS, "I" is an event code.  Subroutine EVNTS selects one of the events 
  115. ARRVL, ENDSV, or ENDSM.  The programmer (user) needs to write only the 
  116. event subroutines in order to have a complete simulation program.
  117.  
  118.       Table 2  General conditions of Single Server Queueing System
  119. ------------------------------------------------------------------------
  120. ENTITIES    ATTRIBUTES   EVENTS      ATTRIBUTES       RELATIONSHIP
  121. ------------------------------------------------------------------------
  122. Customers  Arrival rate  Arrival of  Time of arrival  Customers who wait-
  123.            Arrival type  a customer  Customer  type   ing area of server
  124.            Job type                  Service prior-
  125.                                      ity
  126.  
  127. Server     Server rate   End of      Time of comple- 
  128.                          service     tion
  129. ------------------------------------------------------------------------
  130.  
  131.  
  132.  
  133. Arriving Customers ----> Waiting area ---> Server ---> Departing
  134.  
  135. Customers -----> Satisfied Customers
  136.           -----> Dissatisfied customers
  137.                  Customers Who have been served.
  138.  
  139. Fig 1.  General transition of Single Server Queueing System
  140.  
  141.  
  142. Listing 1.  Layout of the main and Subroutine EVNTS.
  143.  
  144. C       MAIN PROGRAM
  145.         DIMENSION NSET(6,ID)
  146. C       ID; to be specified by user
  147.         COMMON  (GASP variables)
  148.         COMMON  (non-GASP variables)
  149. C
  150. C       Initialization of non-GASP variables
  151.         CALL    GASP(NSET)
  152. C       If more runs are desired, insert GO TO statement
  153. C       to either reinitialize non-GASP variables or
  154. C       to call GASP again
  155.         CALL    EXIT
  156.         END
  157. C
  158.         SUBROUTINE      EVNTS(I,NSET)
  159.         DIMENSION NSET(6,ID)
  160. C       ID; to be specified
  161.         COMMON  (GASP variables)
  162.         COMMON  (non-GASP variables)
  163. C
  164.         GO TO (1,2,3), I
  165.     1   CALL    ARRIV(NSET)
  166.         RETURN
  167.     2   CALL    ESERV(NSET)
  168.         RETURN
  169.     3   CALL    ENDSM(NSET)
  170.         RETURN
  171.         END
  172.  
  173. 2.3 GASP Library
  174.      The GASP subprograms given in Table 1 have been provided as the
  175. GASP library (GASPLIB.FOR, GASLIBX.FOR, etc.).  Here is an outline 
  176. hierarchy  for EXA1 (USER1, see 3.2 below).
  177.  
  178. *EXA1 (Main)
  179.     GASP
  180.         DATAN
  181.         MONTR
  182.         RMOVE
  183.             SET
  184.         *EVNTS
  185.             *ARRVL
  186.                 DRAND
  187.                 TMST
  188.                 COLCT
  189.                 FILEM
  190.                     SET
  191.             *ENDSV
  192.                 COLCT
  193.                 HISTO
  194.                 TMST
  195.                 RMOVE
  196.                 FILEM
  197.             *ENDSM
  198.                 TMST
  199.                 RMOVE
  200.                 ENDSV
  201.         SUMRY
  202.            *OTPUT
  203.         ERROR
  204.  
  205. Note that the programs with asterisk are user defined.
  206.         
  207. 3. Statement of A Sample Modeling
  208.  
  209.      In the following I am going to describe a model case in detail.
  210. You can interpret the other examples in the similar manner.
  211.  
  212.      Example 1: A Single-Channel Queueing Situation
  213.  
  214.  Program-id.        USER1.FOR    USER1.F86
  215.  GASP library          GASPLIB.FOR    GASPLIB.F86
  216.  Load module           USER1.COM    EXA1.COM
  217.  GASP data file         GASP1.DAT    GASP1.DAT
  218.  
  219.  3.1 Statement of the problem
  220.      The system to be simulated consists of a single server who processes 
  221. arriving items sequentially.  When the server is processing an item, other
  222. items arriving must wait for service.  Only a single queue can form, and 
  223. there is no limitation on its length.  The time between arrivals of items
  224. and the processing time for the server are assumed to be exponentially
  225. distributed.  The mean time between the arrival of items is 10 time units
  226. and the mean processing time is 6 time units.  The system is to be simulated
  227. for 3000 time units.  Estimates of the expected value and standard deviation
  228. of the server's idle time , the total time spent by items in system, and the
  229. waiting time of the items are to be calculated.
  230.  
  231.      All items arriving before time 3000 should be processed, and the sta-
  232. tistics concerning these items should be included in the overall statis-
  233. tics of the simulation. 
  234.  
  235.         The intial conditions are:
  236.  
  237.         1) The server is busy and will complete service at time 3.5.
  238.         2) The first new arrival to the system will occur at time 0.0.
  239.         3) No items are waiting in the queue.
  240.  
  241. 3.2 Procedure
  242.     The following programs are necessary:
  243.  
  244.     1) The main program of the simulation ..... EXA1
  245.     2) Arrival of an item to the system....... Subroutine ARRVL
  246.     3) A completion of the processing of an item by the server
  247.                                        ....... Subroutine ENDSV
  248.     4) The completion of the simulation at a time specified by 
  249.        the programmer                  ....... Subroutine ENDSM
  250.     5) Control routine for subroutines ARRVL, ENDSV, and ENDSM
  251.                                            ....... Subroutine EVNTS
  252.     6) To provide information in addition to that normally printed 
  253.           in the GASP summary report      ....... Subroutine OTPUT
  254.     
  255. Note that all of the above programs must be written by the programmer
  256. (user).  They have been designated as USER*.*.
  257.  
  258. 4. GASP Data Format
  259.       There are eight types of "Data Card" to be input to GASP.  They are 
  260. listed in Tables 3 through 10, and are stored as GASP*.DAT files in the
  261. card image.
  262.  
  263. Table 3  Type 1 Data Card for GASP
  264. -----------------------------------------------------------------
  265. GASP variables      Column (FORMAT)       Definition
  266. Initialized 
  267. -----------------------------------------------------------------
  268. NAME                1 to 12 (6A2)       Title of simulation
  269. NPROJ               13 to 16 (I4)       Project number
  270. MON                 17 to 18 (I2)       Month number (MM)
  271. NDAY                19 to 20 (I2)       Day number (DD)
  272. NYR                 21 to 24 (I4)       Year number (19YY)
  273. NRUNS               25 to 28 (I4)       Number of simulation runs
  274.                     to be made
  275. ------------------------------------------------------------------
  276.  
  277.  Table 4  Type 2 Data Card for GASP
  278. ----------------------------------------------------------------------
  279. GASP variables      Column (FORMAT)         Definition
  280. Initialized 
  281. ----------------------------------------------------------------------
  282. NPRMS               1 to 5 (I5)         Number of sets of parameters
  283.                                 to be used insimulation
  284. NHIST               6 to 10 (I5)        Number of histograms required
  285.                                     for the simulation
  286. NCLCT               11 to 15 (I5)       Number of variables for which
  287.                                 statistics are collected in
  288.                                         subroutine COLCT
  289. NSTAT               16 to 20 (I5)       Number of variables for which
  290.                                 statistics are collected in
  291.                                         subroutine TMST
  292. ID                  21 to 25 (I5)       Number of columns in the filing
  293.                                 array NSET
  294. IM                  26 to 30 (I5)       Maximum number of attributes
  295.                                 associated with any entry of
  296.                                         the filling array
  297. NOQ                 31 to 35 (I5)       Number of files contained in
  298.                                 the filling array
  299. MXC                 36 to 40 (I5)       Largest number of cells to be
  300.                                 used in any histogram
  301. SCALE               41 to 50 (F10.2)    Parameter used to scale attri-
  302.                                 bute value to avoid truncation
  303.                                         errors due to the use of fixed
  304.                     point array for the filling 
  305. ----------------------------------------------------------------------
  306.  
  307. Table 5  Type 3 Data Card for GASP. If NHIST > 0, the number of cells
  308.       for each histogram used is initialized from Type 3 Data Card.
  309.      The GASP variable NCELS(K) is the number of cells in histogram
  310.      K ,not including the end cells.
  311. -----------------------------------------------------------------------
  312. GASP variables      Column (FORMAT)          Definition
  313. Initialized 
  314. --------------------------------------------------------------------
  315. NCELS(1)              1 to 5  (I5)
  316. NCELS(2)              6 to 10  (I5)
  317. NCELS(3)              11 to 15 (I5)
  318. NCELS(4)              16 to 20 (I5)
  319. --------------------------------------------------------------------
  320.  
  321. Table 6  Type 4 Data Card for GASP.  The values of the vector KRANK
  322.      are initialized with Type 4 Data Card.
  323. --------------------------------------------------------------------
  324. GASP variables      Column (FORMAT)        Definition
  325. Initialized 
  326. --------------------------------------------------------------------
  327. KRANK(1)              1 to 5   (I5)
  328. KRANK(2)              6 to 10  (I5)
  329. KRANK(3)              11 to 15 (I5)
  330. KRANK(4)              16 to 20 (I5)
  331. --------------------------------------------------------------------
  332.  
  333. Table 7  Type 5 Data Card for GASP.  This card reads value for the
  334.      vector INN.  INN(J) is the variable that specifies
  335.      whether File J is a low-value-first (LVF) or high-value-
  336.      first (HVF) file. The code for LVF and HVF are 1 and 2,
  337.      respectively.
  338. -------------------------------------------------------------------
  339. GASP variable
  340. initialized         Column (FORMAT)           Definition
  341. -------------------------------------------------------------------
  342. INN(1)              1 to 5   (I5)
  343. INN(2)              6 to 10  (I5)
  344. INN(3)              11 to 15 (I5)
  345. INN(4)              16 to 20 (I5)
  346. -------------------------------------------------------------------
  347.  
  348. Table 8  Type 6 Data Card for GASP.  This card is used only when
  349.      parameters are used in the simulation (NPRMS >= 1).
  350. -----------------------------------------------------------------
  351. GASP variables
  352. Initialized         Column (FORMAT)            Definition
  353. -----------------------------------------------------------------
  354. PARAM(J,1)          1 to 10  (F10.4)
  355. PARAM(J,2)          11 to 20 (F10.4)
  356. PARAM(J,3)          21 to 30 (F10.4) 
  357. PARAM(J,4)          31 to 40 (F10.4)
  358. -----------------------------------------------------------------
  359.  
  360. Table 9  Type 7 Data Card for GASP
  361. ----------------------------------------------------------------------
  362. GASP variable
  363. initialized     Column (FORMAT)          Definition
  364. -----------------------------------------------------------------------
  365. MSTOP        1 to 5 (I5)           0: End of simulation, event has
  366.                                    been furnished by the programmer.
  367.                                        MSTOP > 0: The simulation is to
  368.                        end when TNOW >= TFIN.
  369.                                        MSTOP < 0: Programmer indicated 
  370.                        the simulation run is completed
  371.                        and ask the final reports. 
  372. JCLR            6 to 10 (I5)           0: Do not clear statistical
  373.                                    storage areas.
  374.                                        1: Clear statistical storage
  375. NOPRT           11 to 15 (I5)          0: Final GASP summary report
  376.                                        1: No final summary report
  377. NEP             16 to 20 (I5)          A control variable which
  378.                                    determine the data card
  379.                                        type at which DATAN will 
  380.                                        begin to process foe the
  381.                                        next simulation run
  382. TBEG            21 to 30 (F10.3)       Beginning time of the simula-
  383.                                    tion run.
  384. TFIN            31 to 40 (F10.3)       Final or ending time of the
  385.                                    simulation if MSTOP > 0. 
  386. JSEED           41 to 44 (I4)          Random number seed,
  387.                                    ISEED = JSEED
  388. ----------------------------------------------------------------------
  389.  
  390. Table 10  Type 8 Data Card for GASP.  Actually there are two kinds of
  391.       Type 8 Cards. They are used to initialize the filing array and
  392.       to insert initial entries into it.  Each set of Type 8 Cards 
  393.       contains the file number (JQ) and the attributes (ATRIB) for
  394.       one entry that is to be inserted in file JQ. If JQ is negative,
  395.       the entire filing array is initialized.  If JQ is positive,
  396.       the values in ATRIB are inserted into an entry in File JQ.
  397. -----------------------------------------------------------------------
  398. GASP variable       Column (FORMAT)         Definition
  399. Initialized 
  400. -----------------------------------------------------------------------
  401. JQ                1 to 10 (I10)       File number, if JQ < 0 
  402.                     the array is initialized.
  403. -----------------------------------------------------------------------
  404. ATRIB(1)            1 to 10 (F10.4)
  405. ATRIB(2)            11 to 20 (F10.4)
  406. ATRIB(3)            21 to 30 (F10.4)
  407.   .                         .
  408.   .                         .
  409. ATRIB(7)            61 to 70 (F10.4)
  410. ----------------------------------------------------------------------
  411.  
  412.   
  413. 5.  Data Format for Example 1 (GASP1.DAT)
  414.  
  415. Column Layout:
  416.               1         2         3         4         5         6
  417.      123456789012345678901234567890123456789012345678901234567890
  418.  
  419.      TEST-PROG-1    1 2281984   1                          Type 1 Card
  420.          0    1    2    2   25    4    2   22      10.00   Type 2 Card
  421.         20                                                 Type 3 Card
  422.          1    3                                            Type 4 Card
  423.          1    1                                            Type 5 Card
  424.          0    1    0    7     0.0    3000.0  0567          Type 7 Card
  425.              -1                                            Type 8 Card
  426.         0.0    1.0       0.0       0.0                 Type 8 Card
  427.               1                                            Type 8 Card
  428.          3000.0    3.0       0.0       0.0                 Type 8 Card
  429.               1                           Type 8 Card    
  430.             3.5    2.0       0.0       0.0                 Type 8 Card
  431.               0                                            End of data
  432.        
  433.  Remarks
  434.         File 1 is the event file, and File 2 is the queue of items
  435.         waiting for processing. The attributes associated with each
  436.         of these files are shown below:
  437.  
  438.       File 1
  439.         Attribute 1:    Scheduled time of event.
  440.         Attribute 2:    Event Code.
  441.         Attribute 3:    Time customer enters system, if event code
  442.                         is 2.
  443.         Attribute 4:    Not used.
  444.  
  445.       File 2
  446.         Attributes 1, 2 and 4: Not used.
  447.         Attribute 3:    Time item entered system.
  448.  
  449. 6. How to Use GASP
  450. 6.1 Organization of GASP Disks
  451.     The GASP program package submitted to the Public Domain consists
  452. of the following four volumes.
  453.  
  454.     Vol.1 of 4: Documentation and CP/M-80 (FORTRAN-80) Version
  455.     Vol.2 of 4: CP/M-86 (SSS FORTRAN/ai-FORTRAN) Version and
  456.             Source Programs of GASP Subprograms
  457.     Vol.3 of 4: Executable GASP Code for CP/M-86
  458.     Vol.4 of 4: Extended Version of GASP II for F80 and F86
  459.  
  460.     Those who have only FORTRAN-80 should get Vols. 1, 2 and 4.
  461.  
  462. 6.2 Using Microsoft FORTRAN-80 on CP/M-80
  463. 1) Compile user programs in FORTRAN-80
  464.    f80 USER1,tty:=USER1/n  (c/r)
  465.  
  466. 2) Compile GASP Library programs
  467.    f80 GASLIB,tty:=GASLIB/n  (c/r)
  468.  
  469. 3) Link USER1.REL, and GASLIB.REL to make object module
  470.    l80 USER1,GASLIB,forlib/s,EXA1/n/e
  471.  
  472. 4) Execute Object module EXA1.COM
  473.    EXA1  (c/r)
  474.  
  475. 5) Input GASP Data file
  476.    Output GASP data file to Display(3) or Printer(2)
  477.    Enter Output Device number 2 or 3: 2 (c/r)
  478.  
  479.    Input GASP data file name (max 8 characters): GASP1   (c/r)
  480.    Input GASP data file name: GASP1   DAT
  481.  
  482. 6.3  Using Super Soft FORTRAN-86
  483.  
  484.  1) Compile user programs in FORTRAN-86
  485.     for USER1.F86  USER1.REL  (c/r)
  486.     cnv USER1.REL  USER1.R86  (c/r)
  487.  
  488.  2) Compile GASP Library programs
  489.     for  GASLIB.F86  GASLIB.REL
  490.     for  GASLIB.REL  GASLIB.R86
  491.  
  492.  3) Link USER1.R86, and GASLIB.R86 to make object module
  493.     link86 -o EXEC1 semu USER1 GASLIB sflib.lib mlib.lib
  494.  
  495.  4) Execute Object module EXEC1.CMD
  496.     EXEC1  (c/r)
  497.  
  498.  5) Input GASP Data file
  499.     Output GASP data file to Display(1) or Printer(4): 
  500.     Output Device number 1 or 4: 4 (c/r)
  501.  
  502.     Input GASP data file name (max 12 characters) : GASP1.DAT (c/r)
  503.     Input GASP data file name : GASP1.DAT
  504.  
  505.  
  506.  
  507.                              REFERENCES
  508.  
  509. [1] A. Alan, B. Pritsker and P. J. Kiviat: "Simulation with GASP II -
  510.     A FORTRAN based Simulation Language," 1969
  511. [2] P. J. Kiviat: "GASP- A General Activity Simulation Program,"
  512.     Applied Research Lab., United States Steel Corporation, 
  513.     Monroeville, Pa., 1963
  514. [3] A. Alan  and B. Pritsker: "The GASP IV Simulation Language," 
  515.      Wiley, New York, 1975
  516.  
  517.  
  518. ****************************************************************
  519. Editor's comments to Japanese users:
  520.  
  521.     Japanese documentation on this program package has been
  522. published by the contributor in the following journal.
  523.  
  524. ╘╧╖▐▄ ╧║─: ó16bit ╓│ FORTRAN Compiler ╔ Testú, Information,
  525.       Vol.4 (1985), No.3, p.21
  526.