1 / 51

Day 1, Section 2 Problem Solution C:\Program Files\Simscript3\models\Heath2

Day 1, Section 2 Problem Solution C:Program FilesSimscript3modelsHeath2. 1 Preamble 2 3 '' Entities, Attributes, & Sets Problem - CACI Products Company 4 '' Solution to Student Problem F 5 '' HEATH1.SRC, WESTAPR.DAT 6

lucus
Télécharger la présentation

Day 1, Section 2 Problem Solution C:\Program Files\Simscript3\models\Heath2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Day 1, Section 2 Problem SolutionC:\Program Files\Simscript3\models\Heath2 1 Preamble 2 3 '' Entities, Attributes, & Sets Problem - CACI Products Company 4 '' Solution to Student Problem F 5 '' HEATH1.SRC, WESTAPR.DAT 6 7 Normally mode is undefined 8 9 Permanent entities 10 11 Every APPROACH has 12 an APP.NAME and 13 owns a CHECK.POINT.SET 14 15 Define APP.NAME as a text variable 16 17 Temporary entities 18 19 Every CHECK.POINT has 20 a CK.NBR, 21 a CK.X, 22 a CK.Y and 23 belongs to a CHECK.POINT.SET 24 25 Define CK.NBR, 26 CK.X, 27 CK.Y as integer variables 28 29 End ''Preamble Ex2-1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  2. 1 Main 2 3 Call READ.APPROACHES 4 Call PRINT.APPROACHES 5 6 Read as / using unit 5 7 8 End ''Main Ex2-2 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  3. 1 Routine READ.APPROACHES 2 3 Define .APR, 4 .NBR.APPROACHES as integer variables 5 6 Define .CP as a pointer variable 7 8 '' Open the file 9 10 Open unit 11 for input, name = "WESTAPR.DAT" 11 Use unit 11 for input 12 13 '' Skip the comments at the top 14 15 While mode is alpha 16 Do 17 Start new record 18 Loop ''mode is alpha 19 20 '' Read the number of approaches, start a new record 21 '' and create the approaches 22 23 Read .NBR.APPROACHES 24 Start new record 25 26 Create every APPROACH(.NBR.APPROACHES) 27 Ex2-3 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  4. 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 ——————————————

  5. 1 Routine PRINT.APPROACHES 2 3 Define .CP as a pointer variable 4 5 '' Print column headings 6 7 Skip 5 lines 8 9 Print 3 lines thus Check Point X Y ----- ----- ----- 13 Skip 1 line 14 15 '' Print the approach name and the data on each check point 16 17 For each APPROACH 18 Do 19 20 Print 1 line with APP.NAME(APPROACH) thus *********************** 22 23 For each .CP in the CHECK.POINT.SET(APPROACH) do 24 Print 1 line with CK.NBR(.CP), 25 CK.X(.CP), 26 CK.Y(.CP) thus ** ***.* ***.* 28 Loop ''each .CP in the CHECK.POINT.SET(APPROACH) 29 30 Skip 1 line 31 32 Loop ''each APPROACH 33 34 End ''PRINT.APPROACHES Ex2-4 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  6. Output Check Point X Y ----- ----- ----- Polar 6 0. 20.0 5 10.0 15.0 4 10.0 10.0 3 13.0 10.0 2 16.0 14.0 1 20.0 14.0 Western 7 0. 9.0 5 10.0 15.0 4 10.0 10.0 3 13.0 10.0 2 16.0 14.0 1 20.0 14.0 Check Point X Y ----- ----- ----- Southern 8 10.0 0. 5 10.0 15.0 4 10.0 10.0 3 13.0 10.0 2 16.0 14.0 1 20.0 14.0 Continental 10 15.0 5.0 9 20.0 2.0 5 10.0 15.0 4 10.0 10.0 3 13.0 10.0 2 16.0 14.0 1 20.0 14.0 Ex2-5 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  7. This page is intentionally blank Ex2-6 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  8. PORT.DAT Input File Day 2, Section 4 Problem SolutionC:\Program Files\Simscript3\models\AnswerB NUMBER OF TUGS: 1 NUMBER OF DOCKS: 3 RUN LENGTH (DAYS): 365 Ex4-3 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  9. 1 Preamble 2 3 '' Pacific Port Problem - CACI Products Company 4 '' Solution to Student Problem B 5 '' files: ANSWERB.SRC, PORT.DAT 6 7 Normally mode is undefined 8 9 Processes include 10 GENERATOR, 11 SHIP and 12 REPORT 13 14 Resources include 15 DOCK and 16 TUG 17 18 '' Input global variables 19 20 Define RUN.LENGTH as a real variable 21 Define NBR.DOCKS and NBR.TUGS as integer variables 22 23 '' Output global variables 24 25 Define WAITING.TIME as a real variable 26 Define TOTAL.WAITING.TIME and MAX.WAITING.TIME as real variables 27 Define NO.OF.SHIPS.SERVED as an integer variable 28 29 End ''Preamble Ex4-1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  10. 1 Main 2 3 Call INITIALIZE 4 5 Activate a GENERATOR now 6 Activate a REPORT in RUN.LENGTH days 7 8 Start simulation 9 10 Read as / using unit 5 11 12 End 1 Routine INITIALIZE 2 3 Open unit 10 for input, name = "PORT.DAT" 4 Use unit 10 for input 5 6 Skip 3 fields 7 Read NBR.TUGS 8 9 Skip 3 fields 10 Read NBR.DOCKS 11 12 Skip 3 fields 13 Read RUN.LENGTH 14 15 Close unit 10 16 17 Create every TUG(1) 18 Let U.TUG(1) = NBR.TUGS 19 Create every DOCK(1) 20 Let U.DOCK(1) = NBR.DOCKS 21 22 End ''INITIALIZE Ex4-2 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  11. 1 Process GENERATOR 2 3 Until time.v >= RUN.LENGTH 4 Do 5 Activate a SHIP now 6 Wait uniform.f(4.0, 18.0, 1) hours 7 Loop ''time.v >= RUN.LENGTH do 8 9 End ''GENERATOR Ex4-4 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  12. 1 Process SHIP 2 3 Define .ARRIVAL.TIME, 4 .UNLOAD.TIME and 5 .PROBABILITY 6 as real variables 7 8 Let .PROBABILITY = random.f(2) 9 Select case .PROBABILITY 10 Case 0.0 to .25 11 Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3) 12 Case .25 to .80 13 Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3) 14 Default 15 Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3) 16 Endselect ''.PROBABILITY 17 18 Let .ARRIVAL.TIME = time.v 19 20 Request 1 DOCK(1) 21 Request 1 TUG(1) 22 Wait 1.0 hour 23 Relinquish 1 TUG(1) 24 25 Work .UNLOAD.TIME hours 26 27 Request 1 TUG(1) 28 Wait 1.0 hour 29 Relinquish 1 TUG(1) 30 Relinquish 1 DOCK(1) 31 32 Add 1 to NO.OF.SHIPS.SERVED 33 Let WAITING.TIME = (time.v - .ARRIVAL.TIME) * hours.v - .UNLOAD.TIME 34 Add WAITING.TIME to TOTAL.WAITING.TIME 35 Let MAX.WAITING.TIME = max.f(WAITING.TIME, MAX.WAITING.TIME) 36 37 End ''SHIP Ex4-5 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  13. 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 **.** hours The maximum waiting time was **.** hours 20 21 Skip 2 lines 22 23 End ''REPORT Ex4-6 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  14. 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 4.01 hours The maximum waiting time was 34.00 hours Ex4-7 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  15. See C:\Program Files\Simscript3\models\ProblemRfor same model using multiple replications Ex4-8 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  16. Day 3, Section 6 Problem SolutionC:\Program Files\Simscript3\models\AnswerC 1 Preamble 2 3 '' Pacific Port Problem - CACI Products Company 4 '' Solution to Student Problem C 5 '' files: PROBLEMC.SRC, PORT.DAT, WAIT.GRF 6 7 Normally mode is undefined 8 9 Processes include 10 GENERATOR, 11 SHIP and 12 REPORT 13 14 Every SHIP has 15 a SHIP.TYPE 16 17 Define SHIP.TYPE as an integer variable 18 19 Define ..OLD.SHIP to mean 1 20 Define ..NEW.SHIP to mean 2 21 22 Resources include 23 DOCK and 24 TUG 25 26 '' Input global variables 27 28 Define RUN.LENGTH as a real variable 29 Define NBR.DOCKS, NBR.TUGS, NBR.NEW.SHIPS as integer variables Ex6-1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  17. 30 31 '' Internal global variables 32 33 Define DOCKS.IN.USE as an integer variable 34 Define IN.PORT.TIME as a real variable 35 36 '' Output global variables 37 38 Define WAITING.TIME as a real variable 39 40 '' Statistics 41 42 Accumulate AVG.DOCK.QUEUE as the average and 43 MAX.DOCK.QUEUE as the maximum 44 of N.Q.DOCK 45 46 Accumulate DOCK.UTILIZATION as the average of DOCKS.IN.USE 47 48 Accumulate AVG.TUG.QUEUE as the average and 49 MAX.TUG.QUEUE as the maximum 50 of N.Q.TUG 51 52 Accumulate TUG.UTILIZATION as the average of N.X.TUG 53 54 Tally AVG.IN.PORT.TIME as the average, 55 MAX.IN.PORT.TIME as the maximum and 56 NO.OF.SHIPS.SERVED as the number 57 of IN.PORT.TIME 58 59 Tally AVG.SHIP.DELAY as the average and 60 MAX.SHIP.DELAY as the maximum of WAITING.TIME Ex6-2 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  18. 61 62 ''------------------------------------------------------------------------ 63 64 Processes include 65 GRAPHICS.DISPLAY 66 67 '' Internal global variables 68 69 Define WLO, 70 WHI and 71 WDELTA 72 as integer variables 73 74 '' Statistics 75 76 Tally WAITING.TIME.HISTOGRAM(WLO to WHI by WDELTA) 77 as the histogram of WAITING.TIME 78 79 End ''Preamble Ex6-3 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  19. 1 Main 2 3 Call INITIALIZE 4 5 Activate a GENERATOR now 6 Activate a GRAPHICS.DISPLAY now 7 Activate a REPORT in RUN.LENGTH days 8 9 Start simulation 10 11 Read as / using unit 5 12 13 End 1 Process GENERATOR 2 3 Define .I as an integer variable 4 5 For .I = 1 to NBR.NEW.SHIPS 6 Do 7 Activate a SHIP in uniform.f (0, 10, 4) days 8 LET SHIP.TYPE(SHIP) = ..NEW.SHIP 9 Loop 10 11 Until time.v > = RUN.LENGTH 12 Do 13 Activate a SHIP now 14 Let SHIP.TYPE(SHIP) = ..OLD.SHIP 15 Wait uniform.f(4.0, 18.0, 1) hours 16 Loop ''time.v > = RUN.LENGTH 17 18 End ''GENERATOR Ex6-4 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  20. 1 Process SHIP 2 3 Define .UNLOAD.TIME and 4 .PROBABILITY 5 as real variables 6 7 If SHIP.TYPE(SHIP) = ..OLD.SHIP 8 9 Let .PROBABILITY = random.f(2) 10 Select case .PROBABILITY 11 Case 0.0 to .25 12 Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3) 13 Case .25 to .80 14 Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3) 15 Default 16 Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3) 17 Endselect ''.PROBABILITY 18 19 Call HARBOR.OPERATIONS 20 giving .UNLOAD.TIME 21 22 Else 23 24 Until time.v > RUN.LENGTH 25 Do 26 Let .UNLOAD.TIME = exponential.f (21, 5) 27 Call HARBOR.OPERATIONS 28 giving .UNLOAD.TIME 29 Wait normal.f (10, 1, 6) days 30 Loop 31 32 Endif 33 34 End ''SHIP Ex6-5 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  21. 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 Request 1 DOCK(1) 9 Request 1 TUG(1) 10 11 Wait 1.0 hour 12 13 Relinquish 1 TUG(1) 14 15 Add 1 to DOCKS.IN.USE 16 Work .UNLOAD.TIME hours 17 Subtract 1 from DOCKS.IN.USE 18 19 Request 1 TUG(1) 20 21 Wait 1.0 hour 22 23 Relinquish 1 TUG(1) 24 Relinquish 1 DOCK(1) 25 26 Let IN.PORT.TIME = (time.v - .ARRIVAL.TIME) * hours.v 27 Let WAITING.TIME = IN.PORT.TIME - .UNLOAD.TIME 28 29 End ''HARBOR.OPERATIONS Ex6-6 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  22. 1 Process GRAPHICS.DISPLAY 2 3 '' Display the histogram immediately 4 Display histogram WAITING.TIME.HISTOGRAM with "WAIT.GRF" 5 6 '' Display the histogram every 50 days 7 Until time.v >= RUN.LENGTH 8 Do 9 Wait 50 days 10 Display histogram WAITING.TIME.HISTOGRAM 11 Loop ''time.v >= RUN.LENGTH do 12 13 '' Display the histogram one last time 14 15 Display histogram WAITING.TIME.HISTOGRAM 16 17 End ''GRAPHICS.DISPLAY Ex6-7 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  23. 1 Routine INITIALIZE 2 3 Open unit 10 for input, name = "PORT.DAT" 4 Use unit 10 for input 5 6 Skip 3 fields 7 Read NBR.TUGS 8 9 Skip 3 fields 10 Read NBR.DOCKS 11 12 Skip 3 fields 13 Read RUN.LENGTH 14 15 Skip 3 fields 16 Read NBR.NEW.SHIPS 17 18 Close unit 10 19 20 Create every TUG(1) 21 Let U.TUG(1) = NBR.TUGS 22 Create every DOCK(1) 23 Let U.DOCK(1) = NBR.DOCKS 24 25 Show WAITING.TIME.HISTOGRAM with "WAIT.GRF" 26 27 End ''INITIALIZE Ex6-8 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  24. 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 Ex6-9 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  25. 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 Ex6-10 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  26. 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 2.98 ships. The maximum queue for the dock was 13 ships. The tug utilization was 21.4 %. The average queue for the tug was .02 ships. The maximum queue for the tug was 2 ships. Ex6-11 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  27. This page is intentionally blank. Ex6-12 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  28. Day 4, Section 8 Problem SolutionC:\Program Files\Simscript3\models\AnswerD 1 Preamble 2 3 '' Pacific Port Problem - CACI Products Company 4 '' Solution to Student Problem D 5 '' files: ANSWERD.SRC, INPUT.FRM, WAIT.GRF, WEATHER.DAT 6 7 Normally mode is undefined 8 9 Processes include 10 GENERATOR, 11 SHIP and 12 REPORT 13 14 Every SHIP has 15 a SHIP.TYPE, 16 a SHIP.STATUS and 17 belongs to the FLEET 18 19 Define SHIP.STATUS, 20 SHIP.TYPE as integer variables 21 22 The system owns the FLEET 23 24 External Processes include 25 STORM 26 27 External process unit is 10 28 Ex8-1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  29. 29 Resources include 30 DOCK, 31 TUG and 32 PERMIT 33 34 Define ..OLD.SHIP to mean 1 35 Define ..NEW.SHIP to mean 2 36 37 Define ..AT.SEA to mean 1 38 Define ..IN.HARBOR to mean 2 39 40 Define ..TO.DEPART to mean 1 41 42 '' Input global variables 43 44 Define RUN.LENGTH as a real variable 45 Define NBR.DOCKS, NBR.TUGS, NBR.NEW.SHIPS as integer variables 46 47 '' Internal global variables 48 49 Define DOCKS.IN.USE as an integer variable 50 Define IN.PORT.TIME as a real variable 51 52 '' Output global variables 53 54 Define WAITING.TIME as a real variable 55 56 '' Statistics 57 Ex8-2 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  30. 58 Accumulate AVG.DOCK.QUEUE as the average and 59 MAX.DOCK.QUEUE as the maximum 60 of N.Q.DOCK 61 62 Accumulate DOCK.UTILIZATION as the average of DOCKS.IN.USE 63 64 Accumulate AVG.TUG.QUEUE as the average and 65 MAX.TUG.QUEUE as the maximum 66 of N.Q.TUG 67 68 Accumulate TUG.UTILIZATION as the average of N.X.TUG 69 70 Tally AVG.IN.PORT.TIME as the average, 71 MAX.IN.PORT.TIME as the maximum and 72 NO.OF.SHIPS.SERVED as the number 73 of IN.PORT.TIME 74 75 Tally AVG.SHIP.DELAY as the average and 76 MAX.SHIP.DELAY as the maximum of WAITING.TIME 77 Ex8-3 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  31. 78 ''------------------------------------------------------------------------ 79 80 Processes include 81 GRAPHICS.DISPLAY 82 83 '' Internal global variables 84 85 Define WLO, 86 WHI and 87 WDELTA 88 as integer variables 89 90 '' Statistics 91 92 Tally WAITING.TIME.HISTOGRAM(WLO to WHI by WDELTA) 93 as the histogram of WAITING.TIME 94 95 End ''Preamble Ex8-4 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  32. 1 Main 2 3 Call INITIALIZE 4 5 Activate a GENERATOR now 6 Activate a GRAPHICS.DISPLAY now 7 Activate a REPORT in RUN.LENGTH days 8 9 Start simulation 10 11 Read as / using unit 5 12 13 End Ex8-5 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  33. 1 Process GENERATOR 2 3 Define .I as an integer variable 4 5 For .I = 1 to NBR.NEW.SHIPS 6 Do 7 Activate a SHIP in uniform.f (0, 10, 4) days 8 LET SHIP.TYPE(SHIP) = ..NEW.SHIP 9Let SHIP.STATUS(SHIP) = ..AT.SEA 10 File this SHIP in the FLEET 11 Loop 12 13 Until time.v > = RUN.LENGTH 14 Do 15 Activate a SHIP now 16 Let SHIP.TYPE(SHIP) = ..OLD.SHIP 17 Let SHIP.STATUS(SHIP) = ..IN.HARBOR 18 Wait uniform.f(4.0, 18.0, 1) hours 19 Loop ''time.v > = RUN.LENGTH 20 21 End ''GENERATOR —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  34. 1 Process SHIP 2 3 Define .UNLOAD.TIME and 4 .PROBABILITY 5 as real variables 6 7 If SHIP.TYPE(SHIP) = ..OLD.SHIP 8 9 Let .PROBABILITY = random.f(2) 10 Select case .PROBABILITY 11 Case 0.0 to .25 12 Let .UNLOAD.TIME = uniform.f(16.0, 20.0, 3) 13 Case .25 to .80 14 Let .UNLOAD.TIME = uniform.f(21.0, 27.0, 3) 15 Default 16 Let .UNLOAD.TIME = uniform.f(32.0, 40.0, 3) 17 Endselect ''.PROBABILITY 18 19 Call HARBOR.OPERATIONS 20 giving .UNLOAD.TIME 21 22 Else 23 24 Until time.v > RUN.LENGTH 25 Do 26 Let .UNLOAD.TIME = exponential.f (21, 5) 27 Call HARBOR.OPERATIONS 28 giving .UNLOAD.TIME 29 Wait normal.f (10, 1, 6) days 30 Loop 31 32Remove this SHIP from the FLEET 33 34 Endif 35 36 End ''SHIP Ex8-6 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  35. 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 8Let 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 30Relinquish 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 Ex8-7 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  36. 1 Process STORM 2 3 Define .DURATION as a real variable 4 5 Read .DURATION 6 7 Request 1 PERMIT(..TO.DEPART) 8 For each SHIP in FLEET 9 with SHIP.STATUS(SHIP) = ..AT.SEA 10 Do 11 Interrupt SHIP 12 Loop ''each SHIP in FLEET do 13 14 Wait .DURATION days 15 16 Relinquish 1 PERMIT(..TO.DEPART) 17 For each SHIP in FLEET 18 with SHIP.STATUS(SHIP) = ..AT.SEA 19 Do 20 Resume SHIP 21 Loop ''each SHIP in FLEET do 22 23 End ''STORM Ex8-8 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  37. 1 Routine INITIALIZE 2 3 Define .FORM as a pointer variable 4 Define .FIELD as a text variable 5 6 Open unit 10 for input, name = "WEATHER.DAT" 7 Call origin.r (1, 1, 2005) 8 9 '' Display the form and get run data from the user 10 11 Show .FORM with "INPUT.FRM" 12 Let .FIELD = accept.f(.FORM, 'FORM.CTRL') 13 14 '' Create the tug and docks 15 16 Create every TUG(1) 17 Let U.TUG(1) = NBR.TUGS 18 Create every DOCK(1) 19 Let U.DOCK(1) = NBR.DOCKS 20 21 Create every PERMIT(1) 22 Let U.PERMIT(..TO.DEPART) = 1 23 24 '' Warning elimination 25 26 Let .FIELD = .FIELD 27 28 End ''INITIALIZE Ex8-9 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  38. 1 Routine FORM.CTRL 2 3 Given 4 .FIELD, 5 .FORM 6 Yielding 7 .STATUS 8 9 '' Control routine for the input form 10 11 Define .FORM as a pointer variable 12 Define .FIELD as a text variable 13 Define .STATUS as an integer variable 14 15 Select case .FIELD 16 17 Case "RUN" 18 Let RUN.LENGTH = ddval.a(dfield.f("RUN LENGTH", .FORM)) 19 Let NBR.DOCKS = int.f(ddval.a(dfield.f("NBR DOCKS", .FORM))) 20 Let NBR.TUGS = int.f(ddval.a(dfield.f("NBR TUGS", .FORM))) 21 Let NBR.NEW.SHIPS = int.f(ddval.a(dfield.f("NBR NEW SHIPS", .FORM))) 22 Return 23 24 Case "QUIT" 25 Stop 26 27 Default 28 29 Endselect ''.FIELD 30 31 '' Warning elimination 32 33 Let .STATUS = .STATUS 34 35 End ''FORM.CTRL Ex8-10 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  39. 1 Process GRAPHICS.DISPLAY 2 3 '' Display the histogram immediately 4 Display histogram WAITING.TIME.HISTOGRAM with "WAIT" 5 6 '' Display the histogram every 50 days 7 Until time.v >= RUN.LENGTH 8 Do 9 Wait 50 days 10 Display histogram WAITING.TIME.HISTOGRAM 11 Loop ''time.v >= RUN.LENGTH do 12 13 '' Display the histogram one last time 14 15 Display histogram WAITING.TIME.HISTOGRAM 16 17 End ''GRAPHICS.DISPLAY Ex8-11 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  40. 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 Skip 1 line 9 10 Print 17 lines with time.v, 11 NO.OF.SHIPS.SERVED, 12 NBR.NEW.SHIPS, 13 AVG.SHIP.DELAY, 14 MAX.SHIP.DELAY, 15 AVG.IN.PORT.TIME, 16 MAX.IN.PORT.TIME, 17 (DOCK.UTILIZATION/NBR.DOCKS) * 100, 18 AVG.DOCK.QUEUE(1), 19 MAX.DOCK.QUEUE(1), 20 (TUG.UTILIZATION(1)/NBR.TUGS) * 100, 21 AVG.TUG.QUEUE(1) and 22 MAX.TUG.QUEUE(1) thus Ex8-12 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  41. 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 Ex8-13 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  42. 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 .17 ships. The maximum queue for the dock was 3 ships. The tug utilization was 18.1 %. The average queue for the tug was .01 ships. The maximum queue for the tug was 2 ships. Ex8-14 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  43. 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 2.83 ships. The maximum queue for the dock was 12 ships. The tug utilization was 21.3 %. The average queue for the tug was .02 ships. The maximum queue for the tug was 2 ships. Ex8-15 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  44. This page is intentionally blank. Ex8-16 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  45. Day 5, Section 10 Problem SolutionC:\Program Files\Simscript3\models\Lhwg 1 Preamble 2 3 '' Heathrow Airport Animation - CACI Products Company 4 '' Solution to Student Problem: HEATHROW 5 '' files: LHWG.SRC, ACFT.ICN, LHW.ICN, BOX.ICN, CHECKPT.DAT 6 7 Normally mode is undefined 8 9 Temporary entities include 10 MAP 11 12 Every CHECK.POINT has 13 a CHK.X, 14 a CHK.Y and 15 belongs to an APPROACH 16 17 Define CHK.X and 18 CHK.Y 19 as real variables 20 21 The system owns an APPROACH 22 Ex10-1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  46. 23 Graphic entities include 24 MAP 25 26 Processes include 27 AIRCRAFT 28 29 Dynamic graphic entities include 30 AIRCRAFT 31 32 Define ..DISPLAY.VIEW.PORT to mean 2 33 34 Define minute to mean units 35 Define minutes to mean units 36 37 End ''Preamble 1 Main 2 3 Call READ.APPROACH.DATA 4 Call SET.GRAPHICS 5 6 Create a MAP 7 Display MAP with "LHW.ICN" 8 9 Activate an AIRCRAFT now 10 Show AIRCRAFT with "ACFT.ICN" 11 12 Start simulation 13 14 End ''Main Ex10-2 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  47. 1 Process AIRCRAFT 2 3 Define .DIRECTION, 4 .SPEED and 5 .TIME 6 as real variables 7 8 Define .1ST.CP, 9 .CP 10 as pointer variables 11 12 Let .SPEED = 3 ''miles per minute or 180 knots 13 14 Let .1ST.CP = F.APPROACH 15 Let location.a(AIRCRAFT) = location.f(CHK.X(.1ST.CP),CHK.Y(.1ST.CP)) 16 17 For each .CP after .1ST.CP in the APPROACH do 18 Call VECTOR 19 Given 20 location.x(AIRCRAFT), location.y(AIRCRAFT), 21 CHK.X(.CP), CHK.Y(.CP), 22 .SPEED 23 Yielding 24 .TIME, 25 .DIRECTION 26 27 Let orientation.a(AIRCRAFT) = .DIRECTION 28 Let velocity.a(AIRCRAFT) = velocity.f(.SPEED, .DIRECTION) 29 30 Wait .TIME minutes 31 Ex10-3 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  48. 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 ——————————————

  49. 1 Routine READ.APPROACH.DATA 2 3 Define .CP as a pointer variable 4 5 Open unit 10 for input, name = "CHECKPT.DAT" 6 Use unit 10 for input 7 8 While mode is not alpha 9 Do 10 11 Create a CHECK.POINT called .CP 12 13 Read CHK.X(.CP), 14 CHK.Y(.CP) 15 16 File .CP in the APPROACH 17 18 Loop ''mode is not alpha do 19 20 Close unit 10 21 22 End ''READ.APPROACH.DATA Ex10-4 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

  50. 1 Routine SET.GRAPHICS 2 3 Let timescale.v = 300 4 5 '' Set up a display view port 6 7 Let vxform.v = ..DISPLAY.VIEW.PORT 8 Call setworld.r (-11, 11, -11, 11) 9 Call setview.r (1000, 32000, 1000, 32000) 10 11 End ''SET.GRAPHICS Ex10-5 —————————— CACI Products Company ———————————————————————————— SimScript II.5 ——————————————

More Related