-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
98 lines (65 loc) · 1.78 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import matplotlib.pyplot as plt
import random as rd
import numpy as np
# Inputs
export_file_path="data.xyz"
population = 200
sick = 4 # percent
dt = 0.05 # time
Speed = 30
Time = 50 # total time
Iteration = int(Time/dt)
plist = np.arange(population)
rd.shuffle(plist)
# init
pop = []
for i in range(population):
pop.append(Person(rd.uniform(0,200),rd.uniform(0,200),rd.uniform(0,359)))
pop[i].box(0,0,200,200)
saveXYZ(pop,'data.xyz')
# sick population
for i in range(int(sick*population/100)):
pop[plist[i]].stat=1
check = np.zeros([population,population])
SEl = np.zeros([Iteration])
REl = np.zeros([Iteration])
HEl = np.zeros([Iteration])
Vert = np.arange(Iteration)
for j in range(Iteration):
# plt.subplot(2,1,1)
SS =0
RE =0
HE =0
for i in range(population):
# pop[i].plot()
pop[i].newPosition(Speed,dt)
pop[i].updatestat()
if pop[i].stat==1:
SS+=1
elif pop[i].stat==2:
RE+=1
else:
HE+=1
saveXYZ(pop,'data.xyz')
# plt.show(block=False)
# plt.plot([0,0,200,200,0],[0,200,200,0,0],'k',linewidth=1)
# plt.title(j*dt)
# plt.axis('off')
# plt.axis('equal')
SEl[j] =SS
REl[j] =RE
HEl[j] = HE
# plt.subplot(2,1,2)
# plt.bar(Vert,HEl, color='b', bottom =REl+SEl, width=1.8,label = 'Helth')
# plt.bar(Vert,REl, color='g', bottom =SEl,width=1.8, label = 'Recover:'+str(RE))
# plt.bar(Vert,SEl,color='r', width=1.8,label ='Sick:'+str(SS))
# plt.legend()
# plt.xticks(Ver, ('V1', 'V2', 'V3', 'V4', 'V5'))
# plt.pause(0.01)
# plt.clf()
if SS == 0:
break
for ii in range(population):
for jj in range(ii):
# print(ii,jj)
pop[ii].neighber(pop[jj])