Esempio n. 1
0
    def test_fusion_and_adding_rates(self):

        A, B, C = list("ABC")

        epi = EpiModel(list("ABC"))

        # this should not raise a warning that rates do not sum to zero
        # as it will be actively suppressed
        epi.add_fusion_processes([
            (A, B, 1, C),
        ])

        with self.assertWarns(UserWarning):
            # this should raise a warning that rates do not sum to zero
            epi.add_quadratic_events([
                ((A, B), 1, [(C, -1), (A, +1)]),
            ])
        # now rates should sum to zero
        epi.add_quadratic_events([
            ((A, B), 1, [(B, +1)]),
        ])

        with self.assertWarns(UserWarning):
            # this should raise a warning that rates do not sum to zero
            epi.add_linear_events([((A, ), 1, [(B, -1)])])
Esempio n. 2
0
    def test_stochastic_fission(self):

        A, B, C = list("ABC")

        N = 10
        epi = EpiModel([A, B, C],
                       N,
                       correct_for_dynamical_population_size=True)
        epi.add_fusion_processes([
            (A, B, 1.0, C),
        ])
        epi.set_initial_conditions({A: 5, B: 5})

        t, res = epi.simulate(1e9)

        assert (res[C][-1] == 5)
Esempio n. 3
0
    def test_correcting_for_declining_pop_size(self):

        A, B = list("AB")
        epi = EpiModel([A, B], 10, correct_for_dynamical_population_size=True)
        epi.add_transition_processes([
            #(None, 0.1, A),
        ])
        epi.add_fusion_processes([
            (A, B, 1, B),
        ])
        epi.set_initial_conditions({B: 4, A: 6})
        tt = np.linspace(0, 30)
        result = epi.integrate(tt)
        #from matplotlib import pyplot as pl
        #pl.plot(tt, result[A], label=A)
        #pl.plot(tt, result[B], label=B)
        epi.correct_for_dynamical_population_size = False
        result = epi.integrate(tt)