In [6]:
from dzdy import *
import matplotlib.pyplot as plt
In [7]:
da = Director()
da.load_pc('scripts/pSIR.txt')
da.load_pc('scripts/pSIR_net.txt')
da.load_dc('scripts/SIR_bn.txt')
In [8]:
cfd = da.new_mc('ABM_SIR', 'ABM', tar_pc='pSIR', tar_dc='SIR_BN')
cfd.add_behaviour('cycle', be_type='Reincarnation', s_birth = 'Sus', s_death = 'Dead')
cfd.add_behaviour('transmission', be_type='ComFDShock', s_src = 'Inf', t_tar = 'Infect')
cfd.set_observations(states=['Sus', 'Inf', 'Rec'],
behaviours=['transmission'])
In [9]:
a1, out = da.simulate('ABM_SIR', y0= {'Sus': 95, 'Inf': 5}, to=20)
out.plot()
plt.show()
In [10]:
cfdf = da.new_mc('ABM_SIR_Fast', 'ABM', tar_pc='pSIR', tar_dc='SIR_BN')
cfdf.add_behaviour('cycle', be_type='Reincarnation', s_birth = 'Sus', s_death = 'Dead')
cfdf.add_behaviour('transmission', be_type='ComFDShockFast', s_src = 'Inf', t_tar = 'Infect', dt=0.5)
cfdf.set_observations(states=['Sus', 'Inf', 'Rec'], behaviours=['transmission'])
In [11]:
a2, out = da.simulate('ABM_SIR_Fast', y0= {'Sus': 95, 'Inf': 5}, to=20)
out.plot()
plt.show()
In [12]:
cfdf = da.new_mc('ABM_SIR_DD', 'ABM', tar_pc='pSIR_net', tar_dc='SIR_BN')
cfdf.add_behaviour('cycle', be_type='Reincarnation', s_birth = 'Sus', s_death = 'Dead')
cfdf.add_behaviour('transmission', be_type='ComDDShock', s_src = 'Inf', t_tar = 'Infect')
cfdf.set_observations(states=['Sus', 'Inf', 'Rec'], behaviours=['transmission'])
In [13]:
a3, out = da.simulate('ABM_SIR_DD', y0= {'Sus': 95, 'Inf': 5}, to=20)
out.plot()
plt.show()