# Visualizing the Transit Map Log Page

Go back to: Visualizing the Transit Map of the Spread of an Infectious Disease

## Contents

- 1 Week 1
- 2 Week 2
- 3 Week 3: testing a baby program (Part I)
- 4 Week 4: testing a baby program (Part II)
- 5 Week 5: testing a baby program(Part III)
- 6 Week 6: testing baby programs and the whole population
- 7 Week 7 & 8
- 8 week 9: Trees
- 9 Week 9: More trees (twopi,...)
- 10 Week 10: More graphs, vaccination & quarantine
- 11 week 11: some minor adjustments
- 11.1 firstInKey 82, radius ratio, Probability infection=1, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2
- 11.2 firstInKey 82, radius ratio, Probability infection=0.01, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2
- 11.3 firstInKey 82, radius ratio, Probability infection=0.01, quarantine=false, vaccine=false, Stochastic probability with sigma(volatility) =1, edge discount factor =incubationLimit/2
- 11.4 firstInKey 82, Area, Probability infection=0.01, quarantine=false, vaccine=50% of the population, vaccineContagiousProbability=0, deterministic probability, edge discount factor =incubationLimit/2
- 11.5 firstInKey 82, Area, Probability infection=0.01, quarantine=false, vaccine=50% of the population, vaccineContagiousProbability=0.001, deterministic probability, edge discount factor =incubationLimit/2
- 11.6 firstInKey 82, Area, Probability infection=0.01, quarantine=true, quarantine house=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2
- 11.7 firstInKey 82, Area, Probability infection=0.01, quarantine=true, quarantine house=true, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2
- 11.8 firstInKey 82, Radius Ratio, Probability infection=0.005, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

## Week 1

- Understand Lujun's program

- Import Lujun's code to Java, understand the structure of the database and the algorithm generating the events, add documentations, and identify unclear variables
- Try to run the code to generating the database; ran for over 20 minutes but still didn't finish.
- Analyze the time efficiency of generating database and simulations

- Identify ways to improve the algorithm

- Theoretically, we should be able to generate the database in order n (linear order): if we can generate the schedule student by student and entry by entry.

- Based on Lujun's code, propose improvement 1: instead of loping through time slots and generating dining halls, rooms, and etc. slot by slot with the student schedule table, we should create a separate table for those places and given them IDs, and in the student schedule table, assign those IDs by algorithm; then we can count the number of people in the end and document in the corresponding tables.
- Propose improvement 2: remove unnecessary iterations; use less for lopes and more mathematical (probability) algorithms.

- Identify the potential problems and propose improvements:

- Potential problems:

- Places like dinning halls and large gathering places have a system that is more close to dynamic rather than discrete.
- The simulation algorithm for spreading the virus is not efficient enough. Notice if we want to add more functionality of the simulation (such as the genetic traits of the population), the program is going to run even slower.

- Solutions:

- For the first problem:
- We can randomly initialize the data, and use stochastic modeling to create the schedule table.

- Pro: the schedule simulation can be more accurate. Con: generate the Markov Chain could be complicated.
- We might want to keep the model simple in the cost of accuracy.

- Or we shall use (one semester) student (of those who already graduated) class schedule provided by the registrar, and generate the rest of the table by discrete probability algorithms.
- For the second problem:
- Plan 1: We can use a partial differential equations model (diffusion) to simulate the spread of the virus.

- Theoretically, we are expecting this model to run significantly faster because we are looking at the population in the given place as a whole. We can get number of people being effected in a given place through integration (over a period of time), and then assign people randomly to be affected (however the total number affected should match the model).
- Additional benefit: This will allow us to add more functionality of the simulation easily (e.g. the genetic traits of people) by adding partial differential equation terms.
- Faculty source: Panos Kevrekidis (UMass Mathematics Department).
- Reference: Partial Differential Equations by Walter A. Strauss Chapter 8.

- Plan 2: We can use a stochastic model to simulate the spread of the virus.

- We expected this model to run more accurate than PDE model, but slower. We need to generate our Markov Chain (probability table) according to the virus input.

- Talked to Gwen Spencer (Smith College Math Department, research area: optimization), and she showed great interested in our project.

- Some thoughts of the Tree visualization:

- Plan 1: we can create a tree separating by different genetic traits, and use the length of the nodes to indicate the time of being infected. (It is necessary, thus, to clean up and update the simulation algorithms)
- Plan 2: we can create a tree by the number of people get infected by each day, and the connection between two levels of nodes will be the source and recipient relation.

- If time permitted, we might want to generate both trees.

- Plan for the semester:

- Phase 1: clean up and update the simulation algorithms (maybe allow user to customize the genetic traits)(use the data from the registrar to create the simulation algorithm).
- Phase 2: come up with detailed tree structures and algorithms.
- Phase 3: combine the simulation algorithm and tree algorithms and put into shinny in R (create an interactive webpage).
- Phase 4: (if time permitted) see whether we can generalize our model to a bigger size (e.g. the population in a city).

- Where to start:

- 1. Import the student schedule from Fall 2009, but randomize students' IDs. Then generate student schedule of the week.
- 2. Figure out how genetics (or other components) affect the spread of the virus.

## Week 2

--Kyra Gan 17:33, 7 February 2016 (EST)

Instead of using Priority Q, we might want to cache the data through out the simulation by using separate tables and array list, linked list. Here is some thoughts about the data structure:

- What we need to create a tree that represent the source and recipient relation (length of the branch represent time): student status ordered by time, lists of student infection source and recipient.

- How are we going to simulate the spread of the virus: iterating through places on campus (instead of student schedule). We are going to randomly choose a student on campus to be a infected carrier of a certain virus:

- 1) we are going to get student current place of time1, and modeling the spread of virus in that place, and update ALL student status at time1 (those in the room might get infected, and update the rest population status to heathy, since we only have one source).

- 2) we can iterate through all places(or rather, the places where 1< the # of infected < # student in the place) at time2 (get student inside the room, their status) and update student status place by place (since we are expecting the number of places on campus is less than the number of student, we are expecting the iteration length is shorter).

- 3) we are going to repeat the same iteration at time3, time4 and so on, until the campus infected student number == the campus population.

- Rmk:

- 1) this model will easily allow change in parameters like the number of source, and the students genetic traits that change the probability of infection, which might be useful for further study.

- 2) for the modeling the spread of the virus part, that is where the PDE model or the stochastic modeling come in and play their roles.

- We want to preserve the table of places on campus and student status to create the tree in the end, and thus we are using ArrayList to store the data (since we are going to expected lots of add call). We are using hash table here because we can assess different elements from different data table faster. Thus, we also want to a create dictionary of student IDs and their hash values, and a dictionary for campus place names and their hash values.

- On the other hand, since we want to assess student schedule by time, and we are expecting student to have repeated schedule for every week (since the data of student schedule is given, we are not going to expect students to have identical schedules on MWF, and on TuTh), we are going to use a iterator and get to our next time element. (Namely, we are only going to store one week’s student schedule, and use that schedule repeatedly.)

- Assumptions, rules and Pseudo Code:

- Idea:

- 1) Initialize a hash table of Linked list to store students’ schedules. (student ID, student place (ID) ordered by time (later on we want to store whether student has specific genetic traits that will effect the chances of being contagious))

- 2) Initialize an hash table of array list to store the places on campus including student rooms (name of the place, capacity, number of people (and their ID) inside the place tagged by time, number of people infected tagged by time, number of people healthy (not under remission) tagged by time)

- 3) Initialize an hash table(same hash value for each student as the schedule table) of Array list to store students’ status by time (not infected, (infected: incubation, contagious), remission, source, direct recipients tagged by time)

- Assumptions and rules:--Kyra Gan 21:34, 7 February 2016 (EST)

