idmtools_calibra.calib_manager module#

idmtools_calibra.calib_manager.set_parameter_sweep_callback(simulation: Simulation, param: str, value: Any) Dict[str, Any][source]#

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)[source]#

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: IPlatform | None = None, name: str = 'calib_test', sim_runs_per_param_set: int = 1, max_iterations: int = 5, plotters: List[BasePlotter] | None = None, map_replicates_callback=None, directory='.')[source]#

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)[source]#
property suite_id#
property iteration#
run_calibration(**kwargs)[source]#

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: int | None = None, loop: bool = True)[source]#

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()[source]#
set_experiment_builder_function(exp_builder_function)[source]#

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)[source]#

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: int | None = None) SimulationBuilder[source]#

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)[source]#

Create iteration state :param iteration: the # of the iteration

Returns: created IterationState

create_calibration()[source]#

Create the working directory for a new calibration. Cache the relevant suite-level information to allow re-initializing this instance.

finalize_calibration()[source]#

Get the final samples from the next point algorithm.

cache_calibration(**kwargs)[source]#

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()[source]#

Backup CalibManager.json for resume action

serialize_results()[source]#
resume_calibration(**kwargs)[source]#
delete()[source]#
cleanup()[source]#

Cleanup the current calibration - Delete the result directory - If LOCAL -> also delete the simulations

read_calib_data(force=False)[source]#
property calibration_path#
property analyzer_list#
property required_components#
iteration_directory()[source]#
state_for_iteration(iteration)[source]#
param_names()[source]#
site_analyzer_names()[source]#
get_last_iteration()[source]#

Determines the last (most recent) completed iteration number. Returns: the last completed iteration number as an int

get_parameter_sets_with_likelihoods()[source]#

Returns: a list of ParameterSet objects.