Skip to content

Commit 7a1b582

Browse files
committed
fix(model): begin interval audit at start of data collection period (rather than start of warm-up period) (plus re-run notebooks)
1 parent 5c6b461 commit 7a1b582

File tree

6 files changed

+103
-84
lines changed

6 files changed

+103
-84
lines changed

notebooks/analysis.ipynb

Lines changed: 76 additions & 75 deletions
Large diffs are not rendered by default.

notebooks/choosing_parameters.ipynb

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.
3.46 KB
Loading
4.46 KB
Loading

simulation/model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ def attend_clinic(self, patient):
521521
def interval_audit(self, interval):
522522
"""
523523
Audit waiting times and resource utilisation at regular intervals.
524+
This is set-up to start when the warm-up period has ended.
524525
525526
The running mean wait time is calculated using Welford's Running
526527
Average, which is a method that avoids the need to store previous wait
@@ -531,6 +532,10 @@ def interval_audit(self, interval):
531532
interval (int, optional):
532533
Time between audits in minutes.
533534
"""
535+
# Wait until warm-up period has passed
536+
yield self.env.timeout(self.param.warm_up_period)
537+
538+
# Begin interval auditor
534539
while True:
535540
self.audit_list.append({
536541
'resource_name': 'nurse',

tests/test_unittest_model.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,17 @@ def helper_warmup(warm_up_period):
221221
)
222222

223223
# Check that the first interval audit entry with no warm-up has time and
224-
# results of 0
224+
# no queue or wait time. However, as our first patient arrives at time 0,
225+
# we do expect to have utilisation over 0.
225226
first_interval = results_none['interval_audit'].iloc[0]
226227
assert first_interval['simulation_time'] == 0, (
227228
'With no warm-up, expect first entry in interval audit to be ' +
228229
f'at time 0, but it was at time {first_interval['simulation_time']}.'
229230
)
230-
assert first_interval['utilisation'] == 0, (
231+
assert first_interval['utilisation'] > 0, (
231232
'With no warm-up, expect first entry in interval audit to ' +
232-
f'have 0 utilisation, but it was {first_interval['utilisation']}.'
233+
'have utilisation greater than 0 (as first patient arrives at time ' +
234+
f'0), but utilisation was {first_interval['utilisation']}.'
233235
)
234236
assert first_interval['queue_length'] == 0, (
235237
'With no warm-up, expect first entry in interval audit to ' +
@@ -242,6 +244,16 @@ def helper_warmup(warm_up_period):
242244
f'{first_interval['running_mean_wait_time']}.'
243245
)
244246

247+
# Check that first interval audit entry with a warm-up has time 500
248+
# (matching length of warm-up period) - and so ensuring the first entry
249+
# in the interval audit, which occurs at the end of the warm-up period,
250+
# has not been deleted.
251+
first_interval_warmup = results_warmup['interval_audit'].iloc[0]
252+
assert first_interval_warmup['simulation_time'] == 500, (
253+
'With warm-up of 500, expect first entry in interval audit to be ' +
254+
f'at time 500, but it was at time {first_interval['simulation_time']}.'
255+
)
256+
245257

246258
def test_arrivals():
247259
"""

0 commit comments

Comments
 (0)