forked from qBioTurin/SIR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.R
103 lines (83 loc) · 3.18 KB
/
Main.R
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
library(epimod)
#downloadContainers()
start_time <- Sys.time()
model.generation(net_fname = "./Net/SIR.PNPRO")
end_time <- Sys.time()-start_time
### Sensitivity analysis
## Simple version where only the transition rates vary.
# execution time 4 mins
start_time <- Sys.time()
sensitivity<-model.sensitivity(n_config = 200,
solver_fname = "Net/SIR.solver",
parameters_fname = "Input/FunctionsSensitivity_list.csv",
reference_data = "Input/reference_data.csv",
functions_fname = "Rfunction/FunctionSensitivity.R",
distance_measure = "mse" ,
target_value = "target" ,
i_time = 0,
f_time = 7*10, # weeks
s_time = 1, # days
parallel_processors = 2
)
end_time <- Sys.time()-start_time
##############################
## Let draw the trajectories
##############################
source("./Rfunction/SensitivityPlot.R")
pl = SensitivityPlot(folder = "SIR_sensitivity/")
pl$TrajS
pl$TrajI
pl$TrajR
pl$Points
### Calibration analysis
# Execution time 30 mins
start_time <- Sys.time()
model.calibration(parameters_fname = "Input/Functions_list_Calibration.csv",
functions_fname = "Rfunction/FunctionCalibration.R",
solver_fname = "Net/SIR.solver",
reference_data = "Input/reference_data.csv",
distance_measure = "mse" ,
f_time = 7*10, # weeks
s_time = 1, # days
# Vectors to control the optimization
ini_v = c(0.02,0.001),
lb_v = c(0.01, 0.0001),
ub_v = c(0.05, 0.002),
max.time = 2
)
end_time <- Sys.time()-start_time
##############################
## Let draw the calibration results
##############################
source("Rfunction/CalibrationPlot.R")
plots <- calibration.plot(solverName_path = "SIR_calibration/SIR-calibration-1.trace",
reference_path ="Input/reference_data.csv",
print=F)
plots$plS
plots$plI
plots$plR
### Model Analysis
# Deterministic:
model.analysis(solver_fname = "Net/SIR.solver",
parameters_fname = "Input/Functions_list_ModelAnalysis.csv",
solver_type = "LSODA",
f_time = 7*10, # weeks
s_time = 1
)
source("Rfunction/ModelAnalysisPlot.R")
AnalysisPlot = ModelAnalysisPlot(Stoch = F ,print = F,
trace_path = "./SIR_analysis/SIR-analysis-1.trace")
AnalysisPlot$plI
model_analysis(solver_fname = "Net/SIR.solver",
parameters_fname = "Input/Functions_list_ModelAnalysis.csv",
solver_type = "SSA",
n_run = 500,
parallel_processors = 2,
f_time = 7*10, # weeks
s_time = 1
)
AnalysisPlot = ModelAnalysisPlot(Stoch = T ,print = F,
trace_path = "./SIR_analysis/SIR-analysis-1.trace")
AnalysisPlot$plI
AnalysisPlot$HistI
plS