GPSS

From Wikipedia the free encyclopedia

GPSS
A GPSS World simulation
Sample Code
GENERATE   15,5 SEIZE      Barber ADVANCE    10,2 RELEASE    Barber TERMINATE  1 
Designed byGeoffrey Gordon
DeveloperIBM
First appeared1961; 63 years ago (1961)
Filename extensions.gps
Major implementations
GPSS World, JGPSS

General Purpose Simulation System (GPSS) is a simulation language used for discrete-event simulations. It is especially useful in the modelling of queuing systems, with many statistics being collected automatically.[1] The typical simulation consists of Transactions being generated in the system (usually at a certain interval), performing a defined set of rules (like use a resource, wait, transfer), and being removed from the simulation.

History[edit]

GPSS was developed in the 1960s by Geoffrey Gordon, an employee of IBM's Advanced Systems Development Division (ASDD). This division was heavily involved with research into the design of teleprocessing systems, trying to achieve an economic balance of the use of computer resources and shared lines between server terminals. The simulation system, then known as the Gordon Simulator, became very popular in the study of teleprocessing systems within ASDD. It subsequently was fixed and documented on October 25, 1960 in an internal IBM memorandum.[2] Between the winter and summer of 1961, a group of three programmers (including Gordon) rewrote the simulation system with a new algorithm and new block types. It was officially released as a supported IBM-label program on September 27, 1961 with 25 block types. At this point, Gordon stopped working on the simulation system.

In 1963, GPSS II was released with 32 block types. It introduced system numerical attributes, which allowed tracking the current content of a Storage, the length of a Queue, or the current clock time.

In 1965, GPSS III was released. It was made available for IBM Systems 7090/94 and 7040/44.

In 1967, GPSS/360 was released to run on the newly released System 360.

In 1970, GPSS V was released with 49 block types.

In the 1980s, GPSS/VAC and GPSS/PC were released. These appear to be the last official IBM-label releases before the language became unlicensed.[3]

Subsequently, there were releases for IBM 360,[4] Univac 1108, and CDC.[5] [6] [7]

Over time, other implementations were developed for systems including DEC's VAX, a specialized APL version for large-scale Univac systems,[8] and Macintosh.[9]

In 2001, the Windows program GPSS World[10] was released with new features to GPSS. It includes scripting with PLUS (a Pascal-like language), graphical system state displays, graphing, and optimization experiments.

In 2009, a graphical Java-based tool called JGPSS (Java General Purpose Simulation System) was developed to teach the GPSS simulation language.[11][12]

Description[edit]

A GPSS simulation is written in an Assembly-style "block diagram language" with many different single-purpose commands ("Blocks") to control the flow of a Transaction, statistics collection, and variables.

Simulations have Transaction entry points through the GENERATE command, such as a customer walking into a store. Then, actions are performed through claiming Facilities/Storage (like a cashier), waiting, saving statistics, etc. Finally, the simulated transaction exits the simulation through the TERMINATE command. Each command verb is referred to as a "control".

Blocks can be facility-oriented (such as machines in a job shop) or transaction-oriented (such parts of work-in-process, signals in electronic components or documents in a bureaucratic procedure). GPSS automatically keep track of statistics for display on a report.

Entities can be broadly classified in Resources, Computational entities and Statistical entities.[13] Resources, like Facilities and Storages represent limited capacity resources. Computational entities, like Ampervariables (variables), Functions and random generators are used to represent the state of Transactions or elements of their environment. Statistical entities, like Queues or Tables (histograms) collect statistical information of interest.

Basic Transaction commands[edit]

Transactions can :

  • Automatically enter the simulation (GENERATE)
  • Use a facility or storage (SEIZE/ENTER respectively)
  • Stop using a facility or storage (RELEASE/LEAVE respectively)
  • Wait (ADVANCE)
  • Transfer to another section of code (TRANSFER)
  • Exit the simulation (TERMINATE)

Along with these main tasks, they can also hold parameters with the ASSIGN command. Transactions are implicitly sectioned off in the code.

There can be multiple transactions in the code that happen at once. A transaction starts with GENERATE and ends with TERMINATE. The code inbetween could potentially be shared between multiple transactions by means of the TRANSFER command, but besides that your transaction lifecycles will be separated. It helps to add whitespace between lines of action of one transaction versus another.

