Ejemplo n.º 1
0
 def __init__(self, nu, beta, S0, I0, R0, T, V0, p):
     ProblemSIR.__init__(self, nu, beta, S0, I0, R0, T)
     self.V0 = V0
     if isinstance(p, (float, int)):
         self.p = lambda t: p
     elif callable(p):
         self.p = p
Ejemplo n.º 2
0
    def __init__(self, nu, beta, p, S0, I0, RO, V0,
                 T):  ## -> Skriver som attributter
        PSIR.__init__(self, nu, beta, S0, I0, RO, T)
        self.V0 = V0

        if isinstance(p, (float, int)):  # p tall
            self.p = lambda t: p
        elif callable(p):  # p funksjon
            self.p = p
Ejemplo n.º 3
0
    def __init__(self, nu, beta,  S0, I0, R0, T, V0, p):
        ProblemSIR.__init__(self,nu, beta, S0, I0, R0, T)   #calling __init__ from Superclass
        self.V0= V0     #initialization of vaccination (belongs to ProblemSIRV)

        # wrap fraction as a function of time or constant
        if isinstance(p,(float,int)):
            self.p= lambda t: p
        elif callable(p):
            self.p= p
Ejemplo n.º 4
0
    def __init__(self, v, beta, S0, I0, R0, V0, p, T):

        ProblemSIR.__init__(self, v, beta, S0, I0, R0,
                            T)  # let ProblemSIR store parameters
        self.V0 = V0  # initial no. people vaccinated

        if isinstance(p, (float, int)):  # is p a number?
            self.p = lambda t: p  # wrap p in a function
        elif callable(p):
            self.p = p
Ejemplo n.º 5
0
def test():
    #  S0 = initial healthy population
    #  I0 = initial infected population
    #  R0 = initial resistant population
    #  v0 = initial vaccinated population
    #  T  = duration (days)
    #beta = probability of infection per SI pair

    vaccine_problem = ProblemSIRV(beta=0.0005,
                                  v=0.1,
                                  S0=1500,
                                  I0=1,
                                  R0=0,
                                  V0=0,
                                  p=0.1,
                                  T=60)
    vaccine_sim = SolverSIRV(vaccine_problem, 0.5)
    vaccine_sim.solve()
    vaccine_sim.plot()
    print 'The maximum no. people infected now with vaccination:', int(
        vaccine_sim.calc_max())

    old_problem = ProblemSIR(beta=0.0005, v=0.1, S0=1500, I0=1, R0=0, T=60)
    simulation_old = SolverSIR(old_problem, 0.5)
    simulation_old.solve()
    print 'Compared to the old maximum no. of infected (beta=0.0005):', int(
        simulation_old.calc_max())
Ejemplo n.º 6
0
    def __init__(self, v, beta, S0, I0, R0, V0, p, T):

        ProblemSIR.__init__(self, v, beta, S0, I0, R0,
                            T)  # let ProblemSIR store parameters
        self.V0 = V0  # initial no. people vaccinated
        self.p = p  # fraction of susceptibles vaccinated per dt
Ejemplo n.º 7
0
 def __init__(self, nu, beta, S0, I0, R0, T, V0, p):
     ProblemSIR.__init__(self, nu, beta, S0, I0, R0, T)
     self.V0, self.p = V0, p
Ejemplo n.º 8
0
import matplotlib.pyplot as plt
import numpy as np
from SIR_class import ProblemSIR, SolverSIR

problem = ProblemSIR(beta=5e-4, nu=.1, S0=1500, I0=1, R0=0, T=60)
solver = SolverSIR(problem, .5)
solver.solve()
plt.subplot(2, 1, 1)
plt.title('Constant beta')
solver.plot()

problem_ = ProblemSIR(beta=lambda t: 0.0005 if t <= 12 else 0.0001,
                      nu=0.1,
                      S0=1500,
                      I0=1,
                      R0=0,
                      T=60)
solver_ = SolverSIR(problem_, .5)
solver_.solve()
plt.subplot(2, 1, 2)
plt.title('Varying beta')
solver_.plot()
plt.legend()
plt.show()