diff options
author | Ta180m | 2020-04-29 19:09:32 -0500 |
---|---|---|
committer | Ta180m | 2020-04-29 19:09:32 -0500 |
commit | 9a82dd97daf6b899be8c8aa1d0f311f86b82d8e7 (patch) | |
tree | 5c8c3a219604db5ae24f6a48c17f611e4b506873 | |
parent | 7aab8f8c52aaf082a8aadd7eb7e0afd01acebe34 (diff) |
Hopefully fixed everything
-rw-r--r-- | COVID-19-SIR.png | bin | 0 -> 40438 bytes | |||
-rw-r--r-- | COVID-19.png | bin | 40198 -> 0 bytes | |||
-rw-r--r-- | LinearCompartmentModels.mw (renamed from 2020Unit08-CalcIII.LinearCompartmentModels.mw) | 0 | ||||
-rw-r--r-- | NLCModel01.mw (renamed from 2020Unit08-CalcIII.InfectiousDiseaseNLCModel01.mw) | 0 | ||||
-rw-r--r-- | NLCModel02.mw (renamed from 2020Unit08-CalcIII.InfectiousDiseaseNLCModel02.mw) | 0 | ||||
-rw-r--r-- | NLCModel03.mw (renamed from 2020Unit08-CalcIII.InfectiousDiseaseNLCModel03.mw) | 0 | ||||
-rw-r--r-- | SARS-SIR.png | bin | 0 -> 41624 bytes | |||
-rw-r--r-- | SARS.png | bin | 28280 -> 0 bytes | |||
-rw-r--r-- | TEST.png | bin | 26285 -> 0 bytes | |||
-rw-r--r-- | out/COVID-19-SIR-data.csv | 3 | ||||
-rw-r--r-- | out/COVID-19-SIR-prediction.csv | 78 | ||||
-rw-r--r-- | out/COVID-19-data.csv | 3 | ||||
-rw-r--r-- | out/COVID-19-prediction.csv | 78 | ||||
-rw-r--r-- | out/SARS-SIR-data.csv | 3 | ||||
-rw-r--r-- | out/SARS-SIR-prediction.csv | 77 | ||||
-rw-r--r-- | out/SARS-data.csv | 3 | ||||
-rw-r--r-- | out/SARS-prediction.csv | 77 | ||||
-rw-r--r-- | out/TEST-data.csv | 3 | ||||
-rw-r--r-- | out/TEST-prediction.csv | 4 | ||||
-rw-r--r-- | sir_model.cpp | 4 | ||||
-rw-r--r-- | sir_model.exe | bin | 0 -> 48143 bytes | |||
-rw-r--r-- | solver2.py | 61 |
22 files changed, 195 insertions, 199 deletions
diff --git a/COVID-19-SIR.png b/COVID-19-SIR.png Binary files differnew file mode 100644 index 0000000..4497cb1 --- /dev/null +++ b/COVID-19-SIR.png diff --git a/COVID-19.png b/COVID-19.png Binary files differdeleted file mode 100644 index b57bf1a..0000000 --- a/COVID-19.png +++ /dev/null diff --git a/2020Unit08-CalcIII.LinearCompartmentModels.mw b/LinearCompartmentModels.mw index 1b482d4..1b482d4 100644 --- a/2020Unit08-CalcIII.LinearCompartmentModels.mw +++ b/LinearCompartmentModels.mw diff --git a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel01.mw b/NLCModel01.mw index b371730..b371730 100644 --- a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel01.mw +++ b/NLCModel01.mw diff --git a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel02.mw b/NLCModel02.mw index ee5d005..ee5d005 100644 --- a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel02.mw +++ b/NLCModel02.mw diff --git a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel03.mw b/NLCModel03.mw index d17ba93..d17ba93 100644 --- a/2020Unit08-CalcIII.InfectiousDiseaseNLCModel03.mw +++ b/NLCModel03.mw diff --git a/SARS-SIR.png b/SARS-SIR.png Binary files differnew file mode 100644 index 0000000..d9332e0 --- /dev/null +++ b/SARS-SIR.png diff --git a/SARS.png b/SARS.png Binary files differdeleted file mode 100644 index 53eb45c..0000000 --- a/SARS.png +++ /dev/null diff --git a/TEST.png b/TEST.png Binary files differdeleted file mode 100644 index dab8c0b..0000000 --- a/TEST.png +++ /dev/null diff --git a/out/COVID-19-SIR-data.csv b/out/COVID-19-SIR-data.csv new file mode 100644 index 0000000..68fc931 --- /dev/null +++ b/out/COVID-19-SIR-data.csv @@ -0,0 +1,3 @@ +Beta: 0.11506051868918243 +Gamma: 0.004484787817138545 +R0: 25.65573297570077
\ No newline at end of file diff --git a/out/COVID-19-SIR-prediction.csv b/out/COVID-19-SIR-prediction.csv new file mode 100644 index 0000000..dda0000 --- /dev/null +++ b/out/COVID-19-SIR-prediction.csv @@ -0,0 +1,78 @@ +,Actual,S,I,R +1/22/20,0.0033333333333333335,9999.666666666666,0.33333333333333337,0.0 +1/23/20,0.0033333333333333335,9999.626113483311,0.3723057932824626,0.0015807234055033998 +1/24/20,0.006666666666666667,9999.580819471055,0.4158342816934694,0.003346247251000438 +1/25/20,0.006666666666666667,9999.530230573782,0.46445125535619813,0.00531817086165759 +1/26/20,0.016666666666666666,9999.473709826556,0.5187688441820978,0.007521329263086074 +1/27/20,0.016666666666666666,9999.410196574465,0.5798062772339272,0.009997148300881093 +1/28/20,0.016666666666666666,9999.339138930427,0.6480939379280791,0.012767131645821241 +1/29/20,0.016666666666666666,9999.260060733477,0.7240894731817856,0.01584979334159779 +1/30/20,0.016666666666666666,9999.172254217212,0.8084730926218743,0.01927269016575604 +1/31/20,0.023333333333333334,9999.074780009785,0.9021475685847693,0.023072421629695316 +2/1/20,0.02666666666666667,9998.966467133905,1.0062382361164908,0.02729462997866896 +2/2/20,0.02666666666666667,9998.845913006835,1.1220929929726546,0.03199400019178435 +2/3/20,0.03666666666666667,9998.711483440398,1.2512822996184734,0.037234259982002894 +2/4/20,0.03666666666666667,9998.561312640975,1.3955991792287554,0.043088179796139985 +2/5/20,0.03666666666666667,9998.393303209497,1.5570592176879055,0.0496375728148651 +2/6/20,0.03666666666666667,9998.205126141458,1.7379005635899234,0.056973294952701675 +2/7/20,0.03666666666666667,9997.994220826904,1.9405839282384063,0.06519524485802725 +2/8/20,0.03666666666666667,9997.75779505044,2.1677925856465476,0.07441236391307328 +2/9/20,0.03666666666666667,9997.492824991228,2.422432372537136,0.0847426362339254 +2/10/20,0.03666666666666667,9997.196055222987,2.7076316883425555,0.0963130886705231 +2/11/20,0.04,9996.863998713989,3.0267414952047873,0.10925979080666 +2/12/20,0.04,9996.492936827064,3.38333531797541,0.12372785495998372 +2/13/20,0.043333333333333335,9996.078919319601,3.7812092442155962,0.13987143618199585 +2/14/20,0.043333333333333335,9995.617764343546,4.2243819241961145,0.15785373225805216 +2/15/20,0.043333333333333335,9995.1003045259,4.721655585099373,0.17803988899952877 +2/16/20,0.043333333333333335,9994.516837015459,5.282346835600999,0.2008161489413117 +2/17/20,0.043333333333333335,9993.866263436728,5.907518666955111,0.22621789631618436 +2/18/20,0.043333333333333335,9993.14533367619,6.600300535008138,0.2543657888027925 +2/19/20,0.043333333333333335,9992.348486073488,7.366041685509018,0.2854722410034983 +2/20/20,0.043333333333333335,9991.467847421447,8.212311154109193,0.31984142444438063 +2/21/20,0.05,9990.493232966062,9.148897766362614,0.3578692675752351 +2/22/20,0.05,9989.412146406505,10.187810137725744,0.4000434557695737 +2/23/20,0.05,9988.209779895118,11.343276673557556,0.4469434313246251 +2/24/20,0.05,9986.86901403742,12.631745569119527,0.4992403934613348 +2/25/20,0.05,9985.3704178921,14.07188480957564,0.5576972983243645 +2/26/20,0.05,9983.692248971025,15.684582169992398,0.6231688589820928 +2/27/20,0.05333333333333334,9981.810453239235,17.492945215338796,0.6966015454266151 +2/28/20,0.05333333333333334,9979.69866511494,19.522301300486347,0.7790335845737427 +2/29/20,0.08,9977.328207469527,21.800197570209086,0.8715949602630044 +3/1/20,0.1,9974.668091627558,24.356400959183517,0.9755074132576449 +3/2/20,0.17666666666666667,9971.685017366766,27.222898191988705,1.092084441244626 +3/3/20,0.24333333333333335,9968.34337291806,30.43389578310618,1.2227312988346257 +3/4/20,0.3466666666666667,9964.605234965518,34.025820036919995,1.3689449975620385 +3/5/20,0.5733333333333334,9960.430368646397,38.037317047716726,1.5323143058849769 +3/6/20,0.7233333333333334,9955.77622755113,42.50925269968544,1.7145197491852677 +3/7/20,1.12,9950.597953723314,47.4847126669177,1.9173336097684561 +3/8/20,1.5,9944.8448045356,53.01237292907167,2.142822535329084 +3/9/20,1.7133333333333334,9938.42938086884,59.17565842355453,2.3949607076053994 +3/10/20,2.3600000000000003,9931.284416242248,66.03936148704915,2.6762222707021737 +3/11/20,3.6833333333333336,9923.337837581861,73.67299461476044,2.9891678033797313 +3/12/20,5.19,9914.501858677362,82.16105475639304,3.3370865662455413 +3/13/20,7.156666666666667,9904.672980182095,91.60302331615122,3.7239965017542147 +3/14/20,9.523333333333333,9893.731989613054,102.11336615273899,4.1546442342075025 +3/15/20,9.726666666666667,9881.543961350886,113.82153357936006,4.634505069754301 +3/16/20,14.356666666666667,9867.958256639891,126.87196036371769,5.169782996390647 +3/17/20,20.32,9852.808523588024,141.42406572801508,5.767410683959723 +3/18/20,29.576666666666668,9835.912697166894,157.65225334895476,6.435049484151843 +3/19/20,46.980000000000004,9817.072999211756,175.7459113577394,7.181089430504479 +3/20/20,64.67666666666668,9796.075938421527,195.90941234007096,8.014649238402235 +3/21/20,85.75,9772.692310358772,218.3621133361513,8.94557630507686 +3/22/20,112.11333333333334,9746.677197449711,243.33835584068188,9.984446709607242 +3/23/20,145.54333333333335,9717.769968984217,271.0874658028638,11.14256521291942 +3/24/20,179.12,9685.694281115815,301.87375362639807,12.431965257786567 +3/25/20,219.26000000000002,9650.158076861686,335.9765141694853,13.865408968829001 +3/26/20,279.4533333333334,9610.856608434478,373.6868457962786,15.456545769241968 +3/27/20,338.8566666666667,9567.478576225396,415.2978095557358,17.223614218867255 +3/28/20,404.9266666666667,9519.55452671549,461.25900332866496,19.186469955843926 +3/29/20,469.6966666666667,9466.575218355096,512.0586800277034,21.366101617200858 +3/30/20,539.4566666666667,9408.030818560183,568.1836003605466,23.78558107927107 +3/31/20,627.24,9343.41090371236,630.1190328299489,26.470063457691705 +4/1/20,711.2066666666667,9272.204459158873,698.3487537337221,29.44678710740408 +4/2/20,812.0533333333334,9193.899879212608,773.3550471647377,32.745073622653635 +4/3/20,918.6066666666667,9107.984967152086,855.6187050109245,36.39632783698995 +4/4/20,1029.4833333333333,9013.946935221464,945.6190269552703,40.434037823266756 +4/5/20,1123.5500000000002,8911.272404630537,1043.8338204758206,44.89377489364194 +4/6/20,1222.2,8799.447405554742,1150.7394008456806,49.8131935995775 +4/7/20,1320.7366666666667,8677.957377135148,1266.8105911330124,55.23203173183961 diff --git a/out/COVID-19-data.csv b/out/COVID-19-data.csv deleted file mode 100644 index 7809e69..0000000 --- a/out/COVID-19-data.csv +++ /dev/null @@ -1,3 +0,0 @@ -Beta: 0.12123601582761864 -Gamma: 0.004788532110372095 -R0: 25.317991616891955
\ No newline at end of file diff --git a/out/COVID-19-prediction.csv b/out/COVID-19-prediction.csv deleted file mode 100644 index adec705..0000000 --- a/out/COVID-19-prediction.csv +++ /dev/null @@ -1,78 +0,0 @@ -,Actual,S,I,R -1/22/20,0.01529051987767584,49999.0,1.0,0.0 -1/23/20,0.01529051987767584,49998.87142424206,1.1234972154720178,0.005078542461735381 -1/24/20,0.03058103975535168,49998.726971267446,1.2622445067142218,0.010784225844925973 -1/25/20,0.03058103975535168,49998.564682877775,1.418122720321673,0.017194401905434777 -1/26/20,0.0764525993883792,49998.38234997699,1.5932536885634114,0.024396334439772325 -1/27/20,0.0764525993883792,49998.1761616234,1.7912976312291053,0.032540745365268506 -1/28/20,0.0764525993883792,49997.94267086507,2.0155651686230516,0.04176396630732312 -1/29/20,0.0764525993883792,49997.68103501622,2.2668658997885043,0.052099083983799914 -1/30/20,0.0764525993883792,49997.389420767366,2.5469608746381214,0.06361835799887736 -1/31/20,0.10703363914373089,49997.064956030794,2.858608840222778,0.07643512898078467 -2/1/20,0.12232415902140673,49996.70372994068,3.2055662407315637,0.09070381858180188 -2/2/20,0.12232415902140673,49996.30079285303,3.592587217491785,0.10661992947825968 -2/3/20,0.16819571865443425,49995.85015634566,4.025423608968964,0.12442004537053958 -2/4/20,0.16819571865443425,49995.344793218246,4.510824950766836,0.14438183098307383 -2/5/20,0.16819571865443425,49994.77663749231,5.05653847562736,0.16682403206434543 -2/6/20,0.16819571865443425,49994.13658441118,5.671309113430702,0.1921064753868881 -2/7/20,0.16819571865443425,49993.41449044005,6.36487949119525,0.2206300687472865 -2/8/20,0.16819571865443425,49992.59917326595,7.1479899330776036,0.2528368009661757 -2/9/20,0.16819571865443425,49991.67841179774,8.032378460372584,0.2892097418882419 -2/10/20,0.16819571865443425,49990.6389461661,9.03078079151322,0.3302730423822217 -2/11/20,0.1834862385321101,49989.46647772359,10.156930342070767,0.3765919343409029 -2/12/20,0.1834862385321101,49988.145669044556,11.425558224754685,0.4287727306811233 -2/13/20,0.19877675840978593,49986.66014392524,12.85239324941266,0.4874628253437725 -2/14/20,0.19877675840978593,49984.99248738367,14.454161923030584,0.5533506932937899 -2/15/20,0.19877675840978593,49983.12424565975,16.248588449732576,0.6271658905201664 -2/16/20,0.19877675840978593,49981.02889523054,18.261139779188554,0.70996499027104 -2/17/20,0.19877675840978593,49978.651306317464,20.54472852896415,0.8039651535683541 -2/18/20,0.19877675840978593,49975.97895646455,23.11139937053732,0.909644164911142 -2/19/20,0.19877675840978593,49972.9967703992,25.97565285443824,1.027576746355153 -2/20/20,0.19877675840978593,49969.678659363395,29.162561937280955,1.1587786993212803 -2/21/20,0.2293577981651376,49965.98752111364,32.70777198176339,1.3047069045955584 -2/22/20,0.2293577981651376,49961.875239921,36.65750075666734,1.4672593223291648 -2/23/20,0.2293577981651376,49957.2826865711,41.068538436858454,1.6487749920384194 -2/24/20,0.2293577981651376,49952.13971836411,46.0082476032863,1.8520340326047855 -2/25/20,0.2293577981651376,49946.365179114735,51.55456324298426,2.0802576422748684 -2/26/20,0.2293577981651376,49939.86689915227,57.795992749069626,2.337108098660416 -2/27/20,0.24464831804281345,49932.54169532051,64.83161592074356,2.626688758738319 -2/28/20,0.24464831804281345,49924.275370977855,72.7710849632911,2.95354405885061 -2/29/20,0.3669724770642202,49914.94271599721,81.73462448808112,3.322659514704465 -3/1/20,0.4587155963302752,49904.40750676606,91.85303151256642,3.739461721372202 -3/2/20,0.8103975535168195,49892.522506186426,103.26767546028361,4.209818353291284 -3/3/20,1.1162079510703364,49879.12946367488,116.13049816085325,4.740038164264311 -3/4/20,1.5902140672782874,49864.05911516256,130.6040138499797,5.336870987459033 -3/5/20,2.6299694189602447,49847.13118309514,146.86130916945123,6.007507735408336 -3/6/20,3.318042813455657,49828.154376432845,165.08604316714002,6.759580400010251 -3/7/20,5.137614678899083,49806.92639065047,185.472447297002,7.601162052527955 -3/8/20,6.8807339449541285,49783.15387362768,208.30131583295304,8.544810539364274 -3/9/20,7.859327217125382,49756.46216012896,233.93144509123292,9.606394779802377 -3/10/20,10.825688073394495,49726.5796666417,262.62464902953786,10.79568432875744 -3/11/20,16.896024464831804,49693.16121368366,294.7130775011809,12.125708815156308 -3/12/20,23.807339449541285,49655.78361959187,330.60339369236084,13.612986715763734 -3/13/20,32.82874617737003,49613.94570052266,370.7767741221621,15.277525355182393 -3/14/20,43.68501529051988,49567.068270451586,415.7889086425552,17.14282090585288 -3/15/20,44.6177370030581,49514.49414117355,466.2700004383959,19.2358583880537 -3/16/20,65.85626911314985,49455.48812230267,522.9247660274261,21.587111669901272 -3/17/20,93.21100917431193,49389.237021272376,586.5324352602737,24.23054346734994 -3/18/20,135.67278287461772,49314.84964333535,657.9467513204519,27.20360534419196 -3/19/20,215.5045871559633,49231.35679156358,738.0959707243596,30.5472377120575 -3/20/20,296.6819571865443,49137.7112668483,827.9828633212821,34.30586983041465 -3/21/20,393.348623853211,49032.787867900035,928.68471229339,38.52741980656942 -3/22/20,514.2813455657492,48915.38339124859,1041.3533141557398,43.26329459566571 -3/23/20,667.6299694189603,48784.216631243034,1167.2149787562737,48.5683900006854 -3/24/20,821.651376146789,48637.92838005173,1307.5705292758196,54.5010906724482 -3/25/20,1005.7798165137615,48475.23815719861,1463.632752792264,61.12909000912159 -3/26/20,1281.8960244648317,48294.55190123027,1636.9083208388115,68.53977793091411 -3/27/20,1554.388379204893,48093.39034634198,1829.7869013768861,76.82275228112964 -3/28/20,1857.4617737003057,47869.19051439562,2044.730256305486,86.07922929888963 -3/29/20,2154.571865443425,47619.33475639337,2284.2426197884333,96.4226238181884 -3/30/20,2474.571865443425,47341.150752477726,2550.8706982543795,107.97854926789326 -3/31/20,2877.2477064220184,47031.91151193145,2847.2036703968,120.88481767174422 -4/1/20,3262.4159021406726,46688.835373177644,3175.8731871739956,135.29143964835436 -4/2/20,3725.0152905198775,46309.086003779696,3539.553371809094,151.36062441120953 -4/3/20,4213.792048929664,45889.772400441274,3940.960819790049,169.26677976866858 -4/4/20,4722.400611620795,45427.94888900639,4382.85459886964,189.1965121239631 -4/5/20,5153.899082568807,44920.61512445932,4868.036249065472,211.3486264751976 -4/6/20,5606.422018348624,44364.71609092467,5399.349782659975,235.93412641534957 -4/7/20,6058.4250764526,43757.14210166731,5979.681684200406,263.1762141322693 diff --git a/out/SARS-SIR-data.csv b/out/SARS-SIR-data.csv new file mode 100644 index 0000000..b8e7f28 --- /dev/null +++ b/out/SARS-SIR-data.csv @@ -0,0 +1,3 @@ +Beta: 0.031662971068960946 +Gamma: 0.018519768809938723 +R0: 1.7096850070811285
\ No newline at end of file diff --git a/out/SARS-SIR-prediction.csv b/out/SARS-SIR-prediction.csv new file mode 100644 index 0000000..9a3a4c5 --- /dev/null +++ b/out/SARS-SIR-prediction.csv @@ -0,0 +1,77 @@ +,Actual,S,I,R +4/10/03,499.0,9500.0,500.0,0.0 +4/11/03,529.5,9484.884979595565,505.80148109959003,9.313539304844733 +4/12/03,554.0,9469.619417390539,511.64566678773895,18.73491582172085 +4/14/03,595.0,9454.202845099702,517.5322376669819,28.26491723331429 +4/15/03,616.0,9438.634815392412,523.4608571171718,37.90432749041551 +4/16/03,634.0,9422.91490886804,529.4311682856298,47.65392284632816 +4/17/03,648.5,9407.04273428322,535.4427939878531,57.51447172892478 +4/18/03,679.0,9391.017928551839,541.4953367075137,67.48673474064691 +4/19/03,679.0,9374.840156745033,547.5883785964601,77.57146465850494 +4/21/03,701.0,9358.509112091206,553.7214814747153,87.76940643407822 +4/22/03,717.0,9342.024515976005,559.894186830479,98.08129719351507 +4/23/03,729.0,9325.38611794234,566.1060158201255,108.5078662375327 +4/24/03,744.0,9308.593695690377,572.3564692682052,119.04983504141725 +4/25/03,755.0,9291.647076432952,578.6450722781254,129.70785128892103 +4/26/03,763.5,9274.546254563056,584.9716358776624,140.48210955928025 +4/28/03,778.5,9257.291082520527,591.3356116538148,151.37330582565713 +4/29/03,786.0,9239.88140918478,597.736342445242,162.38224836997682 +4/30/03,794.5,9222.31712462584,604.173152454918,173.50972291924018 +5/1/03,800.0,9204.598160104344,610.6453472501305,184.75649264552393 +5/2/03,805.5,9186.724488071535,617.1522137624829,196.1232981659804 +5/3/03,810.5,9168.696122169269,623.6930202878924,207.61085754283772 +5/5/03,818.5,9150.513117230008,630.2670164865909,219.21986628339982 +5/6/03,823.0,9132.175569276827,636.8734333831252,230.95099734004629 +5/7/03,827.0,9113.68361552341,643.5114833663562,242.80490111023255 +5/8/03,830.5,9095.03743437405,650.1803601894597,254.78220543648973 +5/9/03,833.5,9076.237245423648,656.8792389699258,266.8835156064247 +5/10/03,837.0,9057.283309457718,663.6072761895597,279.10941435272 +5/12/03,841.5,9038.175928452385,670.3636096944803,291.4604618531342 +5/13/03,844.5,9018.915445574376,677.1473586951217,303.9371957305013 +5/14/03,849.0,8999.502245181035,683.9576237662324,316.5401310527311 +5/15/03,851.5,8979.936752820313,690.7934868468756,329.26976033280937 +5/16/03,853.0,8960.219435230772,697.6540112404288,342.1265535287975 +5/17/03,855.0,8940.350800341583,704.5382416145842,355.11095804383234 +5/19/03,857.0,8920.331397272523,711.4452040013485,368.223398726127 +5/20/03,859.0,8900.161816333986,718.3739057970432,381.46427786896993 +5/21/03,859.5,8879.84268902697,725.3233357623042,394.8339752107257 +5/22/03,861.0,8859.374688043083,732.2924640220818,408.3328479348343 +5/23/03,862.0,8838.758527264547,739.2802420656409,421.96123066981147 +5/24/03,862.0,8817.994961764189,746.2856027465614,435.719435489249 +5/26/03,863.0,8797.084787805446,753.3074602827372,449.60775191181426 +5/27/03,864.0,8776.028842842372,760.3447102563772,463.62644690125006 +5/28/03,865.0,8754.828005519617,767.3962296140044,477.77576486637554 +5/29/03,866.0,8733.483195672457,774.4608766664569,492.05592766108515 +5/30/03,868.0,8711.995374326762,781.5374910888871,506.46713458434937 +5/31/03,869.5,8690.365543699023,788.6248939207617,521.0095623802142 +6/2/03,873.0,8668.594747196334,795.7218875658625,535.6833652378015 +6/3/03,873.5,8646.684069416404,802.8272557922855,550.4886747913089 +6/4/03,874.0,8624.634636147548,809.9397637324413,565.4256001200094 +6/5/03,874.0,8602.447614368692,817.0581578830551,580.4942277482527 +6/6/03,875.0,8580.12421224937,824.1811661051668,595.6946216454631 +6/9/03,876.5,8557.665679149726,831.3074976241306,611.0268232261413 +6/10/03,877.0,8535.073305620519,838.4358430296157,626.490851349864 +6/11/03,877.0,8512.34842340311,845.5648742756055,642.0867023212829 +6/12/03,877.5,8489.492405429475,852.6932446803977,657.8143498901256 +6/13/03,877.5,8466.506665822197,859.8195889266052,673.6737452511964 +6/16/03,877.5,8443.392659894469,866.9425230611552,689.664817044374 +6/17/03,877.5,8420.151884150095,874.0606444952892,705.7874713546134 +6/18/03,877.5,8396.78587628349,881.1725320045638,722.0415917119461 +6/19/03,877.5,8373.296215179671,888.2767457288496,738.4270390914784 +6/20/03,877.5,8349.684520914274,895.3718271723321,754.943651913392 +6/23/03,877.5,8325.952454753542,902.4562992035115,771.5912460429457 +6/24/03,877.5,8302.101719154323,909.528666055202,788.3696147904728 +6/25/03,877.5,8278.134057764082,916.587413324533,805.2785289113833 +6/26/03,877.5,8254.051255420887,923.6310079729482,822.3177366061623 +6/27/03,877.5,8229.855138153422,930.6578983262057,839.4869635203708 +6/30/03,877.5,8205.547573180975,937.6665140743783,856.7859127446457 +7/1/03,877.5,8181.130468913446,944.6552662718534,874.214264814699 +7/2/03,877.5,8156.605774951346,951.622547337333,891.7716777113201 +7/3/03,877.5,8131.9754820857925,958.5667310538335,909.4577868603722 +7/4/03,877.5,8107.241622298517,965.4861725686861,927.2722051327953 +7/7/03,877.5,8082.406268761857,972.3792083935365,945.2145228446052 +7/8/03,877.5,8057.47153583876,979.2441564043446,963.2843077568929 +7/9/03,877.5,8032.439579082788,986.0793158413854,981.4811050758253 +7/10/03,877.5,8007.312595238105,992.8829673092482,999.8044374526455 +7/11/03,877.5,7982.09282223949,999.6533727768367,1018.2538049836719 +8/7/03,877.5,7956.78253921233,1006.3887755773695,1036.8286852102988 diff --git a/out/SARS-data.csv b/out/SARS-data.csv deleted file mode 100644 index 65b5f2f..0000000 --- a/out/SARS-data.csv +++ /dev/null @@ -1,3 +0,0 @@ -Beta: 1e-08 -Gamma: 0.0061248427719888315 -R0: 1.6326949723074842e-06
\ No newline at end of file diff --git a/out/SARS-prediction.csv b/out/SARS-prediction.csv deleted file mode 100644 index f677152..0000000 --- a/out/SARS-prediction.csv +++ /dev/null @@ -1,77 +0,0 @@ -,Actual,S,I,R -4/10/03,0.1566473081148956,9999.0,1.0,0.0 -4/11/03,0.16622194318003453,9998.999999990032,0.9938938857782499,0.00610612419019138 -4/12/03,0.17391304347826086,9998.999999980124,0.9878250561849686,0.01217496369104556 -4/14/03,0.18678386438549677,9998.999999970278,0.9817932835629529,0.018206746160137382 -4/15/03,0.1933762360696908,9998.99999996049,0.9757983416361868,0.02420169787385227 -4/16/03,0.1990268403704285,9998.999999950764,0.9698400055077305,0.03016004372949699 -4/17/03,0.20357871605713387,9998.999999941096,0.9639180446502709,0.036082014254761215 -4/18/03,0.2131533511222728,9998.999999931486,0.958032229361117,0.0419678391527109 -4/19/03,0.2131533511222728,9998.999999921936,0.9521823415639332,0.04781773650003748 -4/21/03,0.2200596452676189,9998.999999912445,0.9463681643524197,0.05363192320339512 -4/22/03,0.22508240464605242,9998.99999990301,0.9405894819398969,0.05941061504981562 -4/23/03,0.22884947417987755,9998.999999893635,0.9348460796593057,0.0651540267067084 -4/24/03,0.233558311097159,9998.999999884314,0.9291377439632077,0.07086237172186058 -4/25/03,0.23701145816983205,9998.999999875054,0.9234642624237851,0.07653586252343685 -4/26/03,0.23967979908962483,9998.999999865848,0.9178254237328403,0.08217471041997958 -4/28/03,0.24438863600690627,9998.999999856698,0.9122210177017966,0.08777912560040879 -4/29/03,0.246743054465547,9998.999999847605,0.9066508352616974,0.09334931713402214 -4/30/03,0.2494113953853398,9998.999999838567,0.9011146684632072,0.09888549297049494 -5/1/03,0.25113796892167634,9998.999999829583,0.8956123104766106,0.10438785993988008 -5/2/03,0.2528645424580129,9998.999999820655,0.8901435555918127,0.10985662375260818 -5/3/03,0.25443415476377335,9998.999999811782,0.8847081992183395,0.11529198899948748 -5/5/03,0.2569455344529901,9998.999999802963,0.8793060378853373,0.1206941591517038 -5/6/03,0.2583581855281745,9998.999999794198,0.8739368692415727,0.1260633365608207 -5/7/03,0.2596138753727829,9998.999999785487,0.8686004920554333,0.1313997224587793 -5/8/03,0.26071260398681523,9998.999999776828,0.8632967062149268,0.1367035169578984 -5/9/03,0.26165437137027153,9998.99999976822,0.8580253127276819,0.14197491905087448 -5/10/03,0.26275309998430385,9998.999999759668,0.8527861137209471,0.14721412661078156 -5/12/03,0.2641657510594883,9998.999999751168,0.8475789124415923,0.1524213363910714 -5/13/03,0.26510751844294456,9998.999999742719,0.8424035132561074,0.1575967440255734 -5/14/03,0.266520169518129,9998.999999734322,0.8372597216506029,0.16274054402849447 -5/15/03,0.26730497567100925,9998.999999725975,0.8321473442308099,0.1678529297944193 -5/16/03,0.2677758593627374,9998.99999971768,0.8270661887220798,0.17293409359831027 -5/17/03,0.26840370428504157,9998.999999709435,0.8220160639693852,0.17798422659550728 -5/19/03,0.2690315492073458,9998.999999701242,0.8169967799373182,0.18300351882172788 -5/20/03,0.26965939412964995,9998.999999693096,0.8120081477100923,0.18799215919306728 -5/21/03,0.269816355360226,9998.999999685002,0.8070499794915413,0.1929503355059984 -5/22/03,0.2702872390519542,9998.999999676957,0.8021220886051191,0.1978782344373717 -5/23/03,0.27060116151310626,9998.999999668962,0.7972242894939008,0.20277604154441542 -5/24/03,0.27060116151310626,9998.999999661015,0.7923563977205816,0.20764394126473523 -5/26/03,0.27091508397425834,9998.999999653117,0.7875182299674773,0.21248211691631466 -5/27/03,0.2712290064354104,9998.999999645266,0.7827096040365243,0.21729075069751472 -5/28/03,0.2715429288965625,9998.999999637463,0.7779303388492795,0.22207002368707426 -5/29/03,0.27185685135771465,9998.999999629708,0.7731802544469202,0.22682011584410958 -5/30/03,0.2724846962800188,9998.999999622001,0.7684591719902444,0.23154120600811465 -5/31/03,0.27295557997174696,9998.999999614342,0.7637669137596708,0.23623347189896113 -6/2/03,0.2740543085857793,9998.999999606727,0.7591033031552382,0.24089709011689836 -6/3/03,0.27421126981635535,9998.99999959916,0.754468164696606,0.24553223614255326 -6/4/03,0.27436823104693137,9998.99999959164,0.7498613240230546,0.2501390843369304 -6/5/03,0.27436823104693137,9998.999999584164,0.7452826078934843,0.2547178079414121 -6/6/03,0.2746821535080835,9998.999999576736,0.7407318441864165,0.25926857907775797 -6/9/03,0.27515303719981166,9998.999999569352,0.7362088618999928,0.2637915687481058 -6/10/03,0.27530999843038767,9998.999999562013,0.7317134911519751,0.26828694683497056 -6/11/03,0.27530999843038767,9998.999999554719,0.7272455646461425,0.27275488063484693 -6/12/03,0.27546695966096374,9998.99999954747,0.7228049183018899,0.27719553422860754 -6/13/03,0.27546695966096374,9998.999999540265,0.7183913861666602,0.28160907356908 -6/16/03,0.27546695966096374,9998.999999533102,0.7140048031056461,0.2859956637913417 -6/17/03,0.27546695966096374,9998.999999525984,0.7096450049155073,0.2903554690990009 -6/18/03,0.27546695966096374,9998.999999518912,0.7053118283243721,0.2946886527641958 -6/19/03,0.27546695966096374,9998.999999511881,0.7010051109918364,0.2989953771275956 -6/20/03,0.27546695966096374,9998.999999504893,0.6967246915089644,0.30327580359839945 -6/23/03,0.27546695966096374,9998.999999497948,0.6924704093982882,0.3075300926543374 -6/24/03,0.27546695966096374,9998.999999491043,0.6882421051138082,0.3117584038416696 -6/25/03,0.27546695966096374,9998.999999484184,0.6840396200409922,0.3159608957751869 -6/26/03,0.27546695966096374,9998.999999477364,0.6798627964967765,0.32013772613821057 -6/27/03,0.27546695966096374,9998.999999470589,0.6757114777295653,0.32428905168259226 -6/30/03,0.27546695966096374,9998.999999463853,0.671585507919231,0.32841502822871405 -7/1/03,0.27546695966096374,9998.999999457157,0.6674847321771137,0.3325158106654888 -7/2/03,0.27546695966096374,9998.999999450503,0.6634089965460216,0.3365915529503593 -7/3/03,0.27546695966096374,9998.999999443891,0.6593581480002312,0.34064240810929924 -7/4/03,0.27546695966096374,9998.999999437317,0.6553320344454865,0.34466852823681265 -7/7/03,0.27546695966096374,9998.999999430785,0.651330504719,0.3486700644959339 -7/8/03,0.27546695966096374,9998.999999424292,0.647353408589452,0.35264716711822797 -7/9/03,0.27546695966096374,9998.99999941784,0.643400596756991,0.35659998540379023 -7/10/03,0.27546695966096374,9998.999999411426,0.6394719208532331,0.36052866772124653 -7/11/03,0.27546695966096374,9998.99999940505,0.635567233441263,0.3644333615077531 -8/7/03,0.27546695966096374,9998.999999398715,0.6316863880156327,0.36831421326899677 diff --git a/out/TEST-data.csv b/out/TEST-data.csv deleted file mode 100644 index bc98828..0000000 --- a/out/TEST-data.csv +++ /dev/null @@ -1,3 +0,0 @@ -Beta: 0.4000000000000001 -Gamma: 1.0000000000049032e-08 -R0: 39999999.99980388
\ No newline at end of file diff --git a/out/TEST-prediction.csv b/out/TEST-prediction.csv deleted file mode 100644 index dd28231..0000000 --- a/out/TEST-prediction.csv +++ /dev/null @@ -1,4 +0,0 @@ -,Actual,S,I,R -1/22/20,1,13499.000074068588,0.9999259314124879,0.0 -1/23/20,2,13498.508297406446,1.4917025812581148,1.2295557754239627e-08 -1/24/20,3,13497.774897248144,2.225102721222464,3.06330734100344e-08 diff --git a/sir_model.cpp b/sir_model.cpp index f054c36..9525347 100644 --- a/sir_model.cpp +++ b/sir_model.cpp @@ -6,12 +6,12 @@ using namespace std; const int DAYS = 200, ITER = 10000; // Population size -const int POP = 2000; +const int POP = 10000; // Model parameters // Beta = infection rate // Gamma = removal rate -const double beta = 0.42, gamma = 0.25; +const double beta = 0.3944, gamma = 0.02664; // Compartments double S[DAYS + 1], I[DAYS + 1], R[DAYS + 1]; diff --git a/sir_model.exe b/sir_model.exe Binary files differnew file mode 100644 index 0000000..9acbc84 --- /dev/null +++ b/sir_model.exe @@ -1,3 +1,4 @@ +#!/usr/bin/python3 from datetime import datetime, timedelta import matplotlib.pyplot as plt @@ -20,17 +21,19 @@ parser.add_argument('--end', '-e', dest = 'end', default = None, help = 'the dat parser.add_argument('--incubation', '-i', dest = 'incubation_period', default = None, help = 'the incubation period of the disease (only applicable if using SIRE model; ignored otherwise); none by default') parser.add_argument('--predict', '-p', dest = 'prediction_range', default = None, help = 'the number of days to predict the course of the disease (defaults to None, meaning the model will not predict beyond the given data)') parser.add_argument('--country', '-c', dest = 'country', default = 'US', help = 'the country that is being modeled (defaults to US)') -parser.add_argument('--population', '-P', dest = 'population', default = '10000', help = 'the population of the model (defaults to 10000)') +parser.add_argument('--popcountry', '-pc', dest = 'popcountry', default = '3328200000', help = 'the population of the country (defaults to US population)') +parser.add_argument('--popmodel', '-pm', dest = 'popmodel', default = '10000', help = 'the population of the model (defaults to 10000)') +parser.add_argument('--initial', '-I', dest = 'initial', default = '1', help = 'initial infected people (defaults to 1') args = parser.parse_args() -S_0 = (int(args.population) - 1) / int(args.population) -I_0 = 1 / int(args.population) +# Running a model for a million population is quite hard, so here we've reduced the population and modified the actual stats to match +correction_factor = int(args.popmodel) / int(args.popcountry) + +S_0 = (int(args.popcountry) - int(args.initial)) / int(args.popcountry) +I_0 = int(args.initial) / int(args.popcountry) R_0 = 0 E_0 = 0 -# Running a model for a million population is quite hard, so here we've reduced the population and modified the actual stats to match -correction_factor = int(args.population) / 3270000 if args.country == 'US' else int(args.population) / 63710000 if args.country == 'Hong_Kong' else 1 - class Learner(object): def __init__(self, country): self.country = country @@ -155,9 +158,9 @@ class Learner(object): beta, gamma = optimal.x print(f'Beta: {beta}, Gamma: {gamma}, R0: {beta/gamma}') new_index, extended_actual, prediction = self.predict(confirmed_data, beta = beta, gamma = gamma) - print(f'Predicted I: {prediction.y[1][-1] * int(args.population)}, Actual I: {extended_actual[-1] * correction_factor}') + print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}') df = compose_df(prediction, extended_actual, correction_factor, new_index) - with open(f'out/{args.disease}-data.csv', 'w+') as file: + with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file: file.write(f'Beta: {beta}\nGamma: {gamma}\nR0: {beta/gamma}') elif args.mode == 'SIR': optimal = minimize( @@ -170,9 +173,9 @@ class Learner(object): beta, gamma = optimal.x print(f'Beta: {beta}, Gamma: {gamma}, R0: {beta/gamma}') new_index, extended_actual, prediction = self.predict(confirmed_data, beta = beta, gamma = gamma) - print(f'Predicted I: {prediction.y[1][-1] * int(args.population)}, Actual I: {extended_actual[-1] * correction_factor}') + print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}') df = compose_df(prediction, extended_actual, correction_factor, new_index) - with open(f'out/{args.disease}-data.csv', 'w+') as file: + with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file: file.write(f'Beta: {beta}\nGamma: {gamma}\nR0: {beta/gamma}') elif args.mode == 'ESIR': optimal = minimize( @@ -185,9 +188,9 @@ class Learner(object): beta, gamma, mu = optimal.x print(f'Beta: {beta}, Gamma: {gamma}, Mu: {mu} R0: {beta/(gamma + mu)}') new_index, extended_actual, prediction = self.predict(confirmed_data, beta = beta, gamma = gamma, mu = mu) - print(f'Predicted I: {prediction.y[1][-1] * int(args.population)}, Actual I: {extended_actual[-1] * correction_factor}') + print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}') df = compose_df(prediction, extended_actual, correction_factor, new_index) - with open(f'out/{args.disease}-data.csv', 'w+') as file: + with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file: file.write(f'Beta: {beta}\nGamma: {gamma}\nMu: {mu}\nR0: {beta/(gamma + mu)}') elif args.mode == 'SEIR': exposed_data = self.load_exposed(self.country) @@ -202,15 +205,15 @@ class Learner(object): beta, gamma, mu, sigma = optimal.x print(f'Beta: {beta}, Gamma: {gamma}, Mu: {mu}, Sigma: {sigma} R0: {(beta * sigma)/((mu + gamma) * (mu + sigma))}') new_index, extended_actual, prediction = self.predict(confirmed_data, beta = beta, gamma = gamma, mu = mu) - print(f'Predicted I: {prediction.y[1][-1] * int(args.population)}, Actual I: {extended_actual[-1] * correction_factor}') + print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}') df = compose_df(prediction, extended_actual, correction_factor, new_index) - with open(f'out/{args.disease}-data.csv', 'w+') as file: + with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file: file.write(f'Beta: {beta}\nGamma: {gamma}\nMu: {mu}\nSigma: {sigma}\nR0: {(beta * sigma)/((mu + gamma) * (mu + sigma))}') fig, ax = plt.subplots(figsize=(15, 10)) ax.set_title(f'{args.disease} cases over time ({args.mode} Model)') df.plot(ax=ax) - fig.savefig(f"{args.out if args.out != None else args.disease}.png") - df.to_csv(f'out/{args.disease}-prediction.csv') + fig.savefig(f"{args.out if args.out != None else args.disease}-{args.mode}.png") + df.to_csv(f'out/{args.disease}-{args.mode}-prediction.csv') def filter_zeroes(arr): out = np.array(arr) @@ -226,13 +229,13 @@ def compose_df(prediction, actual, correction_factor, index): if data == 'Actual': df_dict['Actual'] = filter_zeroes(actual * correction_factor) elif data == 'S': - df_dict['S'] = prediction.y[0] * int(args.population) + df_dict['S'] = prediction.y[0] * int(args.popmodel) elif data == 'I': - df_dict['I'] = prediction.y[1] * int(args.population) + df_dict['I'] = prediction.y[1] * int(args.popmodel) elif data == 'R': - df_dict['R'] = prediction.y[2] * int(args.population) + df_dict['R'] = prediction.y[2] * int(args.popmodel) elif data == 'E': - df_dict['E'] = prediction.y[3] * int(args.population) + df_dict['E'] = prediction.y[3] * int(args.popmodel) return pd.DataFrame(df_dict, index=index) @@ -247,8 +250,8 @@ def loss_linear(point, confirmed, recovered): R = y[2] return [-beta * S, beta * S - gamma * I, gamma * I] solution = solve_ivp(model, [0, size], [S_0,I_0,R_0], t_eval=np.arange(0, size, 1), vectorized=True) - sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.population)))**2)) - sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.population)))**2)) + sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.popmodel)))**2)) + sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.popmodel)))**2)) return sol_inf * 0.5 + sol_rec * 0.5 def loss_sir(point, confirmed, recovered): @@ -260,8 +263,8 @@ def loss_sir(point, confirmed, recovered): R = y[2] return [-beta * S * I, beta * S * I - gamma * I, gamma * I] solution = solve_ivp(model, [0, size], [S_0,I_0,R_0], t_eval=np.arange(0, size, 1), vectorized=True) - sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.population)))**2)) - sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.population)))**2)) + sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.popmodel)))**2)) + sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.popmodel)))**2)) return sol_inf * 0.5 + sol_rec * 0.5 def loss_esir(point, confirmed, recovered): @@ -273,8 +276,8 @@ def loss_esir(point, confirmed, recovered): R = y[2] return [mu - beta * S * I - mu * S, beta * S * I - gamma * I - mu * I, gamma * I - mu * R] solution = solve_ivp(model, [0, size], [S_0,I_0,R_0], t_eval=np.arange(0, size, 1), vectorized=True) - sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.population)))**2)) - sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.population)))**2)) + sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.popmodel)))**2)) + sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.popmodel)))**2)) return sol_inf * 0.5 + sol_rec * 0.5 def loss_seir(point, confirmed, recovered, exposed): @@ -287,9 +290,9 @@ def loss_seir(point, confirmed, recovered, exposed): E = y[3] return [mu - beta * S * I - mu * S, beta * S * I - sigma * E - mu * E, sigma * E * I - gamma * I - mu * I, gamma * I - mu * R] solution = solve_ivp(model, [0, size], [S_0,E_0,I_0,R_0], t_eval=np.arange(0, size, 1), vectorized=True) - sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.population)))**2)) - sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.population)))**2)) - sol_exp = np.sqrt(np.mean((solution.y[3] - (exposed.values * correction_factor/int(args.population)))**2)) + sol_inf = np.sqrt(np.mean((solution.y[1] - (confirmed.values.flatten() * correction_factor/int(args.popmodel)))**2)) + sol_rec = np.sqrt(np.mean((solution.y[2] - (recovered.values * correction_factor/int(args.popmodel)))**2)) + sol_exp = np.sqrt(np.mean((solution.y[3] - (exposed.values * correction_factor/int(args.popmodel)))**2)) return sol_inf/3 + sol_rec/3 + sol_exp/3 my_learner = Learner(args.country) |