ModFn(
                    DTKConfigBuilder.update_params, {
                        "Run_Number": run_num,
                        "x_Temporary_Larval_Habitat": 10**hab_exp
                    }),
            ] for run_num in range(10)
             for hab_exp in np.concatenate((np.arange(-3.75, -2, 0.25),
                                            np.arange(-2, 2.25, 0.1)))])

    run_sim_args = {
        "config_builder": cb,
        "exp_name": sweep_name,
        "exp_builder": builder
    }

    em = ExperimentManagerFactory.from_cb(cb)
    em.run_simulations(**run_sim_args)

    em.wait_for_finished(verbose=True)
    assert (em.succeeded())

    analyzer = PfPRAnalyzer(expt_name=sweep_name,
                            report_names=sites["name"].tolist(),
                            sweep_variables=[
                                "Run_Number", "x_Temporary_Larval_Habitat",
                                "intervention", "intervention_coverage"
                            ])

    am = AnalyzeManager(em.experiment, analyzers=analyzer)
    am.analyze()
    add_all_reports(cb, catch, start=0 * 365)

    arab_burnin = 9.388
    funest_burnin = 10.2778
    set_ento(cb, arab_burnin, funest_burnin, arab_times, arab_spline,
             funest_times, funest_spline)

    SetupParser.init()
    SetupParser.set("HPC", "priority", priority)
    SetupParser.set("HPC", "node_group", coreset)

    modlists = []

    new_modlist = [
        ModFn(DTKConfigBuilder.set_param, 'Run_Number', seed)
        for seed in range(num_seeds)
    ]
    modlists.append(new_modlist)

    new_modlist = [
        ModFn(DTKConfigBuilder.set_param, 'x_Regional_Migration', x)
        for x in [0.1, 0.01, 0.001, 0.0001, 0]
    ]
    modlists.append(new_modlist)

    builder = ModBuilder.from_combos(*modlists)

    exp_manager = ExperimentManagerFactory.init()
    exp_manager.run_simulations(config_builder=cb,
                                exp_name=experiment_name,
                                exp_builder=builder)
Example #3
0
from simtools.ModBuilder import SingleSimulationBuilder
from dtk.generic import serialization
from os import path

# This block will be used unless overridden on the command-line
SetupParser.default_block = 'EXAMPLE'

cb_serializing = DTKConfigBuilder.from_defaults('VECTOR_SIM')
configure_site(cb_serializing, 'Namawala')

cb_reloading = DTKConfigBuilder.from_defaults('VECTOR_SIM')
configure_site(cb_reloading, 'Namawala')

if __name__ == "__main__":
    SetupParser.init()
    exp_manager = ExperimentManagerFactory.from_setup()

    timesteps_to_serialize = [5, 10, 50]
    old_simulation_duration = cb_serializing.params["Simulation_Duration"]
    serialized_last_timestep = timesteps_to_serialize[-1]
    serialization.add_SerializationTimesteps(config_builder=cb_serializing,
                                             timesteps=timesteps_to_serialize,
                                             end_at_final=True)

    serialized_builder = SingleSimulationBuilder()
    exp_manager.run_simulations(config_builder=cb_serializing,
                                exp_builder=serialized_builder,
                                exp_name="Sample serialization test")
    exp_manager.wait_for_finished()

    serialized_sim = exp_manager.experiment.simulations[0]
Example #4
0
    ]  # Ids of the created experiments for resuming capabilities

    # Check if we want to resume
    if os.path.exists('ids.json'):
        print("Previous run detected... Run [N]ew, [R]esume, [A]bort?")
        resp = ""
        while resp not in ('N', 'R', 'A'):
            resp = input()
        if resp == "A":
            exit()
        elif resp == "R":
            # In the resume case, retrieve the ids and create the managers
            experiments_ids = json.load(open('ids.json', 'r'))
            for id in experiments_ids:
                experiments.append(
                    ExperimentManagerFactory.from_experiment(str(id)))
        elif resp == "N":
            # Delete shelve file
            if os.path.exists('DownloadAnalyzerTPI.shelf'):
                os.remove('DownloadAnalyzerTPI.shelf')
            # Delete the ids
            os.remove('ids.json')

    # If experiment_ids is empty -> we need to commission
    if not experiments_ids:
        # Create a suite to hold all the experiments
        suite_id = create_suite(suite_name)

        # Create the scenarios
        for scenario in scenarios_dict:
            scenario_name = scenario['Scenario']
