610 likes | 631 Views
CSI4123/SYS5110 – Fundamentals of Modeling and Simulation. Annex A - Process Oriented Simulation with GPSS. Topics of Discussion. Introduction to GPSS Simple Manufacturing Problem GPSS Transaction Flow Programmer’s view of the Transaction Flow GPSS Entities System Numeric Attributes
E N D
CSI4123/SYS5110 – Fundamentals of Modeling and Simulation Annex A - Process Oriented Simulation with GPSS
Topics of Discussion • Introduction to GPSS • Simple Manufacturing Problem • GPSS Transaction Flow • Programmer’s view of the Transaction Flow • GPSS Entities • System Numeric Attributes • GPSS Commands • Transaction Chains • Entity Categories • Next module: from the Conceptual Model to the Process oriented Simulation Model; • Reading: Annex 2 of the manuscript
What is GPSS? • General Purpose Simulation System • Process-oriented • Discrete Event Simulation • Basic ideas • Transaction Entities – flows through the simulation • Entities – everything is an entity • Examples: Transactions, Facility, Storage, etc. • List processing – lists called chains • Block entity – programming functions • As Transactions flow through the simulation, they impact on the simulation model using these Blocks. • A sequence of Blocks defines a process (Block segment) • A process determines how Transactions flow in the simulation. • Flow through chains versus flow through Blocks
Simple Manufacturing Problem • Workstation works on one part at a time.
Conceptual Modeling versus Simulation Modeling • Conceptual Model Structure • Workstation is a resource • Components are consumers • Queue collects components • Conceptual Model Behaviour • Activities defining processing at workstation • GPSS Simulation Structure • Workstation and Queue implemented as a Facility Entity • Components are Transaction Entities • GPSS Simulation Behaviour • Processes define how the Transactions will flow among Entities
GPSS Simulation Program *****Component A Arrives CompA GENERATE 6,3 ; Adds Transactions to simulation SEIZE WK0 ; Try to gain ownership of WK0 ADVANCE 10 ; Service time RELEASE WK0 ; Releases ownership of WK0 TERMINATE ; Leave simulation *****Component B Arrives CompB GENERATE 7,4 ; Adds Transactions to simulation SEIZE WK0 ; Try to gain ownership of WK0 ADVANCE 5 ; Service time RELEASE WK0 ; Releases ownership of WK0 TERMINATE ; Leave simulation
Block Entities • GENERATE: This Block is responsible for inserting Transaction into the simulation model. According to the arguments, Transactions enter the simulation every 6 ± 3 time units. • TERMINATE: Transactions leave the simulation model when they enter this Block. • SEIZE: A Transaction enters this Block when it gains ownership of the Facility. • RELEASE: A Transaction releases ownership of the named Facility when it enters this block. • ADVANCE: Use to simulate the service time duration. A Transaction remains in this Block for some duration as defined by the statement arguments. In this case10 time units is used as the duration. • Block Segment – a sequence of Blocks that represent a process
Transaction Entities • Data-tuple of data values called parameters • Standard Parameters • Identifier: an integer that uniquely identifies each Transaction • Current Block: Indicates the Block entity at which the Transaction is located. • Next Block: Indicates the Block entity the Transaction will next enter. • Priority: Defines the priority of the Transaction. • Mark time: Initially set to the time the Transaction entered the simulation model. • BDT: Contains a time value to indicate when the Transaction can be processed. This value is present when the Transaction is part of the Future Event Chain, • See the Primer for the complete list of standard parameters • Additional parameters can be defined and created for Transactions
List Processing • Transactions are moved between chains • Chains are priority based FIFO lists • Main chains for processing • Current Event Chain (CEC) • Transaction at head of CEC becomes active transaction • Processed until it comes to rest (on another chain) • Next Transaction processed until CEC is empty • Future Event Chain (FEC) • Contains Transactions waiting for time to advance • Ordered according to the BDT parameter values • When CEC is empty, it is replenished from the FEC, moving all Transactions with the smallest and identical BDT value to the CEC • Time is advanced to the BDT value of the transferred Transactions • What about these other Transaction chains shown in the next slide?
Other Transaction Chains • Delay Chain • When Transaction tries to obtain ownership of a busy Facility: • it will be refused entry into the SEIZE Block • Moved from the CEC to the Delay Chain • When a Transaction releases the ownership of a Facility by entering the RELEASE Block • The Transaction at the head of the Delay Chain is given ownership • The Transaction is then moved into the CEC • Other Chains • Pending and Interrupt chains are used to support pre-emption • The Retry chain used to support testing
Programmer’s View of Transaction Flow • A GPSS program contains one or more interacting processes using Block segments that can include • How Transactions enter the model • Their flow among structural entities • Service times • Decisions for selecting different paths through the model • When Transactions exit the model • Etc.
Graphical Representation of Block Segments • Another view of Transaction Flow • Transactions are created by the GENERATE Block • They flow from Block to Block • When entering a Block, a specific action is invoked • Transactions may be refused entry into a Block (ex SEIZE Block) • The TERMINATE Block removes Transactions from the simulation • Such flow implemented by updating the Current Block and Next Block parameters in Transactions
Topics of Discussion • Introduction to GPSS • Simple Manufacturing Problem • GPSS Transaction Flow • Programmer’s view of the Transaction Flow • Other GPSS notions • System Numeric Attributes • GPSS Commands • Transaction Chains • Entity Categories
System Numeric Attributes • Mechanism to access simulation data • Transaction parameters • Transaction identifier • System Clock • State of entities • Facility available • Number of Transactions is a Block • Statistics • Facility Utilisation Time
SNA Format • Two parts: • SNA Class • An operand which is typically an Entity Identifier • Examples with SNA Class W provides number of Transactions in Block • W22 : represents the number of Transactions in Block 22 • W$CompA : represents the number of Transactions in Block labelled CompA (GENERATE block in the example of the previous section). • W*5 : represents the number of Transactions in the Block identified by the value of the current Transaction’s parameter 5 • W*BLKNUM : represents the number of Transactions in the Block identified by the value of the current Transaction’s parameter named BLKNUM. • W*$BLKNUM: same as W*BLKNUM
Other Examples of SNAs • P5 and P$Name – To reference parameters of the active Transaction. • F1, F$WK0 - Indicates when a Facility is busy (owned by a Transaction) • FC1, FC$WK0 – Facility capture count that gives number of times a Facility has been SEIZE’d. • FR1, FR$WK0 – Facility utilisation that indicate the percentage of time a Facility was busy. • N22, N$CompA – Block entry count that gives the number of Transactions that have entered a Block.
Atomic SNAs • Do not have an operand • Parameters of the active Transaction • A1: Assembly Set • M1: Transit Time which equals to the AC1 – mark time (time that the transaction entered the simulation). • PR: Priority • XN1: Identifer. • AC1 : Absolute value of the system clock (since the start of the simulation). • C1: Relative value of the system clock, since the last RESET Command. • TG1: Remaining termination count. See the TERMINATE Block.
Using Indirect Addressing • Consider the following Block Sequence: TEST E 0,F*Station . . . SEIZE P$Station • Parameter Station provides the Block number of the Facility • Used indirect addressing to reference in SNA • Can use a single Block segment to define same process for 10’s or 100’s of Facilities • See the SELECT Block
Topics of Discussion • Introduction to GPSS • Simple Manufacturing Problem • GPSS Transaction Flow • Programmer’s view of the Transaction Flow • GPSS Entities • System Numeric Attributes • GPSS Commands • Transaction Chains • Entity Categories
GPSS Commands • Commands can serve two purposes • Declaring and Initialising Entities • Controlling a simulation • GPSS World offers a GUI for controlling a simulation
Commands - Declaring and Initialising Entities • BVARIABLE: Declare Boolean Variable Entities • VARIABLE or FVARIABLE: Used to declare Variable Entities • FUNCTION: Used to declare a Function entity. • MATRIX: Used to declare a Matrix Entity. • QTABLE: Used to declare a Table entity • TABLE: Used to declare a Table entity • STORAGE: Used to declare and configure a Storage entity. • EQU: Used to assign a value to a Name. Useful for assigning names to constants. • INITIAL: Used to initialise a Matrix Entity, a SaveValue Entity, or a LogicSwitch Entity. • RMULT: Used to set the seeds for the random number generators.
Commands - Controlling a Simulation • CLEAR: Completely re-initialises the simulation • RESET: Resets the statistical accumulators, but leaves Transactions in the simulation. • START: Command that starts a simulation. • STOP: Used to set or remove a stop condition (break point) at a Block. • HALT: Used to halt the execution of the simulation. The hot key Cntrl-Alt-H can be used to invoke HALT. • STEP: Used to execute a specified number of Blocks. • CONTINUE: Used to continue the simulation after hitting a stop condition. • SHOW: Used to display the state of the simulation. Can be used to examine SNAs or calculate expressions.
Topics of Discussion • Introduction to GPSS • Simple Manufacturing Problem • GPSS Transaction Flow • Programmer’s view of the Transaction Flow • GPSS Entities • System Numeric Attributes • GPSS Commands • Transaction Chains • Entity Categories
Transaction Chains • Two main Transactions chains already introduced: CEC and FEC • Other chains include User chains, Delay chains, Retry chains, Pending chains, and Interrupt Chains • Transactions can be only one of the following chains at a time • CEC • FEC • Delay Chain • Pending Chain • User Chain • Other rules may also apply • For example, a Transaction can be on any number of Interrupt chains but then cannot be on the FEC.
Retry Chain • Certain Blocks such at TEST and GATE can refuse entry when a test fails • Test consists of evaluating expression containing SNAs referencing entities • When Test fails, Transaction will be placed on the Retry chains of all entities referenced in the expression • When the state of one of the entities changes, the Transaction is returned to the CEC • The test is then re-evaluated • If successful, the Transaction enters the Block and is removed from all Retry chains • Others removed from the CEC until another entity referenced by expression changes state
Other Chains • Delay Chain • Queues Transaction waiting for a Facility or Storage Entity • Priority based FIFO discipline • Pending Chain • Queues Transactions waiting to pre-empt a Facility using interrupt mode pre-emption • Interrupt Chain • Queues Transactions that have been pre-empted in a Facility • User Chain • General purpose chain that can be used to implement different queuing disciplines
Topics of Discussion • Introduction to GPSS • Simple Manufacturing Problem • GPSS Transaction Flow • Programmer’s view of the Transaction Flow • GPSS Entities • System Numeric Attributes • GPSS Commands • Transaction Chains • Entity Categories
GPSS Entity Categories • Basic Category • Includes Transaction and Block Entities • Structural Category • Represents structural aspect of simulation • Includes Facility, Storage, User Chain, LogicSwitch, Numeric Group and Transaction Group entities • Data and Procedures Category • Used for generating and storing data • Include the Matrix, SaveValue, Variable, and Function entities • Output Category • For collecting and presenting statistical data • Includes the Queue and Table Entities
Transaction Entities Parameters • Parameters • Already seen Transaction number, priority, Mark Time, Current Block, Next Block, BDT • Additional Standard Parameters: • Assembly Set – It is possible to split a Transaction into a number of Transactions using the SPLIT bloc. All Transactions resulting from such an operation have the same value for the assembly set parameter. This allows the possibility to re-assemble the split Transactions with the ASSEMBLE Block. When a Transaction enters a simulation, its assembly set number is set to its Transaction number. • Delay Indicator – A flag parameter set when a Block refuse entry to a Transaction. This parameter remains set until it reaches a TRANSFER Block that can redirect the Transaction based on the value of this parameter. • Trace Indicator – A flag that enables messages each time a Transaction enters a Block. This flag is set and reset by the TRACE and UNTRACE Blocks respectively
Transaction Entity State • Related to occupation of chains • Assumes one of the following states • Active – The Transaction currently being processed. That is, the Transaction reached the head of the Current Events Chain. • Suspended – The Transaction is waiting for processing on either the FEC or CEC. • Passive – The Transaction is resting in a Delay Chain, Pending Chain, or User Chain. In this case, it will not be in either the FEC or CEC. • Terminated – The Transaction has left the simulation. • Can also be in the pre-empted state, i.e. occupy an Interrupt Chain
Blocks that affect Transactions • ASSIGN: This Block assigns values to Transaction parameters. • MARK: This Block sets the mark time parameter to the current time. • TRANSFER SBR – The Transfer Block, in subroutine mode, will update a parameter in the Transaction with the Block number of the TRANFER Block. This is to allow the Transaction return to this point, thus providing subroutine function. • SELECT – The Select Block provides many features to select entities from a set, such as selecting from a set of Facility entities. When such an entity has been selected, its identifier will be saved in a parameter of the active Transaction. • LOOP – This Block will decrement a parameter in the Transaction. If the parameter value is not 0, then the Transaction will be sent to a Block identified by a LOOP operand. Otherwise, the Transaction proceeds the Block following the LOOP block. • TRACE and UNTRACE: These Blocks turn on and off the Transaction trace indicator. • GENERATE – This Block generates Transactions. • TERMINATE – This Block removes Transactions from the simulation.
Blocks that affect Transactions • SPLIT – This Block splits a Transaction into a number of Transactions. All new Transactions will have the same assembly set number. • ASSEMBLE – This Block re-assembles the Transactions created by the SPLIT Block. When a specified number of Transactions in the assembly set have been collected, a single Transaction will exit the ASSEMBLE Block, • GATHER – This Block collects Transactions created by the SPLIT Block (i.e. from the same assembly set). When a specified number of Transactions from the same assembly set have been collected, they are allowed to exit the Block. • MATCH – This Block works in pairs. That is, two Match Blocks are placed in a simulation model and will allow Transactions through only when both Blocks see Transactions from the same assembly set. • ADOPT – This Block will change the assembly set value of the active Transaction. • COUNT – This Block counts entities and places the count in a parameter. • INDEX – This Block will add the value of a parameter identified by an operand with the value of another operand and saves the result in operand 1. For example, INDEX 4,23.4 will add 23.4 to the value in parameter 4 and save the results in parameter1 .
Transaction Entity SNAs • The following SNAs provide information about the Active Transaction: • A1 – The value of the assembly set identifier. • MB – Can be used to determine if another Transaction from the same assembly set is located at a specific Block with number EntNum using the expression MBEntNum. The SNA returns a 1 if such a Transaction exists and 0 otherwise. • MP – This SNA can be used to compute a transit time. It provides a value equal to the current time clock minus the value in a parameter identified in the SNA (ex. MPParam). • M1 – This SNA returns the value equal to the current time clock minus the Mark Time. • P – This SNA can be used to return the value of a parameter (ex. PParam). • PR – This SNA gives the value of the priority. • XN1 – This SNA gives the value of the Transaction number.
Block Entities • Programming element • Represents actions invoke by Transaction that enters it • Graphical representations • Related SNAs • N – The total number of Transactions that have entered a Block. • W- The current number of Transactions occupying a Block • Most Blocks will be introduced with related entities • Other Blocks include • Miscellaneous Blocks • Test and Displacement Blocks • Data Stream Blocks
Miscellaneous Blocks • ADVANCE – Places the Transaction entering the Block on the FEL. Many options exist for defining the time delay. • BUFFER – Moves the active Transaction on the CEC behind other Transactions of equal or greater priority. • EXECUTE – The EXECUTE operand identifies a Block number. When a Transaction enters this Block, it will execute the action associated with the Block identified in the operand. For example, a Transaction parameter could be used to identify the Block to execute, as in, EXECUTE P$BlkNum. • PLUS – This Block evaluates an expression that may include PLUS procedures. If a second operand is provided, the result of the evaluation is saved in the active Transaction parameter.
Test and Displacement Blocks • DISPLACE – A Transaction to displace another. • GATE – Changes the flow of a Transaction based on the state of an entity. It operates in two modes. • Refuse mode, the GATE will block Transactions until the entity has assumed the expected state. • In the Alternate Exit mode, the GATE will sent the Transaction to an alternate Block if the test on the entity is unsuccessful • TEST – Creates a test to compare values, often using expressions with SNAs, to affect the flow of a Transaction. Can also operate in Refuse mode or Alternate Exit mode. • TRANSFER – This Block will have the entering Transaction jump to a new Block location. An number of options are available with the Block, including • unconditional transfer, • picking a location randomly, • selecting among a number of Blocks that are non-blocking, • using a Function to compute the Block location, • and much more.
Data Stream Blocks • OPEN – Opens a data stream. For example, OPEN (“Data.Txt”),2,ERROR will open the file Data.Txt as stream 2. If an error occurs, then the Transaction is sent to the Block ERROR. • READ – Retrieves a line of text from a data stream. • WRITE – Writes a line of text to a data stream. • SEEK – Sets the line position of a data stream. • CLOSE – Used to close a data stream.
GPSS Entity Categories • Basic Category • Includes Transaction and Block Entities • Structural Category • Represents structural aspect of simulation • Includes Facility, Storage, User Chain, LogicSwitch, Numeric Group and Transaction Group entities • Data and Procedures Category • Used for generating and storing data • Include the Matrix, SaveValue, Variable, and Function entities • Output Category • For collecting and presenting statistical data • Includes the Queue and Table Entities
Facility Entity • Owned by a single Transaction • Busy and Idle States • Transactions that cannot gain ownership are placed on the Delay chain • Number of chains • Delay • Retry • Pending • Interrupt
Facility Pre-emption • Transactions removes ownership from another • Two modes • Interrupt mode: Cannot pre-empt a Transaction that has already pre-empted another • Priority mode: Can only pre-empt a Transaction of lower priority • Pending chain contains Transactions waiting to pre-empt using interrupt mode • Interrupt chain contains Transactions that have been pre-empted
Releasing Facility Ownership • Ownership is given to the Transactions from one of the Facility’s chains in the following order: • Pending chain, the Transaction enters the PREEMPT Block and is placed on the CEC, • Interrupt chain, • Delay chain, the Transaction enters the SEIZE or PREEMPT Block and is placed on the CEC.
Facility SNAs • SNAs related to Facility State: • F- Returns 1 if the Facility is busy and 0 otherwise. • FI – Returns 1 if the Facility is currently preempted using Interrupt Mode pre-emption and 0 otherwise. • FV –Returns 1 if the Facility is available and 0 otherwise. • SNAs related to statistics: • FC - Returns the number of times the Facility has been owned by a Transaction (SEIZEd or PREEMPTed). • FR – Returns the percentage of time the Facility has been busy. It is expressed as parts per thousand using a value between 0 and 1000. • FT – Returns the average time that the Facility has been owned by a Transaction.
Blocks related to Facilities • SEIZE: Gain ownership • RELEASE: Release Ownership • PREEMPT: Pre-empt (both interrupt and priority modes) • RETURN: Release ownership after pre-emption • FAVAIL: Make Facility available • FUNAVAIL: Make Facility unavailable (many options to deal with Transactions in Facility)
Storage Entity • Provides space • Transaction that enters occupies space • Default is 1 unit of space • When not enough space available, Transactions that try to enter queued on Delay Chain • When space is freed, Delay chain is scanned to find first Transaction that fits
Storage Entity SNAs • SNAs related to the Storage Entity state: • R – Provides the amount of storage units available within the Storage entity. • S – Provides the amount of storage units in use within the Storage entity. • SE – Returns 1 if the Storage entity is empty and 0 otherwise. • SF – Returns 1 if the Storage entity is full and 0 otherwise. • SV – Returns 1 if the Storage entity is available and 0 otherwise. • SNA related to statistics: • SA– Returns the time weighted average of storage capacity in use. • SC– Returns the total number of storage acquired. • SR – Returns the fraction of total utilization as expressed in parts per thousand using a value between 0 and 1000. • SM– Returns the maximum storage value used within the entity, i.e. the high water mark. • ST – Returns the average holding time per unit storage.
Blocks and Commands Related to Storage Entity • Blocks • ENTER: Enter and occupy space in the entity. • LEAVE: Release space and exit the entity. • SAVAIL: Make entity available. • SUNAVAIL: Make entity unavailable • Commands • STORAGE: Must be used to declare the capacity of the Storage entity.
User Chain Entity • Used to queue Transactions. • SNAs related to State • CH – Returns the number of Transactions currently in the User chain. • SNAs related to Statistics • CA – Returns the average number of Transactions in the User chain. • CC – Returns the total number of Transactions that have visited the User chain. • CM– Returns the maximum number of Transactions that have occupied the User chain, i.e. the high water mark. • CT– Returns the average time that Transaction have stayed in the User chain. • Related Blocks • LINK: To place Transaction on a User Chain. • UNLINK: To remove a Transaction from a User Chain. Many options for selecting Transaction.