GENERATE[edit]

GENERATE 0.1 

Transaction generated every 0.1 time unit.

GENERATE 15,4 

Transaction is generation every 15 time units, plus or minus 4 time units.

GENERATE

ADVANCE[edit]

To have a transaction wait, use the ADVANCE command. It has similar arguments to GENERATE.

ADVANCE 10,6 

Transaction waits 10+-6 seconds.

ADVANCE

SEIZE, RELEASE (Facilities)[edit]

To use a Facility, which only allows one use at a time, use the SEIZE command. To stop using it, use the RELEASE command.

         GENERATE 30,5   ; Generate a customer every 30+-5 time units          SEIZE Barber    ; Use a facility          ADVANCE 15,4    ; Wait 15+-4 time units          RELEASE Barber  ; Stop using the facility          TERMINATE 1     ; Leave the barber shop 

If you want more than one use at a time, use Storage.

SEIZE

RELEASE

ENTER, LEAVE (Storages)[edit]

Seating  STORAGE 100     ; 100 people allowed in lounge seating           GENERATE 10,5   ; Generate a person every 10+-5 time units          ENTER Seating,1 ; Person sits down          ADVANCE 15,4    ; Wait 15+-4 time units          LEAVE Barber,1  ; Person stops sitting          TERMINATE 1     ; Exit the seating area 

This way, multiple people can sit in the Seating at once. If this was a Facility (using SEIZE/RELEASE), it would block others who tried to use the resource.

The ENTER command takes the storage reference as Argument A and the amount to reserve with Argument B. The LEAVE command's arguments are the same.

ENTER

LEAVE

TERMINATE[edit]

To remove the transaction, use TERMINATE.

