Skip to content

Commit 78dc7f2

Browse files
committed
fix(parameters): switch to standard classes (dataclasses not appropriate)
1 parent b6b97e9 commit 78dc7f2

File tree

2 files changed

+251
-75
lines changed

2 files changed

+251
-75
lines changed

.pylintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[FORMAT]
2-
max-line-length=79
2+
max-line-length=79
3+
4+
[MESSAGES CONTROL]
5+
disable=too-many-arguments,too-many-positional-arguments,too-few-public-methods,too-many-instance-attributes

simulation/model.py

Lines changed: 247 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,247 @@
11
"""
2-
Discrete Event Simulation Model.
3-
"""
2+
Stroke pathway simulation parameters.
43
5-
from dataclasses import dataclass
4+
It includes arrival rates, length of stay distributions, and routing
5+
probabilities between different care settings.
6+
"""
67

78

8-
@dataclass
99
class ASUArrivals:
10-
"""Acute stroke unit arrivals."""
11-
stroke = 1.2
12-
tia = 9.3
13-
neuro = 3.6
14-
other = 3.2
10+
"""
11+
Arrival rates for the acute stroke unit (ASU) by patient type.
12+
13+
These are the average time intervals (in days) between new admissions.
14+
For example, a value of 1.2 means a new admission every 1.2 days.
15+
"""
16+
def __init__(self, stroke=1.2, tia=9.3, neuro=3.6, other=3.2):
17+
"""
18+
Arguments:
19+
stroke (float):
20+
Stroke patient.
21+
tia (float):
22+
Transient ischaemic attack (TIA) patient.
23+
neuro (float):
24+
Complex neurological patient.
25+
other (float):
26+
Other patient types (including medical outliers).
27+
"""
28+
self.stroke = stroke
29+
self.tia = tia
30+
self.neuro = neuro
31+
self.other = other
1532

1633

17-
@dataclass
1834
class RehabArrivals:
19-
"""Rehab arrivals."""
20-
stroke = 21.8
21-
neuro = 31.7
22-
other = 28.6
35+
"""
36+
Arrival rates for the rehabiliation unit by patient type.
37+
38+
These are the average time intervals (in days) between new admissions.
39+
For example, a value of 21.8 means a new admission every 21.8 days.
40+
"""
41+
def __init__(self, stroke=21.8, neuro=31.7, other=28.6):
42+
"""
43+
Arguments:
44+
stroke (float):
45+
Stroke patient.
46+
neuro (float):
47+
Complex neurological patient.
48+
other (float):
49+
Other patient types.
50+
"""
51+
self.stroke = stroke
52+
self.neuro = neuro
53+
self.other = other
2354

2455

25-
@dataclass
2656
class ASULOS:
27-
"""Acute stroke unit length of stay."""
28-
stroke_no_esd_mean = 7.4
29-
stroke_no_esd_sd = 8.61
30-
stroke_esd_mean = 4.6
31-
stroke_esd_sd = 4.8
32-
tia_mean = 1.8
33-
tia_sd = 2.3
34-
neuro_mean = 4.0
35-
neuro_sd = 5.0
36-
other_mean = 3.8
37-
other_sd = 5.2
38-
39-
40-
@dataclass
57+
"""
58+
Mean and standard deviation (SD) of length of stay (LOS) in days in the
59+
acute stroke unit (ASU) by patient type.
60+
"""
61+
def __init__(
62+
self, stroke_no_esd_mean=7.4, stroke_no_esd_sd=8.61,
63+
stroke_esd_mean=4.6, stroke_esd_sd=4.8, tia_mean=1.8, tia_sd=2.3,
64+
neuro_mean=4.0, neuro_sd=5.0, other_mean=3.8, other_sd=5.2
65+
):
66+
"""
67+
Arguments:
68+
stroke_no_esd_mean (float):
69+
Mean LOS for stroke patients without early support discharge
70+
(ESD) services.
71+
stroke_no_esd_sd (float):
72+
SD of LOS for stroke patients without ESD.
73+
stroke_esd_mean (float):
74+
Mean LOS for stroke patients with ESD.
75+
stroke_esd_sd (float):
76+
SD of LOS for stroke patients with ESD.
77+
tia_mean (float):
78+
Mean LOS for transient ischemic attack (TIA) patients.
79+
tia_sd (float):
80+
SD of LOS for TIA patients.
81+
neuro_mean (float):
82+
Mean LOS for complex neurological patients.
83+
neuro_sd (float):
84+
SD of LOS for complex neurological patients.
85+
other_mean (float):
86+
Mean LOS for other patient types.
87+
other_sd (float):
88+
SD of LOS for other patient types.
89+
"""
90+
self.stroke_no_esd_mean = stroke_no_esd_mean
91+
self.stroke_no_esd_sd = stroke_no_esd_sd
92+
self.stroke_esd_mean = stroke_esd_mean
93+
self.stroke_esd_sd = stroke_esd_sd
94+
self.tia_mean = tia_mean
95+
self.tia_sd = tia_sd
96+
self.neuro_mean = neuro_mean
97+
self.neuro_sd = neuro_sd
98+
self.other_mean = other_mean
99+
self.other_sd = other_sd
100+
101+
41102
class RehabLOS:
42-
"""Rehab length of stay."""
43-
rehab_los_stroke_no_esd_mean = 28.4
44-
rehab_los_stroke_no_esd_sd = 27.2
45-
rehab_los_stroke_esd_mean = 30.3
46-
rehab_los_stroke_esd_sd = 23.1
47-
rehab_los_tia_mean = 18.7
48-
rehab_los_tia_sd = 23.5
49-
rehab_los_neuro_mean = 27.6
50-
rehab_los_neuro_sd = 28.4
51-
rehab_los_other_mean = 16.1
52-
rehab_los_other_sd = 14.1
53-
54-
55-
@dataclass
103+
"""
104+
Mean and standard deviation (SD) of length of stay (LOS) in days in the
105+
rehabilitation unit by patient type.
106+
"""
107+
def __init__(
108+
self, stroke_no_esd_mean=28.4, stroke_no_esd_sd=27.2,
109+
stroke_esd_mean=30.3, stroke_esd_sd=23.1, tia_mean=18.7, tia_sd=23.5,
110+
neuro_mean=27.6, neuro_sd=28.4, other_mean=16.1, other_sd=14.1
111+
):
112+
"""
113+
Arguments:
114+
stroke_no_esd_mean (float):
115+
Mean LOS for stroke patients without early support discharge
116+
(ESD) services.
117+
stroke_no_esd_sd (float):
118+
SD of LOS for stroke patients without ESD.
119+
stroke_esd_mean (float):
120+
Mean LOS for stroke patients with ESD.
121+
stroke_esd_sd (float):
122+
SD of LOS for stroke patients with ESD.
123+
tia_mean (float):
124+
Mean LOS for transient ischemic attack (TIA) patients.
125+
tia_sd (float):
126+
SD of LOS for TIA patients.
127+
neuro_mean (float):
128+
Mean LOS for complex neurological patients.
129+
neuro_sd (float):
130+
SD of LOS for complex neurological patients.
131+
other_mean (float):
132+
Mean LOS for other patient types.
133+
other_sd (float):
134+
SD of LOS for other patient types.
135+
"""
136+
self.stroke_no_esd_mean = stroke_no_esd_mean
137+
self.stroke_no_esd_sd = stroke_no_esd_sd
138+
self.stroke_esd_mean = stroke_esd_mean
139+
self.stroke_esd_sd = stroke_esd_sd
140+
self.tia_mean = tia_mean
141+
self.tia_sd = tia_sd
142+
self.neuro_mean = neuro_mean
143+
self.neuro_sd = neuro_sd
144+
self.other_mean = other_mean
145+
self.other_sd = other_sd
146+
147+
56148
class ASURouting:
57-
"""Routing out of the acute stroke unit."""
58-
rehab_stroke = 0.24
59-
rehab_tia = 0.01
60-
rehab_neuro = 0.11
61-
rehab_other = 0.05
62-
esd_stroke = 0.13
63-
esd_tia = 0.01
64-
esd_neuro = 0.05
65-
esd_other = 0.10
66-
other_stroke = 0.63
67-
other_tia = 0.98
68-
other_neuro = 0.84
69-
other_other = 0.85
70-
71-
72-
@dataclass
149+
"""
150+
Probabilities of each patient type being transferred from the acute
151+
stroke unit (ASU) to other destinations.
152+
"""
153+
def __init__(
154+
self,
155+
rehab_stroke=0.24, rehab_tia=0.01, rehab_neuro=0.11, rehab_other=0.05,
156+
esd_stroke=0.13, esd_tia=0.01, esd_neuro=0.05, esd_other=0.10,
157+
other_stroke=0.63, other_tia=0.98, other_neuro=0.84, other_other=0.85
158+
):
159+
"""
160+
Arguments:
161+
rehab_stroke (float):
162+
Stroke patient to rehabilitation unit.
163+
rehab_tia (float):
164+
Transient ischemic attack (TIA) patient to rehabilitation unit.
165+
rehab_neuro (float):
166+
Complex neurological patient to rehabilitation unit.
167+
rehab_other (float):
168+
Other patient type to rehabilitation unit.
169+
esd_stroke (float):
170+
Stroke patient to early support discharge (ESD) services.
171+
esd_tia (float):
172+
TIA patient to ESD.
173+
esd_neuro (float):
174+
Complex neurological patient to ESD.
175+
esd_other (float):
176+
Other patient type to ESD.
177+
other_stroke (float):
178+
Stroke patient to other destinations (e.g., own home, care
179+
home, mortality).
180+
other_tia (float):
181+
TIA patient to other destinations.
182+
other_neuro (float):
183+
Complex neurological patient to other destinations.
184+
other_other (float):
185+
Other patient type to other destinations.
186+
"""
187+
self.rehab_stroke = rehab_stroke
188+
self.rehab_tia = rehab_tia
189+
self.rehab_neuro = rehab_neuro
190+
self.rehab_other = rehab_other
191+
self.esd_stroke = esd_stroke
192+
self.esd_tia = esd_tia
193+
self.esd_neuro = esd_neuro
194+
self.esd_other = esd_other
195+
self.other_stroke = other_stroke
196+
self.other_tia = other_tia
197+
self.other_neuro = other_neuro
198+
self.other_other = other_other
199+
200+
73201
class RehabRouting:
74-
"""Routing out of rehab."""
75-
rehab_to_esd_stroke = 0.40
76-
rehab_to_esd_tia = 0
77-
rehab_to_esd_neuro = 0.09
78-
rehab_to_esd_other = 0.13
79-
rehab_to_other_stroke = 0.60
80-
rehab_to_other_tia = 1
81-
rehab_to_neuro = 0.91
82-
rehab_to_other = 0.88
83-
84-
85-
@dataclass
202+
"""
203+
Probabilities of each patient type being transferred from the rehabiliation
204+
unit to other destinations.
205+
"""
206+
def __init__(
207+
self, esd_stroke=0.40, esd_tia=0, esd_neuro=0.09,
208+
esd_other=0.13, other_stroke=0.60, other_tia=1,
209+
other_neuro=0.91, other_other=0.88
210+
):
211+
"""
212+
Arguments:
213+
esd_stroke (float):
214+
Stroke patient to early support discharge (ESD) services.
215+
esd_tia (float):
216+
Transient ischemic attack (TIA) patient to ESD.
217+
esd_neuro (float):
218+
Complex neurological patient to ESD.
219+
esd_other (float):
220+
Other patient type to ESD.
221+
other_stroke (float):
222+
Stroke patient to other destinations (e.g., own home, care
223+
home, mortality).
224+
other_tia (float):
225+
TIA patient to other destinations.
226+
other_neuro (float):
227+
Complex neurological patient to other destinations.
228+
other_other (float):
229+
Other patient type to other destinations.
230+
"""
231+
self.esd_stroke = esd_stroke
232+
self.esd_tia = esd_tia
233+
self.esd_neuro = esd_neuro
234+
self.esd_other = esd_other
235+
self.other_stroke = other_stroke
236+
self.other_tia = other_tia
237+
self.other_neuro = other_neuro
238+
self.other_other = other_other
239+
240+
86241
class Param:
87-
"""Default parameters for simulation."""
88-
# pylint: disable=too-many-arguments,too-many-positional-arguments
242+
"""
243+
Default parameters for simulation.
244+
"""
89245
def __init__(
90246
self,
91247
asu_arrivals=ASUArrivals(),
@@ -95,7 +251,24 @@ def __init__(
95251
asu_routing=ASURouting(),
96252
rehab_routing=RehabRouting()
97253
):
98-
"""Initialise instance of the parameter class."""
254+
"""
255+
Initialise a parameter set for the simulation.
256+
257+
Arguments:
258+
asu_arrivals (ASUArrivals):
259+
Arrival rates to the acute stroke unit (ASU).
260+
rehab_arrivals (RehabArrivals):
261+
Arrival rates to the rehabilitation unit.
262+
asu_los (ASULOS):
263+
Length of stay (LOS) distributions for patients in the ASU.
264+
rehab_los (RehabLOS):
265+
LOS distributions for patients in the rehabilitation unit.
266+
asu_routing (ASURouting):
267+
Transfer probabilities from the ASU to other destinations.
268+
rehab_routing (RehabRouting):
269+
Transfer probabilities from the rehabilitation unit to other
270+
destinations.
271+
"""
99272
self.asu_arrivals = asu_arrivals
100273
self.rehab_arrivals = rehab_arrivals
101274
self.asu_los = asu_los

0 commit comments

Comments
 (0)