- In order to fix some discrete time block problem in Lujun’s code, we might want to use new assumptions and rules here:

- 1) if a student has morning classes in a given day, she is going to eat breakfast; if she does not have morning classes, she is not going to eat breakfast.

- 1.1) Assume a student leaves her house 60 to 25 minutes before her class for breakfast. (uniformly distributed)
- 1.2) Assume a student leaves her house 70 to 40 minutes before her class for lunch. (uniformly distributed)
- 1.3) For the simplicity, we ignore the fact of work-study student might not have morning classes but breakfast. (we are also ignoring everything else that is related with work-study)

- 2) it takes a student 20 minutes to eat breakfast, 30 minutes to eat lunch and dinner

- 3) For our current stage, we assume that the infection of professors doesn’t effect the student population. (Though unrealistic, we want to keep our model simple for now to generate the first transit map)

- 4) Since breakfast does not start until 7:00am, we assume all students are in their room before 7:00am; since the library closes at 1:00am, we assume all students are in their room after 1:00am.

- 5) Assume it takes 10 minutes to walk from one place to another, we will only generate a new event if the time difference between two exiting event is larger than 10 minutes.

- 6) Assume if the time difference between two events is >= 60 minutes, there is 0.3 chance that she is going to be in her room, there is 0.4 chance that she is going to be in the library, and there is 0.1 chance that she is going to be in the building of her next class (if there is one), there is going to be 0.1 chance that she is going to be in campus center (and reject if she does not have a class afterwards), and there is going to be 0.1 chance that she is going to be in the gym (and reject if it pasts the gym hour)

- 7) Assume a student does not stay in one place more than 2 hours except her room.

- 8) Assume if the time difference between two events is between 40 to 60 minutes, there is 0.2 chance that she is going to be in her room, there is 0.4 chance that she is going to be in the library, there is 0.2 chance that she is going to be in campus center, and 0.2 chance that she is going to be in the building of her next event.

- 9) Assume if the time difference between two events is between 20 to 40 minutes, there is 0.6 chance that she is going to be in the library, 0.2 chance that she is going to be in campus center, and 0.2 chance that she is going to be in the building of her next event.

- 10) Assume if the time difference between two events id between 10 to 20 minutes, there is 1.0 chance that she is going to be in the building of her next event.

- 11) For the weekend, we assume 20% of students go to breakfast, all student attend brunch, and all student attend dinner.

- 11.1)Assume if the time difference between two events is >= 60 minutes, there is 0.4 chance that she is going to be in her room, there is 0.3 chance that she is going to be in the library, there is going to be 0.1 chance that she is going to be in campus center, and there is going to be 0.2 chance that she is going to be in the gym (and reject if it pasts the gym hour)

- Here is the first version of the Pseudo Code.

## Week 3: testing a baby program (Part I)

Baby Program Assumptions:

- Everyone has breakfast together in the house from 8 am to 8:30

- If someone has class at that time, we assume she does not eat breakfast.

- Everyone has lunch from 12:20 to 12:50
- Everyone has dinner from 17:30 to 18:30
- Everyone stay together in the house from 19:00 to 21:00

- If someone has class at that time, we assume she does not attend the whole section.

Step 1: filter 10 test data objects from the original data file. Here is the R file for cleaning the data: babydata.r and here is the test data in csv: TestData.csv.

--Kyra Gan 20:51, 14 February 2016 (EST)

Step 2: create unit (basic) structures: (since all of these files are well documented, at this stage, we have no extra documentations)

Step 3: read the csv file and create the student hash table and place hash table

Step 4: create unit structures for the student status hash table for virus spread simulation:

See Program Source Page

## Week 4: testing a baby program (Part II)

--Kyra Gan 20:23, 21 February 2016 (EST)

Debug the previous and finish the virus spread simulation part of the data structure:

- Writing JUnit testing files, and update the previous data structure.
- To to this page for the source files: Program Source Page

- Here is the system.out.print of the student hash table and place hash table:

```
59=433|
placeMCCONN103|date:Mon|start time:800|end time:850|
placeSAB-RD101A|date:Mon|start time:1100|end time:1210|
place433|date:Mon|start time:1220|end time:1250|
placeMCCONN203|date:Mon|start time:1310|end time:1600|
place433|date:Mon|start time:1730|end time:1830|
place433|date:Mon|start time:1900|end time:2100|
placeMCCONN103|date:Tu|start time:800|end time:850|
place433|date:Tu|start time:1220|end time:1250|
placeSEELYE202|date:Tu|start time:1300|end time:1430|
placeSEELYE202|date:Tu|start time:1500|end time:1650|
.
.
.
healthyID:54|58||
date:Su|start time:800|end time:830|
StudentID:54|58||
ContagiousID:|
healthyID:54|58||
date:Su|start time:1220|end time:1250|
StudentID:54|58||
ContagiousID:|
healthyID:54|58||
date:Su|start time:1730|end time:1830|
StudentID:54|58||
ContagiousID:|
healthyID:54|58||
date:Su|start time:1900|end time:2100|
```

- KG check the table the tables manually, and both tables look right.

- Finishing rest part of the simulation:

- Some Assumptions of this simple simultaion:

- We randomly choose one student to be infected at the beginning (by using the random number generator)
- The probability of students getting infected is

- Version 1: p=1 (we will use this for now.)
- Version 2: proportional to the length of time they spend together: p=length (in hours) *(probability parameter input), p<=1.

- We will stop the simulation either after 30 days(since the sample is very small at this stage) or the size of Status Hash Table is empty.
- Assume the incubation period is 2 day, infectious period is 6 days.

- Simulation Steps:

