---
# System prepended metadata

title: Debugging HeuristicV1 Revision 3
tags: [Debug]

---

---
tags: Debug
---

# Debugging HeuristicV1 Revision 3

### Description

Very similar to Revision 2, except I have entirely rewritten the heuristic algorithm with tests. I probably introduced new bugs in the re-writing, but at least we can add test cases for the issues we find in this revision.

<!-- - plotting changes
- Heuristic Algorithm
 -->
<!-- ![](https://i.imgur.com/okMiOmV.png)
Caption: The infection chain in the debug run.
 -->
![](https://i.imgur.com/uxd2QFM.png)
Red rings are spaced at 10 day intervals. 5 init people sick. Distance = time. Only showing human-human transmission coming directly from the initially infected humans (environmental transmission makes it much uglier). It seems like the viral load spike is quite strong. Like, most infections happen during the spike

#### TODO:
- bugs
    - chain 1: What triggers a risk update of 0 on 2020-03-20 from human:511 of value 0?
    - chain 3: positive test but risk level is still 7 on 2020-03-07. Should be set to 15.
- features
    - Idea: use rec level 3 even for those who have taken a test. Unset them once the results are out based on the test results.
    - prevalence estimation for covid
    - P(covid | symptom)
- DONE:
     - Ran normalization 

#### Useful links
- [googledoc for a high-level description of the heuristic (v1)](https://docs.google.com/document/d/1_J1jcn5b0h7h5_bzjH-qx4LerWNFRJOzBI2vCm1n3AA/edit?usp=sharing)
- [plot wiki](https://hackmd.io/N-g61aZLQaSB_cz5SttM6Q) for information on how to read the plots.


### Infection Chains
Observations - 
1. On 2020-03-06, why is there a risk message (of value 0) being sent when the risk is still at 0?
2. Signals from Asymptomatic and Presymptomatic will always be weak. 
3. No one is going in Level 1. On 2020-03-14, what makes the person rec leve 2 instead of 1?
4. human:526 is not asymptomatic, but it is not showing any symptoms. 
5. What triggers a risk update of 0 on 2020-03-20 from human:511 of value 0?

![](https://i.imgur.com/VAE2P2o.png)

Observation - 
1. Why is the severity of symptoms wavy? If I am severe today, it can't be that I feel good tomorrow and then severe again day after tomorrow? Or can I? Even if it's reported severity, heuristic should look at last D days symptoms.
2. human:220 has severe symptoms on 2020-03-19 but the risk level is 1. 
3. human:220 doesn't seem to follow max-rule
4. Idea: use rec level 3 even for those who have taken a test. Unset them once the results are out based on the test results. 
5. human:220 received a 15 and has 12 because of severe symptoms, he should be a complete 15. We can combine both the conditions. This will lead to a stronger signla to human:432.
6. What made human:432 to jump to rec level 3 on 2020-03-20?
![](https://i.imgur.com/dhovVpH.png)

Observations -
1. No messages being exchanged between these two.
2. positive test but risk level is still 7 on 2020-03-07. It can happen because these observations are at midnight, and `human`s timeslot might be after midnight. 
![](https://i.imgur.com/o7c0hPE.png)

Observations - 
1. too short

![](https://i.imgur.com/n98n71K.png)

Observations - 
1.There is no one-to-one risk-recommendation mapping
2. why is h554 going to orange on 03-05? If it is because of 3 symptoms, this should be reflected in the pseudo-code, but I don't see it. And the same condition should have triggered a bump in risk level too. 
3. Similarly, why is h554 going to R=7 on 03-06 and h334 to orange with a risk level of 2? According to pseudo-code should be yellow. It looks like pseudo-code and code of heuristic don't match yet.
![](https://i.imgur.com/QKVNNFP.png)

Observations- 
1. human:609 should have been Risk level 2 on 2020-03-04 because of a 7 from human:525
2. Risk level 12 and receiving 15 should turn someone into 15. 
![](https://i.imgur.com/0HoYlJa.png)

Observations - 
1. Severity of human:151 on 2020-03-09 is 0 (None). It isn't mild. What is causing the risk level to be 7?
2. 
![](https://i.imgur.com/tuNQTgx.png)
![](https://i.imgur.com/5fX2Vzt.png)
![](https://i.imgur.com/Fecs0vt.png)
Observations:
1. Weird that h631 is getting tested with no observed symptoms and received R'=10. What are the conditions for getting tested? Is it because infector got a positive test?
2. H718 lives in the same house as h417. When h417 got a positive test, h718 got tested but he was not *yet* infected and was negative. However, because that pout him in green, that he ended up being less prudent than he should have and got infected on 03-10. Need to change the heuristic.

![](https://i.imgur.com/qk9by1J.png)

### Baseball Cards
![](https://i.imgur.com/eEfoUul.png)
![](https://i.imgur.com/SznoMpk.png)
![](https://i.imgur.com/dNUqrUG.png)
![](https://i.imgur.com/fovFBHh.png)
![](https://i.imgur.com/NkYEVfg.png)
![](https://i.imgur.com/uURlddq.png)
![](https://i.imgur.com/i2JcZ6D.png)
![](https://i.imgur.com/sELmQT7.png)
![](https://i.imgur.com/wACdUir.png)
![](https://i.imgur.com/lsN1n2e.png)
![](https://i.imgur.com/9H17syd.png)
![](https://i.imgur.com/VGDNxQD.png)
![](https://i.imgur.com/gtZORCe.png)
![](https://i.imgur.com/nea332P.png)
![](https://i.imgur.com/0HovccL.png)
![](https://i.imgur.com/DdIzQ70.png)
![](https://i.imgur.com/VWp096m.png)
![](https://i.imgur.com/dkEKEEQ.png)
![](https://i.imgur.com/rkEsaUq.png)
![](https://i.imgur.com/bWfPjSQ.png)


### Simulation Logs

######## DEMOGRAPHICS #########
age distribution
                  0
count  1000.000000
mean     42.052000
std      23.480218
min       1.000000
25%      23.750000
50%      42.000000
75%      60.000000
max     101.000000
house age distribution
                 0
count  381.000000
mean    41.295626
std     14.403380
min      9.000000
25%     29.500000
50%     41.000000
75%     50.200000
max     92.000000
house size distribution
                 0
count  381.000000
mean     2.556430
std      1.264949
min      1.000000
25%      2.000000
50%      2.000000
75%      4.000000
max      5.000000
Fraction of asymptomatic 0.216
######## COVID PROPERTIES #########
Avg. incubation days  5.76
Avg. recovery days  19.41
Avg. infectiousnes onset days  3.47
######## COVID SPREAD #########
human-human transmissions 119
environment-human transmissions 55
environmental transmission ratio 0.462
Ro 2.699206349206349
Generation times 6.5208116319444445 
Cumulative Incidence [0.0, 0.0, 0.0020100502512562816, 0.004028197381671702, 0.004044489383215369, 0.0040609137055837565, 0.004077471967380225, 0.01023541453428864, 0.001034126163391934, 0.007246376811594203, 0.0020855057351407717, 0.0041797283176593526, 0.0031479538300104933, 0.002105263157894737, 0.004219409282700422, 0.00847457627118644, 0.004273504273504274, 0.0, 0.002145922746781116, 0.004301075268817204, 0.0064794816414686825, 0.003260869565217391, 0.006543075245365322, 0.0043907793633369925, 0.0033076074972436605, 0.0055309734513274336, 0.008898776418242492, 0.004489337822671156, 0.005636978579481398]
R : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.0, 3.1666666666666665, 2.857142857142857, 2.5555555555555554, 1.9166666666666667, 1.7333333333333334, 1.5714285714285714, 1.375, 1.3076923076923077, 1.3, 1.121212121212121]
******** R0 *********
Asymptomatic R0 2.111111111111111
Presymptomatic R0 2.1538461538461537
Symptomatic R0 1.3076923076923077
******** Transmission Ratios *********
% asymptomatic transmission 15.97%
% presymptomatic transmission 23.53%
% symptomatic transmission 14.29%
******** R0 LOCATIONS *********
workplace R0 2.1
household R0 1.565217391304348
school R0 1.25
hospital R0 1.0
senior_residency R0 1.0
######## SYMPTOMS #########
P(symptoms = x | covid patient), where x is:
   gastro                      : 0.4062
    nausea_vomiting             : 0.3906
    severe                      : 0.3750
    light_trouble_breathing     : 0.3594
    heavy_trouble_breathing     : 0.3438
    runny_nose                  : 0.2500
    sneezing                    : 0.1875
    moderate_trouble_breathing  : 0.1719
    confused                    : 0.0938
    unusual                     : 0.0469
P(symptoms = x | human had some sickness e.g. cold, flu, allergies, covid), where x is:
   gastro                      : 0.1940
    nausea_vomiting             : 0.1866
    severe                      : 0.1791
    light_trouble_breathing     : 0.1716
    heavy_trouble_breathing     : 0.1642
    runny_nose                  : 0.1194
    sneezing                    : 0.0896
    moderate_trouble_breathing  : 0.0821
    confused                    : 0.0448
    unusual                     : 0.0224
######## MOBILITY #########
Day - 
Mon #avg: 8.804 %:15.98 
Tue #avg: 8.24925 %:14.97 
Wed #avg: 7.158 %:12.99 
Thurs #avg: 6.88 %:12.49 
Fri #avg: 9.016 %:16.36 
Sat #avg: 7.642 %:13.87 
Sun #avg: 7.354 %:13.35 
Average Daily Contacts 
(1, 10) #avg: 24.194534808067665 %:16.21 
(11, 20) #avg: 21.52100313479624 %:14.96 
(21, 30) #avg: 12.759127789046651 %:10.97 
(31, 40) #avg: 12.664667666166917 %:11.05 
(41, 50) #avg: 12.185344827586205 %: 9.86 
(51, 60) #avg: 12.000738916256157 %:10.62 
(61, 70) #avg: 12.471544715447154 %: 9.69 
(71, 80) #avg: 15.200090744101635 %: 7.30 
(81, 101) #avg: 34.3897353648757 %: 9.35 
######## COVID Testing Statistics #########
Proportion infected :  12.400%
Positivity rate:  30.952%
Total Tests: 126 Total positive tests: 39 Total negative tests: 87
Maximum tests given to an individual: 5
Proportion of population tested until end:  12.600%
Proportion of population tested daily Avg:  0.394%
Proportion of population tested daily Max:  0.600%
Proportion of population tested daily Min:  0.000%
P(tested | symptoms = x), where x is 
    severe  0.417
    moderate  1.000
    mild  0.451
P(symptoms = x | tested), where x is:
   hard_time_waking_up         : 0.1508
    sneezing                    : 0.1429
    headache                    : 0.1111
    chills                      : 0.0873
    moderate_trouble_breathing  : 0.0873
    severe                      : 0.0794
    heavy_trouble_breathing     : 0.0635
    confused                    : 0.0238
    light_trouble_breathing     : 0.0238
    unusual                     : 0.0159
######## Effective Contacts & % infected #########
Eff. contacts: 5.299 	 % infected:  11.900%
## Part 2: Aggregate Statistics

### Pareto Adoption
![](https://i.imgur.com/SnXrHUD.png)



### JellyBeans

![](https://i.imgur.com/LTtdamb.png)
![](https://i.imgur.com/dKy7tRf.png)
![](https://i.imgur.com/XCa9PTq.png)

### Pre-symptomatic curves
![](https://i.imgur.com/bdKmAF9.png)
![](https://i.imgur.com/mqsedUH.png)
![](https://i.imgur.com/1dfyIny.png)
![](https://i.imgur.com/vgVJh5H.png)

![](https://i.imgur.com/tJJl0g0.png)
![](https://i.imgur.com/QNbzjRD.png)
![](https://i.imgur.com/g2TWVGs.png)
![](https://i.imgur.com/q9fqWjM.png)
![](https://i.imgur.com/MVRe9cK.png)


### Generation Times
##### Heuristic
![](https://i.imgur.com/tbOi0CJ.png)
![](https://i.imgur.com/BoOYZII.png)
![](https://i.imgur.com/gTHDZKw.png)

##### BDT1
![](https://i.imgur.com/m3nC8P9.png)
![](https://i.imgur.com/amL7rVM.png)
![](https://i.imgur.com/2EMtYBx.png)

##### No intervention

![](https://i.imgur.com/aNuh47e.png)

### Epi Tables

heuristicv1_-1
|                             |   Average |   Std Err |
|:----------------------------|----------:|----------:|
| Incubation                  |      5.68 |      0.23 |
| Infectiousness              |      3.43 |      0.12 |
| Recovery                    |     19.16 |      0.25 |
| Generation Time             |      6    |      0.07 |
| Daily Contact               |     14.8  |      1.22 |
| Presymptomatic Transmission |      0.31 |      0.01 |
| Asymptomatic Transmission   |      0.09 |      0.01
