예제 #1
0
def runSimulation(outputPrefix, fraction, workplace, iteration, rng_seed,
                  days):
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config", "workplace.xml"))
    # Set some parameters

    outputPrefix = os.path.join(
        outputPrefix, workplace + str(fraction) + "_" + str(iteration))

    control.runConfig.setParameter("seeding_rate", fraction)
    control.runConfig.setParameter("disease_config_file",
                                   "disease_influenza.xml")
    control.runConfig.setParameter("output_prefix", outputPrefix)
    control.runConfig.setParameter("rng_seed", rng_seed)

    control.runConfig.setParameter("num_days", str(days))
    control.runConfig.setParameter("geopop_gen.population_size", "600000")
    control.runConfig.setParameter("geopop_gen.workplace_distribution_file",
                                   "data/" + workplace)

    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
예제 #2
0
def runSimulation(outputPrefix, v, iteration, rng_seed):
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config", "run_import_default.xml"))
    # Set some parameters

    if v:
        outputPrefix = os.path.join(outputPrefix,
                                    vaccinatedFolder + "_" + str(iteration))
    else:
        outputPrefix = os.path.join(outputPrefix,
                                    notVaccinatedFolder + "_" + str(iteration))

    control.runConfig.setParameter("immunity_profile", "AgeDependent")
    control.runConfig.setParameter("immunity_distribution_file",
                                   "data/lower_student_immunity.xml")
    control.runConfig.setParameter("immunity_link_probability", 0)
    control.runConfig.setParameter("population_file",
                                   "data/2_2_gengeopop.proto")
    control.runConfig.setParameter("geopopulation_file",
                                   "data/2_2_gengeopop.proto")
    control.runConfig.setParameter("output_prefix", outputPrefix)
    control.runConfig.setParameter("rng_seed", rng_seed)

    print("config done")
    if v:
        control.registerCallback(vaccinate, EventType.Stepped)
    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
예제 #3
0
def runSimulation(outputPrefix, fraction, iteration, rng_seed):
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config", "run_generate_default.xml"))
    # Set some parameters

    outputPrefix = os.path.join(outputPrefix,
                                str(fraction) + "_" + str(iteration))

    control.runConfig.setParameter("geopop_gen.population_size", 10000)
    control.runConfig.setParameter("geopop_gen.participation_college", 0.0)
    control.runConfig.setParameter("geopop_gen.particpation_workplace", 1.0)
    control.runConfig.setParameter("geopop_gen.fraction_college_commuters",
                                   0.0)
    control.runConfig.setParameter("geopop_gen.fraction_workplace_commuters",
                                   fraction)

    control.runConfig.setParameter("output_prefix", outputPrefix)
    control.runConfig.setParameter("rng_seed", rng_seed)

    print("config done")
    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
def runSimulation(outputPrefix, daycare_fraction, preschool_fraction,
                  workplace, iteration, rng_seed, days):
    print(
        f"DC: {daycare_fraction} / PS: {preschool_fraction} - Iteration {iteration}"
    )
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config", "daycare-preschool.xml"))
    # Set some parameters

    outputPrefix = os.path.join(
        outputPrefix,
        f"DC-{daycare_fraction}-PS-{preschool_fraction}_{iteration}")

    control.runConfig.setParameter("output_prefix", outputPrefix)
    control.runConfig.setParameter("rng_seed", rng_seed)

    control.runConfig.setParameter("num_days", str(days))
    control.runConfig.setParameter("geopop_gen.population_size", "600000")
    control.runConfig.setParameter("geopop_gen.participation_preschool",
                                   preschool_fraction)
    control.runConfig.setParameter("geopop_gen.participation_daycare",
                                   daycare_fraction)

    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
    print("Simulation done")
예제 #5
0
def runSimulation_no_vaccination(seed, filename):
    # Configure simulation
    control = PyController(data_dir="data")
    # Load Configuration file:
    control.loadRunConfig(os.path.join("config", xmlFile))
    control.runConfig.setParameter("rng_seed", seed)
    # Register callbacks
    #control.registerCallback(trackCases, [EventType.Stepped,filename])
    # Let controller run the simulation
    control.control()
    return (seed,
            control.runner.getSimulator().GetPopulation().GetInfectedCount())
예제 #6
0
def runSimulation(immunity, outputPrefix):
    # Configure simulation
    controller = PyController(data_dir="data")
    controller.loadRunConfig(
        os.path.join("config", "outbreak_2019_estimates.xml"))
    controller.runConfig.setParameter("output_prefix",
                                      outputPrefix + "_" + str(immunity))
    controller.runConfig.setParameter("immunity_profile", "Random")
    controller.runConfig.setParameter("immunity_rate", immunity)
    controller.runConfig.setParameter("vaccine_profile", "None")
    controller.registerCallback(count, EventType.Stepped)
    controller.control()
예제 #7
0
def runSimulation(outputPrefix):
    for run in range(0, runs):
        print("run number {0} of {1}".format(run+1, runs))
        controller = PyController(data_dir="data")
        controller.loadRunConfig(os.path.join("config", config))
        controller.runConfig.setParameter("num_days", sim_days)
        controller.runConfig.setParameter("output_prefix", outputPrefix + "_" + config.split(".")[0])
        seed = ""
        for _ in range(4):
            seed += str(random.randint(1, 999999)) + ","
        seed = seed[:-1]
        controller.runConfig.setParameter("rng_seed", seed) 
        controller.registerCallback(trackCases, EventType.Stepped)
        controller.control()
