idmtools_calibra.calib_manager module¶
- idmtools_calibra.calib_manager.set_parameter_sweep_callback(simulation: Simulation, param: str, value: Any) Dict[str, Any] ¶
Convenience callback for sweeps
- Parameters
simulation – Simulation we are updating
param – Parameter
value – Value
- Returns
Tags to set on simulation
- class idmtools_calibra.calib_manager.SampleIndexWrapper(map_sample_to_model_input_fn)¶
Bases:
object
Wrapper for a SimConfigBuilder-modifying function to add metadata on sample-point index when called in a iteration over sample points
- class idmtools_calibra.calib_manager.CalibManager(task: ITask, map_sample_to_model_input_fn, sites: List[CalibSite], next_point: NextPointAlgorithm, platform: Optional[IPlatform] = None, name: str = 'calib_test', sim_runs_per_param_set: int = 1, max_iterations: int = 5, plotters: Optional[List[BasePlotter]] = None, map_replicates_callback=None, directory='.')¶
Bases:
object
Manages the creation, execution, and resumption of multi-iteration a calibration suite. Each iteration spawns a new ExperimentManager to configure and commission either local or HPC simulations for a set of random seeds, sample points, and site configurations.
- classmethod open_for_reading(calibration_directory)¶
- property suite_id¶
- property iteration¶
- run_calibration(**kwargs)¶
Create and run a complete multi-iteration calibration suite. kwargs supports the following optional parameters: :param resume: bool, default=False, flag required for calibration resume :param iteration: int, default=None, from which iteration to resume :param iter_step: str, default=None, from which calibration step to resume. support values: ‘commission’, ‘analyze’, plot’ and ‘next_point’ :param loop: bool, default=True, if like to continue to next iteration :param max_iterations, int, default=None, user can override the max_iterations defined in calib_manager: :param backup: bool, default=False, if like to backup Calibration.json :param dry_run: bool, default=False, if like to really execute resume action :param directory: str, default=None, calibration directory
Returns: None
- run_iterations(iteration: int = 0, max_iterations: Optional[int] = None, loop: bool = True)¶
Run iterations in a loop :param iteration: the # of iterations :param max_iterations: max iterations :param loop: if or not continue iteration loop
Returns: None
- post_iteration()¶
- set_experiment_builder_function(exp_builder_function)¶
Set the experiment builder to a predefined one, such that exp_builder_func will return it :param exp_builder_function: an experiment builder object
Returns: None
- set_map_replicates_callback(map_replicates_callback)¶
This sets the maps replicate callback. This callback should take a value parameter that is the value of the replicate.
Normally you would want to map this to a value in the config :param map_replicates_callback:
Returns:
- default_experiment_builder_function(next_params, n_replicates: Optional[int] = None) SimulationBuilder ¶
Defines the function that builds the experiment for each iteration of a calibration run
- Parameters
next_params – The next parameters to run
n_replicates – Number of replicates
- Returns
Simulation Builder
- create_iteration_state(iteration)¶
Create iteration state :param iteration: the # of the iteration
Returns: created IterationState
- create_calibration()¶
Create the working directory for a new calibration. Cache the relevant suite-level information to allow re-initializing this instance.
- finalize_calibration()¶
Get the final samples from the next point algorithm.
- cache_calibration(**kwargs)¶
Cache information about the CalibManager that is needed to resume after an interruption. N.B. This is not currently the complete state, some of which relies on nested and frozen functions. As such, the ‘resume’ logic relies on the existence of the original configuration script. :param **kwargs: extra info
Returns: None
- backup_calibration()¶
Backup CalibManager.json for resume action
- serialize_results()¶
- resume_calibration(**kwargs)¶
- delete()¶
- cleanup()¶
Cleanup the current calibration - Delete the result directory - If LOCAL -> also delete the simulations
- read_calib_data(force=False)¶
- property calibration_path¶
- property analyzer_list¶
- property required_components¶
- iteration_directory()¶
- state_for_iteration(iteration)¶
- param_names()¶
- site_analyzer_names()¶
- get_last_iteration()¶
Determines the last (most recent) completed iteration number. Returns: the last completed iteration number as an int
- get_parameter_sets_with_likelihoods()¶
Returns: a list of ParameterSet objects.