Skip to content

Commit da16a9e

Browse files
committed
fix(model): resolved bug where first entry in patients and interval was erased when warmup was 0, and re-ran analysis with new script, which has minor differents in floating point of time-weighted now those are stored in list rather than summed live
1 parent 4f5a36a commit da16a9e

File tree

8 files changed

+163
-160
lines changed

8 files changed

+163
-160
lines changed

notebooks/analysis.ipynb

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

notebooks/choosing_parameters.ipynb

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.
-2.76 KB
Loading
-6.66 KB
Loading

outputs/example_overall.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
arrivals,mean_q_time_nurse,mean_time_with_nurse,mean_nurse_utilisation,mean_nurse_utilisation_tw,mean_nurse_q_length
2-
10776.741935483871,0.499036905566402,9.978456743390534,0.49767035119563796,0.497804034286856,0.12459850290556283
3-
115.80327218806197,0.06739346957542013,0.11513823236530764,0.007524465631261531,0.0075405891452702024,0.017212719807337778
4-
10734.264952313013,0.47431678135150124,9.936223698796068,0.4949103549196282,0.4950381238581607,0.11828482630760263
5-
10819.21891865473,0.5237570297813028,10.020689787985,0.5004303474716477,0.5005699447155513,0.13091217950352302
2+
10776.741935483871,0.499036905566402,9.978456743390534,0.49767035119563796,0.49780403428685593,0.12459850290556283
3+
115.80327218806197,0.06739346957542013,0.11513823236530764,0.007524465631261531,0.007540589145270748,0.017212719807337778
4+
10734.264952313013,0.47431678135150124,9.936223698796068,0.4949103549196282,0.4950381238581605,0.11828482630760263
5+
10819.21891865473,0.5237570297813028,10.020689787985,0.5004303474716477,0.5005699447155514,0.13091217950352302

