Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Peter Jentsch
CovidAlertABM
Commits
5b083556
Commit
5b083556
authored
Jun 10, 2021
by
Peter Jentsch
Browse files
parameter fits
parent
980b9b71
Changes
7
Hide whitespace changes
Inline
Side-by-side
CovidAlertVaccinationModel/abm_parameter_fits/fit_all_parameters.dat
View file @
5b083556
No preview for this file type
CovidAlertVaccinationModel/src/ABM/parameter_optimization.jl
View file @
5b083556
...
@@ -15,9 +15,16 @@ function solve_w_parameters(default_p, p_names, new_p_list)
...
@@ -15,9 +15,16 @@ function solve_w_parameters(default_p, p_names, new_p_list)
end
end
function
fit_distribution_parameters
(
p_tuple
)
function
fit_distribution_parameters
(
p_tuple
)
p_names
=
(
:
ω
,
:
π_base_y
,
:
π_base_m
,
:
π_base_o
,
:
ζ
)
p_names
=
(
:
ω
,
:
β_y
,
:
β_m
,
:
β_o
,
:
π_base_y
,
:
π_base_m
,
:
π_base_o
,
:
ζ
)
β_y_val
=
0.00077
β_m_val
=
0.00065
β_o_val
=
0.75
priors
=
Factored
(
priors
=
Factored
(
Uniform
(
0.0
,
0.01
),
Uniform
(
0.0
,
0.01
),
TriangularDist
(
β_y_val
-
0.0005
,
β_y_val
+
0.0005
),
TriangularDist
(
β_m_val
-
0.0005
,
β_m_val
+
0.0005
),
TriangularDist
(
β_o_val
-
0.0005
,
β_o_val
+
0.0005
),
Uniform
(
-
5.0
,
3.0
),
Uniform
(
-
5.0
,
3.0
),
Uniform
(
-
5.0
,
3.0
),
Uniform
(
-
5.0
,
3.0
),
Uniform
(
-
5.0
,
3.0
),
Uniform
(
-
5.0
,
3.0
),
...
@@ -26,18 +33,8 @@ function fit_distribution_parameters(p_tuple)
...
@@ -26,18 +33,8 @@ function fit_distribution_parameters(p_tuple)
#simulation begins in july
#simulation begins in july
#60 days for opinion dynamics to stabilize, then immunization begins in september,
#60 days for opinion dynamics to stabilize, then immunization begins in september,
#infection introduced at beginning of december
#infection introduced at beginning of december
sim_length
=
400
p_tuple_adjust
=
merge
(
p_tuple
,
(
sim_length
=
sim_length
,
I_0_fraction
=
0.005
,
immunization_begin_day
=
60
,
infection_introduction_day
=
180
,
immunizing
=
true
,
)
)
function
cost
(
p
)
function
cost
(
p
)
output
,
model
=
solve_w_parameters
(
p_tuple
_adjust
,
p_names
,
p
)
output
,
model
=
solve_w_parameters
(
p_tuple
,
p_names
,
p
)
ymo_vaccination_ts
=
output
.
daily_immunized_by_age
ymo_vaccination_ts
=
output
.
daily_immunized_by_age
total_postinf_vaccination
=
sum
.
(
eachrow
(
ymo_vaccination_ts
[
:
,
181
:
end
]))
total_postinf_vaccination
=
sum
.
(
eachrow
(
ymo_vaccination_ts
[
:
,
181
:
end
]))
...
@@ -57,17 +54,17 @@ function fit_distribution_parameters(p_tuple)
...
@@ -57,17 +54,17 @@ function fit_distribution_parameters(p_tuple)
+
sum
((
total_postinf_vaccination
.-
total_postinf_vaccination
)
.^
2
)
+
sum
((
total_postinf_vaccination
.-
total_postinf_vaccination
)
.^
2
)
+
sum
((
final_size
.-
target_final_size
)
.^
2
)
+
sum
((
final_size
.-
target_final_size
)
.^
2
)
end
end
# display(cost((0.005,0.00075, 0.00063,0.75,-1.4,-1.4,-0.95)))
# display(cost((0.005,0.00075, 0.00063,0.75,-1.4,-1.4,-0.95
,1.25
)))
out
=
smc
(
priors
,
cost
;
verbose
=
true
,
nparticles
=
25
0
,
parallel
=
true
)
out
=
smc
(
priors
,
cost
;
verbose
=
true
,
nparticles
=
100
0
,
parallel
=
true
)
return
NamedTuple
{
p_names
}(
ntuple
(
i
->
out
.
P
[
i
]
.
particles
,
length
(
p_names
)))
return
NamedTuple
{
p_names
}(
ntuple
(
i
->
out
.
P
[
i
]
.
particles
,
length
(
p_names
)))
end
end
function
fit_parameters
(
default_parameters
)
function
fit_parameters
(
default_parameters
)
# pre_inf_behaviour_parameters_path =joinpath(PACKAGE_FOLDER,"abm_parameter_fits","pre_inf_behaviour_parameters.dat")
# pre_inf_behaviour_parameters_path =joinpath(PACKAGE_FOLDER,"abm_parameter_fits","pre_inf_behaviour_parameters.dat")
# post_inf_behaviour_parameters_path = joinpath(PACKAGE_FOLDER,"abm_parameter_fits","post_inf_behaviour_parameters.dat")
# post_inf_behaviour_parameters_path = joinpath(PACKAGE_FOLDER,"abm_parameter_fits","post_inf_behaviour_parameters.dat")
fit_all_parameters_path
=
joinpath
(
PACKAGE_FOLDER
,
"abm_parameter_fits"
,
"fit_all_parameters.dat"
)
fit_all_parameters_path
=
joinpath
(
PACKAGE_FOLDER
,
"abm_parameter_fits"
,
"fit_all_parameters.dat"
)
#
output = fit_distribution_parameters(default_parameters)
output
=
fit_distribution_parameters
(
default_parameters
)
#
serialize(fit_all_parameters_path,output)
serialize
(
fit_all_parameters_path
,
output
)
fitted_parameter_tuple
=
deserialize
(
fit_all_parameters_path
)
fitted_parameter_tuple
=
deserialize
(
fit_all_parameters_path
)
...
...
CovidAlertVaccinationModel/src/ABM/solve.jl
View file @
5b083556
...
@@ -176,7 +176,7 @@ end
...
@@ -176,7 +176,7 @@ end
function
solve!
(
modelsol
,
recordings
...
)
function
solve!
(
modelsol
,
recordings
...
)
init_indices
=
rand
(
Random
.
default_rng
(
Threads
.
threadid
()),
1
:
modelsol
.
nodes
,
round
(
Int
,
modelsol
.
nodes
*
modelsol
.
params
.
I_0_fraction
))
init_indices
=
rand
(
Random
.
default_rng
(
Threads
.
threadid
()),
1
:
modelsol
.
nodes
,
round
(
Int
,
modelsol
.
nodes
*
modelsol
.
params
.
I_0_fraction
))
@show
length
(
init_indices
)
for
t
in
1
:
modelsol
.
sim_length
for
t
in
1
:
modelsol
.
sim_length
agents_step!
(
t
,
modelsol
,
init_indices
)
agents_step!
(
t
,
modelsol
,
init_indices
)
#advance agent states based on the new network
#advance agent states based on the new network
...
...
CovidAlertVaccinationModel/test/ABM/mixing_test.jl
View file @
5b083556
using
CovidAlertVaccinationModel
:
generate_contact_vectors!
using
CovidAlertVaccinationModel
:
abm
,
generate_contact_vectors!
using
CovidAlertVaccinationModel
:
ModelSolution
,
AgentDemographic
,
mean
,
get_weight
using
CovidAlertVaccinationModel
:
ModelSolution
,
AgentDemographic
,
mean
,
get_weight
using
CovidAlertVaccinationModel
:
AgentStatus
,
get_u_0
,
get_parameters
,
solve!
,
DebugRecorder
,
WeightedGraph
,
contact_time_distributions
,
GraphEdge
using
CovidAlertVaccinationModel
:
AgentStatus
,
get_u_0
,
get_parameters
,
solve!
,
DebugRecorder
,
WeightedGraph
,
contact_time_distributions
,
GraphEdge
using
LightGraphs
using
LightGraphs
...
@@ -135,8 +135,5 @@ end
...
@@ -135,8 +135,5 @@ end
for
i
in
eachindex
(
mixing_dist
)
for
i
in
eachindex
(
mixing_dist
)
@test
mean
(
mixing_dist
[
i
])
≈
mean
(
dist
[
i
])
atol
=
0.2
@test
mean
(
mixing_dist
[
i
])
≈
mean
(
dist
[
i
])
atol
=
0.2
end
end
display
(
var
.
(
mixing_dist
))
display
(
var
.
(
dist
))
display
(
"===="
)
end
end
end
end
\ No newline at end of file
post_inf_fitting.pdf
View file @
5b083556
No preview for this file type
post_inf_fitting_posteriors.pdf
View file @
5b083556
No preview for this file type
timeseries.pdf
View file @
5b083556
No preview for this file type
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment