templates.set_dynamic_header_table(header, table)

# Let's use a standard DTKConfigBuilder.
config_builder = DTKConfigBuilder()
# ignore_missing is required when using templates
config_builder.ignore_missing = True

# Use the default COMPS 2.10 and the SamplesInput folder for input files
# See examples\AssetManagement\use_custom_executable.py for more information
config_builder.set_exe_collection('EMOD 2.10')

# For the experiment builder in the example, we use a ModBuilder from_combos to run
# each of the configurations for two separate run numbers.
# The first line needs to be the modifier functions coming from the templates
experiment_builder = ModBuilder.from_combos(
    templates.get_modifier_functions(),  # <-- Do this first!
    [
        ModFn(DTKConfigBuilder.set_param, 'Run_Number', rn)
        for rn in range(2, 4)
    ])

# This dictionary is used by the `dtk run` command line and allow to pass it some parameters
# If you are running through `python example_templates.py`, this dictionary is unused
run_sim_args = {
    'exp_builder': experiment_builder,
    'exp_name': 'TemplateDemo',
    'config_builder': config_builder
}

# This part is needed if you are running the script through `python example_templates.py`
# It is not used by the command line interface
Ejemplo n.º 2
0
            # Construct the table
            table = [list(c.values()) for c in combined]

            # Change some things in the config.json
            config.set_param('Config_Name', scenario_name)

            # Initialize the template
            tpl = TemplateHelper()
            tpl.set_dynamic_header_table(headers, table)
            tpl.active_templates = [
                config, campaign_tpl, demog, demog_pfa, demog_asrt, demog_acc
            ]

            # Create an experiment builder
            experiment_builder = ModBuilder.from_combos(
                tpl.get_modifier_functions())
            experiment_manager = ExperimentManagerFactory.from_cb(
                config_builder)
            COMPS_experiment_name = scenario_name
            # COMPS_experiment_name = suite_name # I want hover-over in COMPS to be the suite name

            experiment_manager.run_simulations(exp_name=COMPS_experiment_name,
                                               exp_builder=experiment_builder,
                                               suite_id=suite_id)
            experiments.append(experiment_manager)
            experiments_ids.append(experiment_manager.experiment.exp_id)

        # Dump the experiment ids for resume
        with open('ids.json', 'w') as out:
            json.dump(experiments_ids, out)