예제 #8
0
def runSimulation(outputPrefix, vaccinationLevel):
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config", "run_default.xml"))
    # Set some parameters
    control.runConfig.setParameter("vaccine_rate", vaccinationLevel / 100)
    control.runConfig.setParameter("output_cases", "false")
    control.runConfig.setParameter("contact_output_file", "false")
    control.runConfig.setParameter("output_prefix", outputPrefix + "_" + str(vaccinationLevel))
    control.runConfig.setParameter("seeding_rate", 0.00000334) # Seed 2 infected persons in population of 600 000
    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
예제 #9
0
def runSimulation(year, R0, seed):
    configFile = os.path.join("config", "ageImmunityShift.xml")
    control = PyController(data_dir="data")
    control.loadRunConfig(configFile)
    control.runConfig.setParameter(
        "output_prefix",
        str(year) + "_R0_" + str(R0) + "_" + str(seed))
    control.runConfig.setParameter("rng_seed", seed)
    control.runConfig.setParameter("r0", R0)
    control.runConfig.setParameter("immunity_profile", "Random")
    control.runConfig.setParameter("immunity_rate", IMMUNITY_RATES[year])
    control.registerCallback(registerSusceptibles, EventType.AtStart)
    control.registerCallback(trackCases, EventType.Stepped)
    control.control()
    return
예제 #10
0
def runSimulation(immunity_rate):
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    control.loadRunConfig(os.path.join("config",
                                       "outbreak_2019_estimates.xml"))
    # Set some parameters
    control.runConfig.setParameter("output_prefix",
                                   outputDirectory(immunity_rate))
    control.runConfig.setParameter("immunity_profile", "Random")
    control.runConfig.setParameter("immunity_rate", immunity_rate / 100)
    control.runConfig.setParameter("rng_seed", random.randint(0, 100000000))
    control.runConfig.setParameter("vaccine_profile", None)
    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
예제 #11
0
def runSimulation(output_prefix, immunity_level, rng_seed, iteration=1):
    """Run the simulator, for one immunity level."""
    # Set up simulator
    control = PyController(data_dir="data")
    # Load configuration from file
    cfile = os.path.join("config", "outbreak_2019_estimates.xml")
    control.loadRunConfig(cfile)
    # Set some parameters
    control.runConfig.setParameter("immunity_profile", "Random")
    control.runConfig.setParameter("immunity_rate", immunity_level / 100)
    control.runConfig.setParameter("rng_seed", rng_seed)
    control.runConfig.setParameter("vaccine_profile", "None")
    outputmap = "{}_{}_{}".format(output_prefix, immunity_level, iteration)
    control.runConfig.setParameter("output_prefix", outputmap)
    control.registerCallback(trackCases, EventType.Stepped)
    # Run simulation
    control.control()
예제 #12
0
def runSimulation(comuter_fraction, outputPrefix):
    tree = ET.parse(os.path.join("config", 'run_generate_default.xml'))
    geopop = tree.getroot().find("geopop_gen")
    comuters = geopop.find("fraction_workplace_commuters")
    comuters.text = str(comuter_fraction)
    tree.write(os.path.join("config", "run_generate_default_temp.xml"))

    # Configure simulation
    controller = PyController(data_dir="data")
    controller.loadRunConfig(
        os.path.join("config", "run_generate_default_temp.xml"))
    controller.runConfig.setParameter("num_days", "400")
    controller.runConfig.setParameter(
        "output_prefix", outputPrefix + "_" + str(comuter_fraction))
    controller.runConfig.setParameter("seeding_rate", 0.00000334)
    controller.registerCallback(trackCases, EventType.Stepped)
    controller.control()
예제 #13
0
def runSimulation(level, outputPrefix):
    tree = ET.parse(os.path.join("config", config))
    geopop = tree.getroot().find("geopop_gen")
    comuters = geopop.find(param)
    comuters.text = str(level)
    tree.write(os.path.join("config", config))

    for run in range(0, runs):
        print("run number {0} of {1}".format(run + 1, runs))
        controller = PyController(data_dir="data")
        controller.loadRunConfig(os.path.join("config", config))
        controller.runConfig.setParameter("num_days", sim_days)
        controller.runConfig.setParameter("output_prefix",
                                          outputPrefix + "_" + str(level))
        controller.runConfig.setParameter("seeding_rate", 0.00000334)
        seed = ""
        for _ in range(4):
            seed += str(random.randint(1, 999999999)) + ","
        seed = seed[:-1]
        controller.runConfig.setParameter("rng_seed", seed)
        controller.registerCallback(trackCases, EventType.Stepped)
        controller.control()
예제 #14
0
def runSimulation(year, R0, numDays, seed, trackIndexCase):
    configFile = os.path.join("config", "ageImmunityShift.xml")
    control = PyController(data_dir="data")
    control.loadRunConfig(configFile)
    control.runConfig.setParameter(
        "output_prefix",
        str(year) + "_R0_" + str(R0) + "_" + str(seed))
    control.runConfig.setParameter("rng_seed", seed)
    control.runConfig.setParameter("r0", R0)
    control.runConfig.setParameter("num_days", numDays)
    control.runConfig.setParameter("immunity_link_probability", 0)
    control.runConfig.setParameter("immunity_profile", "AgeDependent")
    control.runConfig.setParameter(
        "immunity_distribution_file",
        os.path.join("data",
                     str(year) + "_measles_immunity.xml"))
    if trackIndexCase:
        control.runConfig.setParameter("track_index_case", "true")
    control.registerCallback(registerSusceptibles, EventType.AtStart)
    control.registerCallback(trackCases, EventType.Stepped)
    control.registerCallback(registerAgesInfected, EventType.AtFinished)
    control.control()
    return