Example #5
0
# This block will be used unless overridden on the command-line
SetupParser.default_block = 'HPC'

cb = DTKConfigBuilder.from_defaults('VECTOR_SIM')
configure_site(cb, 'Namawala')
cb.set_param('Simulation_Duration',365)


analyzers = (TimeseriesAnalyzer(),
             VectorSpeciesAnalyzer())


builder = GenericSweepBuilder.from_dict({'Run_Number': range(5)})

run_sim_args =  {
    'exp_name': 'testrunandanalyze',
    'exp_builder': builder,
    'config_builder':cb
}

if __name__ == "__main__":
    SetupParser.init(selected_block=SetupParser.default_block)
    exp_manager = ExperimentManagerFactory.from_cb(config_builder=cb)
    exp_manager.run_simulations(**run_sim_args)
    exp_manager.wait_for_finished(verbose=True)

    am = AnalyzeManager(exp_manager.experiment)
    for a in analyzers:
        am.add_analyzer(a)
    am.analyze()
from simtools.AnalyzeManager.AnalyzeManager import AnalyzeManager
from simtools.ExperimentManager.ExperimentManagerFactory import ExperimentManagerFactory
from simtools.SetupParser import SetupParser

SetupParser.default_block = 'HPC'

cb = DTKConfigBuilder.from_defaults('VECTOR_SIM')
state_file = 'cleared-state-25550.dtk'
temp_path = 'tempdl'
source_simulation = '6ce475d8-15aa-e711-9414-f0921c16b9e5'

if __name__ == "__main__":
    # Download the state file
    da = DownloadAnalyzer(filenames=["output\\{}".format(state_file)],
                          output_path=temp_path)
    am = AnalyzeManager(sim_list=[source_simulation], analyzers=[da])
    am.analyze()

    # Add the state file
    cb.experiment_files.add_file(
        os.path.join(temp_path, source_simulation, state_file))
    load_Serialized_Population(cb, 'Assets', [state_file])

    # Run !
    SetupParser.init()
    exp_manager = ExperimentManagerFactory.from_cb(cb)
    exp_manager.run_simulations(exp_name='test serialization')

    # Cleanup temp directory
    shutil.rmtree(temp_path)
