예제 #1
0
    for name, value in sample.items():
        print("UNUSED PARAMETER: {}".format(name))
    assert (len(sample) == 0)  # All params used

    # Run for 10 years with a random random number seed
    tags.update(cb.set_param('Simulation_Duration', 3650+1))  # 10*365
    tags.update(cb.set_param('Run_Number', random.randint(0, 1e6)))

    return tags


optimtool = OptimToolPSPO(params=params,
                          constrain_sample_fn=constrain_sample,  # <-- WILL NOT BE SAVED IN ITERATION STATE
                          comps_per_iteration=4  # <-- computations per iteration, includes center repeats.
                          )
calib_manager = CalibManager(name='ExampleOptimizationSPSA',  # <-- Please customize this name
                             config_builder=cb,
                             map_sample_to_model_input_fn=map_sample_to_model_input,
                             sites=sites,
                             next_point=optimtool,
                             sim_runs_per_param_set=1,  # <-- Replicates
                             max_iterations=3,  # <-- Iterations
                             plotters=plotters)

run_calib_args = {'calib_manager': calib_manager}

if __name__ == "__main__":
    SetupParser.init()
    calib_manager.run_calibration()
예제 #2
0
optimtool = OptimTool(
    params,
    lambda p: p,
    mu_r=
    r,  # <-- radius for numerical derivatve.  CAREFUL not to go too small with integer parameters
    sigma_r=r / 10.,  # <-- stdev of radius
    center_repeats=
    1,  # <-- Number of times to replicate the center (current guess).  Nice to compare intrinsic to extrinsic noise
    samples_per_iteration=
    100  # <-- Samples per iteration, includes center repeats.  Actual number of sims run is this number times number of sites.
)

calib_name = "CHIKV_Calib_Habitat_Decay_Imports_SingleNode_%s" % site_name
calib_manager = CalibManager(name=calib_name,
                             config_builder=cb,
                             map_sample_to_model_input_fn=sample_point_fn,
                             sites=sites,
                             next_point=optimtool,
                             sim_runs_per_param_set=4,
                             max_iterations=10,
                             plotters=plotters)

#run_calib_args = {'selected_block': "LOCAL"}
run_calib_args = {}

if __name__ == "__main__":
    SetupParser.init(selected_block=SetupParser.default_block)
    #run_calib_args.update(dict(location='HPC'))
    #calib_manager.cleanup()
    calib_manager.run_calibration()  #(**run_calib_args)