The optional argument decrements the completion counter, which is a variable that is chosen by the user when running the simulation. Say you wanted to test 100 customers: you would start the execution of your simulation with START 100. TERMINATE 1 at the end of each transaction would decrement initial value 100 by 1 (99, 98, 97 ...) until it reached zero. At this point, the simulation stops and results are returned. If you omit the argument in TERMINATE, it will be assumed to be 0. This means your simulation will run forever (unless, of course, you have another TERMINATE that does decrement this counter.

TERMINATE

Timer[edit]

To have your program run for a predetermined time, make sure none of your TERMINATES decrement the counter and include a section like this:

GENERATE      ; Generate one transaction ADVANCE 100   ; Run for 100 time units TERMINATE 1   ; End 

Then run your program with START 1. It will run for 100 time units.

ASSIGN (Parameter "Metadata")[edit]

Use the ASSIGN control block to assign a value to a transaction parameter. Called with Pj (j=parameter number)

            ASSIGN 2,V$Orderqty     ;Parameter 2=Order quantity Custwait    ADVANCE 5               ;Lead time is 5 days             ENTER Stock,P2          ;Stock increases by P2 

ASSIGN : ASSIGN Blocks are used to place or modify a value in a Transaction Parameter.

Examples[edit]

Barber Shop[edit]

The following example, taken from Simulation using GPSS,[14] is the "Hello world!" of GPSS and will illustrate the main concepts.

The aim is to simulate one day of operation of a barber shop. Customers arrive in a random constant flow, enter the shop, queue if the barber is busy, get their hair cut on a first-come first-served basis, and then leave the shop. We wish to know the average and maximum waiting line, as well as the number of customers.

       SIMULATE               ; Define model  *  *  Model segment 1  *         GENERATE 18,6          ; Customer arrive every 18±6 mn        QUEUE    Chairs        ; Enter the line        SEIZE    Joe           ; Capture the barber        DEPART   Chairs        ; Leave the line        ADVANCE  16,4          ; Get a hair cut in 16±4 mn        RELEASE  Joe           ; Free the barber        TERMINATE              ; Leave the shop  *  *  Model segment 2  *        GENERATE 480           ; Timer arrives at time = 480 mn        TERMINATE 1            ; Shut off the run  *  *  Control cards  *        START     1            ; Start one run        END                    ; End model 

The "program" is comprised between the SIMULATE and END statements, and is divided into "model segments" and "control cards".

The first segment models customers. The GENERATE block creates a flow of Transactions and schedules them to enter the model with an inter-arrival time uniformly distributed over the range 18±6. It is the programmer's responsibility to interpret these transaction as customers and to understand that the time is to be counted in minutes. The Transactions start their existence in the GENERATE block and progress from Block to Block, according to certain rules, until they reach a TERMINATE which remove them from the model.

Normally transactions progress from one block to the next one, so the customer transactions will leave the GENERATE block to enter the QUEUE Chairs block. This block simulates a waiting line, and collects statistics accordingly. In the example, it materialize a line of chairs and, at the end of the simulation, we will know, among other things, the maximum queue size (how many chairs are needed) and the average waiting time. The QUEUE block requires the name of the queue as a parameter, because more than one queue may exist in the model. Each one is associated with a DEPART block, which is triggered when the transaction leaves the queue. GPSS remembers which transactions are in the queue, so that it possible to know the average time spent, and to check that no buggy transaction is leaving a queue without previously entering in it.

After the QUEUE chairs block, the transaction will try to proceed to the SEIZE Joe block, a block simulating the capture of the Facility named Joe. Facilities model single servers of capacity one. If the facility is busy, the SEIZE will deny the attempting transaction the right to enter. In the example, the customer will wait in the QUEUE block. If it is free, or as soon as it becomes available, the transaction will be allowed to capture the facility, mark it as busy to others transactions and start to count the service time and other statistics, until the same transaction passes the corresponding RELEASE Joe block.

The SEIZE / RELEASE pairs are linked by the facility name, because many independent facilities may exist in the model. They can model operators, like a barber, a repairman, an agent, but also pieces of equipment, like a crane, a gas station, an authorization document, etc., in fact anything with capacity one. To simulate multiple parallel servers, like a team of five barbers, or an oven with a capacity of 10, GPSS uses entities named STORAGEs.

After a customer seizes Joe, she proceeds to the next statement which is ADVANCE 16,4, whose task is to freeze the entity for a prescribed length of time, here a random number picked between 16-4=12 and 16+4=20mn. Other service time distributions are available through GPSS FUNCTION (a somehow different notion than function in other programming languages). During that time, other transactions will be allowed to move through the model, blocking some other facilities that may exist in the model, but not Joe because this facility is busy with the frozen customer. After the prescribed time, the customer will wake up, proceed to the next statement, which will free Joe, and TERMINATE.

Then the next transaction on the previous block, that is a customer sitting on a chair, will be able to SEIZE Joe. To select the "next" transaction, GPSS uses the first-come first-served basis, with priority. Other selection policies can be programmed by direct manipulation of the future event chain entity.

In parallel to this first segment, simulating the customer behavior, a second model segment simulates the end of the day. At time 480mn = 8h an entity is GENERATEd, which will TERMINATE on the next block. This time, the TERMINATE as a parameter of 1, meaning a special counter is decreased by 1. When that counter reaches 0, the program stops and the output is printed. This special counter is set up with the START statement. In the example, it is set to one, thus the simulation will finish after one run of 480 mn in simulated time.

The output contains:

FACILITY           AVERAGE           NUMBER         AVERAGE         SEIZING      PREEMPTING                  UTILIZATION          ENTRIES       TIME/TRAN       TRANS. NO.    TRANS. NO.        Joe            .860               26          15.884              26  QUEUE       MAXIMUM   AVERAGE    TOTAL     ZERO     PERCENT   AVERAGE   $AVERAGE     TABLE    CURRENT            CONTENTS   CONTENT   ENTRIES   ENTRIES    ZEROS  TIME/TRANS TIME/TRANS   NUMBER   CONTENTS   Chairs          1      .160       27        12      44.4      2.851      5.133                    1 $AVERAGE TIME/TRANS = AVERAGE TIME/TRANS EXCLUDING ZERO ENTITIES

It indicates that Joe was busy 86.0% of the time, gave a hair cut to 26 customers and that hair cut took 15.88 minutes on the average. Incidentally, Joe was cutting the hair of customer number 26 when the simulation was closed. No programming provisions were taken for the barber to finish the hair cut before closing the shop.

It indicates also that a maximum of 1 customer was observed waiting his turn, in fact the number of waiting customer was on the average 0.160. A total of 27 customers did enter the queue, so that customer number 27 was still sitting, waiting his turn, when Joe closed the shop. Out of these 27 customers, 12 were served without having to wait. In fact, the queue was empty 44.4% of the time. The average waiting time was 2.851 min, and the average waiting time for the 15=27-12 customers who did really wait was 5.133 min.

Haircuts[edit]

* Pg 108 Q 18 * A one-chair unisex hair shop has arrivals at the rate of one every 20+-15 minutes. * One-half of the arriving customers want a dry cuts, 30% want a style, and 20%  * want a trim only. A dry cut takes 15+-5 minutes, a style cut takes 25+-10 minutes, * and a trim takes 10+-3 minutes. Simulate 50 customers coming through the hair * shop. Compare the given proportion of service rqequests of each type with the * simulated outcome. Are the results reasonable? Base your answer on the binomial * distribution.  Arrivals	FUNCTION	RN1,D4	; 1=dry cut, 2=style, 3=trim 0.0,0/0.5,1/0.8,2/1.0,3  	GENERATE	20,15	; Generate arrivals 	ASSIGN	1,FN$Arrivals	; Assign arrival type to P1 Test1	TEST E	P1,1,Test2	; If P1=1, transfer to DryCut. Else Test2 	TRANSFER	,DryCut Test2	TEST E	P1,2,TrimHair	; If P1=2, transfer to StyCut. Else Trim. 	TRANSFER	,StyCut   DryCut	SEIZE	Chair 	ADVANCE	15,5 	SAVEVALUE	WantedDryCut+,1 	TRANSFER	,Term  StyCut	SEIZE	Chair 	ADVANCE	25,10 	SAVEVALUE	WantedStyleCut+,1 	TRANSFER	,Term  TrimHair	SEIZE	Chair 	ADVANCE	10,3 	SAVEVALUE	WantedTrimHair+,1  Term	RELEASE	Chair 	TERMINATE 1 

Superhighway[edit]

* Pg 108 Q 14 * A superhighway connects one large metropolitan area to another. A vehicle leaves * the first city every 20+-15 seconds. Twenty percent of the vehicles have 1 pass- * enger, 30% of the vehicles have 2 passengers, 10% have 3 passengers, and 10% * have 4 passengers. The remaining 30% of ehicles are buses which carry 40 * people. It takes 60+-10 minutes for a vehicle to travel between the two metro- * politan areas. How long does it take for 5000 people to arrive in the second city?  Passenger	FUNCTION	RN1,D6 0.0,0/0.2,1/0.5,2/0.6,3/0.7,4/1.0,40  	GENERATE	20,15	; New vehicle enters superhighway (seconds) 	ASSIGN	1,FN$Passenger	; Assign number of passengers to P1 	ADVANCE	(60#60),(10#60)	; Travel (minutes to seconds) 	TERMINATE P1	; Decrease the count by number of passengers  * End time is in seconds. Must be divided by 60. * RESULT: 10958 seconds => 182.645 minutes = 3 hr 2 min 

Data Prefixes[edit]

Source:[15]

Transactions[edit]

Prefix Meaning
Pj A parameter of the transaction current being processed by the program.
M1 The transit time of the current transaction.
MPj Intermediate transit time of current transaction.
PR Priority of current transaction (0-127).

Chains[edit]

Prefix Meaning
CHj The current count, which is the number of the transaction on a specified user chain.
CAj The average number of transactions on user chain j.
CCj Total number of entries on user chain j.
CTj Average time per transaction on user chain j.

Blocks[edit]

Prefix Meaning
Nj The entry count of the total number of transactions which have entered a specified block in the block diagram. This count is automatically maintained by the program. Example: N$SAM for the entry count at block SAM. This count does not include the transaction currently in process at its current block.
Wj The wait count, which is the number of transactions currently waiting at a specified block of the block diagram. This count is also maintained automatically by the program. Example: WSHOLD for the current wait count at block HOLD. This count is also exclusive of the transactions currently in process at its current block.

System Attributes[edit]

Quantities[edit]

Prefix Meaning
Kj An indication that the integer is a constant. Example K3276 for the integer 3276 or KO for the integer zero.
RN(x) A computed random number (1<=x<=8). The value of the number is an integer between 0 and 999, inclusive, unless the quantity is to be used as the independent variable of a function. In that case, the number is a fraction greater than or equal to zero, but less than one. In either case, all values within the specified range may be considered equally probable.
C1 The current value of the simulator clock. This quantity is automatically maintained by the program.

Equipment Attributes[edit]

Storages[edit]

Prefix Meaning
Sj The contents of a specified storage in the block diagram. The quantity may be modified by ENTER and LEAVE blocks. Example: S2 for the contents of storage (number) 2.
Rj The number of available units of space in the specified storage. This quantity may be modified by ENTER and LEAVE blocks. Example: R195 for the space remaining in storage 195.
SRj Utilization of storage j in parts per thousand, i.e., if the utilization was .65 the computed value would be 650.
SAj Average contents of storage j (truncated).
SMj Maximum contents of storage j. This quantity is automatically maintained by the program.
SCj Number of entries for storage J. This quantity is automatically maintained by the program.
STj Average time each transaction used storage j (truncated).

Facilities[edit]

Prefix Meaning
Fj The status of the specified facility in the block diagram. This value is zero if the facility is available; otherwise, it is one. This quantity may be modified by SEIZE, RELEASE, PREEMPT, and RETURN blocks. Example: F20 for the status of facility 20.
FRj Utilization of facility j in parts per thousand, i.e., if the utilization was .88 the value of FRj would be 880.
FCj Number of entries for facility j.
FTj Average time each transaction used facility j (truncated).

Groups[edit]

Prefix Meaning
Gj The current number of members of group j.

Statistical Attributes[edit]

Queues[edit]

Prefix Meaning
Qj The length of a specified queue in the block diagram. This quantity may be modified by the QUEUE and DEPART blocks. Example: Q50 for the contents of queue 50.
QAj Average contents of queue j (truncated).
QMj Maximum contents of queue j. This quantity is automatically maintained by the program
QCj Number of entries in queue j. Automatically maintained.
QZj Number of entries in queue j. Automatically maintained.
QTj Average time each transaction was on queue j (including zero entries). When referenced the value will be truncated to an

integer.

QXj Average time each transaction was on queue j (excluding zero entries). Truncated.

Tables[edit]

Prefix Meaning
TBj The computed mean value of a specified histogram-type table which is defined by the user. The TABULATE block is used to enter values in one of these tables. Although the computed average can possess a fractional part, it is not retained unless the computed average is to be used as the independent variable of a function. Example: TB42 for the computed mean value of table 42.
TCj Number of entries in table j.
TDj Computed standard deviation of table j.

Savevalues[edit]

Prefix Meaning
Xj The contents of fullword savevalue j.
XHj The contents of halfword save-value j.
MXj(a,b) The contents of fullword matrix savevalue j, row a, column b. (a and b can be any other SNA)
MHj(a,b) The contents of halfword matrix savevalue j, row a, column b.

Computational Attributes[edit]

Prefix Meaning
FNj A computed function value. Only the integer portion is retained except when used as a function modifier in GENERATE, ADVANCE or ASSIGN blocks.
Vj An arithmetic combination of Standard Numerical Attributes which is called a variable statement and is defined by the user. Only the integer portion is retained. (See Chapter 4.)
BVj The computed value (1 or 0) of Boolean variable j.

Range of the Standard Numerical Attributes[edit]

Entity Symbol Meaning
Transactions P Parameter, fullword[halfword]
PR Priority
M1 Transit time
MP Parameter transit time
Blocks N Total entry count
W Current count
Facilities F Boolean 1 or 0 Status of facility
FR Utilization (parts/thousarid)
FC Entry count
FT Average time/transaction'
Storages S Current contents of storage
R Remaining contents
SR Utilization (parts/thousand)
SA Average contents•
SM Maximum contents
SC Entry count
ST Average time/transaction•
Queues Q Current length of queue
QA Average contents•
QM Maximum contents
QC Total entry count
QZ Number of zero entries
QT Average time/transaction
QX Average time/transaction

excluding zero

Tables TB Table mean•
TC Entry count
TD Standard deviation•
Savevaules X Fullword savevaluc
XII lialfword savevalue
Matrix savevalues M(a,b) Fullword matrix
MH(a, b) Halfword matrix

a = row b = column

Groups G Number of items in group
User's chains CA Average number on chain•
CH Current number on chain
CM Maximum number on chain
CC Total entries
CT Average time entry•
Functions FN Function
Variables V Arithmetic variable
V Floating-point variable
BV Boolean variable
Random numbers RN1-RN8 As function argument, returns 0 to 0.99999. Otherwise, 0.999
Clock C1 Clock time relative to last RESET or CLEAR card.

Conditional Operators[edit]

This is used in TEST command.

E Equal
G Greater Than
GE Greater Than or Equal
L Less Than
LE Less Than or Equal
MAX Equal to the Largest such attribute of all Transactions in the Group
MIN Equal to the Smallest such attribute of all Transactions in the Group
NE Unequal to the reference value specified by Operand E

See also[edit]

References[edit]

  1. ^ Schriber, Thomas (1977), Introduction to GPSS (PDF), p. 1, retrieved 12 December 2023
  2. ^ Geoffrey Gordon (1981). "The development of the General Purpose Simulation System (GPSS)". History of programming languages. pp. 403–426. doi:10.1145/800025.1198386. ISBN 0127450408. In developing GPSS there was no conscious effort to base the design on analog computers, but I feel sure the block diagram notation and the emphasis on making the simulation directly accessible to system analysts rather than through programmers, that are characteristics of GPSS, were unconsciously influenced by the analog computer experience.
  3. ^ IEEE (1984), Winter Simulation Conference Proceedings, ISBN 9780911801040, retrieved 12 December 2023
  4. ^ (GPSS/360, on MFT/MVT but not DOS)
  5. ^ D. C. Div (1968). "Technical Note". IEEE Transactions on Systems Science and Cybernetics. 4 (4): 446–447. doi:10.1109/TSSC.1968.300174. IBM has available GPSS III for the 7044 and 7090 series and GPSS/360 for the larger 360 ... GPSS II has also been available on the UNIVAC 1108
  6. ^ "Introduction to GPSS" (PDF). about the simulation modeling language GPSS. ... summarized; sources comparing GPSS and other .... Corporation's GPSS for Univac 1108 hardware)
  7. ^ B. Liskov (1981). "GPSS Session". History of Programming Languages. ScienceDirect. pp. 403–437. doi:10.1016/B978-0-12-745040-7.50013-2. ISBN 9780127450407. Background: The General Purpose Simulation System (GPSS) is a ... manufacturers that have produced versions of GPSS are UNIVAC (Gorchow, 1968), CDC
  8. ^ Nabil R. Adam; Ali Dogramaci (2014). Current Issues in Computer Simulation. p. 25. ISBN 978-1483258034. GPSS-like ... in the APL version of GPSS, although APL happens to be an interpretive language. ... Univac Corporation, GPSS 1100 for UNIVAC 1108 system.
  9. ^ Ståhl, Ingolf (1990). Introduction to Simulation With Gpss on the Pc, MacIntosh and Vax. ISBN 0-1348-323-10.
  10. ^ "GPSS World REFERENCE MANUAL". athena.ecs.csus.edu. Retrieved 2023-12-11.
  11. ^ P. Fonseca Casas (2009). "jgpss, an open source gpss framework to teach simulation" (PDF). simplify the development of a complete simulation tool following the GPSS syntax. This paper presents ... In the original, GPSS meant Gordon's Programmable Simulation System, in honor of Geoffrey Gordon, its creator.
  12. ^ "Java General Purpose Simulation System". Learn simulation building a simulation engine. JGPSS is an implementation of the GPSS system based in Java.
  13. ^ Stanley Greenberg (1972). GPSS Primer. New York: Wiley-Interscience. ISBN 0471324906.
  14. ^ Schriber, Thomas (1974). Simulation using GPSS. Wiley. ISBN 9780471763109.
  15. ^ General Purpose Simulation System/360: User's Manual (PDF), 1967, retrieved 10 December 2023

External links[edit]