In the print dialog, choose "Save as PDF" as the destination.
Modeling and Simulation, Lab 1
Turn probabilities into random-number intervals, then build a simulation table one customer at a time.
max(), the first customer, unitsFrom lecture 1
Part 1
From a probability table to random-number intervals
00 to 99, as many numbers as its probability in percentYour turn: add up 0.10, 0.18, 0.22, 0.16, then turn each sum into an interval
| Time | Probability | Cumulative | Interval |
|---|---|---|---|
| 1 | 0.10 | 0.10 | 00 - 09 |
| 2 | 0.18 | 0.28 | 10 - 27 |
| 3 | 0.22 | 0.50 | 28 - 49 |
| 4 | 0.16 | 0.66 | 50 - 65 |
Keep adding from 0.66: 0.14, 0.10, 0.05, 0.05
| Time | Probability | Cumulative | Interval |
|---|---|---|---|
| 5 | 0.14 | 0.80 | 66 - 79 |
| 6 | 0.10 | 0.90 | 80 - 89 |
| 7 | 0.05 | 0.95 | 90 - 94 |
| 8 | 0.05 | 1.00 | 95 - 99 |
2: previous cumulative 0.10, this cumulative 0.28 gives 10 - 273: previous 0.28, this 0.50 gives 28 - 4999, a quick check that nothing is lostQ1 inter-arrival times 1 to 10: ten values share 100 numbers, 10 each
| Inter-arrival | Interval | Inter-arrival | Interval |
|---|---|---|---|
| 1 | 00 - 09 | 6 | 50 - 59 |
| 2 | 10 - 19 | 7 | 60 - 69 |
| 3 | 20 - 29 | 8 | 70 - 79 |
| 4 | 30 - 39 | 9 | 80 - 89 |
| 5 | 40 - 49 | 10 | 90 - 99 |
Q1 service-time table: 84, 27, 28, 50, 95
| Random number | Interval | Service time |
|---|---|---|
| 84 | 80 - 89 | 6 |
| 27 | 10 - 27 | 2 |
| 28 | 28 - 49 | 3 |
| 50 | 50 - 65 | 4 |
| 95 | 95 - 99 | 8 |
Part 2
One row per customer, one formula per column
Random number 1
interval lookup
Inter-arrival
Arrival time
Random number 2
interval lookup
Service time
Start
later of arrival and previous end
End
Wait, system, idle
| Column | Server already free | Server still busy |
|---|---|---|
| Arrival | after the previous end | before the previous end |
| Start | the arrival | the previous end |
| Wait | 0 | previous end minus arrival, above 0 |
| Idle | arrival minus previous end, above 0 | 0 |
Part 3
Q1 grocery store, Q2 dentist clinic, Q3 factory
Exercise 1
0.10, 0.18, 0.22, 0.16, 0.14, 0.10, 0.05, 0.0592, 73, 02, 95, 31, 92, 75, 24, 23, 3084, 10, 74, 53, 17, 79, 91, 67, 89, 38Intervals from Part 1. RN 1: 92, 73, 02, 95, 31; RN 2: 84, 10, 74, 53, 17
| Customer | Inter-arrival (RN 1) | Service (RN 2) |
|---|---|---|
| 1 | 10 (92) | 6 (84) |
| 2 | 8 (73) | 2 (10) |
| 3 | 1 (02) | 5 (74) |
| 4 | 10 (95) | 4 (53) |
| 5 | 4 (31) | 2 (17) |
RN 1: 92, 75, 24, 23, 30; RN 2: 79, 91, 67, 89, 38
| Customer | Inter-arrival (RN 1) | Service (RN 2) |
|---|---|---|
| 6 | 10 (92) | 5 (79) |
| 7 | 8 (75) | 7 (91) |
| 8 | 3 (24) | 5 (67) |
| 9 | 3 (23) | 6 (89) |
| 10 | 4 (30) | 3 (38) |
Inter-arrival 10, service 6, nobody ahead
| Column | Working | Value |
|---|---|---|
| Arrival | 0 + 10 | 10 |
| Start | server free | 10 |
| End | 10 + 6 | 16 |
| Wait | 10 - 10 | 0 |
| System | 16 - 10 | 6 |
Inter-arrival 8, service 2, previous end 16
| Column | Working | Value |
|---|---|---|
| Arrival | 10 + 8 | 18 |
| Start | max(18, 16) | 18 |
| End | 18 + 2 | 20 |
| Wait | 18 - 18 | 0 |
| Idle | 18 - 16 | 2 |
Inter-arrival 1, service 5, previous end 20
| Column | Working | Value |
|---|---|---|
| Arrival | 18 + 1 | 19 |
| Start | max(19, 20) | 20 |
| End | 20 + 5 | 25 |
| Wait | 20 - 19 | 1 |
| Idle | 20 - 20 | 0 |
Your turn: find each arrival, then compare it with the previous end
| Customer | Arrival | Previous end | Idle |
|---|---|---|---|
| 4 | 19 + 10 = 29 | 25 | 4 |
| 5 | 29 + 4 = 33 | 33 | 0 |
| 6 | 33 + 10 = 43 | 35 | 8 |
| 7 | 43 + 8 = 51 | 48 | 3 |
Short inter-arrival times 3, 3, 4 against service times 5, 6, 3
| Customer | Arrival | Start (previous end) | Wait |
|---|---|---|---|
| 8 | 54 | 58 | 4 |
| 9 | 57 | 63 | 6 |
| 10 | 61 | 69 | 8 |
| Customer | Wait | Time in system | Idle |
|---|---|---|---|
| 1 | 0 | 6 | 0 |
| 2 | 0 | 2 | 2 |
| 3 | 1 | 6 | 0 |
| 4 | 0 | 4 | 4 |
| 5 | 0 | 2 | 0 |
| Customer | Wait | Time in system | Idle |
|---|---|---|---|
| 6 | 0 | 5 | 8 |
| 7 | 0 | 7 | 3 |
| 8 | 4 | 9 | 0 |
| 9 | 6 | 12 | 0 |
| 10 | 8 | 11 | 0 |
Predict first: out of 10 customers, how long does an average customer wait?
Your turn: find the average service time, then add it to the average wait
From lecture 2
72 min72 - 45 = 27 minYour turn: divide the busy time by the length of the run
Exercise 1
6 patients by appointment: the first at 8:00, then one every 45 minutes
| Service | Service time | Probability |
|---|---|---|
| Filling | 45 min | 0.40 |
| Crown | 60 min | 0.15 |
| Cleaning | 20 min | 0.15 |
| Extraction | 45 min | 0.10 |
| Checkup | 15 min | 0.20 |
Keep the table's order, Filling first. Cumulative: 0.40, 0.55, 0.70, 0.80, 1.00
| Service | Interval | Random numbers | Patients |
|---|---|---|---|
| Filling | 00 - 39 | 11, 34, 25 | 3, 4, 5 |
| Crown | 40 - 54 | 40 | 1 |
| Cleaning | 55 - 69 | 66 | 6 |
| Extraction | 70 - 79 | none | none |
| Checkup | 80 - 99 | 82 | 2 |
Patient 1: crown, 60 min. Patient 2: checkup, 15 min
| Column | Patient 1 | Patient 2 |
|---|---|---|
| Arrival | 8:00 | 8:45 |
| Start | 8:00, dentist free | 9:00, after patient 1 |
| End | 9:00 | 9:15 |
| Wait | 0 | 9:00 - 8:45 = 15 |
Your turn: compare each arrival with the previous end
| Patient | Arrival and start | Service | End |
|---|---|---|---|
| 3 | 9:30 | 45 | 10:15 |
| 4 | 10:15 | 45 | 11:00 |
| 5 | 11:00 | 45 | 11:45 |
| 6 | 11:45 | 20 | 12:05 |
Your turn: add the waits of all the patients (6), then divide by 6
Exercise 1
Find the average units produced and the average vehicles available per day, over 10 days
| Units Xi | P(x = Xi) | Vehicles Yi | P(y = Yi) |
|---|---|---|---|
| 500 | 0.05 | 5 | 0.15 |
| 550 | 0.15 | 6 | 0.35 |
| 600 | 0.25 | 7 | 0.20 |
| 650 | 0.35 | 8 | 0.18 |
| 700 | 0.20 | 9 | 0.12 |
Cumulative: units 0.05, 0.20, 0.45, 0.80, 1.00; vehicles 0.15, 0.50, 0.70, 0.88, 1.00
| Units | Interval | Vehicles | Interval |
|---|---|---|---|
| 500 | 00 - 04 | 5 | 00 - 14 |
| 550 | 05 - 19 | 6 | 15 - 49 |
| 600 | 20 - 44 | 7 | 50 - 69 |
| 650 | 45 - 79 | 8 | 70 - 87 |
| 700 | 80 - 99 | 9 | 88 - 99 |
Units RN 91, 73, 02, 95, 31; vehicles RN 84, 10, 74, 53, 17
| Day | Units (RN 1) | Vehicles (RN 2) |
|---|---|---|
| 1 | 700 (91) | 8 (84) |
| 2 | 650 (73) | 5 (10) |
| 3 | 500 (02) | 8 (74) |
| 4 | 700 (95) | 7 (53) |
| 5 | 600 (31) | 6 (17) |
Units RN 93, 75, 24, 23, 30; vehicles RN 79, 91, 67, 89, 38
| Day | Units (RN 1) | Vehicles (RN 2) |
|---|---|---|
| 6 | 700 (93) | 8 (79) |
| 7 | 650 (75) | 9 (91) |
| 8 | 600 (24) | 7 (67) |
| 9 | 600 (23) | 9 (89) |
| 10 | 600 (30) | 6 (38) |
Part 4
Where marks are lost, and how to check yourself
0.28 ends at 27, not 2800 is the first number and 99 the last; there are 100 numbers, not 990 with no random number; in Q1 customer 1 arrives after the first inter-arrival time (10)0 for customer 1; say clearly if you count the gap from 08:45 + 1:00 = 9:45 (60 minutes added), and waiting times are in minutes, not clock times990Part 5
About 30 minutes. Answers follow each problem.
About 15 minutes
0.10, 0.25, 0.30, 0.20, 0.1585, 19, 98, 44, 53, 79, 52, 9164, 99, 70, 09, 60, 05, 56, 77| Time | Inter-arrival interval | Service cumulative | Service interval |
|---|---|---|---|
| 1 | 00 - 19 | 0.10 | 00 - 09 |
| 2 | 20 - 39 | 0.35 | 10 - 34 |
| 3 | 40 - 59 | 0.65 | 35 - 64 |
| 4 | 60 - 79 | 0.85 | 65 - 84 |
| 5 | 80 - 99 | 1.00 | 85 - 99 |
| Customer | Arrival | Start | End |
|---|---|---|---|
| 1 | 5 | 5 | 8 |
| 2 | 6 | 8 | 13 |
| 3 | 11 | 13 | 17 |
| 4 | 14 | 17 | 18 |
| Customer | Arrival | Start | End |
|---|---|---|---|
| 5 | 17 | 18 | 21 |
| 6 | 21 | 21 | 22 |
| 7 | 24 | 24 | 27 |
| 8 | 29 | 29 | 33 |
Your turn: find the average service time, then add it to the average wait
About 10 minutes
6 cars by appointment: the first at 9:00, then one every 40 minutes
| Service | Service time | Probability |
|---|---|---|
| Oil change | 20 min | 0.35 |
| Tire change | 30 min | 0.30 |
| Brake repair | 50 min | 0.20 |
| Full service | 70 min | 0.15 |
| Service | Cumulative | Interval |
|---|---|---|
| Oil change | 0.35 | 00 - 34 |
| Tire change | 0.65 | 35 - 64 |
| Brake repair | 0.85 | 65 - 84 |
| Full service | 1.00 | 85 - 99 |
| Car | Service | Start | Idle before |
|---|---|---|---|
| 1 | Tire change, 30 min | 9:00 | 0 |
| 2 | Oil change, 20 min | 9:40 | 10 |
| 3 | Full service, 70 min | 10:20 | 20 |
| Car | Service | Start | Wait |
|---|---|---|---|
| 4 | Oil change, 20 min | 11:30 | 30 |
| 5 | Brake repair, 50 min | 11:50 | 10 |
| 6 | Full service, 70 min | 12:40 | 20 |
| Total | 60 |
About 8 minutes
Find the average orders per day and the average drivers available per day, over 8 days
| Orders Xi | P(x = Xi) | Drivers Yi | P(y = Yi) |
|---|---|---|---|
| 20 | 0.10 | 2 | 0.25 |
| 30 | 0.40 | 3 | 0.45 |
| 40 | 0.30 | 4 | 0.20 |
| 50 | 0.20 | 5 | 0.10 |
| Orders | Interval | Drivers | Interval |
|---|---|---|---|
| 20 | 00 - 09 | 2 | 00 - 24 |
| 30 | 10 - 49 | 3 | 25 - 69 |
| 40 | 50 - 79 | 4 | 70 - 89 |
| 50 | 80 - 99 | 5 | 90 - 99 |
| Day | Orders (RN 1) | Drivers (RN 2) |
|---|---|---|
| 1 | 20 (09) | 4 (70) |
| 2 | 40 (55) | 2 (24) |
| 3 | 30 (10) | 5 (95) |
| 4 | 50 (89) | 3 (25) |
| 5 | 30 (49) | 3 (69) |
| Day | Orders (RN 1) | Drivers (RN 2) |
|---|---|---|
| 6 | 50 (80) | 5 (90) |
| 7 | 40 (50) | 2 (00) |
| 8 | 30 (26) | 4 (89) |
| Total | 290 | 28 |
99T(i) = T(i-1) + A(i) and B(i) = max(T(i), E(i-1))D(i) = B(i) - T(i), W(i) = E(i) - T(i), I(i) = B(i) - E(i-1)Mahmoud Abas|Simulation Tables by Hand