martes, 20 de mayo de 2014

Simulacion Of a port Tutorial

Simulation of a port.

Problem Statement
A harbor port has three berths 1, 2 and 3. At any given time Berth1 can accommodate two small ships, or one medium ship. Berth2 and Berth3 can each handle one large ship, two medium ships or four small ships.
The interarrival time of ships is 26 hours, exponentially distributed, and small, medium, and large ships are in the proportions 5:3:2 respectively. Queuing for berths is on a first come first served basis, except that no medium or small ship may go to a berth for which a large ship is waiting, and medium ships have a higher priority than small ships.
Unloading times for ships are exponentially distributed with mean times as follows: small ships, 15 hours; medium ships, 30 hours; and large ships, 45 hours. The loading times are as follows:
 Small ships 24±6 hours uniformly distributed.
 Medium ships 36±10 hours uniformly distributed.
 Large ships 56±12 hours uniformly distributed.
The tide must be high for large ships to enter or leave Berths 2 and 3. Low tide lasts 3 hours, high tide, 10 hours.
1. Run the simulation for 500 days.
2. Determine the distribution of transit times of each type of ship.
3. Determine the utilization of the three berths.

Listing
; GPSS World Sample File - SHIPPORT.GPS
; Based on a model by Gerard F. Cummings
**********************************************************************
* *
* Ship and Port Simulation *
* Time in in Hours *
**********************************************************************
Berth1 EQU 1
Berth2 EQU 2
Berth3 EQU 3
Tide EQU 1
Tsmall EQU 1
Tmedium EQU 2
Tlarge EQU 3
*
*———Boolean Variables———————————————————————
Var1 BVARIABLE (R$Berth2’GE’1+R$Berth3’GE’1)#Q3’E’0
Var2 BVARIABLE R$Berth2’GE’1
Var3 BVARIABLE R$Berth3’GE’1
Var4 BVARIABLE SE$Berth1
Var5 BVARIABLE (R$Berth2’GE’2+R$Berth3’GE’2)#Q3’E’0
Var6 BVARIABLE R$Berth2’GE’2
Var7 BVARIABLE R$Berth3’GE’2
Var8 BVARIABLE SE$Berth3#LS1
Var9 BVARIABLE SE$Berth2#LS1
*
*—Size of Berths in relation to small ships—————————————
Berth1 STORAGE 2
Berth2 STORAGE 4
Berth3 STORAGE 4
*
*————Table Definations——————————————————————
Tsmall TABLE M1,30,10,20 ;Small ship transit time
Tmedium TABLE M1,30,10,20 ;Medium ship transit time
Tlarge TABLE M1,30,10,20 ;Large ship transit time
**********************************************************************
*
*————Day Timer——————————————————————————
        GENERATE  24            ;One xact each day
        TERMINATE 1             ;Clock operates once/day
**********************************************************************
*
*————Tide Control————————————————————————
        GENERATE  ,,0,1
Again   LOGIC R   Tide          ;Cycling xact models the tide
        ADVANCE   3             ;Tide is low for 3 hours
        LOGIC S   Tide          ;Tide comes in
        ADVANCE   10            ;Tide is high for 10 hrs
        TRANSFER  ,Again        ;Branch back to ‘Again’
**********************************************************************
        GENERATE  (Exponential(1,0,26)) ;A ship every 26 hrs.
        TRANSFER  500,,Inter    ;50 % are small
*
*———Characteristics of small ships are assigned to parameters——
        ASSIGN    Size,1        ;Type ship small, size=1
        ASSIGN    Capacity,1    ;Capacity P2=1 Small ship
        ASSIGN    Quenum,1      ;Queue #1 for small ships
        ASSIGN    M_Unload,15   ;Mean unload time
        ASSIGN    M_Load,24     ;Mean load time
        ASSIGN    Loadsp,6      ;Load time spread
        QUEUE     P$Quenum      ;Join queue-small ships
        TRANSFER  Both,Pier1,Pier2
