Skip to content
Snippets Groups Projects
Commit 44426b76 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

infection growth rate fitting

parent 3c995c3e
No related branches found
No related tags found
No related merge requests found
......@@ -92,9 +92,9 @@ version = "1.16.0+6"
[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "a66109c73612c63b10923ac446fddb0f0d21a593"
git-tree-sha1 = "bd0cc939d94b8bd736dce5bbbe0d635db9f94af7"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.9.40"
version = "0.9.41"
[[CheapThreads]]
deps = ["ArrayInterface", "IfElse", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities", "VectorizationBase"]
......@@ -120,6 +120,12 @@ git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.8"
[[CommonSubexpressions]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ac4132ad78082518ec2037ae5770b6e796f7f956"
......@@ -164,6 +170,12 @@ git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.4"
[[CurveFit]]
deps = ["LinearAlgebra", "Polynomials"]
git-tree-sha1 = "eb0e0c7f3c49611223c7ed2d75ad98cfe6a9b18c"
uuid = "5a033b19-8c74-5913-a970-47c3779ef25c"
version = "0.3.5"
[[DataAPI]]
git-tree-sha1 = "dfb3b7e89e395be1e25c2ad6d7690dc29cc53b1d"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
......@@ -171,9 +183,9 @@ version = "1.6.0"
[[DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "78028b8c1c5147515e0a367e6bbe679fc86ff085"
git-tree-sha1 = "6e5452d9cf401ed9048e1cde93815be53d951079"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.0.1"
version = "1.0.2"
[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
......@@ -211,6 +223,24 @@ git-tree-sha1 = "12e8b690de74848e9f41853817a94900a9e13bff"
uuid = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
version = "0.3.8"
[[DiffResults]]
deps = ["StaticArrays"]
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "1.0.3"
[[DiffRules]]
deps = ["NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "214c3fcac57755cfda163d91c58893a8723f93e9"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.0.2"
[[Distances]]
deps = ["LinearAlgebra", "Statistics"]
git-tree-sha1 = "366715149014943abd71aa647a07a43314158b2d"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.2"
[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
......@@ -284,6 +314,18 @@ git-tree-sha1 = "31939159aeb8ffad1d4d8ee44d07f8558273120a"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.11.7"
[[FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"]
git-tree-sha1 = "f6f80c8f934efd49a286bb5315360be66956dfc4"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.8.0"
[[FiniteDifferences]]
deps = ["ChainRulesCore", "LinearAlgebra", "Printf", "Random", "Richardson", "StaticArrays"]
git-tree-sha1 = "ae1ce4975c393bad81a55cb073e2af04bd151f85"
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
version = "0.12.3"
[[FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
......@@ -302,6 +344,12 @@ git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.2"
[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "NaNMath", "Printf", "Random", "SpecialFunctions", "StaticArrays"]
git-tree-sha1 = "e2af66012e08966366a43251e1fd421522908be6"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.18"
[[FreeType2_jll]]
deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "cbd58c9deb1d304f5a245a0b7eb841a2560cfec6"
......@@ -355,15 +403,15 @@ uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
version = "2.59.0+4"
[[Grisu]]
git-tree-sha1 = "972f5abbfc7101df2ea122aa730f4861550aaf2f"
git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.1"
version = "1.0.2"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "0e67ed09b3d89a28bb804ef5b886499f3a40a0cb"
git-tree-sha1 = "b855bf8247d6e946c75bb30f593bfe7fe591058d"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.7"
version = "0.9.8"
[[Hwloc]]
deps = ["Hwloc_jll"]
......@@ -473,7 +521,9 @@ version = "0.6.2"
[[KissABC]]
deps = ["AbstractMCMC", "Distributions", "MonteCarloMeasurements", "Random"]
git-tree-sha1 = "693d4bd4cbb9ad6515414e0935bbd646b15fc16a"
git-tree-sha1 = "c6c85d271b03eb65021e3771eb620ed881078f83"
repo-rev = "master"
repo-url = "https://github.com/francescoalemanno/KissABC.jl.git"
uuid = "9c9dad79-530a-4643-a18b-2704674d4108"
version = "3.0.1"
......@@ -605,6 +655,12 @@ version = "1.3.5"
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Loess]]
deps = ["Distances", "LinearAlgebra", "Statistics"]
git-tree-sha1 = "b5254a86cf65944c68ed938e575f5c81d5dfe4cb"
uuid = "4345ca2d-374a-55d4-8d30-97f9976e7612"
version = "0.5.3"
[[LogExpFunctions]]
deps = ["DocStringExtensions", "LinearAlgebra"]
git-tree-sha1 = "ed26854d7c2c867d143f0e07c198fc9e8b721d10"
......@@ -621,10 +677,16 @@ uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
version = "0.4.6"
[[LoopVectorization]]
deps = ["ArrayInterface", "CheapThreads", "DocStringExtensions", "IfElse", "LinearAlgebra", "OffsetArrays", "Requires", "SLEEFPirates", "Static", "ThreadingUtilities", "UnPack", "VectorizationBase"]
git-tree-sha1 = "da82a865158e1d62e013fa72657fda7e92820a90"
deps = ["ArrayInterface", "CheapThreads", "DocStringExtensions", "IfElse", "LinearAlgebra", "OffsetArrays", "Requires", "SLEEFPirates", "Static", "StrideArraysCore", "ThreadingUtilities", "UnPack", "VectorizationBase"]
git-tree-sha1 = "50652d45832a4f907dbec3c57ac93af6f7d1f28c"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
version = "0.12.12"
version = "0.12.14"
[[LsqFit]]
deps = ["Distributions", "ForwardDiff", "LinearAlgebra", "NLSolversBase", "OptimBase", "Random", "StatsBase"]
git-tree-sha1 = "0c33987800fbc37edf3a5fd94520e6b06783a63b"
uuid = "2fda8390-95c7-5789-9bda-21331edee243"
version = "0.12.0"
[[MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
......@@ -680,13 +742,25 @@ version = "0.7.1"
[[MonteCarloMeasurements]]
deps = ["Distributed", "Distributions", "LinearAlgebra", "MacroTools", "Random", "RecipesBase", "Requires", "SLEEFPirates", "StaticArrays", "Statistics", "StatsBase", "Test"]
git-tree-sha1 = "2529d92658cd24d197f7bc80a34a9109ad4f1970"
git-tree-sha1 = "4852647c2dc2242e5b7e2907a96870a584a9488d"
uuid = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
version = "0.10.2"
version = "0.10.3"
[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
[[MutableArithmetics]]
deps = ["LinearAlgebra", "SparseArrays", "Test"]
git-tree-sha1 = "3301e152b9a208745fad6cd4b068307a5d218a38"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
version = "0.2.18"
[[NLSolversBase]]
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]
git-tree-sha1 = "50608f411a1e178e0129eab4110bd56efd08816f"
uuid = "d41bc354-129a-5804-8e4c-c37616107c6c"
version = "7.8.0"
[[NaNMath]]
git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
......@@ -720,9 +794,9 @@ version = "1.3.4+2"
[[OnlineStats]]
deps = ["AbstractTrees", "Dates", "LinearAlgebra", "OnlineStatsBase", "OrderedCollections", "Random", "RecipesBase", "Statistics", "StatsBase", "SweepOperator"]
git-tree-sha1 = "a3d0e72ffde4f596cc148c4c6555e310dcd5b2ba"
git-tree-sha1 = "042eb860cc994aa73b517f326922b03827bbc159"
uuid = "a15396b6-48d5-5d58-9928-6d29437db91e"
version = "1.5.8"
version = "1.5.9"
[[OnlineStatsBase]]
deps = ["AbstractTrees", "Dates", "LinearAlgebra", "OrderedCollections", "Statistics", "StatsBase"]
......@@ -742,6 +816,12 @@ git-tree-sha1 = "b9b8b8ed236998f91143938a760c2112dceeb2b4"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.4+0"
[[OptimBase]]
deps = ["NLSolversBase", "Printf", "Reexport"]
git-tree-sha1 = "4c26a757fbb5b1893b7df19a44e21762d8f8e470"
uuid = "87e2bd06-a317-5318-96d9-3ecbac512eee"
version = "2.0.1"
[[Opus_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "f9d57f4126c39565e05a2b0264df99f497fc6f37"
......@@ -810,6 +890,12 @@ git-tree-sha1 = "eced322de627fa8469c55f24899fdd4cce7d978c"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.13.2"
[[Polynomials]]
deps = ["Intervals", "LinearAlgebra", "MutableArithmetics", "RecipesBase"]
git-tree-sha1 = "3606b3e972f7a58b62432c95aa2bdab3f3d97831"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "2.0.10"
[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "cde4ce9d6f33219465b55162811d8de8139c0414"
......@@ -840,9 +926,9 @@ version = "0.1.4"
[[ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "6e9c89cba09f6ef134b00e10625590746ba1e036"
git-tree-sha1 = "d85d8f0339a9937afac93e152c76f4745b386202"
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.5.0"
version = "1.6.0"
[[PyCall]]
deps = ["Conda", "Dates", "Libdl", "LinearAlgebra", "MacroTools", "Serialization", "VersionParsing"]
......@@ -893,9 +979,10 @@ uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.3.2"
[[Reexport]]
git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5"
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.0.0"
version = "0.2.0"
[[Referenceables]]
deps = ["Adapt"]
......@@ -909,6 +996,12 @@ git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"
[[Richardson]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "e03ca566bec93f8a3aeb059c8ef102f268a38949"
uuid = "708f8203-808e-40c0-ba2d-98a6953ed40d"
version = "1.4.0"
[[Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "bf3188feca147ce108c76ad82c2792c57abe7b1f"
......@@ -957,9 +1050,9 @@ uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[Showoff]]
deps = ["Dates", "Grisu"]
git-tree-sha1 = "236dd0ddad6e3764cce8d8b09c0bbba6df2e194f"
git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "1.0.2"
version = "1.0.3"
[[SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"]
......@@ -971,10 +1064,10 @@ version = "0.9.3"
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
deps = ["DataStructures"]
git-tree-sha1 = "2ec1962eba973f383239da22e75218565c390a96"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"
version = "1.0.0"
[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
......@@ -1008,11 +1101,16 @@ version = "1.1.2"
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[[StatsAPI]]
git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.0.0"
[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"]
git-tree-sha1 = "4d8ca45223d7a28839e775d73a6f6b6b2ac64fd1"
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "2f6792d523d7448bbe2fec99eca9218f06cc746d"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.6"
version = "0.33.8"
[[StatsFuns]]
deps = ["LogExpFunctions", "Rmath", "SpecialFunctions"]
......@@ -1092,9 +1190,9 @@ version = "0.1.7"
[[TimeZones]]
deps = ["Dates", "EzXML", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "4ba8a9579a243400db412b50300cd61d7447e583"
git-tree-sha1 = "3f6f0be07f33e33bd986a58b4cf2d6c9fd2b7f18"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.5.3"
version = "1.5.4"
[[Transducers]]
deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"]
......@@ -1103,9 +1201,9 @@ uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.64"
[[URIs]]
git-tree-sha1 = "7855809b88d7b16e9b029afd17880930626f54a2"
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.2.0"
version = "1.3.0"
[[UUIDs]]
deps = ["Random", "SHA"]
......@@ -1121,9 +1219,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[VectorizationBase]]
deps = ["ArrayInterface", "Hwloc", "IfElse", "Libdl", "LinearAlgebra", "Static"]
git-tree-sha1 = "5d66756d2d5c538e9ab0c39efcb4512e3a8c3361"
git-tree-sha1 = "293aa2c5cbf201e6b98810cb36d9eeafdafdafd1"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
version = "0.19.31"
version = "0.19.34"
[[VersionParsing]]
git-tree-sha1 = "80229be1f670524750d905f8fc8148e5a8c4537f"
......
......@@ -6,13 +6,17 @@ version = "0.1.0"
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CurveFit = "5a033b19-8c74-5913-a970-47c3779ef25c"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ImportAll = "c65182e5-40f4-518f-8165-175b85689199"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
KissABC = "9c9dad79-530a-4643-a18b-2704674d4108"
......@@ -20,7 +24,9 @@ LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Loess = "4345ca2d-374a-55d4-8d30-97f9976e7612"
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
NamedTupleTools = "d9ec5142-1e00-5aa0-9d6a-321866360f50"
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
......
using CovidAlertVaccinationModel
using OnlineStats
using Plots
const samples = 1
const parameters = (
sim_length = 50,
sim_length = 30,
num_households = 5000,
I_0_fraction = 0.002,
base_transmission_probability = 0.0015,
I_0_fraction = 0.005,
base_transmission_probability = 0.001,
recovery_rate = 1/7,
immunization_loss_prob = 0.0055, #mean time of 6 months
π_base = -0.2,
κ = 0.001,
ω = 0.0000,
ρ = [0.0,0.0,0.0],
π_base = -4.0,
η = 0.0,
κ = 1.0,
ω = 0.001,
ρ = [0.0,0.0,0.0],
ω_en = 0.00,
ρ_en = [0.0,0.0,0.0],
γ = 0.0,
β = 100.0,
notification_parameter = 0.000,
β = 5.0,
notification_parameter = 0.001,
vaccinator_prob = 0.2,
app_user_fraction = 0.4,
notification_threshold = 2,
infection_introduction_delay = 50
immunizing = true,
immunizing = false,
immunization_delay = 14,
immunization_begin_delay = 0,
infection_introduction_delay = 1,
)
function solve_and_plot_parameters()
out = mean_solve(samples, parameters ,DebugRecorder)
p = plot_model(nothing,[nothing],[out])
savefig(p,"timeseries.pdf")
end
solve_and_plot_parameters()
\ No newline at end of file
seasonal_transmission_dist = CovidAlertVaccinationModel.fit_epi_parameters(parameters,0.073) ##seasonal
# outbreak_transmission_dist = CovidAlertVaccinationModel.fit_epi_parameters(parameters,0.241) ##outbreak
\ No newline at end of file
using CovidAlertVaccinationModel
using OnlineStats
using Plots
const samples = 5
const samples = 2
const parameters = (
sim_length = 600,
num_households = 5000,
......
......@@ -32,7 +32,22 @@ function get_u_0(nodes,I_0_fraction,vaccinator_prob)
return status,is_vaccinator
end
struct ModelSolution{T,InfNet,SocNet,WSMixingDist,RestMixingDist}
function app_users(demographics,app_usage_prob)
ymo_usage = [
0.979,
0.921,
0.604,
]
is_app_user = Vector{Bool}(undef,length(demographics))
@inbounds for i in eachindex(demographics)
demo = demographics[i]
is_app_user[i] = rand(RNG) < app_usage_prob*ymo_usage[Int(demo)]
end
return is_app_user
end
mutable struct ModelSolution{T,InfNet,SocNet,WSMixingDist,RestMixingDist}
sim_length::Int
nodes::Int
params::T
......@@ -50,7 +65,8 @@ struct ModelSolution{T,InfNet,SocNet,WSMixingDist,RestMixingDist}
app_user_list::Vector{Int}
app_user_index::Vector{Int}
status_totals::Vector{Int}
status_totals_next::Vector{Int}
daily_vaccinators::Int
daily_infected::Int
ws_matrix_tuple::WSMixingDist
rest_matrix_tuple::RestMixingDist
immunization_countdown::Vector{Int}
......@@ -63,8 +79,8 @@ struct ModelSolution{T,InfNet,SocNet,WSMixingDist,RestMixingDist}
ws_matrix_tuple = map_symmetrize(workschool_mixing)
rest_matrix_tuple = map_symmetrize(rest_mixing)
is_app_user = app_users(demographics,params.app_user_fraction)
app_user_list = zeros(nodes)
is_app_user = rand(RNG,nodes) .< params.app_user_fraction
app_user_index = findall(==(true),is_app_user)
app_user_list[is_app_user] .= collect(1:length(app_user_index))
......@@ -95,7 +111,8 @@ struct ModelSolution{T,InfNet,SocNet,WSMixingDist,RestMixingDist}
app_user_list,
app_user_index,
status_totals,
copy(status_totals),
0,
0,
ws_matrix_tuple,
rest_matrix_tuple,
immunization_countdown
......
......@@ -18,6 +18,7 @@ DebugRecorder should store everything we might want to know about the model outp
"""
struct DebugRecorder{ElType,ArrType1<:AbstractArray{ElType},ArrType2<:AbstractArray{ElType}} <: AbstractRecorder{ElType}
recorded_status_totals::ArrType1
daily_cases::ArrType2
total_vaccinators::ArrType2
mean_time_since_last_notification::ArrType2
end
......@@ -29,8 +30,10 @@ function DebugRecorder(sim_length)
state_totals = @LArray Array{Int}(undef,4,sim_length) (S = (1,:),I = (2,:),R = (3,:), V = (4,:))
total_vaccinators = Vector{Int}(undef,sim_length)
mean_time_since_last_notification = Vector{Int}(undef,sim_length)
daily_cases= Vector{Int}(undef,sim_length)
return DebugRecorder(
state_totals,
daily_cases,
total_vaccinators,
mean_time_since_last_notification,
)
......@@ -46,16 +49,18 @@ function DebugRecorder(val::T, sim_length) where T
total_vaccinators = [copy(val) for j in 1:sim_length]
mean_time_since_last_notification = [copy(val) for j in 1:sim_length]
daily_cases = [copy(val) for j in 1:sim_length]
return DebugRecorder(
state_totals,
daily_cases,
total_vaccinators,
mean_time_since_last_notification
)
end
function record!(t,modelsol, recorder::DebugRecorder)
recorder.total_vaccinators[t] = count(==(true),modelsol.u_vac)
recorder.total_vaccinators[t] = modelsol.daily_vaccinators
recorder.daily_cases[t] = modelsol.daily_infected
recorder.recorded_status_totals[:,t] .= modelsol.status_totals
alerts = filter(>(0),modelsol.time_of_last_alert)
if !isempty(alerts)
......@@ -93,7 +98,7 @@ end
using Printf
const ts_colors = cgrad(:PuBu_9)
function plot_model(varname,univariate_series, output_list::Vector{T},infection_begin,vac_begin) where T<:DebugRecorder
plts = [plot(),plot(),plot(),plot(),plot(),plot()]
plts = [plot() for i=1:7]
for (i,(p,data)) in enumerate(zip(univariate_series, output_list))
# display(p[varname])
if !isnothing(varname)
......@@ -117,6 +122,7 @@ function plot_model(varname,univariate_series, output_list::Vector{T},infection_
title = "Infected over time",
legend=false,
)
plot!(plts[3], mean.(data.recorded_status_totals.R); ribbon = std.(data.recorded_status_totals.R),
label = labelname, line_z = i, color=:blues,
ylabel = "no. of people",
......@@ -145,10 +151,21 @@ function plot_model(varname,univariate_series, output_list::Vector{T},infection_
title = "Mean time since last notification",
legend=false
)
# ic,exp_growth_rate = exp_growth_rate_estimation(mean.(data.daily_cases[infection_begin,:]))
plot!(plts[7], mean.(data.daily_cases); ribbon = std.(data.daily_cases),
label = labelname, line_z = i, color=:blues,
ylabel = "Days",
colorbar = false,
title = "Daily (incident) cases",
legend= false
)
end
for p in plts
vline!(p,[infection_begin]; label = "infection begin", line =:dot)
vline!(p,[vac_begin]; label = "vaccination begin",line = :dot)
end
return plot(plts...;layout = (6,1),size=(800,2500),leftmargin = 8Plots.mm)
return plot(plts...;layout = (7,1),size=(800,2900),leftmargin = 8Plots.mm)
end
using KissABC
using CurveFit
using Loess
@views function exp_growth_rate_estimation(incident_cases)
diff(l) = [l[i] - l[i-1] for i=2:length(l)]
l = length(incident_cases)
loess_interp = loess(1:l,incident_cases)
interp_incident_cases = Loess.predict(loess_interp, collect(1.0:l))
second_deriative =diff(diff(interp_incident_cases))
inflection_pt = any(second_deriative.<=-1) ? findfirst(<=(-1),second_deriative) : l #completely heuristic
ic,exp_growth_rate = exp_fit(1:inflection_pt, incident_cases[1:inflection_pt]) #fit y = a exp(b x), b is exp growth rate
return ic,exp_growth_rate
end
function vaccination_data()
end
function fit_epi_parameters(p_tuple, target_growth_rate)
samples = 1
priors = Factored(Uniform(0.0001,0.005))
function cost(p)
new_params = merge(p_tuple, (base_transmission_probability = p[1],))
out = mean_solve(samples, new_params ,DebugRecorder)
incident_cases = mean.(out.daily_cases)
_,exp_growth_rate = exp_growth_rate_estimation(incident_cases)
return (target_growth_rate - exp_growth_rate)^2
end
out = ABCDE(priors,cost,0.01; verbose=true, nparticles=100,generations=20, parallel = true) #this one has better NaN handling
return out
end
function fit_behavioural_parameters(p_tuple, target_growth_rate)
samples = 1
priors = Factored(Uniform(0.0001,0.005))
function cost(p)
new_params = merge(p_tuple, (base_transmission_probability = p[1],))
out = mean_solve(samples, new_params ,DebugRecorder)
incident_cases = mean.(out.daily_cases)
_,exp_growth_rate = exp_growth_rate_estimation(incident_cases)
return (target_growth_rate - exp_growth_rate)^2
end
out = ABCDE(priors,cost,0.01; verbose=true, nparticles=100,generations=20, parallel = true) #this one has better NaN handling
return out
end
\ No newline at end of file
......@@ -42,6 +42,7 @@ end
Base.@propagate_inbounds @views function update_infection_state!(t,modelsol)
@unpack base_transmission_probability,immunization_loss_prob,recovery_rate,immunizing,immunization_begin_delay = modelsol.params
@unpack u_inf,u_vac,u_next_inf,u_next_vac,demographics,inf_network,status_totals, immunization_countdown = modelsol
daily_cases = 0
function agent_transition!(node, from::AgentStatus,to::AgentStatus)
immunization_countdown[node] = -1
......@@ -49,7 +50,6 @@ Base.@propagate_inbounds @views function update_infection_state!(t,modelsol)
status_totals[Int(to)] += 1
u_next_inf[node] = to
end
u_next_inf .= u_inf
for i in 1:modelsol.nodes
agent_status = u_inf[i]
......@@ -63,6 +63,7 @@ Base.@propagate_inbounds @views function update_infection_state!(t,modelsol)
for j in neighbors(mixing_graph.g,i)
if u_inf[j] == Infected && u_next_inf[i] != Infected
if rand(RNG) < contact_weight(base_transmission_probability,get_weight(mixing_graph,GraphEdge(i,j)))
daily_cases+=1
agent_transition!(i, Susceptible,Infected)
end
end
......@@ -87,13 +88,12 @@ Base.@propagate_inbounds @views function update_infection_state!(t,modelsol)
immunization_countdown[i] -= 1
end
end
# display(immunization_countdown)
modelsol.daily_infected = daily_cases
end
Base.@propagate_inbounds @views function update_vaccination_opinion_state!(t,modelsol,total_infections)
@unpack π_base, η,γ, κ, ω, ρ, ω_en,ρ_en,γ,β = modelsol.params
@unpack demographics,time_of_last_alert, nodes, soc_network,u_vac,u_next_vac,app_user,app_user_list = modelsol
app_user_pointer = 0
for i in 1:nodes
vac_payoff = 0
soc_nbrs_vac = @MArray [0,0,0]
......@@ -131,6 +131,8 @@ Base.@propagate_inbounds @views function update_vaccination_opinion_state!(t,mod
end
end
end
modelsol.daily_vaccinators = count(==(true),u_vac)
end
......@@ -161,11 +163,11 @@ end
function solve!(modelsol,recordings...)
for t in 1:modelsol.sim_length
agents_step!(t,modelsol)
#advance agent states based on the new network
for recording in recordings
record!(t,modelsol,recording)
end
agents_step!(t,modelsol)
end
end
......
......@@ -51,6 +51,7 @@ include("ABM/mixing_distributions.jl")
include("ABM/mixing_graphs.jl")
include("ABM/agents.jl")
include("ABM/model_setup.jl")
include("ABM/parameter_optimization.jl")
include("ABM/output.jl")
include("ABM/solve.jl")
include("ABM/abm.jl")
......
test.pdf 0 → 100644
File added
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment