-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
44 lines (28 loc) · 1.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import datetime
import pandas as pd
from models.person import Person
from World import World
def main():
# print('initializing database')
# client = AsyncIOMotorClient("mongodb://localhost:27017/")
# Initialize beanie with the Product document class and a database
# await init_beanie(database=client.db_name, document_models=[Person, Household, School, Workplace])
w = World('data.json')
n_days = 2
# # print("Generating Population")
w.generate_population("pinar", n_processes=40)
# print(w.db.count(Person))
print("Done!, Simmulating days now...")
w.run_simulation("pinar", n_days)
print("Building Matrix")
w.generate_contact_matrix("pinar", n_days)
labels = [str(i[0])+"-"+str(i[1]) for i in w.data_source.age_groups]
for i in w.mat:
final_mat = w.mat[i]/(2*n_days)
final_mat = final_mat / w.mat_ages
# final_mat = (final_mat.transpose()) / w.mat_ages
df = pd.DataFrame(final_mat, columns=labels)
df.to_csv(f"matrix_{i}.csv")
if __name__ == '__main__':
main()
# build_graph()