- Get place of the first infectious student,
- Calculate the number of student infected in that place n=nearestInt(p*number of student in the room)
- randomly select n students(other than the infected students) from the room to be infected, update their status, and put into the status hash table, Log the events.
- increment time count (let's do 30 minutes for now).
- iterate through the status table get students' places at new time count, repeat above.
- Once students move into remission phase: log events.

- Here are the classes for the simulation part and their JUnit files:

- To to this page for the source files: Program Source Page

Some notes on the csv file provided by the college:

- Notice in the TestData.csv, for student 52, on Thursday, we have the same time entry (900,1020) but with 2 different place codes. (KG will regard this kind of data entries as exogenous wrong data entries. According to KG's program, she will only read the first place entry of that time entry)

## Week 5: testing a baby program(Part III)

--Kyra Gan 03:50, 29 February 2016 (EST)

- Clean up and update previous codes, update and complete JUnit Files.

- BTW, KG has all her JUnits bar green.

- Go to this page for the source files: Program Source Page
- Testing the virus spread simulation: Program Source Page

Some Results and Errors KG is currently getting from the simulation:

- The Log file Out Put:

- From the row data, we observe only the following people interaction (in this sample)

- 53 and 56 live in the same house 1.
- 54 and 58 live in the same house 435.
- 55 and 59 live in the same house 433.

```
2016-02-29 03:42:25: 50 first get infected, enter incubation period
2016-02-29 03:42:25: current daycount: 1current week: 0
2016-02-29 03:42:25: 50 become contagious, enter contagious period
2016-02-29 03:42:25: current daycount: 2current week: 0
2016-02-29 03:42:25: current daycount: 3current week: 0
2016-02-29 03:42:25: current daycount: 4current week: 0
2016-02-29 03:42:25: current daycount: 5current week: 0
2016-02-29 03:42:25: current daycount: 6current week: 0
2016-02-29 03:42:25: current daycount: 0current week: 1
2016-02-29 03:42:25: 50 recovered, enter remission period
2016-02-29 03:42:25: current daycount: 1current week: 1
2016-02-29 03:43:07: 58 first get infected, enter incubation period
2016-02-29 03:43:07: current daycount: 1current week: 0
2016-02-29 03:43:07: 58 become contagious, enter contagious period
2016-02-29 03:43:07: current daycount: 2current week: 0
2016-02-29 03:43:07: 58 infected the following people: 54
2016-02-29 03:43:07: current daycount: 3current week: 0
2016-02-29 03:43:07: 54 become contagious, enter contagious period
2016-02-29 03:43:07: current daycount: 4current week: 0
2016-02-29 03:43:07: current daycount: 5current week: 0
2016-02-29 03:43:07: current daycount: 6current week: 0
2016-02-29 03:43:07: current daycount: 0current week: 1
2016-02-29 03:43:07: 58 recovered, enter remission period
2016-02-29 03:43:07: current daycount: 1current week: 1
2016-02-29 03:43:07: current daycount: 2current week: 1
2016-02-29 03:43:07: current daycount: 3current week: 1
2016-02-29 03:43:07: 54 recovered, enter remission period
2016-02-29 03:43:07: current daycount: 4current week: 1
2016-02-29 03:45:22: 59 first get infected, enter incubation period
2016-02-29 03:45:22: current daycount: 1current week: 0
2016-02-29 03:45:22: 59 become contagious, enter contagious period
2016-02-29 03:45:22: current daycount: 2current week: 0
2016-02-29 03:45:22: 59 infected the following people: 55
2016-02-29 03:45:22: current daycount: 3current week: 0
2016-02-29 03:45:22: 55 become contagious, enter contagious period
2016-02-29 03:45:22: current daycount: 4current week: 0
2016-02-29 03:45:22: current daycount: 5current week: 0
2016-02-29 03:45:22: current daycount: 6current week: 0
2016-02-29 03:45:22: current daycount: 0current week: 1
2016-02-29 03:45:22: 59 recovered, enter remission period
2016-02-29 03:45:22: current daycount: 1current week: 1
2016-02-29 03:45:22: current daycount: 2current week: 1
2016-02-29 03:45:22: current daycount: 3current week: 1
2016-02-29 03:45:22: 55 recovered, enter remission period
2016-02-29 03:45:22: current daycount: 4current week: 1
2016-02-29 03:51:46: 54 first get infected, enter incubation period
2016-02-29 03:51:46: current daycount: 1current week: 0
2016-02-29 03:51:46: 54 become contagious, enter contagious period
2016-02-29 03:51:46: current daycount: 2current week: 0
2016-02-29 03:51:46: 54 infected the following people: 58
2016-02-29 03:51:46: current daycount: 3current week: 0
2016-02-29 03:51:46: 58 become contagious, enter contagious period
2016-02-29 03:51:46: current daycount: 4current week: 0
2016-02-29 03:51:46: current daycount: 5current week: 0
2016-02-29 03:51:46: current daycount: 6current week: 0
2016-02-29 03:51:46: current daycount: 0current week: 1
2016-02-29 03:51:46: 54 recovered, enter remission period
2016-02-29 03:51:46: current daycount: 1current week: 1
2016-02-29 03:51:46: current daycount: 2current week: 1
2016-02-29 03:51:46: current daycount: 3current week: 1
2016-02-29 03:51:46: 58 recovered, enter remission period
2016-02-29 03:51:46: current daycount: 4current week: 1
```

- From above, we can see the simulation is running correctly (in the way KG wants)

- Here is the system.out.print (and debug statement) from the WrapperStatus from the last simulation

```
current date is: Mon
PlaceTimeEntry.removeHID: ID doesn't exist
current date is: Tu
current date is: Wed
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
current date is: Th
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
current date is: Fri
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
current date is: Sa
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
current date is: Su
54checkContagious: true
54checkContagious: true
54checkContagious: true
54checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
current date is: Mon
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
54checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
current date is: Mon
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
current date is: Tu
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
58checkContagious: true
current date is: Wed
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
58checkContagious: true
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
58checkContagious: true
PlaceTimeEntry.removeHID: ID doesn't exist
```

- Let's figure out the first ID doesn't exist statement there!!! (KG knows where are the later ones coming from)

## Week 6: testing baby programs and the whole population

--Kyra Gan 03:13, 6 March 2016 (EST)

Part I: Debug the original program, fully test baby program 1 (bug-free for now)

- Code:

- separate the WrapperStatus.simulation() into smaller units of methods:

- duplicate WrapperStatus name WrapperStatusV2

- create Constants class (static)
- see: Program Source Page

- Results:

```
2016-03-04 18:50:46: 52 first get infected, enter incubation period
2016-03-04 18:50:46: current daycount: 1current week: 0Current date: Mon
2016-03-04 18:50:46: current daycount: 2current week: 0Current date: Tu
2016-03-04 18:50:46: 52 become contagious, enter contagious period on Wed
2016-03-04 18:50:46: current daycount: 3current week: 0Current date: Wed
2016-03-04 18:50:46: current daycount: 4current week: 0Current date: Th
2016-03-04 18:50:46: current daycount: 5current week: 0Current date: Fri
2016-03-04 18:50:46: current daycount: 6current week: 0Current date: Sa
2016-03-04 18:50:46: current daycount: 7current week: 0Current date: Su
2016-03-04 18:50:46: current daycount: 1current week: 1Current date: Mon
2016-03-04 18:50:46: 52 recovered, enter remission period on date exit contagious: Tu under Remission
2016-03-04 18:51:18: 53 first get infected, enter incubation period
2016-03-04 18:51:18: current daycount: 1current week: 0Current date: Mon
2016-03-04 18:51:18: current daycount: 2current week: 0Current date: Tu
2016-03-04 18:51:18: 53 become contagious, enter contagious period on Wed
2016-03-04 18:51:18: current daycount: 3current week: 0Current date: Wed
2016-03-04 18:51:18: 53 infected the following people: 56 on Wed
2016-03-04 18:51:18: current daycount: 4current week: 0Current date: Th
2016-03-04 18:51:18: 56 become contagious, enter contagious period on Fri
2016-03-04 18:51:18: current daycount: 5current week: 0Current date: Fri
2016-03-04 18:51:18: current daycount: 6current week: 0Current date: Sa
2016-03-04 18:51:18: current daycount: 7current week: 0Current date: Su
2016-03-04 18:51:18: current daycount: 1current week: 1Current date: Mon
2016-03-04 18:51:18: 53 recovered, enter remission period on date exit contagious: Tu under Remission
2016-03-04 18:51:18: current daycount: 2current week: 1Current date: Tu
2016-03-04 18:51:18: current daycount: 3current week: 1Current date: Wed
2016-03-04 18:51:18: 56 recovered, enter remission period on date exit contagious: Th under Remission
2016-03-04 19:08:46: 50 first get infected, enter incubation period
2016-03-04 19:08:46: current daycount: 1current week: 0Current date: Mon
2016-03-04 19:08:46: current daycount: 2current week: 0Current date: Tu
2016-03-04 19:08:46: 50 become contagious, enter contagious period on Wed
2016-03-04 19:08:46: current daycount: 3current week: 0Current date: Wed
2016-03-04 19:08:46: current daycount: 4current week: 0Current date: Th
2016-03-04 19:08:46: current daycount: 5current week: 0Current date: Fri
2016-03-04 19:08:46: current daycount: 6current week: 0Current date: Sa
2016-03-04 19:08:46: current daycount: 7current week: 0Current date: Su
2016-03-04 19:08:46: current daycount: 1current week: 1Current date: Mon
2016-03-04 19:08:46: 50 recovered, enter remission period on date exit contagious: Tu under Remission
2016-03-04 19:09:45: 55 first get infected, enter incubation period
2016-03-04 19:09:45: current daycount: 1current week: 0Current date: Mon
2016-03-04 19:09:45: current daycount: 2current week: 0Current date: Tu
2016-03-04 19:09:45: 55 become contagious, enter contagious period on Wed
2016-03-04 19:09:45: current daycount: 3current week: 0Current date: Wed
2016-03-04 19:09:45: 55 infected the following people: 59 on Wed
2016-03-04 19:09:45: current daycount: 4current week: 0Current date: Th
2016-03-04 19:09:45: 59 become contagious, enter contagious period on Fri
2016-03-04 19:09:45: current daycount: 5current week: 0Current date: Fri
2016-03-04 19:09:45: current daycount: 6current week: 0Current date: Sa
2016-03-04 19:09:45: current daycount: 7current week: 0Current date: Su
2016-03-04 19:09:45: current daycount: 1current week: 1Current date: Mon
2016-03-04 19:09:45: 55 recovered, enter remission period on date exit contagious: Tu under Remission
2016-03-04 19:09:45: current daycount: 2current week: 1Current date: Tu
2016-03-04 19:09:45: current daycount: 3current week: 1Current date: Wed
2016-03-04 19:09:45: 59 recovered, enter remission period on date exit contagious: Th under Remission
2016-03-06 03:17:17: 58 first get infected, enter incubation period
2016-03-06 03:17:17: current daycount: 1current week: 0Current date: Mon
2016-03-06 03:17:17: current daycount: 2current week: 0Current date: Tu
2016-03-06 03:17:17: 58 become contagious, enter contagious period on Wed
2016-03-06 03:17:17: current daycount: 3current week: 0Current date: Wed
2016-03-06 03:17:17: 58 infected the following people: 54 on Wed
2016-03-06 03:17:17: current daycount: 4current week: 0Current date: Th
2016-03-06 03:17:17: 54 become contagious, enter contagious period on Fri
2016-03-06 03:17:17: current daycount: 5current week: 0Current date: Fri
2016-03-06 03:17:17: current daycount: 6current week: 0Current date: Sa
2016-03-06 03:17:17: current daycount: 7current week: 0Current date: Su
2016-03-06 03:17:17: current daycount: 1current week: 1Current date: Mon
2016-03-06 03:17:17: 58 recovered, enter remission period on date exit contagious: Tu under Remission
2016-03-06 03:17:17: current daycount: 2current week: 1Current date: Tu
2016-03-06 03:17:17: current daycount: 3current week: 1Current date: Wed
2016-03-06 03:17:17: 54 recovered, enter remission period on date exit contagious: Th under Remission
```

Part II: testing more baby programs

- Testing babydataV2:

- filter a chain of students (sample size 10) that have contacts with one or two student only through class
- set Constants.iterationPeriod=60 since we are expecting longer long for all 10 students to get infected
- see specifics in: Testing Program Source Page
- everything runs correctly :)
- average simulation time (simulate schedule + virus)= 0.19s

- Testing babydataV3:

- selected a sample of 60 students (ID from 1 - 60)
- replaced missing houseCode value to 0 (for now)
- since we have several groups of students living in the same place and we set the infection probability to 1, we see a lot of students enter and exit and infectious period at the same time
- average simulation time (simulate schedule + virus)= 0.45s
- see specifics in: Testing Program Source Page

- Testing babydataV4:

- selected a sample of 500 students (ID from 1-500)
- new data problem: Room = ART STUDIO, KG removed the space between this time manually
- average simulation time (simulate schedule + virus)= 2.55s
- see specifics in: Testing Program Source Page

- Testing the Whole population:

- average simulation time (simulate schedule + virus)= 23.689 s
- the pattern is pretty boring and the infection length is very short: every one is under remission after less than 3 weeks (notice in the program we started from week 0 and ended on week 2)
- see specifics in: Testing Program Source Page

- the most interesting case is babydataV2 (also the one needed the longest simulation week length). This makes sense because in a large population, virus is going to spread faster (plus the probability now is set to 1).

## Week 7 & 8

--Kyra Gan 16:17, 18 March 2016 (EDT)

- Created date index for place value class, and tested new functions;
- Added toString method to all classes;
- Added place field in the Recipient class; (we can now retrieve the place of infection)
- Updated all testFunctions;
- Removed PrintHashTable class;
- Added toCSV method to the elementary classes of Remission hash table;
- ToString the remission hash table and save to csv file:

- see toString(), saveCSVRemissionHT(), toStringV2() and saveCSVRemissionHTV2() in WrapperStatusV3

- saveCSVRemissionHT() follows the format: ID, source, recipient units (time(date, startT, endT, daycount), recipients' IDs);
- saveCSVRemissionHTV2() follows the format: ID, source, recipient units (day of the semester, startT, recipients' IDs);
- if source=-1, id is the first student got infected in the whole population;

- see Program Source Page for the code;
- see Testing Program Source Page for some results;

- see toString and Save Remission hash table to csv parts;
- Testing babydataV2 and Testing babydataV3 have both toString and Save Remission hash table to csv part;
- Testing babydataV4 and Testing babydataV5 only have Save Remission hash table to csv part;

- Performance comparison (run through Eclipse):

- TestData2 (sample size 10): before: 0.188s, after indexing: 0.182s, turn off log: 0.092s
- TestData3 (sample size 60): before: 0.445s, after indexing: 0.402s, turn off log: 0.137s
- TestData4 (sample size 500): before: 2.576s, after indexing: 2.415s, turn off log: 0.412s
- TestData5 (whole campus model): before: 23.689s, after indexing: 23.055s, turn off log: 1.12s

- Testing whole population simulation source recipient contact:

- see testRecipientContact function in WrapperStatusV3 on Program Source Page

- we are now checking contacts for every student.
- for the whole population, writing csv, printing toStringRemissionHT, printing toCSVRemissionHT costs 3.482s in total.

- Some extra functions:

- Created Probability class (both deterministic part and stochastic part) and implemented the part in WrapperStatusV3 that allows us to change the probability of getting infected.

- see code at Program Source Page, go to Probability class.

- Test new functions works (for the deterministic part only):

- run TestData2.csv, first set Constants.infectionProbability=1, we get the correct result as the following

```
145,38,2,Mon,900,900,2,Wed,900,900,6,HILLYR205,2,Wed,1310,1600,0,688,
20,125,3,Th,1300,1300,2,Sa,1300,1300,6,
318,266,3,Tu,1030,1030,2,Th,1030,1030,6,
269,206,0,Th,1030,1030,2,Sa,1030,1030,6,SEELYE110,1,Mon,1100,1210,0,791,
266,688,2,Fri,900,900,2,Su,900,900,6,SEELYE201,3,Mon,1310,1430,0,125,HATFLD204,3,Tu,1030,1150,0,318,
206,-1,0,Mon,0,0,2,Wed,0,0,6,SEELYE106,0,Th,1030,1150,0,269,
688,145,2,Wed,1310,1310,2,Fri,1310,1310,6,HATFLD206,2,Fri,900,950,0,266,
38,791,1,Th,1310,1310,2,Sa,1310,1310,6,SEELYE212,2,Mon,900,1020,0,145,
125,266,3,Mon,1310,1310,2,Wed,1310,1310,6,WRIGHT200,3,Th,1300,1450,0,20,
791,269,1,Mon,1100,1100,2,Wed,1100,1100,6,WRIGHT230,1,Th,1310,1430,0,38,
```

- run TestData2.csv, set Constants.infectionProbability=(float) 0.1, we are expecting to get non of people infected by the first student, and here is the result:

```
current date is: Mon
current date is: Tu
current date is: Wed
current date is: Th
current date is: Fri
current date is: Sa
current date is: Su
current date is: Mon
145=
source=-1,
status: week=0,
incubation time:date=Mon,startT=0,endT=0,daycount=2
contagious time:date=Wed,startT=0,endT=0,daycount=6
recepient:
145,-1,0,Mon,0,0,2,Wed,0,0,6,
```

- \checkmark

## week 9: Trees

--Kyra Gan 17:30, 27 March 2016 (EDT)

### Modify toCSVV2: WrapperStatusV4

- Instead of returning the day of the semester for the recipients, we can simply get the day of semester for the recipient source block, and get place. ( KG took out the whole recipient class in WrapperStatusV4, since according to the way we create nodes, the recipient part is not necessary at all (related StatusV2, statusValueV2))

- see updated version of classes on Program Source Page

- Here is the result when we run the new version of code, data: TestData2.csv, with probability=1: new version is working the same way as the old version

- notice in this version, the first infected student's source = "0" instead of "-1"

```
ID,source,daycount,place,incubDate,incubStartT,incubEndT,incubDaycount,contagDate,contagStartT,contagEndT,contagDaycount
145,38,15,SEELYE212,Mon,900,900,2,Wed,900,900,6,
20,125,25,WRIGHT200,Th,1300,1300,2,Sa,1300,1300,6,
318,266,23,HATFLD204,Tu,1030,1030,2,Th,1030,1030,6,
269,206,4,SEELYE106,Th,1030,1030,2,Sa,1030,1030,6,
266,688,19,HATFLD206,Fri,900,900,2,Su,900,900,6,
206,0,1,413,Mon,0,0,2,Wed,0,0,6,
688,145,17,HILLYR205,Wed,1310,1310,2,Fri,1310,1310,6,
38,791,11,WRIGHT230,Th,1310,1310,2,Sa,1310,1310,6,
125,266,22,SEELYE201,Mon,1310,1310,2,Wed,1310,1310,6,
791,269,8,SEELYE110,Mon,1100,1100,2,Wed,1100,1100,6,
```

- Some remark: KG still keeps the old version to check the recipient source contact, since she has not create the new method to check recipient source contact yet.
- new version time improvements: none

### Data Set 1: 500 student simulation with probability=1

#### Source 1: Matlab: treeplot function

- select the first two columns of data from the previous data table, and creating the tree according to the source recipient relationship only. (not time stamped)

- a very nice short matlab code:

```
% Author: Kyra Gan
% Version: 3/27/2016
%change source from -1 to 0;
C=csvread('remissionHTV2 copy.csv');
%read the size of C from workspace
for i=1:500
nodes(C(i,1))=C(i,2);
end
treeplot(nodes);
```

- and here is the graph:

- click on the picture to see the full resolution

#### Source 2: graphviz

- graphviz : run on python

- tried the following versions
- Version 1

```
#Kyra Gan
#Version 3/27/2016
#adopted from process.py - http://www.graphviz.org/content/process
import csv
from graphviz import Graph
g = Graph('G', filename='Test1process.gv', engine='sfdp')
f = open('remissionHTV2 copy.csv', 'rt')
try:
reader = csv.reader(f)
for row in reader:
g.edge(row[0],row[1])
finally:
f.close()
g.view()
```

- Output: a extremely long graph

- click, click, and click to see the original resolution

- Error creating thumbnail: File with dimensions greater than 12.5 MP

- Version 2

```
#Kyra Gan
#Version 3/27/2016
#adopted from unix.py - http://www.graphviz.org/content/unix
import csv
from graphviz import Digraph
u = Digraph('unix', filename='Test1unix.gv')
u.body.append('size="6,6"')
u.node_attr.update(color='lightblue2', style='filled')
f = open('remissionHTV2 copy.csv', 'rt')
try:
reader = csv.reader(f)
for row in reader:
u.edge(row[0],row[1])
finally:
f.close()
u.view()
```

- Output: same graph as above

- click, click, and click to see the original resolution

#### other sources

- R:package ade4 (Analyses of Ecological Data: methods Exploratory and Euclidean in Environmental Science) :

- see documentation main page ade4 documentation
- see package developer main page ade4 main page

- it seems phylog() only takes specific biology sequence data: have not figure out how to read their data

- More on radial trees:

### Data Set 2: whole campus simulation with probability=0.1

- why we still have a relatively fast spread? because we are still assuming everyone in the house is going to have breakfast, lunch, and dinner together, and they are also going to study at night.

- If we change this assumption, we should see a slower spread.

#### Source 1: Matlab: treeplot function

- select the first two columns of data from the previous data table, and creating the tree according to the source recipient relationship only. (not time stamped)

- a very nice short matlab code:

```
% Author: Kyra Gan
% Version: 3/27/2016
%change source from -1 to 0;
C=csvread('remissionHTV2 wholecampus0.1p.csv');
%read the size of C from workspace
for i=1:2624
nodes(C(i,1))=C(i,2);
end
treeplot(nodes);
```

- and here is the graph:

- click on the picture to see the full resolution

#### Source 2: graphviz

- graphviz : run on python

- tried the following versions
- Version 1

```
#Kyra Gan
#Version 3/27/2016
#adopted from process.py - http://www.graphviz.org/content/process
import csv
from graphviz import Graph
g = Graph('G', filename='Test1process.gv', engine='sfdp')
f = open('remissionHTV2 wholecampus0.1p.csv', 'rt')
try:
reader = csv.reader(f)
for row in reader:
g.edge(row[0],row[1])
finally:
f.close()
g.view()
```

- Output: a extremely long graph

- click, click, and click to see the original resolution

- Version 2

```
#Kyra Gan
#Version 3/27/2016
#adopted from unix.py - http://www.graphviz.org/content/unix
import csv
from graphviz import Digraph
u = Digraph('unix', filename='Test1unix.gv')
u.body.append('size="6,6"')
u.node_attr.update(color='lightblue2', style='filled')
f = open('remissionHTV2 wholecampus0.1p.csv', 'rt')
try:
reader = csv.reader(f)
for row in reader:
u.edge(row[0],row[1])
finally:
f.close()
u.view()
```

- Output: same graph as above

- click, click, and click to see the original resolution

### Data Set 3: whole campus simulation with probability=0.01

- Notice not everyone get infected: only 2548/2624 get infected.

- If we change this assumption, we should see a slower spread.

#### Source 1: Matlab: treeplot function

- select the first two columns of data from the previous data table, and creating the tree according to the source recipient relationship only. (not time stamped)

- a very nice short matlab code:

```
% Author: Kyra Gan
% Version: 3/27/2016
%change source from -1 to 0;
C=csvread('remissionHTV2 wholecampus0.01p.csv');
%read the size of C from workspace
for i=1:2548
nodes(C(i,1))=C(i,2);
end
treeplot(nodes);
```

- and here is the graph:

- click on the picture to see the full resolution

## Week 9: More trees (twopi,...)

--Kyra Gan 17:20, 2 April 2016 (EDT)

### Version 1: simple twopi

- Data: whole population with p=
**0.01**, incubation=2, contagious=6 - Branches are not time stamped
- Here are the code built in WrapperStatusV4 for generating the dot file

```
public String toDot(){
// partition the whole population into two groups
//the list who have recipients, and the one who don't
ArrayList<String> source=new ArrayList<String>();
String dot="digraph spread {"+newline+"rankdir=LR;"+newline+"root="+firstInKey+";"
+newline+"ranksep=3.0;"
+newline+"nodesep=2.0;"+newline+"orientation=\"landscape\";"+newline+
firstInKey+newline;
//first iterate through the sources
for(Entry<String,StatusValueV2> entry: RemissionHT.entrySet()){
String mysource=entry.getValue().getSource();
if(!source.contains(mysource)){
if(mysource.equals("0")){
dot+=entry.getKey()+" [fillcolor=\"goldenrod1\",shape=doublecircle,style=filled,"
+ "fontsize=12];"+newline;
source.add(entry.getKey());
}
else{
dot+=mysource+" [fillcolor=\"coral1\",shape=circle,style=filled,"
+ "fontsize=12];"+newline;
source.add(mysource);
}
}
}
//then we iterate through the keys and add edges
for(Entry<String,StatusValueV2> entry: RemissionHT.entrySet()){
String mykey=entry.getKey();
if(!source.contains(mykey)){
dot+=mykey+" [shape=point,fillcolor=\"blueviolet\",width=0.2,style=filled,"
+ "fontsize=12];"+newline;
}
}
for(Entry<String,StatusValueV2> entry: RemissionHT.entrySet()){
String mykey=entry.getKey();
String mysource=entry.getValue().getSource();
if(!mysource.equals("0")){
dot+=mysource+"->"+mykey+"[arrowshape=none, penwidth=1.2,color="
+ "\"dimgray\"]"+";"+newline;
}
}
dot+="}";
return dot;
}
//this function writes the dot file for plotting the recipient source relationship and
//the edge is stamped by the day of the semester
public void saveRHTtoDotFile(){
try (PrintWriter out =new PrintWriter("remissionHTV2.dot")){
out.println(toDot());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
```

- Here is the dot file: Media:twopiv1.dot.txt
- Here is the graph:

- You can also download the dot file to your workspace and type the following command in Terminal to generate the graph

```
twopi -otwopiv1.png -Tpng twopiv1.dot
```

- to view the full version of the graph, please click, click and click

### Version 2: edge reflects time and node (other than first infected) size reflects the number of recipients

#### whole population with p=**0.1**, incubation=2, contagious=6

- Parameters for branches and size of the nodes

- the length of the branch is proportional to the day of the semester
- the radius of the nodes is proportional to the number of recipients.

- if a student does not have any recipients, the node has width 0.2
- else node has width 0.2*(#of recipients)
**Note: the size of the first infected node is NOT adjusted to the number of recipients in this section**

- from the picture below, we see that 0.2*(#of recipients) sometimes is not a good parameter;

- a way to fix this is to change logarithm, and we will see it later

- Here is the code plugged in the WrapperStatusV5 (with recipient class)

```
public String toDot(){
// partition the whole population into two groups
//the list who have recipients, and the one who don't
//and we use invisibleNodes to keep track of the length of the branch
ArrayList<String> source=new ArrayList<String>();
ArrayList<String> invisibleNodes=new ArrayList<String>();
//initialize invisible nodes list
for(Entry<String,StatusValue> entry: RemissionHT.entrySet()){
if(!entry.getValue().getSource().equals("0")){
int currentday=entry.getValue().getSt().getinfectionDay();
int sourceday=RemissionHT.get(entry.getValue().getSource()).getSt().getinfectionDay();
if(currentday-sourceday>1){
for(int i=0;i<currentday-sourceday-1;i++){
invisibleNodes.add("m"+invisibleNodes.size());
}
}
}
}
String dot="digraph spread {"+newline+"rankdir=LR;"+newline+"root="+firstInKey+";"
+newline+"ranksep=3.0;"
+newline+"nodesep=2.0;"+newline+"orientation=\"landscape\";"+newline+
firstInKey+newline;
//first iterate through the sources
//the size of the node reflect the number of recipient: #of recipient*0.2
for(Entry<String,StatusValue> entry: RemissionHT.entrySet()){
String mysource=entry.getValue().getSource();
if(!source.contains(mysource)){
if(mysource.equals("0")){
dot+=entry.getKey()+" [fillcolor=\"coral1\",shape=doublecircle,style=filled,"
+ "fontsize=12];"+newline;
source.add(entry.getKey());
}
else{
dot+=mysource+" [fillcolor=\"goldenrod1\",shape=circle,"+"width="+
RemissionHT.get(mysource).getRecipientID().size()*0.2+
",style=filled,"+ "fontsize=12];"+newline;
source.add(mysource);
}
}
}
//initialize invisible nodes
dot+="{node[shape=point,style=invis] ";
for(int i=0;i<invisibleNodes.size();i++){
dot+=invisibleNodes.get(i)+" ";
}
dot+="}"+newline;
//then we iterate through the keys and add edges
for(Entry<String,StatusValue> entry: RemissionHT.entrySet()){
String mykey=entry.getKey();
if(!source.contains(mykey)){
dot+=mykey+" [shape=point,fillcolor=\"blueviolet\",width=0.2,style=filled,"
+ "fontsize=12];"+newline;
}
}
Iterator<String> it=invisibleNodes.iterator();
for(Entry<String,StatusValue> entry: RemissionHT.entrySet()){
String mykey=entry.getKey();
String mysource=entry.getValue().getSource();
if(!mysource.equals("0")){
dot+=mysource;
int currentday=entry.getValue().getSt().getinfectionDay();
int sourceday=RemissionHT.get(entry.getValue().getSource()).getSt().getinfectionDay();
if(currentday-sourceday>1){
for(int i=0;i<currentday-sourceday-1;i++){
dot+="->"+it.next();
}
}
dot+="->"+mykey+"[arrowsize=0.4, penwidth=1.2,color="
+ "\"dimgray\"]"+";"+newline;
}
}
dot+="}";
return dot;
}
//this function writes the dot file for plotting the recipient source relationship and
//the edge is stamped by the day of the semester
public void saveRHTtoDotFile(){
try (PrintWriter out =new PrintWriter("remissionHTV2.dot")){
out.println(toDot());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
```

- Here is the dot file: Media:twopi2v1.dot.txt
- Here is the output:

- You can also download the dot file to your workspace and type the following command in Terminal to generate the graph

```
twopi -otwopi2v1.png -Tpng twopi2v1.dot
```

- to see the full resolution of the picture: click, click and click

- Now if we change the size of node to logarithm, with the same data parameters,

```
else{
dot+=mysource+" [fillcolor=\"goldenrod1\",shape=circle,"+"width="+
Math.log(1+RemissionHT.get(mysource).getRecipientID().size()*0.2)+
//RemissionHT.get(mysource).getRecipientID().size()*0.2+
",style=filled,"+ "fontsize=12];"+newline;
source.add(mysource);
}
```

- we will get:

- the dot file: Media:twopi2v2.dot.txt
- output(click, click and click):

#### whole campus student, p=0.01, incubation=2, contagious=6

- when we use the first version of node size, we will get the following dot file: Media:twopi2v3.dot.txt
- and the following output:

- You can also download the dot file to your workspace and type the following command in Terminal to generate the graph

```
twopi -otwopi2v3.png -Tpng twopi2v3.dot
```

- here is the link to a better resolution of the image:Media:twopi2v3(original).png

- go click on the full resolution; the true original size is 14179x10703 px (43.4MB) -> unable to upload the file

### Version 3: edge reflects day of the semester (time), node reflects the size of recipients

#### whole campus student, p=0.01, incubation=2, contagious=6

- Change the size of the first infected student to be proportional to the size of her direct recipients

```
if(mysource.equals("0")){
dot+=entry.getKey()+" [fillcolor=\"coral1\",shape=doublecircle,"+"width="+
entry.getValue().getRecipientID().size()*0.2+
",style=filled,"+ "fontsize=12];"+newline;
source.add(entry.getKey());
}
```

- here is the dot file: Media:twopi3v1.dot.txt

```
twopi -otwop3iv1.png -Tpng twopi3v1.dot
```

- here is the link to a better resolution file: Media:twopi3v1(good).png

- go click on the full resolution

- Here is a compressed version of output:

#### whole campus student, p=0.01, incubation=6, contagious=8

- When KG changes her data parameter to the above, the data was to big for twopi when edge reflects time and node reflects the size of the recipients

```
1x-vl923-72-19-108-65:~ kyragan$ twopi -os1.png -Tpng remissionHTV2.dot
twopi: graph is too large for cairo-renderer bitmaps. Scaling by 0.576833 to fit
twopi(12051,0x7fff79c78000) malloc: *** mach_vm_map(size=18446744073642446848) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
twopi: failure to create cairo surface: out of memory
Segmentation fault: 11
```

- one way to fix it is to change the measure of the length:

- instead of having one arrow represent one day, KG can one arrow represent two or more days in the following way:

--Kyra Gan 22:13, 3 April 2016 (EDT)

- first we create a variable called edgeDiscountFactor in Constants class

```
//Def: edgeDiscountFactor=(actual time length)/target time length
//i.e. we do not differentiate within the edgeDicountFactor unit of days
static float edgeDiscountFactor=incubationLimit/2;
```

- then we add the following code when creating edges:

```
for(Entry<String,StatusValue> entry: RemissionHT.entrySet()){
String mykey=entry.getKey();
String mysource=entry.getValue().getSource();
if(!mysource.equals("0")){
dot+=mysource;
int currentday=entry.getValue().getSt().getinfectionDay();
int sourceday=RemissionHT.get(entry.getValue().getSource()).getSt().getinfectionDay();
int steps=(int) ((currentday-sourceday-1)/Constants.edgeDiscountFactor);
for(int i=0;i<steps;i++){
dot+="->"+it.next();
}
dot+="->"+mykey+"[arrowsize=0.4, penwidth=1.2,color="
+ "\"dimgray\"]"+";"+newline;
}
```

- In addition, KG fixed a bug in simulation and made WrapperStatusV5 more concise

- see Program Source Page for the most recent version of codes

- Here is the dot file: Media:twopi3v2.dot.txt
- and here is a better version of the output : Media:twopi3v2(good).png

```
twopi -otwopi3v2.png -Tpng twopi3v2.dot
```

- and here is another iteration:
- Media:twopi3v3.dot.txt

```
twopi -otwopi3v3.png -Tpng twopi3v3.dot
```

#### stochastic with Sigma=0.1, whole campus student, p=0.01, incubation=6, contagious=8

- first iteration:
- Media:twopi3v5.dot.txt

```
twopi -otwopi3v5.png -Tpng twopi3v5.dot
```

- second iteration:
- Media:twopi3v6.dot.txt

```
twopi -otwopi3v6.png -Tpng twopi3v6.dot
```

### same data set with different graphs

--Kyra Gan 12:49, 5 April 2016 (EDT)

- Parameters: stochastic with Sigma=0.1, whole campus student, p=0.01, incubation=6, contagious=8

- here is the matlab code for the graphs:

```
% Author: Kyra Gan
% Version: 3/27/2016
C=csvread('remissionHTV3.csv');
Y=zeros(1354,1);
%read the size of C from workspace
for i=1:1354
nodes(C(i,1))=C(i,2);
Y(i,1)=C(i,3);
end
subplot(3,1,1);
treeplot(nodes)
title('tree');
subplot(3,1,2);
Y2=sort(Y);
plot(Y2)
title('number of recipients sort');
subplot(3,1,3);
plot(Y)
title('number of recipients');
```

## Week 10: More graphs, vaccination & quarantine

- Generated a new toDot class to generate the dot file from the third version of csv output file

- add the day scaler to the graph (maybe we want to use a brighter color)
- now user can choose between generating the nodes with radius proportional to size of the direct recipients or the area
- if radius proportional, then we have three different color to indicate the size of the recipient

- we have three ranges, 1-5,6-10,>=11, and the darker the color is, the more recipients the node has.

- Fixed the bug of recipientID size, and some bug in the toDot function
- Implemented the vaccination part:

- add variables related to vaccination to Constants class, and modified PlaceTimeEntry class, probability class, WrapperSP class, WrapperStatusV5 class

- we use a hashtable to keep track of the students who receive vaccines (the integer value has no value at this point), since we are going to use containskey function a lot.

- Some assumptions:

- Assume that once a student receives vaccine, she will never be infected, but she can still be a carrier of the virus. i.e. she is contagious.
- The default probability of a vaccinated student to be "infected" and become a carrier is 0.005, but a user can change the probability to any number she or he wants.
- Once a vaccinated student become "infected", she also has the same incubation period. i.e. she does not enter the contagious period directly.
- Once a vaccinated student become contagious, she has the same probability as any other students to infect other student

- For now we are only going to work with the whole campus data.

- Implemented the Quarantine part:

- Quarantine assumption: class size over 40 are canceled, but people can still move around the house

- see the most recent version of the code at Program Source Page
- In this weeks experiment, KG only used the data of Whole Campus, with parameters: infectionProbability=0.01, incubation=6 days, contagious=8 days, if not specify, deterministic =true, vaccineContagiuosProbability= 0.005.

### exampletreeV2

--Kyra Gan 01:05, 6 April 2016 (EDT)

- Here is the third version of the csv output from WrapperStatusV5.

- Here is the version of the graph that nodes' area is proportional to the size of direct recipients

- We can see that twopi does not let the radius of the circle strict to be the number that we set up because of the length of the label. Alternatively, we might want to have the radius to be proportional to the size of direct recipients as we did in the last week.
- Here is the dot file

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oexampletreev2.png -Tpng exampletreev2.dot
```

- here is the output graph (large version available here)

- Here is the version of the graph that the radius of the nodes are proportional to log(1+the size of direct recipients) Note: the size of the source is area proportional (KG forgot to change it).

- Here is the dot file

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oexampletreev3.png -Tpng exampletreev3.dot
```

- here is the output graph ( (large version available here)

- Here is the matlab version of the graphs

- the last graph is the loglog output

```
% Author: Kyra Gan
% Version: 4/6/2016
C=csvread('examplev2.csv');
Y=zeros(1669,1);
%read the size of C from workspace
for i=1:1669
nodes(C(i,1))=C(i,2);
Y(i,1)=C(i,3);
end
subplot(5,1,1);
treeplot(nodes)
title('tree');
subplot(5,1,2);
Y2=sort(Y);
plot(Y2)
title('number of recipients sort');
xlabel('ID');
subplot(5,1,3);
plot(Y)
title('number of recipients raw');
xlabel('ID');
subplot(5,1,4);
h=histogram(Y2,'Normalization','probability');
ylabel('number of students');
xlabel('number of recipients');
subplot(5,1,5);
[a,b]=hist(Y,unique(Y));
S=sum(a);
S2=sum(a);
A=zeros(size(b));
A(1,1)=1;
for i=2:17
S2=S2-a(1,i-1);
A(i,1)=S2/S;
end
plot(b,A);
```

### vaccination

--Kyra Gan 16:25, 9 April 2016 (EDT)

- KG first ran the program without vaccine is distributed

- Here is the csv output to generate all the dot files below:Novaccine.csv.txt
- KG generated three versions of toDot() that she implemented in toDot() class.

- KG then ran the program with percentage of population receive vaccine to be 0.1, 1 iteration
- KG then ran the program with percentage of population receive vaccine to be 0.5, 2 iteration

- For the convenience of comparison, KG implemented a function to set the first infected student to be the any particular person we want
- In addition, KG only graphed the Radius version of the dot file

- since in the no vaccine section, our first infected student is 2571, we are going to pick 2571 to the first student infected in the following simulations

- if a student is vaccinated but contagious, she is going to show up on graph as green (we need to keep in mind that they are still healthy)

- for NO vaccine: there are total 1763 people got infected (total population 2624)
- for 0.1 vaccine: there are less than 1193 people got infected (total population 2624) (total infected+total vaccinated but carrier=1193)
- for 0.5 vaccine:

- if 2571 is vaccinated and carries the virus (at the very beginning): there are total 1 person getting infected (total infected+total vaccinated but carrier=3)
- if 2571 is not vaccinated: there are less than 73 people got infected (total population 2624) (total infected+total vaccinated but carrier=73)

#### No vaccine area

- for NO vaccine: there are total 1763 people got infected (total population 2624)
- Here is the dot file: Media:NovaccineArea.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oNovaccineArea.png -Tpng NovaccineArea.dot
```

- Here is the output file: (large version available here)

#### No vaccine Radius Log

- Here is the dot file: Media:NovaccineRadiusLog.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oNovaccineRadiusLog.png -Tpng NovaccineRadiusLog.dot
```

- Here is the output file:(large version available here)

#### No vaccine Radius

- Here is the dot file: Media:NovaccineRadius.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oNovaccineRadius.png -Tpng NovaccineRadius.dot
```

- Here is the output file: (large version available here)

#### 0.1 vaccine Radius

- for 0.1 vaccine: there are less than 1193 people got infected (total population 2624) (total infected+total vaccinated but carrier=1193)
- Here is the csv file: Media:0.1vaccineRadius.csv.txt
- Here is the dot file: Media:0.1vaccineRadius.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -o0.1vaccineRadius.png -Tpng 0.1vaccineRadius.dot
```

- Here is the output file:(large version available here)

#### 0.5 vaccine Radius V1

- there are total 1 person getting infected (total infected+total vaccinated but carrier=3)
- Here is the csv file: Media:0.5vaccineRadiusV1.csv.txt
- Here is the dot file: Media:0.5vaccineRadiusV1.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -o0.5vaccineRadiusV1.png -Tpng 0.5vaccineRadiusV1.dot
```

- Here is the output file:

#### 0.5 vaccine Radius V2

- there are less than 73 people got infected (total population 2624) (total infected+total vaccinated but carrier=73)
- Here is the csv file: Media:0.5vaccineRadiusV2.csv.txt
- Here is the dot file: Media:0.5vaccineRadiusV2.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -o0.5vaccineRadiusV2.png -Tpng 0.5vaccineRadiusV2.dot
```

- Here is the output file: (large version available here)

### Quarantine

--Kyra Gan 17:27, 9 April 2016 (EDT)

- It is very simple to implement the quarantine part, we need extra four lines in WrapparStatusV5:

```
if(Constants.quarantine){
if(!Character.isDigit(myplace.toCharArray()[0])){ // we use this line to differentiate
//between regular classrooms(is String in letter and number format, but always
//starts with letter) and houses(is a number in String format)
if(myPTE.stdNum()>=40){
continue;
}
}
}
```

- in our simulation, there are total 251 got infected
- we still pick 2571 to be our first infected student
- Here is the csv file: Media:NovaccineQuarantineRadius.csv.txt
- Here is the dot file: Media:NovaccineQuarantineRadius.dot.txt

- you can save the file to your workspace and run the following command to generate the graph

```
twopi -oNovaccineQuarantineRadius.png -Tpng NovaccineQuarantineRadius.dot
```

- Here is the output file: (large version available here)

# week 11: some minor adjustments

--Kyra Gan 00:08, 17 April 2016 (EDT)

- KG rotates the graph back to its normal orientation
- KG set the day scaler edge penwidth to 8 (now we can see the scalers clearly even after resize the graph)
- KG debugged the updateAll function inside WrapperStatusV5
- KG picked the first infected student to be 82, and ran a series of simulations

## firstInKey 82, radius ratio, Probability infection=1, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

--Kyra Gan 14:26, 17 April 2016 (EDT)

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82RadiusRatioProb1DE.csv.txt
- Here is the dot file: Media:firstInKey82RadiusRatioProb1DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82RadiusRatioProb1DE.png -Tpng firstInKey82RadiusRatioProb1DE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82RadiusRatioProb1DE(original).png

### Area

- we used the same csv output file but set the node's area to be proportional to the number of direct recipients
- Here is the dot file: Media:firstInKey82AreaProb1DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb1DE.png -Tpng firstInKey82AreaProb1DE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb1DE(original).png

### RadiusLog

- we used the same csv output file but set the node's area to be log proportional to the number of direct recipients
- Here is the dot file: Media:firstInKey82RadiusLogProb1DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82RadiusLogProb1DE.png -Tpng firstInKey82RadiusLogProb1DE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82RadiusLogProb1DE(original).png

## firstInKey 82, radius ratio, Probability infection=0.01, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82RadiusRatioProb0.01DE.csv.txt
- Here is the dot file: Media:firstInKey82RadiusRatioProb0.01DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82RadiusRatioProb0.01DE.png -Tpng firstInKey82RadiusRatioProb0.01DE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82RadiusRatioProb0.01DE(original).png

### Area

- we used the same csv output file but set the node's area to be proportional to the number of direct recipients
- Here is the dot file: Media:firstInKey82AreaProb0.01DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01DE.png -Tpng firstInKey82AreaProb0.01DE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb0.01DE(original).png

## firstInKey 82, radius ratio, Probability infection=0.01, quarantine=false, vaccine=false, Stochastic probability with sigma(volatility) =1, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82Prob0.01SE.csv.txt
- Here is the dot file: Media:firstInKey82RadiusRatioProb0.01SE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82RadiusRatioProb0.01SE.png -Tpng firstInKey82RadiusRatioProb0.01SE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82RadiusRatioProb0.01SE(original).png

### Area

- we used the same csv output file but set the node's area to be proportional to the number of direct recipients
- Here is the dot file: Media:firstInKey82AreaProb0.01SE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01SE.png -Tpng firstInKey82AreaProb0.01SE.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb0.01SE(original).png

## firstInKey 82, Area, Probability infection=0.01, quarantine=false, vaccine=50% of the population, vaccineContagiousProbability=0, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82AreaProb0.01DEVaccine.csv.txt
- Here is the dot file: Media:firstInKey82AreaProb0.01DEVaccine.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01DEVaccine.png -Tpng firstInKey82AreaProb0.01DEVaccine.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb0.01DEVaccine(original).png

## firstInKey 82, Area, Probability infection=0.01, quarantine=false, vaccine=50% of the population, vaccineContagiousProbability=0.001, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82AreaProb0.01DEVaccineV2.csv.txt
- Here is the dot file: Media:firstInKey82AreaProb0.01DEVaccineV2.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01DEVaccineV2.png -Tpng firstInKey82AreaProb0.01DEVaccineV2.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb0.01DEVaccineV2(original).png

## firstInKey 82, Area, Probability infection=0.01, quarantine=true, quarantine house=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82AreaProb0.01DEQ.csv.txt
- Here is the dot file: Media:firstInKey82AreaProb0.01DEQ.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01DEQ.png -Tpng firstInKey82AreaProb0.01DEQ.dot
```

- Here is the resized output

- Here is a larger version of the file

Media:firstInKey82AreaProb0.01DEQ(original).png

## firstInKey 82, Area, Probability infection=0.01, quarantine=true, quarantine house=true, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82AreaProb0.01DEQH.csv.txt
- Here is the dot file: Media:firstInKey82AreaProb0.01DEQH.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82AreaProb0.01DEQH.png -Tpng firstInKey82AreaProb0.01DEQH.dot
```

- Here is the resized output

## firstInKey 82, Radius Ratio, Probability infection=0.005, quarantine=false, vaccine=false, deterministic probability, edge discount factor =incubationLimit/2

- Here is the csv output that you can use ToDot class to generate the dot file: Media:firstInKey82RRProb0.005DE.csv.txt
- Here is the dot file: Media:firstInKey82RRProb0.005DE.dot.txt
- This the command that you can run the dot file (from terminal)

```
twopi -ofirstInKey82RRProb0.01DEQ.png -Tpng firstInKey82RRProb0.01DEQ.dot
```

- Here is the resized output

- Here is a larger version of the file