Repository navigation
Expand file tree
/
Copy pathexample_vensim_flu.py
More file actions
120 lines (108 loc) · 3.34 KB
/
Copy pathexample_vensim_flu.py
File metadata and controls
120 lines (108 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""A showcase of a mexican flu model with Vensim.
This module shows how you can use vensim models directly
instead of coding the model in Python. The underlying case
is the same as used in example_flu.py
"""
# Created on 20 May, 2011
# .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
# epruyt <e.pruyt (at) tudelft (dot) nl>
import numpy as np
from ema_workbench import (
RealParameter,
Sample,
ScalarOutcome,
TimeSeriesOutcome,
ema_logging,
perform_experiments,
save_results,
)
from ema_workbench.connectors.vensim import VensimModel
if __name__ == "__main__":
ema_logging.log_to_stderr(ema_logging.INFO)
model = VensimModel(
"fluCase", wd=r"./models/flu", model_file=r"FLUvensimV1basecase.vpm"
)
# outcomes
model.outcomes = [
TimeSeriesOutcome("deceased_population_region_1"),
TimeSeriesOutcome("infected_fraction_R1"),
ScalarOutcome(
"max_infection_fraction",
function=np.max,
variable_name="infected_fraction_R1",
),
]
# Plain Parametric Uncertainties
model.uncertainties = [
RealParameter("additional_seasonal_immune_population_fraction_R1", 0, 0.5),
RealParameter(
"additional_seasonal_immune_population_fraction_R2",
0,
0.5,
),
RealParameter(
"fatality_ratio_region_1",
0.0001,
0.1,
),
RealParameter(
"fatality_rate_region_2",
0.0001,
0.1,
),
RealParameter(
"initial_immune_fraction_of_the_population_of_region_1",
0,
0.5,
),
RealParameter(
"initial_immune_fraction_of_the_population_of_region_2",
0,
0.5,
),
RealParameter(
"normal_interregional_contact_rate",
0,
0.9,
),
RealParameter(
"permanent_immune_population_fraction_R1",
0,
0.5,
),
RealParameter(
"permanent_immune_population_fraction_R2",
0,
0.5,
),
RealParameter("recovery_time_region_1", 0.1, 0.75),
RealParameter("recovery_time_region_2", 0.1, 0.75),
RealParameter("susceptible_to_immune_population_delay_time_region_1", 0.5, 2),
RealParameter("susceptible_to_immune_population_delay_time_region_2", 0.5, 2),
RealParameter("root_contact_rate_region_1", 0.01, 5),
RealParameter("root_contact_ratio_region_2", 0.01, 5),
RealParameter(
"infection_ratio_region_1",
0,
0.15,
),
RealParameter("infection_rate_region_2", 0, 0.15),
RealParameter(
"normal_contact_rate_region_1",
10,
100,
),
RealParameter(
"normal_contact_rate_region_2",
10,
200,
),
]
# add policies
policies = [
Sample("no policy", model_file=r"FLUvensimV1basecase.vpm"),
Sample("static policy", model_file=r"FLUvensimV1static.vpm"),
Sample("adaptive policy", model_file=r"FLUvensimV1dynamic.vpm"),
]
results = perform_experiments(model, 1000, policies=policies)
save_results(results, "./data/1000 flu cases with policies.tar.gz")