示例#1
0
def test_household_isolation_intervention_simulation(hi_exit):
    """
    Tests that when asymptomatic and presymptomatic people are not infectious and household isolation occur with no delay,
    all the poeple that are infected are infected at home (of at the beginning), due to the household isolation
    :param hi_exit: params that make sure there are no delay or too short of isolation
    :return: None (since this is a test), but it is asserted that all infections occur within the household
    """
    scenario_name = "test_HI"
    params_to_change = {
        ("disease_parameters", "infectiousness_per_stage", "incubating_post_latent"):
        0.0,
        ("disease_parameters", "infectiousness_per_stage", "asymptomatic"):
        0.0
    }
    delay_on_exit, is_exit_after_recovery = hi_exit
    job = SimpleJob(scenario_name,
                    city_name='kefar yona',
                    interventions=[
                        HouseholdIsolationIntervention(
                            compliance=1,
                            start_date=INITIAL_DATE,
                            duration=timedelta(250),
                            delay_on_enter=0,
                            delay_on_exit=delay_on_exit,
                            is_exit_after_recovery=is_exit_after_recovery)
                    ],
                    scale=1.0,
                    params_to_change=params_to_change,
                    infection_params=SmartInitialInfectionParams(100, 50))
    outdir = run([job], multi_processed=False, with_population_caching=False)
    results = Statistics.load(
        os.path.join(outdir, scenario_name, 'statistics.pkl'))
    summary = results.get_summary_data_for_age_group((0, 99))
    assert summary["Total infected in household"] + summary[
        "Total infected in initial_group"] == summary["Total infected"]
示例#2
0
    def __init__(self,
                 scenario_name,
                 city_name,
                 scale,
                 infection_params=SmartInitialInfectionParams(100, 50),
                 days=250,
                 city_name_to_infect=None,
                 initial_date=INITIAL_DATE,
                 params_to_change=None,
                 datas_to_plot=None,
                 interventions=None):
        """
        Initialize a simple job, that runs one simulation task
        :param scenario_name: str name to use for the directories and filenames of the outputs
        :param city_name: str city name, can be 'all' for entire country simulation
        :param scale: float between 0-1, represents the size scale of the city
        :param days: length of the simulation in days
        :param interventions: list of Intervention objects to apply during the simulation
        :param infection_params: states how the initial infection will happen, see InitialInfectionParams doc
        :param city_name_to_infect: str name of the city that will be infected first, before the simulation
        :param initial_date: datetime.date start date of the run
        :param params_to_change: dict of the temporary changes to make to Param object
        :param datas_to_plot: states what data from the simulation will be counted and saved to output plots,
        see DataToPlot doc. Has a default behavior if the param is omitted.
        """

        super(SimpleJob,
              self).__init__(scenario_name, city_name, scale, days,
                             initial_date, params_to_change, interventions)
        self.infection_params = infection_params
        self.city_name_to_infect = city_name_to_infect
        self.datas_to_plot = datas_to_plot
        if self.datas_to_plot is None:
            self.datas_to_plot = {
                "persons":
                make_age_and_state_datas_to_plot(),
                "infector_age":
                make_infections_age_datas_to_plot(),
                "infector_state":
                make_infections_infector_state_datas_to_plot(),
                "infection_environment":
                make_infections_environment_datas_to_plot()
            }
示例#3
0
def test_school_closure_intervention_simulation():
    """
    Test that when school isolation is on, no one is infected at school.
    :return: True is there are 0 infections at school
    """
    scenario_name = "test_PC"
    job = SimpleJob(scenario_name,
                    city_name='kefar yona',
                    interventions=[
                        SchoolClosureIntervention(start_date=INITIAL_DATE,
                                                  duration=timedelta(250),
                                                  compliance=1.0,
                                                  proportion_of_envs=1.0,
                                                  city_name='kefar yona',
                                                  age_segment=(0, 9))
                    ],
                    scale=1.0,
                    infection_params=SmartInitialInfectionParams(100, 50))
    outdir = run([job], multi_processed=False, with_population_caching=False)
    results = Statistics.load(
        os.path.join(outdir, scenario_name, 'statistics.pkl'))
    summary = results.get_summary_data_for_age_group((0, 9))
    assert summary["Total infected in school"] == 0
示例#4
0
def test_school_isolation_intervention_simulation():
    """
    Test that when school isolation is on, all the relevant people are infected only at shool
    """
    scenario_name = "test_PI"
    job = SimpleJob(scenario_name,
                    city_name='kefar yona',
                    interventions=[
                        SchoolIsolationIntervention(start_date=INITIAL_DATE,
                                                    duration=timedelta(250),
                                                    compliance=1.0,
                                                    proportion_of_envs=1.0,
                                                    city_name='kefar yona',
                                                    age_segment=(4, 12))
                    ],
                    scale=1.0,
                    infection_params=SmartInitialInfectionParams(100, 50))
    outdir = run([job], multi_processed=False, with_population_caching=False)
    results = Statistics.load(
        os.path.join(outdir, scenario_name, 'statistics.pkl'))
    summary = results.get_summary_data_for_age_group((4, 12))
    assert summary["Total infected in school"] + summary[
        "Total infected in initial_group"] == summary["Total infected"]