def run_projection(self, p: Parameters, policy: Sequence[Tuple[float, int]]):
        raw = sim_sir(
            self.susceptible,
            self.infected,
            p.recovered,
            self.gamma,
            -self.i_day,
            policy
        )

        calculate_dispositions(raw, self.rates, p.market_share)
        calculate_admits(raw, self.rates)
        calculate_census(raw, self.days)

        return raw
示例#2
0
def test_sim_sir():
    """
    Rounding to move fast past decimal place issues
    """
    raw = sim_sir(
        5,
        6,
        7,
        0.1,
        0,
        [(0.1, 40)],  # s  # i  # r  # gamma  # i_day  # beta1  # n_days1
    )

    assert round(raw["susceptible"][0], 0) == 5
    assert round(raw["infected"][0], 2) == 6
    assert round(raw["recovered"][0], 0) == 7
    assert round(raw["susceptible"][-1], 2) == 0
    assert round(raw["infected"][-1], 2) == 0.18
    assert round(raw["recovered"][-1], 2) == 17.82
示例#3
0
def fixture_penn_chime_raw_df_no_policy(penn_chime_setup) -> DataFrame:
    """Runs penn_chime SIR model for no social policies
    """
    p, simsir = penn_chime_setup

    n_days = simsir.raw_df.day.max() - simsir.raw_df.day.min()
    policies = [(simsir.beta, n_days)]
    raw = sim_sir(
        simsir.susceptible,
        simsir.infected,
        p.recovered,
        simsir.gamma,
        -simsir.i_day,
        policies,
    )
    calculate_dispositions(raw, simsir.rates, market_share=p.market_share)
    calculate_admits(raw, simsir.rates)
    calculate_census(raw, simsir.days)

    raw_df = DataFrame(raw)
    raw_df.index = simsir.raw_df.date

    return raw_df.fillna(0)