outputs/example_run.csv

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
run_number,scenario,arrivals,mean_q_time_nurse,mean_time_with_nurse,mean_nurse_utilisation,mean_nurse_utilisation_tw,mean_nurse_q_length
2-
0,0,10972,0.504541081338615,9.84226781662332,0.4996386466177992,0.4997404525127849,0.12814409130665008
3-
1,0,10784,0.514150649003393,10.060480983450425,0.5019905433327594,0.502069010098797,0.1283472360845507
4-
2,0,10854,0.5232349226016817,9.925024519746302,0.4981297032213408,0.4982604514269931,0.1326692082859329
5-
3,0,10831,0.4791488631810612,9.9370571543943,0.49822049332297624,0.4982689502894135,0.12013104947023319
6-
4,0,10720,0.46145745726579823,10.015904147971671,0.4968703372055205,0.4971055007588973,0.11450981346966105
7-
5,0,10772,0.3882646868128185,9.884995942861282,0.492904233058074,0.4930559758823053,0.09681451866545558
8-
6,0,10831,0.4669381081669874,10.041799654744745,0.503356251584998,0.5034005361957391,0.11706959836936667
2+
0,0,10972,0.504541081338615,9.84226781662332,0.4996386466177992,0.49974045251278504,0.12814409130665008
3+
1,0,10784,0.514150649003393,10.060480983450425,0.5019905433327594,0.5020690100987935,0.1283472360845507
4+
2,0,10854,0.5232349226016817,9.925024519746302,0.4981297032213408,0.49826045142699366,0.1326692082859329
5+
3,0,10831,0.4791488631810612,9.9370571543943,0.49822049332297624,0.49826895028941315,0.12013104947023319
6+
4,0,10720,0.46145745726579823,10.015904147971671,0.4968703372055205,0.4971055007588991,0.11450981346966105
7+
5,0,10772,0.3882646868128185,9.884995942861282,0.492904233058074,0.4930559758823056,0.09681451866545558
8+
6,0,10831,0.4669381081669874,10.041799654744745,0.503356251584998,0.5034005361957363,0.11706959836936667
99
7,0,10781,0.625888360901447,10.086979128063648,0.5034489381047406,0.5037422085180931,0.15619681525181714
10-
8,0,10772,0.4684971326393017,10.202270228377186,0.508790994907774,0.5089130015618383,0.11682062761089254
11-
9,0,10705,0.5634349862001105,10.09260227901333,0.49997178325917613,0.5002278075946729,0.1399966447950717
12-
10,0,10927,0.562585969190057,10.083553615426284,0.5098373896503802,0.5099889270180503,0.14230039086434612
13-
11,0,10688,0.39781182403365434,9.893334037740962,0.4895233535105571,0.48962710728052056,0.09842159202017818
14-
12,0,11092,0.44530362984867583,9.810905063859671,0.5034276977164731,0.5034590643983867,0.11437196007956935
15-
13,0,10640,0.4397605749351992,9.933879963761742,0.48925457544062534,0.4892677288083271,0.10831140086366944
16-
14,0,10904,0.6107822771635987,10.167683587926042,0.513130373051619,0.5135294499218972,0.1541659710692565
17-
15,0,10849,0.47670998312351787,9.975581276412813,0.5009629889699926,0.5010455334069686,0.11971820849321864
18-
16,0,10719,0.428336230071242,9.809804967118032,0.4866947365248423,0.4868274499224406,0.10628092708642692
19-
17,0,10713,0.505574486075843,9.989154604862323,0.4954087210793937,0.4957697619501451,0.1253754506789469
20-
18,0,10568,0.3615821082986753,9.800182515281657,0.4793715775153063,0.4795652084277097,0.08845369723380557
21-
19,0,10707,0.4191589720392036,9.9193906381964,0.4915291568180775,0.4917635127186296,0.10388738688943873
22-
20,0,10845,0.6120142008002236,9.813774247048583,0.49261944375555833,0.49267201493881163,0.15364106499255614
23-
21,0,10726,0.5173212645251098,9.858186468091487,0.48940978932654106,0.4895612849605359,0.1284441639651928
24-
22,0,10618,0.5316566599495316,9.969891296475984,0.4892835610032433,0.4893719186906082,0.13067431517000294
25-
23,0,10914,0.5270546197660896,9.925291785145637,0.5013818263178943,0.501433800156172,0.1331544935214607
26-
24,0,10660,0.5029697553047842,9.96454608027881,0.49160360886911897,0.49162164437257694,0.12411244424881943
27-
25,0,10685,0.6270646900660448,10.236338445072258,0.5060501169430693,0.5061407672693311,0.15515572552368928
28-
26,0,10806,0.5061794260886525,10.039653295082593,0.5022615440123254,0.5023039700989318,0.126615159220231
29-
27,0,10748,0.4925537687951073,10.050997027592315,0.4999546777219452,0.5001183558252156,0.12254555340300495
30-
28,0,10589,0.4577189216542841,10.044180668559221,0.4923573694687436,0.4923672645089264,0.11219411253234293
31-
29,0,10863,0.5422405738480466,10.034383892923174,0.5046064549261675,0.5047331518468727,0.13635091096554006
32-
30,0,10796,0.5102078888697092,9.922063713004379,0.49578999982774674,0.49597325153194355,0.12767905794112022
10+
8,0,10772,0.4684971326393017,10.202270228377186,0.508790994907774,0.5089130015618397,0.11682062761089254
11+
9,0,10705,0.5634349862001105,10.09260227901333,0.49997178325917613,0.5002278075946733,0.1399966447950717
12+
10,0,10927,0.562585969190057,10.083553615426284,0.5098373896503802,0.5099889270180521,0.14230039086434612
13+
11,0,10688,0.39781182403365434,9.893334037740962,0.4895233535105571,0.489627107280519,0.09842159202017818
14+
12,0,11092,0.44530362984867583,9.810905063859671,0.5034276977164731,0.503459064398387,0.11437196007956935
15+
13,0,10640,0.4397605749351992,9.933879963761742,0.48925457544062534,0.48926772880832675,0.10831140086366944
16+
14,0,10904,0.6107822771635987,10.167683587926042,0.513130373051619,0.5135294499218969,0.1541659710692565
17+
15,0,10849,0.47670998312351787,9.975581276412813,0.5009629889699926,0.5010455334069701,0.11971820849321864
18+
16,0,10719,0.428336230071242,9.809804967118032,0.4866947365248423,0.48682744992243954,0.10628092708642692
19+
17,0,10713,0.505574486075843,9.989154604862323,0.4954087210793937,0.4957697619501464,0.1253754506789469
20+
18,0,10568,0.3615821082986753,9.800182515281657,0.4793715775153063,0.4795652084277076,0.08845369723380557
21+
19,0,10707,0.4191589720392036,9.9193906381964,0.4915291568180775,0.49176351271863106,0.10388738688943873
22+
20,0,10845,0.6120142008002236,9.813774247048583,0.49261944375555833,0.4926720149388125,0.15364106499255614
23+
21,0,10726,0.5173212645251098,9.858186468091487,0.48940978932654106,0.4895612849605331,0.1284441639651928
24+
22,0,10618,0.5316566599495316,9.969891296475984,0.4892835610032433,0.4893719186906069,0.13067431517000294
25+
23,0,10914,0.5270546197660896,9.925291785145637,0.5013818263178943,0.5014338001561723,0.1331544935214607
26+
24,0,10660,0.5029697553047842,9.96454608027881,0.49160360886911897,0.49162164437257705,0.12411244424881943
27+
25,0,10685,0.6270646900660448,10.236338445072258,0.5060501169430693,0.5061407672693301,0.15515572552368928
28+
26,0,10806,0.5061794260886525,10.039653295082593,0.5022615440123254,0.5023039700989324,0.126615159220231
29+
27,0,10748,0.4925537687951073,10.050997027592315,0.4999546777219452,0.5001183558252174,0.12254555340300495
30+
28,0,10589,0.4577189216542841,10.044180668559221,0.4923573694687436,0.49236726450892265,0.11219411253234293
31+
29,0,10863,0.5422405738480466,10.034383892923174,0.5046064549261675,0.5047331518468752,0.13635091096554006
32+
30,0,10796,0.5102078888697092,9.922063713004379,0.49578999982774674,0.49597325153194544,0.12767905794112022

