Day 1--The General Purpose Language
Download
Report
Transcript Day 1--The General Purpose Language
Day 1, Section 2 Problem Solution
C:\Program Files\Simscript3\models\Heath2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Preamble
''
''
''
Entities, Attributes, & Sets Problem - CACI Products Company
Solution to Student Problem F
HEATH1.SRC, WESTAPR.DAT
Normally mode is undefined
Permanent entities
Every APPROACH has
an APP.NAME and
owns a CHECK.POINT.SET
Define APP.NAME as a text variable
Temporary entities
Every CHECK.POINT has
a CK.NBR,
a CK.X,
a CK.Y and
belongs to a CHECK.POINT.SET
Define CK.NBR,
CK.X,
CK.Y as integer variables
End ''Preamble
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-1
1
2
3
4
5
6
7
8
Main
Call READ.APPROACHES
Call PRINT.APPROACHES
Read as / using unit 5
End ''Main
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Routine READ.APPROACHES
Define .APR,
.NBR.APPROACHES as integer variables
Define .CP as a pointer variable
''
Open the file
Open unit 11 for input, name = "WESTAPR.DAT"
Use unit 11 for input
''
Skip the comments at the top
While mode is alpha
Do
Start new record
Loop ''mode is alpha
''
''
Read the number of approaches, start a new record
and create the approaches
Read .NBR.APPROACHES
Start new record
Create every APPROACH(.NBR.APPROACHES)
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-3
28
''
Read the approach name and checkpoint data
29
30
For each APPROACH called .APR
31
Do
32
Read APP.NAME(.APR)
33
While mode is not alpha
34
Do
35
Create a CHECK.POINT called .CP
36
Read CK.NBR(.CP),
37
CK.X(.CP),
38
CK.Y(.CP)
39
File .CP in the CHECK.POINT.SET(.APR)
40
Loop ''mode is not alpha do
41
Loop ''each APPROACH called .APR do
42
43
Close unit 11
44
45
End ''READ.APPROACHES
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
1
2
3
4
5
6
7
8
9
13
14
15
16
17
18
19
20
Routine PRINT.APPROACHES
Define .CP as a pointer variable
''
Print column headings
Skip 5 lines
Print 3 lines thus
Check
Point
X
Y
----- ----- ----Skip 1 line
''
Print the approach name and the data on each check point
For each APPROACH
Do
Print 1 line with APP.NAME(APPROACH) thus
***********************
22
23
24
25
26
**
28
29
30
31
32
33
34
For each .CP in the CHECK.POINT.SET(APPROACH) do
Print 1 line with CK.NBR(.CP),
CK.X(.CP),
CK.Y(.CP) thus
***.* ***.*
Loop ''each .CP in the CHECK.POINT.SET(APPROACH)
Skip 1 line
Loop ''each APPROACH
End ''PRINT.APPROACHES
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-4
Output
Check
Point
-----
Polar
6
5
4
3
2
1
Western
7
5
4
3
2
1
X
-----
0.
10.0
10.0
13.0
16.0
20.0
0.
10.0
10.0
13.0
16.0
20.0
Y
-----
20.0
15.0
10.0
10.0
14.0
14.0
9.0
15.0
10.0
10.0
14.0
14.0
Check
Point
-----
X
-----
Y
-----
Southern
8
10.0
5
10.0
4
10.0
3
13.0
2
16.0
1
20.0
0.
15.0
10.0
10.0
14.0
14.0
Continental
10
15.0
9
20.0
5
10.0
4
10.0
3
13.0
2
16.0
1
20.0
5.0
2.0
15.0
10.0
10.0
14.0
14.0
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-5
This page is intentionally blank
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex2-6
Day 2, Section 4 Problem Solution
C:\Program Files\Simscript3\models\AnswerB
PORT.DAT Input File
NUMBER OF TUGS:
1
NUMBER OF DOCKS:
3
RUN LENGTH (DAYS): 365
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Preamble
''
''
''
Pacific Port Problem - CACI Products Company
Solution to Student Problem B
files: ANSWERB.SRC, PORT.DAT
Normally mode is undefined
Processes include
GENERATOR,
SHIP and
REPORT
Resources include
DOCK and
TUG
''
Input global variables
Define RUN.LENGTH as a real variable
Define NBR.DOCKS and NBR.TUGS as integer variables
''
Output global variables
Define WAITING.TIME as a real variable
Define TOTAL.WAITING.TIME and MAX.WAITING.TIME as real variables
Define NO.OF.SHIPS.SERVED as an integer variable
End ''Preamble
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-1
1
2
3
4
5
6
7
8
9
10
11
12
Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Routine INITIALIZE
Call INITIALIZE
Activate a GENERATOR now
Activate a REPORT in RUN.LENGTH days
Start simulation
Read as / using unit 5
End
Open unit 10 for input, name = "PORT.DAT"
Use unit 10 for input
Skip 3 fields
Read NBR.TUGS
Skip 3 fields
Read NBR.DOCKS
Skip 3 fields
Read RUN.LENGTH
Close unit 10
Create every TUG(1)
Let U.TUG(1) = NBR.TUGS
Create every DOCK(1)
Let U.DOCK(1) = NBR.DOCKS
End ''INITIALIZE
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-2
1
2
3
4
5
6
7
8
9
Process GENERATOR
Until time.v >= RUN.LENGTH
Do
Activate a SHIP now
Wait uniform.f(4.0, 18.0, 1) hours
Loop ''time.v >= RUN.LENGTH do
End ''GENERATOR
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Process SHIP
Define .ARRIVAL.TIME,
.UNLOAD.TIME and
.PROBABILITY
as real variables
Let .PROBABILITY = random.f(2)
Select case .PROBABILITY
Case 0.0 to .25
Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3)
Case .25 to .80
Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3)
Default
Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3)
Endselect ''.PROBABILITY
Let .ARRIVAL.TIME = time.v
Request 1 DOCK(1)
Request 1 TUG(1)
Wait 1.0 hour
Relinquish 1 TUG(1)
Work .UNLOAD.TIME hours
Request 1 TUG(1)
Wait 1.0 hour
Relinquish 1 TUG(1)
Relinquish 1 DOCK(1)
Add
Let
Add
Let
1 to NO.OF.SHIPS.SERVED
WAITING.TIME = (time.v - .ARRIVAL.TIME) * hours.v - .UNLOAD.TIME
WAITING.TIME to TOTAL.WAITING.TIME
MAX.WAITING.TIME = max.f(WAITING.TIME, MAX.WAITING.TIME)
End ''SHIP
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-5
1 Process REPORT
2
3
Skip 2 output lines
4
5
Print 4 lines with RUN.LENGTH thus
Pacific Port Problem (Answer to Student Problem B)
Run length is *** days.
10
Skip 2 output lines
11
12
Print 4 lines with time.v,
13
NO.OF.SHIPS.SERVED,
14
TOTAL.WAITING.TIME/NO.OF.SHIPS.SERVED and
15
MAX.WAITING.TIME thus
After ***.** days, *** ships have been unloaded.
The average waiting time was
The maximum waiting time was
20
21
Skip 2 lines
22
23 End ''REPORT
**.** hours
**.** hours
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-6
Results
Pacific Port Problem (Answer to Student Problem B)
Run length is 365 days.
After 365.00 days, 792 ships have been unloaded.
The average waiting time was
The maximum waiting time was
4.01 hours
34.00 hours
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-7
See C:\Program Files\Simscript3\models\ProblemR
for same model using multiple replications
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex4-8
Day 3, Section 6 Problem Solution
C:\Program Files\Simscript3\models\AnswerC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Preamble
''
''
''
Pacific Port Problem - CACI Products Company
Solution to Student Problem C
files: PROBLEMC.SRC, PORT.DAT, WAIT.GRF
Normally mode is undefined
Processes include
GENERATOR,
SHIP and
REPORT
Every SHIP has
a SHIP.TYPE
Define SHIP.TYPE as an integer variable
Define ..OLD.SHIP to mean 1
Define ..NEW.SHIP to mean 2
Resources include
DOCK and
TUG
''
Input global variables
Define RUN.LENGTH as a real variable
Define NBR.DOCKS, NBR.TUGS, NBR.NEW.SHIPS as integer variables
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-1
30
31 ''
32
33
34
35
36 ''
37
38
39
40 ''
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Internal global variables
Define DOCKS.IN.USE as an integer variable
Define IN.PORT.TIME as a real variable
Output global variables
Define WAITING.TIME as a real variable
Statistics
Accumulate AVG.DOCK.QUEUE as the average and
MAX.DOCK.QUEUE as the maximum
of N.Q.DOCK
Accumulate DOCK.UTILIZATION as the average of DOCKS.IN.USE
Accumulate AVG.TUG.QUEUE as the average and
MAX.TUG.QUEUE as the maximum
of N.Q.TUG
Accumulate TUG.UTILIZATION as the average of N.X.TUG
Tally AVG.IN.PORT.TIME as the average,
MAX.IN.PORT.TIME as the maximum and
NO.OF.SHIPS.SERVED as the number
of IN.PORT.TIME
Tally AVG.SHIP.DELAY as the average and
MAX.SHIP.DELAY as the maximum of WAITING.TIME
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-2
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
''-----------------------------------------------------------------------Processes include
GRAPHICS.DISPLAY
''
Internal global variables
Define WLO,
WHI and
WDELTA
as integer variables
''
Statistics
Tally WAITING.TIME.HISTOGRAM(WLO to WHI by WDELTA)
as the histogram of WAITING.TIME
End ''Preamble
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-3
1
2
3
4
5
6
7
8
9
10
11
12
13
Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Process GENERATOR
Call INITIALIZE
Activate a GENERATOR now
Activate a GRAPHICS.DISPLAY now
Activate a REPORT in RUN.LENGTH days
Start simulation
Read as / using unit 5
End
Define .I as an integer variable
For .I = 1 to NBR.NEW.SHIPS
Do
Activate a SHIP in uniform.f (0, 10, 4) days
LET SHIP.TYPE(SHIP) = ..NEW.SHIP
Loop
Until time.v > = RUN.LENGTH
Do
Activate a SHIP now
Let SHIP.TYPE(SHIP) = ..OLD.SHIP
Wait uniform.f(4.0, 18.0, 1) hours
Loop ''time.v > = RUN.LENGTH
End ''GENERATOR
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Process SHIP
Define .UNLOAD.TIME and
.PROBABILITY
as real variables
If SHIP.TYPE(SHIP) = ..OLD.SHIP
Let .PROBABILITY = random.f(2)
Select case .PROBABILITY
Case 0.0 to .25
Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3)
Case .25 to .80
Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3)
Default
Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3)
Endselect ''.PROBABILITY
Call HARBOR.OPERATIONS
giving .UNLOAD.TIME
Else
Until time.v > RUN.LENGTH
Do
Let .UNLOAD.TIME = exponential.f (21, 5)
Call HARBOR.OPERATIONS
giving .UNLOAD.TIME
Wait normal.f (10, 1, 6) days
Loop
Endif
End ''SHIP
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Routine HARBOR.OPERATIONS
given .UNLOAD.TIME
Define .ARRIVAL.TIME, .UNLOAD.TIME as real variables
Let .ARRIVAL.TIME = time.v
Request 1 DOCK(1)
Request 1 TUG(1)
Wait 1.0 hour
Relinquish 1 TUG(1)
Add 1 to DOCKS.IN.USE
Work .UNLOAD.TIME hours
Subtract 1 from DOCKS.IN.USE
Request 1 TUG(1)
Wait 1.0 hour
Relinquish 1 TUG(1)
Relinquish 1 DOCK(1)
Let IN.PORT.TIME = (time.v - .ARRIVAL.TIME) * hours.v
Let WAITING.TIME = IN.PORT.TIME - .UNLOAD.TIME
End
''HARBOR.OPERATIONS
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Process GRAPHICS.DISPLAY
''
Display the histogram immediately
Display histogram WAITING.TIME.HISTOGRAM with "WAIT.GRF"
''
Display the histogram every 50 days
Until time.v >= RUN.LENGTH
Do
Wait 50 days
Display histogram WAITING.TIME.HISTOGRAM
Loop ''time.v >= RUN.LENGTH do
''
Display the histogram one last time
Display histogram WAITING.TIME.HISTOGRAM
End ''GRAPHICS.DISPLAY
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Routine INITIALIZE
Open unit 10 for input, name = "PORT.DAT"
Use unit 10 for input
Skip 3 fields
Read NBR.TUGS
Skip 3 fields
Read NBR.DOCKS
Skip 3 fields
Read RUN.LENGTH
Skip 3 fields
Read NBR.NEW.SHIPS
Close unit 10
Create every TUG(1)
Let U.TUG(1) = NBR.TUGS
Create every DOCK(1)
Let U.DOCK(1) = NBR.DOCKS
Show WAITING.TIME.HISTOGRAM with "WAIT.GRF"
End ''INITIALIZE
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-8
1 Process REPORT
2
3
Print 3 lines with RUN.LENGTH thus
Pacific Port Problem (Solution to Student Problem C)
Run length is *** Days.
7
8
Skip 1 line
9
10
Print 15 lines with time.v,
11
NO.OF.SHIPS.SERVED,
12
AVG.SHIP.DELAY,
13
MAX.SHIP.DELAY,
14
AVG.IN.PORT.TIME,
15
MAX.IN.PORT.TIME,
16
(DOCK.UTILIZATION/NBR.DOCKS) * 100,
17
AVG.DOCK.QUEUE(1),
18
MAX.DOCK.QUEUE(1),
19
(TUG.UTILIZATION(1)/NBR.TUGS) * 100,
20
AVG.TUG.QUEUE(1) and
21
MAX.TUG.QUEUE(1) thus
After *** days, *** ships have been unloaded.
The average waiting time was ***.* hours
The maximum waiting time was ***.* hours
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-9
The average in-port time for a ship was ***.* hours.
The maximum in-port time for a ship was ***.* hours.
The dock utilization was **.* %.
The average queue for the dock was **.** ships.
The maximum queue for the dock was
** ships.
The tug utilization was **.* %.
The average queue for the tug was **.** ships.
The maximum queue for the tug was
** ships.
37
38 End ''REPORT
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-10
Results
Pacific Port Problem (Solution to Student Problem C)
Run length is 365 Days.
After 365 days, 938 ships have been unloaded.
The average waiting time was 29.9 hours
The maximum waiting time was 110.5 hours
The average in-port time for a ship was 54.7 hours.
The maximum in-port time for a ship was 189.4 hours.
The dock utilization was 88.4 %.
The average queue for the dock was
The maximum queue for the dock was
2.98 ships.
13 ships.
The tug utilization was 21.4 %.
The average queue for the tug was
The maximum queue for the tug was
.02 ships.
2 ships.
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-11
This page is intentionally blank.
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex6-12
Day 4, Section 8 Problem Solution
C:\Program Files\Simscript3\models\AnswerD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Preamble
''
''
''
Pacific Port Problem - CACI Products Company
Solution to Student Problem D
files: ANSWERD.SRC, INPUT.FRM, WAIT.GRF, WEATHER.DAT
Normally mode is undefined
Processes include
GENERATOR,
SHIP and
REPORT
Every SHIP has
a SHIP.TYPE,
a SHIP.STATUS and
belongs to the FLEET
Define SHIP.STATUS,
SHIP.TYPE as integer variables
The system owns the FLEET
External Processes include
STORM
External process unit is 10
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-1
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Resources include
DOCK,
TUG and
PERMIT
Define ..OLD.SHIP to mean 1
Define ..NEW.SHIP to mean 2
Define ..AT.SEA
to mean 1
Define ..IN.HARBOR to mean 2
Define ..TO.DEPART to mean 1
''
Input global variables
Define RUN.LENGTH as a real variable
Define NBR.DOCKS, NBR.TUGS, NBR.NEW.SHIPS as integer variables
''
Internal global variables
Define DOCKS.IN.USE as an integer variable
Define IN.PORT.TIME as a real variable
''
Output global variables
Define WAITING.TIME as a real variable
''
Statistics
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-2
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Accumulate AVG.DOCK.QUEUE as the average and
MAX.DOCK.QUEUE as the maximum
of N.Q.DOCK
Accumulate DOCK.UTILIZATION as the average of DOCKS.IN.USE
Accumulate AVG.TUG.QUEUE as the average and
MAX.TUG.QUEUE as the maximum
of N.Q.TUG
Accumulate TUG.UTILIZATION as the average of N.X.TUG
Tally AVG.IN.PORT.TIME as the average,
MAX.IN.PORT.TIME as the maximum and
NO.OF.SHIPS.SERVED as the number
of IN.PORT.TIME
Tally AVG.SHIP.DELAY as the average and
MAX.SHIP.DELAY as the maximum of WAITING.TIME
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-3
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
''-----------------------------------------------------------------------Processes include
GRAPHICS.DISPLAY
''
Internal global variables
Define WLO,
WHI and
WDELTA
as integer variables
''
Statistics
Tally WAITING.TIME.HISTOGRAM(WLO to WHI by WDELTA)
as the histogram of WAITING.TIME
End ''Preamble
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-4
1
2
3
4
5
6
7
8
9
10
11
12
13
Main
Call INITIALIZE
Activate a GENERATOR now
Activate a GRAPHICS.DISPLAY now
Activate a REPORT in RUN.LENGTH days
Start simulation
Read as / using unit 5
End
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Process GENERATOR
Define .I as an integer variable
For .I = 1 to NBR.NEW.SHIPS
Do
Activate a SHIP in uniform.f (0, 10, 4) days
LET SHIP.TYPE(SHIP)
= ..NEW.SHIP
Let SHIP.STATUS(SHIP) = ..AT.SEA
File this SHIP in the FLEET
Loop
Until time.v > = RUN.LENGTH
Do
Activate a SHIP now
Let SHIP.TYPE(SHIP)
= ..OLD.SHIP
Let SHIP.STATUS(SHIP) = ..IN.HARBOR
Wait uniform.f(4.0, 18.0, 1) hours
Loop ''time.v > = RUN.LENGTH
End ''GENERATOR
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Process SHIP
Define .UNLOAD.TIME and
.PROBABILITY
as real variables
If SHIP.TYPE(SHIP) = ..OLD.SHIP
Let .PROBABILITY = random.f(2)
Select case .PROBABILITY
Case 0.0 to .25
Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3)
Case .25 to .80
Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3)
Default
Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3)
Endselect ''.PROBABILITY
Call HARBOR.OPERATIONS
giving .UNLOAD.TIME
Else
Until time.v > RUN.LENGTH
Do
Let .UNLOAD.TIME = exponential.f (21, 5)
Call HARBOR.OPERATIONS
giving .UNLOAD.TIME
Wait normal.f (10, 1, 6) days
Loop
Remove this SHIP from the FLEET
Endif
End ''SHIP
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-6
1
Routine HARBOR.OPERATIONS
2
given .UNLOAD.TIME
3
4
Define .ARRIVAL.TIME, .UNLOAD.TIME as real variables
5
6
Let .ARRIVAL.TIME = time.v
7
8
Let SHIP.STATUS(SHIP) = ..IN.HARBOR
9
10
Request 1 DOCK(1)
11
Request 1 TUG(1)
12
13
Wait 1.0 hour
14
15
Relinquish 1 TUG(1)
16
17
Add 1 to DOCKS.IN.USE
18
Work .UNLOAD.TIME hours
19
Subtract 1 from DOCKS.IN.USE
20
21
Request 1 TUG(1)
22
23
Wait 1.0 hour
24
25
Relinquish 1 TUG(1)
26
Relinquish 1 DOCK(1)
27
28
Request 1 PERMIT(..TO.DEPART)
29
Let SHIP.STATUS(SHIP) = ..AT.SEA
30
Relinquish 1 PERMIT(..TO.DEPART)
31
32
Let IN.PORT.TIME = (time.v - .ARRIVAL.TIME) * hours.v
33
Let WAITING.TIME = IN.PORT.TIME - .UNLOAD.TIME
34
35 End
''HARBOR.OPERATIONS
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Process STORM
Define .DURATION as a real variable
Read .DURATION
Request 1 PERMIT(..TO.DEPART)
For each SHIP in FLEET
with SHIP.STATUS(SHIP) = ..AT.SEA
Do
Interrupt SHIP
Loop ''each SHIP in FLEET do
Wait .DURATION days
Relinquish 1 PERMIT(..TO.DEPART)
For each SHIP in FLEET
with SHIP.STATUS(SHIP) = ..AT.SEA
Do
Resume SHIP
Loop ''each SHIP in FLEET do
End
''STORM
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Routine INITIALIZE
Define .FORM as a pointer variable
Define .FIELD as a text variable
Open unit 10 for input, name = "WEATHER.DAT"
Call origin.r (1, 1, 2005)
''
Display the form and get run data from the user
Show .FORM with "INPUT.FRM"
Let .FIELD = accept.f(.FORM, 'FORM.CTRL')
''
Create the tug and docks
Create every TUG(1)
Let U.TUG(1) = NBR.TUGS
Create every DOCK(1)
Let U.DOCK(1) = NBR.DOCKS
Create every PERMIT(1)
Let U.PERMIT(..TO.DEPART) = 1
''
Warning elimination
Let .FIELD = .FIELD
End ''INITIALIZE
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Routine FORM.CTRL
Given
.FIELD,
.FORM
Yielding
.STATUS
''
Control routine for the input form
Define .FORM as a pointer variable
Define .FIELD as a text variable
Define .STATUS as an integer variable
Select case .FIELD
Case "RUN"
Let RUN.LENGTH
Let NBR.DOCKS
Let NBR.TUGS
Let NBR.NEW.SHIPS
Return
=
=
=
=
ddval.a(dfield.f("RUN LENGTH", .FORM))
int.f(ddval.a(dfield.f("NBR DOCKS", .FORM)))
int.f(ddval.a(dfield.f("NBR TUGS", .FORM)))
int.f(ddval.a(dfield.f("NBR NEW SHIPS", .FORM)))
Case "QUIT"
Stop
Default
Endselect ''.FIELD
''
Warning elimination
Let .STATUS = .STATUS
End ''FORM.CTRL
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Process GRAPHICS.DISPLAY
''
Display the histogram immediately
Display histogram WAITING.TIME.HISTOGRAM with "WAIT"
''
Display the histogram every 50 days
Until time.v >= RUN.LENGTH
Do
Wait 50 days
Display histogram WAITING.TIME.HISTOGRAM
Loop ''time.v >= RUN.LENGTH do
''
Display the histogram one last time
Display histogram WAITING.TIME.HISTOGRAM
End ''GRAPHICS.DISPLAY
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-11
1 Process REPORT
2
3
Print 3 lines with RUN.LENGTH thus
Pacific Port Problem (Solution to Student Problem D)
Run length is *** Days.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Skip 1 line
Print 17 lines with time.v,
NO.OF.SHIPS.SERVED,
NBR.NEW.SHIPS,
AVG.SHIP.DELAY,
MAX.SHIP.DELAY,
AVG.IN.PORT.TIME,
MAX.IN.PORT.TIME,
(DOCK.UTILIZATION/NBR.DOCKS) * 100,
AVG.DOCK.QUEUE(1),
MAX.DOCK.QUEUE(1),
(TUG.UTILIZATION(1)/NBR.TUGS) * 100,
AVG.TUG.QUEUE(1) and
MAX.TUG.QUEUE(1) thus
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-12
After *** days, *** ships have been unloaded.
*** new ships present.
The average waiting time was ***.* hours
The maximum waiting time was ***.* hours
The average in-port time for a ship was ***.* hours.
The maximum in-port time for a ship was ***.* hours.
The dock utilization was **.* %.
The average queue for the dock was **.** ships.
The maximum queue for the dock was
** ships.
The tug utilization was **.* %.
The average queue for the tug was **.** ships.
The maximum queue for the tug was
** ships.
40
41 End ''REPORT
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-13
Results with No New Ships
Pacific Port Problem (Solution to Student Problem D)
Run length is 365 Days.
After 365 days, 792 ships have been unloaded.
0 new ships present.
The average waiting time was
8.4 hours
The maximum waiting time was 237.3 hours
The average in-port time for a ship was 33.4 hours.
The maximum in-port time for a ship was 255.1 hours.
The dock utilization was 75.3 %.
The average queue for the dock was
The maximum queue for the dock was
The tug utilization was 18.1 %.
The average queue for the tug was
The maximum queue for the tug was
.17 ships.
3 ships.
.01 ships.
2 ships.
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-14
Results with 5 New Ships
Pacific Port Problem (Solution to Student Problem D)
Run length is 365 Days.
After 365 days, 932 ships have been unloaded.
5 new ships present.
The average waiting time was 32.9 hours
The maximum waiting time was 237.3 hours
The average in-port time for a ship was 57.6 hours.
The maximum in-port time for a ship was 255.1 hours.
The dock utilization was 87.8 %.
The average queue for the dock was
The maximum queue for the dock was
2.83 ships.
12 ships.
The tug utilization was 21.3 %.
The average queue for the tug was
The maximum queue for the tug was
.02 ships.
2 ships.
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-15
This page is intentionally blank.
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex8-16
Day 5, Section 10 Problem Solution
C:\Program Files\Simscript3\models\Lhwg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Preamble
''
''
''
Heathrow Airport Animation - CACI Products Company
Solution to Student Problem: HEATHROW
files: LHWG.SRC, ACFT.ICN, LHW.ICN, BOX.ICN, CHECKPT.DAT
Normally mode is undefined
Temporary entities include
MAP
Every CHECK.POINT has
a CHK.X,
a CHK.Y and
belongs to an APPROACH
Define CHK.X and
CHK.Y
as real variables
The system owns an APPROACH
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-1
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Graphic entities include
MAP
Processes include
AIRCRAFT
Dynamic graphic entities include
AIRCRAFT
Define ..DISPLAY.VIEW.PORT to mean 2
Define minute to mean units
Define minutes to mean units
End ''Preamble
Main
Call READ.APPROACH.DATA
Call SET.GRAPHICS
Create a MAP
Display MAP with "LHW.ICN"
Activate an AIRCRAFT now
Show AIRCRAFT with "ACFT.ICN"
Start simulation
End ''Main
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Process AIRCRAFT
Define .DIRECTION,
.SPEED and
.TIME
as real variables
Define .1ST.CP,
.CP
as pointer variables
Let .SPEED = 3 ''miles per minute or 180 knots
Let .1ST.CP = F.APPROACH
Let location.a(AIRCRAFT) = location.f(CHK.X(.1ST.CP),CHK.Y(.1ST.CP))
For each .CP after .1ST.CP in the APPROACH do
Call VECTOR
Given
location.x(AIRCRAFT), location.y(AIRCRAFT),
CHK.X(.CP), CHK.Y(.CP),
.SPEED
Yielding
.TIME,
.DIRECTION
Let orientation.a(AIRCRAFT) = .DIRECTION
Let velocity.a(AIRCRAFT) = velocity.f(.SPEED, .DIRECTION)
Wait .TIME minutes
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-3
32
Loop ''each .CP in the APPROACH after .1ST.CP do
33
34
Let velocity.a(AIRCRAFT) = 0
35
36
Call messagebox.r ("Click to end program!","End of Program")
37
38
End ''AIRCRAFT
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Routine READ.APPROACH.DATA
Define .CP as a pointer variable
Open unit 10 for input, name = "CHECKPT.DAT"
Use unit 10 for input
While mode is not alpha
Do
Create a CHECK.POINT called .CP
Read CHK.X(.CP),
CHK.Y(.CP)
File .CP in the APPROACH
Loop ''mode is not alpha do
Close unit 10
End ''READ.APPROACH.DATA
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-4
1
2
3
4
5
6
7
8
9
10
11
Routine SET.GRAPHICS
Let timescale.v = 300
''
Set up a display view port
Let vxform.v = ..DISPLAY.VIEW.PORT
Call setworld.r (-11, 11, -11, 11)
Call setview.r (1000, 32000, 1000, 32000)
End ''SET.GRAPHICS
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Routine VECTOR
Given
.X1,
.Y1,
.X2,
.Y2,
.SPEED
Yielding
.TIME,
.DIRECTION
''Coordinates of first point
''Coordinates of second point
''Speed of object
''Time to go from first to second point
''Direction from first to second point (radians)
Define .X1, .Y1,
.X2, .Y2,
.DELTA.X, .DELTA.Y,
.SPEED,
.TIME,
.DIRECTION
as real variables
Let
Let
Let
Let
.DELTA.X = .X2 - .X1
.DELTA.Y = .Y2 - .Y1
.TIME = sqrt.f(.DELTA.X ** 2 + .DELTA.Y ** 2) / .SPEED
.DIRECTION = arctan.f(.DELTA.Y, .DELTA.X)
End ''VECTOR
—————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————
Ex10-6