コード例 #1
0
    def test_quadratic_processes(self):

        S, E, I, R = sympy.symbols("S E I R")
        epi = SymbolicEpiModel([S, E, I, R])
        quadratic_rates = [I * S]
        quadratic_events = [Matrix([[-1, +1, 0, 0]])]
        epi.add_transmission_processes([
            (S, I, 1, I, E),
        ])
        for r0, r1 in zip(quadratic_rates, epi.quadratic_rate_functions):
            assert (r0 == r1)
        for e0, e1 in zip(quadratic_events, epi.quadratic_event_updates):
            assert (all([_e0 == _e1 for _e0, _e1 in zip(e0, e1)]))
コード例 #2
0
    def test_adding_quadratic_processes(self):

        S, E, I, A, R, rho = sympy.symbols("S E I A R rho")
        epi = SymbolicEpiModel([S, E, I, A, R])

        epi.set_processes([
            (S, I, rho, I, E),
        ])
        epi.add_transmission_processes([
            (S, A, rho, A, E),
        ])
        quadratic_rates = [I * S * rho, S * A * rho]
        quadratic_events = [
            Matrix([[-1, +1, 0, 0, 0]]),
            Matrix([[-1, +1, 0, 0, 0]])
        ]
        for r0, r1 in zip(quadratic_rates, epi.quadratic_rate_functions):
            assert (r0 == r1)
        for e0, e1 in zip(quadratic_events, epi.quadratic_event_updates):
            assert (all([_e0 == _e1 for _e0, _e1 in zip(e0, e1)]))
コード例 #3
0
    print(epi.find_fixed_points())

    omega = sympy.symbols("omega")
    epi = SymbolicSIRSModel(eta, rho, omega)
    print()
    print(epi.ODEs())
    print(epi.find_fixed_points())

    import sympy
    from epipack import SymbolicEpiModel

    S, I, eta, rho = sympy.symbols("S I eta rho")

    SIS = SymbolicEpiModel([S, I])
    SIS.add_transmission_processes([
        (I, S, eta, I, I),
    ])
    SIS.add_transition_processes([
        (I, rho, S),
    ])

    print(SIS.find_fixed_points())

    print(SIS.get_eigenvalues_at_fixed_point({S: 1}))

    print("==========")
    SIS = SymbolicEpiModel([S, I])
    SIS.set_processes([
        (I, S, eta / (1 - I), I, I),
        (I, rho, S),
    ])