simulation/model.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,20 +554,22 @@ def init_results_variables(self):
554554

555555
def warm_up_complete(self):
556556
"""
557-
Resets all results collection variables once warm-up period has passed.
557+
If there is a warm-up period, then reset all results collection
558+
variables once warm-up period has passed.
558559
"""
559-
# Delay process until warm-up period has completed
560-
yield self.env.timeout(self.param.warm_up_period)
560+
if self.param.warm_up_period > 0:
561+
# Delay process until warm-up period has completed
562+
yield self.env.timeout(self.param.warm_up_period)
561563

562-
# Reset results collection variables
563-
self.init_results_variables()
564+
# Reset results collection variables
565+
self.init_results_variables()
564566

565-
# If there was a warm-up period, log that this time has passed so we
566-
# can distinguish between patients before and after warm-up in logs
567-
if self.param.warm_up_period > 0:
568-
self.param.logger.log('─' * 10)
569-
self.param.logger.log(f'{self.env.now:.2f}: Warm up complete.')
570-
self.param.logger.log('─' * 10)
567+
# If there was a warm-up period, log that this time has passed so
568+
# can distinguish between patients before and after warm-up in logs
569+
if self.param.warm_up_period > 0:
570+
self.param.logger.log('─' * 10)
571+
self.param.logger.log(f'{self.env.now:.2f}: Warm up complete.')
572+
self.param.logger.log('─' * 10)
571573

572574
def run(self):
573575
"""
@@ -578,6 +580,7 @@ def run(self):
578580
self.param.data_collection_period)
579581

580582
# Schedule process which will reset results when warm-up period ends
583+
# (or does nothing if these is no warm-up)
581584
self.env.process(self.warm_up_complete())
582585

583586
# Schedule patient generator to run during simulation

tests/test_unittest_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,20 @@ def helper_warmup(warm_up_period):
224224
# results of 0
225225
first_interval = results_none['interval_audit'].iloc[0]
226226
assert first_interval['simulation_time'] == 0, (
227-
'With no warm-up, expect first entry in interval audit results to be ' +
227+
'With no warm-up, expect first entry in interval audit to be ' +
228228
f'at time 0, but it was at time {first_interval['simulation_time']}.'
229229
)
230230
assert first_interval['utilisation'] == 0, (
231-
'With no warm-up, expect first entry in interval audit results to ' +
231+
'With no warm-up, expect first entry in interval audit to ' +
232232
f'have 0 utilisation, but it was {first_interval['utilisation']}.'
233233
)
234234
assert first_interval['queue_length'] == 0, (
235-
'With no warm-up, expect first entry in interval audit results to ' +
235+
'With no warm-up, expect first entry in interval audit to ' +
236236
'have no queue, but there was queue length of ' +
237237
f'{first_interval['queue_length']}.'
238238
)
239239
assert first_interval['running_mean_wait_time'] == 0, (
240-
'With no warm-up, expect first entry in interval audit results to ' +
240+
'With no warm-up, expect first entry in interval audit to ' +
241241
'have running mean wait time of 0 but it was ' +
242242
f'{first_interval['running_mean_wait_time']}.'
243243
)

0 commit comments

Comments
 (0)