Example #7
0
    def run_test(self):
        SetupParser.init()
        self.exp_manager = ExperimentManagerFactory.init()
        exp_manager = self.exp_manager

        for tag in self.exp_tags:
            exp_manager.experiment_tags[tag] = self.exp_tags[tag]

        cfg_builder = self.cb
        cfg_builder.set_param("Config_Name", "Full run sim")
        fullrun_builder = SingleSimulationBuilder()
        fullrun_builder.tags['role'] = 'fullrun'
        exp_manager.run_simulations(config_builder=cfg_builder,
                                    exp_builder=fullrun_builder,
                                    exp_name=self.exp_name)

        old_sim_duration = cfg_builder.params["Simulation_Duration"]
        for ts in self.timesteps_to_serialize:
            ts_string = str(ts)
            serialization.add_SerializationTimesteps(
                config_builder=cfg_builder, timesteps=[ts], end_at_final=True)
            cfg_builder.set_param("Config_Name",
                                  "Serializing sim at {0}".format(ts_string))
            serialized_builder = SingleSimulationBuilder()
            serialized_builder.tags['role'] = 'serializer'
            serialized_builder.tags[self.s_timestep_tagname] = ts_string
            exp_manager.run_simulations(config_builder=cfg_builder,
                                        exp_builder=serialized_builder,
                                        exp_name=self.exp_name)

        exp_manager.wait_for_finished()

        self.baseline_sim = exp_manager.experiment.get_simulations_with_tag(
            'role', 'fullrun')[0]
        cfg_builder.params.pop("Serialization_Time_Steps")

        for ts in self.timesteps_to_serialize:
            ts_string = str(ts)
            serialized_sim = exp_manager.experiment.get_simulations_with_tag(
                self.s_timestep_tagname, ts_string)[0]
            serialized_output_path = path.join(serialized_sim.get_path(),
                                               'output')

            # build s_pop_filename
            prefix_len = 5 - len(ts_string)
            prefix = '0' * prefix_len
            s_pop_filename = 'state-{0}{1}.dtk'.format(prefix, ts_string)

            cfg_builder.set_param("Config_Name",
                                  "Reloading sim at {0}".format(ts_string))
            reloaded_builder = SingleSimulationBuilder()
            reloaded_builder.tags['role'] = 'reloader'
            reloaded_builder.tags[self.s_timestep_tagname] = ts_string
            cfg_builder.params["Start_Time"] = ts
            cfg_builder.params["Simulation_Duration"] = old_sim_duration - ts

            serialization.load_Serialized_Population(
                config_builder=cfg_builder,
                population_filenames=[s_pop_filename],
                population_path=serialized_output_path)
            exp_manager.run_simulations(config_builder=cfg_builder,
                                        exp_builder=reloaded_builder,
                                        exp_name=self.exp_name)
        exp_manager.wait_for_finished()
        self.create_combined_charts()
        if self.inset_channels:
            self.test_channels(self.inset_channels,
                               original_report_name='InsetChart.json')
Example #8
0
        active_experiments = DataStore.get_active_experiments()
        logger.debug('Waiting loop pass number %d, pid %d' % (count, os.getpid()))
        logger.debug('Active experiments')
        logger.debug(active_experiments)
        logger.debug('Managers')
        logger.debug(managers.keys())

        # Create all the managers
        for experiment in active_experiments:
            logger.debug("Looking for manager for experiment %s" % experiment.id)
            if experiment.id not in managers:
                logger.debug('Creating manager for experiment id: %s' % experiment.id)
                manager = None
                try:
                    sys.path.append(experiment.working_directory)
                    manager = ExperimentManagerFactory.from_experiment(experiment)
                except Exception as e:
                    logger.debug('Exception in creation manager for experiment %s' % experiment.id)
                    logger.debug(e)
                    logger.debug(traceback.format_exc())

                if manager:
                    if manager.location == "LOCAL": manager.local_queue = local_queue
                    managers[experiment.id] = manager

            else:
                # Refresh the experiment
                logger.debug("Found manager for experiment %s" % experiment.id)
                managers[experiment.id].experiment = experiment

        # Check every one of them
Example #9
0
cb = CMSConfigBuilder.from_files(model_file='inputs/models/simplemodel.emodl',
                                 config_file='inputs/models/simplemodel.cfg')

# If the base collection containing CMS exists, use it
# If not, use the local
if SetupParser.default_block == "HPC":
    try:
        cb.set_collection_id('CMS 0.82 Pre-release')
    except SimulationAssets.InvalidCollection:
        cb.set_experiment_executable('inputs/compartments/compartments.exe')
        cb.set_dll_root('inputs/compartments')
else:
    cb.set_experiment_executable('inputs/compartments/compartments.exe')
    cb.set_dll_root('inputs/compartments')

run_sim_args = {"config_builder": cb, "exp_name": "First CMS run"}

if __name__ == "__main__":
    SetupParser.init()
    em = ExperimentManagerFactory.from_cb(run_sim_args["config_builder"])
    em.run_simulations(exp_name=run_sim_args["exp_name"])

    # Wait for the simulation to complete
    em.wait_for_finished(verbose=True)

    # Analyze
    am = AnalyzeManager(exp_list='latest')
    am.add_analyzer(SimpleCMSAnalyzer())
    am.analyze()