*———Assign Berth 1 When Available————————————————
Pier1   GATE SNF  Berth1
        ASSIGN    Berth_Num,1   ;Berth obtained=Berth1
*———Move into Berth and Unload and Load—————————————
Small   ENTER     P$Berth_num,P$Capacity ;Enter berth using up
                                ; ship capacity
        DEPART    P$Quenum      ;Depart queue
        ADVANCE   P$M_Unload,(Exponential(1,0,1)) ;Unload time
        ADVANCE   P$M_Load,P$Loadsp ;Loading time
        TEST E    P$Size,3,Skipit ;A large ship?
*———When Switch is Set, Tide is High———————————————
        GATE LS   Tide          ;Wait for tide
Skipit  LEAVE     P$Berth_Num,P$Capacity ;Leave berth by
                                ; ship capacity
        TABULATE  P$Quenum      ;Tabulate transit time
                                ; by ship type
        TERMINATE               ;Ship sails
**********************************************************************
*———Assign Berth 2 or Berth 3 when available(dependent——————
* on the ship configuration
Pier2   TEST E    BV$Var1,1     ;Small ship tries 2 or 3
        TRANSFER  Both,Bert2,Bert3 ;Try berth2 or berth3
Bert2   TEST E    BV$VAR2,1     ;Berth2 available?
        ASSIGN    Berth_Num,2   ;Assigned to berth2
        TRANSFER  ,Small
Bert3   TEST E    BV$Var3,1     ;Berth3 available?
        ASSIGN    Berth_Num,3   ;Assigned to berth3
        TRANSFER  ,Small
*
*———Characteristics of medium ships are assigned to parameters——
Inter   TRANSFER  400,,Large    ;20% of all ships
                                ; are large
        PRIORITY  2             ;All medium ships
                                ; enter here
        ASSIGN    Size,2        ;Type ship medium,
                                ; Size=2
        ASSIGN    Capacity,2    ;Capacity = 2
                                ; Medium ship
        ASSIGN    Quenum,2      ;Queue 2 for med ships
        ASSIGN    M_Unload,30   ;Mean unload time
        ASSIGN    M_Load,36     ;Mean load time
        ASSIGN    Loadsp,10     ;Load time spread
        QUEUE     P$Quenum      ;Join queue for small
                                ; ships
        TRANSFER  Both,Quay1,Quay2
Quay1   TEST E    BV$Var4,1     ;Try for berth1
        ASSIGN    Berth_Num,1   ;Assigned to berth1
        TRANSFER  ,Small        ;Transfer for processing
Quay2   TEST E    BV$Var5,1     ;Try for berth 2 or 3
        TRANSFER  Both,,Quay3   ;Try berth2 first
        TEST E    BV$Var6,1     ;Is berth2 available?
        ASSIGN    Berth_Num,2   ;Gets berth2
        TRANSFER  ,Small        ;Transfer for processing
Quay3   TEST E    BV$Var7,1     ;Try for berth3
        ASSIGN    Berth_Num,3   ;Assigned to berth3
        TRANSFER  ,Small        ;Transfer for
                                ; unload/load
*
*———Characteristics of large ships are assigned to parameters——
Large   PRIORITY  3             ;All large ships
                                ; enter here
        ASSIGN    Size,3        ;Type ship large, Size=3
        ASSIGN    Capacity,4    ;Capacity=4 Large ship
        ASSIGN    Quenum,3      ;Queue number 3 for
                                ; large ships
        ASSIGN    M_Unload,45   ;Mean unload time
        ASSIGN    M_Load,56     ;Mean load time
        ASSIGN    Loadsp,12     ;Load time spread
        QUEUE     P$Quenum      ;Join queue for
                                ; large ships
        TRANSFER  Both,First,Second ;Try Berth3 and Berth2
First   TEST E    BV$Var8,1     ;Try Berth3 first
        ASSIGN    Berth_Num,3   ;Berth number=3
                                ; Entered Berth3
        TRANSFER  ,Small        ;Transfer for
                                ; unload/load
Second  TEST E    BV$Var9,1     ;Try berth2 second
        ASSIGN    Berth_Num,2   ;Berth number=2
                                ; Entered Berth2
        TRANSFER ,Small ;Transfer for
                                ; unload/load
**********************************************************************

The model is organized into several segments. After the non-Block Entities are defined, there are three more model segments. Transactions in the top segment time the simulation and decrement the Termination Count once per simulated day. A single transaction circulates in the middle segment to represent the ebb and flow of the tides. This affects the accessibility of the berths. Transactions in the bottom segment represent ships. Each is given attributes according to the size of the ship it represents. It then waits for a suitable berth, exchanges cargo, and leaves the port.
There are 9 Boolean variables, or GPSS Bvariable Entities, defined in the beginning of the model. Boolean Variables return a value of 1 or 0 when evaluated. When the value of the BVARIABLE expression is 0 a 0 result is returned, otherwise a value of 1 is returned. They are used to determine the state of the port and  which actions are possible.
The logic of the SHIPPORT.GPS model is depicted below.


Figure 21—1. The Logic of the Shipport Model.

Running the Simulation
To run the simulation and create a Standard Report,
CHOOSE    File / Open
and in the dialog box
SELECT      Shipport
and then
SELECT      Open
Next, create the simulation
CHOOSE      Command / Create Simulation
then
CHOOSE      Command / START
and in the dialog box, replace the 1.
TYPE      500
SELECT     OK
The simulation will end when 500 transactions have entered the TERMINATE 1 Block. This represents 500 days of operation.
When the simulation ends, GPSS World writes a report to the default report file, Shipport.1.1. As discussed in Chapter 1, the Report extension will vary depending on saved simulations and previously existing reports. For our purposes, we will assume that this is the first time the simulation has been created and run giving an extension of 1.1.
This report will be automatically displayed in a window. If you close the window, you can reopen it by using the GPSS World File / Open in the Main Menu. Then you should choose Report in the "Files of type" drop down box at the bottom of the window. GPSS World reports are written in a special format. If you wish to edit the report, you will have to copy its contents to the clipboard and from there into a word processor. You will not be able to open the file directly in a word processor.

Discussion of Results
From the GPSS Tables named "Tsmall", "Tmedium" and "Tlarge" we see histograms of the transit times for small, medium, and large ships, respectively. The average transit times were about 44, 74, and 115 hours.
The Berth utilizations were 52%, 49% and 54% for Berths 1, 2, and 3, respectively.

Inside the Simulation
Let 's now explore the ending condition of the simulation, which generated the Standard Report above. If you are not at the end of the simulation, please Retranslate the model and run it again.
Now, let’s open some graphics windows.
CHOOSE     Window / Simulation Window / Storages Window
This is the Storages Window. It gives utilization and queuing information on the Berths. Notice how the color of the icons corresponds to the amount of Storage in use. Look at the histograms of transit times for small, medium, and large ships one after the other. First, for the small ships,
CHOOSE      Window / Simulation Window / Table Window
and in the drop-down box in the dialog box
CLICK ON      The Down Arrow at the Right End of the Box
CLICK ON      TSMALL
SELECT      OK
and for the medium ships
CHOOSE      Window / Simulation Window / Table Window
and in the drop-down box in the dialog box
CLICK ON      The Down Arrow at the Right End of the Box
CLICK ON      TMEDIUM
SELECT     OK
and for the large ships
CHOOSE     Window / Simulation Window / Table Window
and since TLARGE is already selected in the drop-down box in the dialog box
SELECT     OK
Please feel free to modify the parameters and Blocks of this simulation.
When you are done, if you wish to go on to the next lesson, close all windows related to this model.
CLICK ON      The X-Upper Right of Each Window
Otherwise, to end the session
CLICK ON      The X-Upper Right of Main Window.



Share This Article Facebook +Google Twitter Digg Reddit