Professional Documents
Culture Documents
Python
Python
#Correo: judmejiabe@unal.edu.co
#Libraries
import numpy as np
import plotly.graph_objs as go
import pandas as pd
class SEI3RD(object):
def __init__(self,
incubationRate,
transmissionRate2,
transmissionRate3,
recoveryProbability0,
recoveryProbability1,
recoveryProbability2,
recoveryProbability3,
recoveryRate0,
recoveryRate1,
recoveryRate2,
recoveryRate3,
worsenCondition0,
worsenCondition1,
worsenCondition2,
worsenCondition3):
"""Crea una instancia de la clase SEIAR, que modelará una epidemia
de acuerdo a un modelo SEI3RD con los parámetros dados"""
self.omega = incubationRate
self.beta2 = transmissionRate2
self.beta3 = transmissionRate3
self.delta0 = recoveryProbability0
self.delta1 = recoveryProbability1
self.delta2 = recoveryProbability2
self.delta3 = recoveryProbability3
self.gamma0 = recoveryRate0
self.gamma1 = recoveryRate1
self.gamma2 = recoveryRate2
self.gamma3 = recoveryRate3
self.sigma0 = worsenCondition0
self.sigma1 = worsenCondition1
self.sigma2 = worsenCondition2
self.sigma3 = worsenCondition3
#print(self.T)
return(np.max(np.linalg.eigvals(- np.matmul(self.T,
np.linalg.inv(self.Sigma)))))
def solve_SEI3RD(self, E_0, I0_0, I1_0, I2_0, I3_0, R_0, D_0, T):
"""Resuelve las ecuaciones diferenciales y calcula el número final
de individuos retirados. R_0 en este caso es la proporción inicial
de individuos retirados. T nos dá la ventana máxima de tiempo
donde se quiere observar el fenómeno"""
self.E0 = E_0
self.I0_0 = I0_0
self.I1_0 = I1_0
self.I2_0 = I2_0
self.I3_0 = I3_0
self.R_0 = R_0
self.D_0 = D_0
self.T = T
return(results)
w = 1.2
trace0 = go.Scatter(
x = self.t,
y = self.S * numberSusceptible,
mode = 'lines',
name = 'Susceptibles',
line = dict(color = 'blue',
width = w)
)
trace1 = go.Scatter(
x = self.t,
y = self.E * numberSusceptible,
mode = 'lines',
name = 'Expuestos',
line = dict(color = 'pink',
width = w)
)
trace2 = go.Scatter(
x = self.t,
y = self.I0 * numberSusceptible,
mode = 'lines',
name = 'Asintomáticos',
line = dict(color = 'cyan',
width = w)
)
trace3 = go.Scatter(
x = self.t,
y = self.I1 * numberSusceptible,
mode = 'lines',
name = 'SÃntomas Moderados',
line = dict(color = 'yellow',
width = w)
)
trace4 = go.Scatter(
x = self.t,
y = self.I2 * numberSusceptible,
mode = 'lines',
name = 'SÃntomas Severos',
line = dict(color = 'orange',
width = w)
)
trace5 = go.Scatter(
x = self.t,
y = self.I3 * numberSusceptible,
mode = 'lines',
name = 'CrÃticos',
line = dict(color = 'red',
width = w)
)
trace6 = go.Scatter(
x = self.t,
y = self.R * numberSusceptible,
mode = 'lines',
name = 'Recuperados',
line = dict(color = 'green',
width = w)
)
trace7 = go.Scatter(
x = self.t,
y = self.D * numberSusceptible,
mode = 'lines',
name = 'Muertes',
line = dict(color = 'black',
width = w)
)
if separated:
fig = make_subplots(rows=4, cols=2,
subplot_titles=("Susceptibles",
"Expuestos (Estado Latente)",
"Asintomáticos",
"SÃntomas Moderados",
"SÃntomas Severos",
"CrÃticos",
"Recuperados",
"Muertos"))
else:
fig = go.Figure()
fig.add_trace(trace0)
fig.add_trace(trace1)
fig.add_trace(trace2)
fig.add_trace(trace3)
fig.add_trace(trace4)
fig.add_trace(trace5)
fig.add_trace(trace6)
fig.add_trace(trace7)
fig.update_layout(
title="Proyecciones Modelo SEI3RD",
xaxis_title = "DÃas",
yaxis_title = "Prevalencia",
)
fig.layout.template = 'seaborn'
fig.show()