1010# ' @param other Numeric. Mean days between other patient arrivals.
1111# '
1212# ' @return A named list of arrival intervals for ASU.
13+ # ' @export
14+
1315create_asu_arrivals <- function (
14- stroke = 1.2 , tia = 9.3 , neuro = 3.6 , other = 3.2
16+ stroke = 1.2 , tia = 9.3 , neuro = 3.6 , other = 3.2
1517) {
16- list (
17- stroke = stroke ,
18- tia = tia ,
19- neuro = neuro ,
20- other = other
21- )
18+ return (as.list(environment()))
2219}
2320
2421# ' Rehabilitation unit arrival intervals (days).
@@ -31,14 +28,12 @@ create_asu_arrivals <- function(
3128# ' @param other Numeric. Mean days between other patient arrivals.
3229# '
3330# ' @return A named list of arrival intervals for rehabilitation unit.
31+ # ' @export
32+
3433create_rehab_arrivals <- function (
35- stroke = 21.8 , neuro = 31.7 , other = 28.6
34+ stroke = 21.8 , neuro = 31.7 , other = 28.6
3635) {
37- list (
38- stroke = stroke ,
39- neuro = neuro ,
40- other = other
41- )
36+ return (as.list(environment()))
4237}
4338
4439# ' Acute Stroke Unit (ASU) length of stay (LOS) distributions (days).
@@ -63,22 +58,17 @@ create_rehab_arrivals <- function(
6358# ' @param other_sd Numeric. SD LOS for other patients.
6459# '
6560# ' @return A named list of LOS distributions for ASU.
61+ # ' @export
62+
6663create_asu_los <- function (
67- stroke_noesd_mean = 7.4 , stroke_noesd_sd = 8.61 ,
68- stroke_esd_mean = 4.6 , stroke_esd_sd = 4.8 ,
69- stroke_mortality_mean = 7.0 , stroke_mortality_sd = 8.7 ,
70- tia_mean = 1.8 , tia_sd = 2.3 ,
71- neuro_mean = 4.0 , neuro_sd = 5.0 ,
72- other_mean = 3.8 , other_sd = 5.2
64+ stroke_noesd_mean = 7.4 , stroke_noesd_sd = 8.61 ,
65+ stroke_esd_mean = 4.6 , stroke_esd_sd = 4.8 ,
66+ stroke_mortality_mean = 7.0 , stroke_mortality_sd = 8.7 ,
67+ tia_mean = 1.8 , tia_sd = 2.3 ,
68+ neuro_mean = 4.0 , neuro_sd = 5.0 ,
69+ other_mean = 3.8 , other_sd = 5.2
7370) {
74- list (
75- stroke_noesd = list (mean = stroke_noesd_mean , sd = stroke_noesd_sd ),
76- stroke_esd = list (mean = stroke_esd_mean , sd = stroke_esd_sd ),
77- stroke_mortality = list (mean = stroke_mortality_mean , sd = stroke_mortality_sd ),
78- tia = list (mean = tia_mean , sd = tia_sd ),
79- neuro = list (mean = neuro_mean , sd = neuro_sd ),
80- other = list (mean = other_mean , sd = other_sd )
81- )
71+ return (as.list(environment()))
8272}
8373
8474# ' Rehabilitation unit length of stay (LOS) distributions (days).
@@ -97,20 +87,16 @@ create_asu_los <- function(
9787# ' @param other_sd Numeric. SD LOS for other patients.
9888# '
9989# ' @return A named list of LOS distributions for rehabilitation unit.
90+ # ' @export
91+
10092create_rehab_los <- function (
101- stroke_noesd_mean = 28.4 , stroke_noesd_sd = 27.2 ,
102- stroke_esd_mean = 30.3 , stroke_esd_sd = 23.1 ,
103- tia_mean = 18.7 , tia_sd = 23.5 ,
104- neuro_mean = 27.6 , neuro_sd = 28.4 ,
105- other_mean = 16.1 , other_sd = 14.1
93+ stroke_noesd_mean = 28.4 , stroke_noesd_sd = 27.2 ,
94+ stroke_esd_mean = 30.3 , stroke_esd_sd = 23.1 ,
95+ tia_mean = 18.7 , tia_sd = 23.5 ,
96+ neuro_mean = 27.6 , neuro_sd = 28.4 ,
97+ other_mean = 16.1 , other_sd = 14.1
10698) {
107- list (
108- stroke_noesd = list (mean = stroke_noesd_mean , sd = stroke_noesd_sd ),
109- stroke_esd = list (mean = stroke_esd_mean , sd = stroke_esd_sd ),
110- tia = list (mean = tia_mean , sd = tia_sd ),
111- neuro = list (mean = neuro_mean , sd = neuro_sd ),
112- other = list (mean = other_mean , sd = other_sd )
113- )
99+ return (as.list(environment()))
114100}
115101
116102# ' ASU routing probabilities.
@@ -137,18 +123,15 @@ create_rehab_los <- function(
137123# ' @param other_other Numeric. Probability other patient to other.
138124# '
139125# ' @return A named list of routing probabilities for ASU.
126+ # ' @export
127+
140128create_asu_routing <- function (
141- stroke_rehab = 0.24 , stroke_esd = 0.13 , stroke_other = 0.63 ,
142- tia_rehab = 0.01 , tia_esd = 0.01 , tia_other = 0.98 ,
143- neuro_rehab = 0.11 , neuro_esd = 0.05 , neuro_other = 0.84 ,
144- other_rehab = 0.05 , other_esd = 0.10 , other_other = 0.85
129+ stroke_rehab = 0.24 , stroke_esd = 0.13 , stroke_other = 0.63 ,
130+ tia_rehab = 0.01 , tia_esd = 0.01 , tia_other = 0.98 ,
131+ neuro_rehab = 0.11 , neuro_esd = 0.05 , neuro_other = 0.84 ,
132+ other_rehab = 0.05 , other_esd = 0.10 , other_other = 0.85
145133) {
146- list (
147- stroke = list (rehab = stroke_rehab , esd = stroke_esd , other = stroke_other ),
148- tia = list (rehab = tia_rehab , esd = tia_esd , other = tia_other ),
149- neuro = list (rehab = neuro_rehab , esd = neuro_esd , other = neuro_other ),
150- other = list (rehab = other_rehab , esd = other_esd , other = other_other )
151- )
134+ return (as.list(environment()))
152135}
153136
154137# ' Rehabilitation unit routing probabilities.
@@ -170,18 +153,15 @@ create_asu_routing <- function(
170153# ' @param other_other Numeric. Probability other patient to other.
171154# '
172155# ' @return A named list of routing probabilities for rehabilitation unit.
156+ # ' @export
157+
173158create_rehab_routing <- function (
174- stroke_esd = 0.40 , stroke_other = 0.60 ,
175- tia_esd = 0 , tia_other = 1 ,
176- neuro_esd = 0.09 , neuro_other = 0.91 ,
177- other_esd = 0.13 , other_other = 0.88
159+ stroke_esd = 0.40 , stroke_other = 0.60 ,
160+ tia_esd = 0L , tia_other = 1L ,
161+ neuro_esd = 0.09 , neuro_other = 0.91 ,
162+ other_esd = 0.13 , other_other = 0.88
178163) {
179- list (
180- stroke = list (esd = stroke_esd , other = stroke_other ),
181- tia = list (esd = tia_esd , other = tia_other ),
182- neuro = list (esd = neuro_esd , other = neuro_other ),
183- other = list (esd = other_esd , other = other_other )
184- )
164+ return (as.list(environment()))
185165}
186166
187167# ' Generate complete parameter list for simulation.
@@ -196,34 +176,30 @@ create_rehab_routing <- function(
196176# ' @param data_collection_period Integer. Length of data collection period
197177# ' (days).
198178# ' @param number_of_runs Integer. Number of simulation runs.
199- # ' @param audit_interval Numeric. Audit interval (days ).
179+ # ' @param scenario_name Label for scenario (int|float|string ).
200180# ' @param cores Integer. Number of CPU cores to use.
181+ # ' @param log_to_console Whether to print activity log to console.
182+ # ' @param log_to_file Whether to save activity log to file.
183+ # ' @param file_path Path to save log to file.
201184# '
202185# ' @return A named list of all simulation parameters.
186+ # ' @export
187+
203188create_parameters <- function (
204- asu_arrivals = create_asu_arrivals(),
205- rehab_arrivals = create_rehab_arrivals(),
206- asu_los = create_asu_los(),
207- rehab_los = create_rehab_los(),
208- asu_routing = create_asu_routing(),
209- rehab_routing = create_rehab_routing(),
210- warm_up_period = 365 * 3 ,
211- data_collection_period = 365 * 5 ,
212- number_of_runs = 150 ,
213- audit_interval = 1 ,
214- cores = 1
189+ asu_arrivals = create_asu_arrivals(),
190+ rehab_arrivals = create_rehab_arrivals(),
191+ asu_los = create_asu_los(),
192+ rehab_los = create_rehab_los(),
193+ asu_routing = create_asu_routing(),
194+ rehab_routing = create_rehab_routing(),
195+ warm_up_period = 365L * 3L , # 3 years
196+ data_collection_period = 365L * 5L , # 5 years
197+ number_of_runs = 150L ,
198+ scenario_name = NULL ,
199+ cores = 1L ,
200+ log_to_console = FALSE ,
201+ log_to_file = FALSE ,
202+ file_path = NULL
215203) {
216- list (
217- asu_arrivals = asu_arrivals ,
218- rehab_arrivals = rehab_arrivals ,
219- asu_los = asu_los ,
220- rehab_los = rehab_los ,
221- asu_routing = asu_routing ,
222- rehab_routing = rehab_routing ,
223- warm_up_period = warm_up_period ,
224- data_collection_period = data_collection_period ,
225- number_of_runs = number_of_runs ,
226- audit_interval = audit_interval ,
227- cores = cores
228- )
204+ return (as.list(environment()))
229205}
0 commit comments