header = [
    'ACTIVE_TEMPLATES', 'Start_Year__KP_Seeding_Year',
    'Condom_Usage_Probability__KP_INFORMAL.Max', 'Base_Infectivity', 'TAGS'
]
table = [[[cfg, cpn, demog_pfa], 1985, 0.95, 1.5e-3, {
    'Testing1a': None,
    'Testing1b': 'Works'
}], [[cfg, cpn_outbreak, demog_pfa], 1980, 0.50, 1.0e-3, {
    'Testing2': None
}]]

# Initialize the template system
# ==============================
# Create an instance of the TemplateHelper helper class and, if desired, give it templates to work with.
# In this example, there's no need to set the campaign_template because it will be set dynamically from the table above.
templates = TemplateHelper()

# Give the header and table to the template helper
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.
示例#2
0
demog_pfa = DemographicsTemplate.from_file(
    os.path.join(template_files_dir, 'PFA_Overlay.json'))
demog_acc = DemographicsTemplate.from_file(
    os.path.join(template_files_dir, 'Accessibility_and_Risk_IP_Overlay.json'))
demog_asrt = DemographicsTemplate.from_file(
    os.path.join(template_files_dir, 'Risk_Assortivity_Overlay.json'))
cfg = ConfigTemplate.from_file(os.path.join(template_files_dir, 'config.json'))
cpn = make_campaign_template(template_files_dir)

# For quick test simulations, this is set to a very low value
static_params = {'Base_Population_Scale_Factor': 0.05}
cfg.set_params(static_params)
cpn.set_params(static_params)

# Prepare templates
templates = TemplateHelper()
table_base = {
    'ACTIVE_TEMPLATES': [cfg, cpn, demog_pfa, demog_acc, demog_asrt],
    'TAGS': {
        'Scenario': 'StatusQuo_Baseline',
        'pyOptimTool': None
    }
}

config_builder = DTKConfigBuilder()
config_builder.ignore_missing = True


def constrain_sample(sample):
    if 'Pr Ex Trns Male LOW' and 'Pr Ex Trns Male MED' in sample:
        sample['Pr Ex Trns Male LOW'] = min(
示例#3
0
            # Extract the headers
            headers = [
                k.replace('CONFIG.', '').replace('DEMOGRAPHICS.',
                                                 '').replace('CAMPAIGN.', '')
                for k in combined[0].keys()
            ]

            # 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,