scine_puffin.utilities.kinetic_modeling_sensitivity_analysis¶
Classes
|
Provides a Wrapper around SALib for sensitivity analysis of the RMS kinetic modeling output. |
- class scine_puffin.utilities.kinetic_modeling_sensitivity_analysis.RMSKineticModelingSensitivityAnalysis(rms_kinetic_model: RMSKineticModel, n_cores: int, sample_size: int, distribution_shape: str = 'unif')[source]¶
Provides a Wrapper around SALib for sensitivity analysis of the RMS kinetic modeling output.
SALib samples the parameters (activation energies and enthalpies) within the uncertainty around input value. The input parameters are sampled uniformly distribution of the parameters.
To ensure that we can use multiprocessing, we cannot work with any Julia objects in the main thread. Julia objects may only be constructed after starting the parallel loop.
- Parameters:
- rms_kinetic_modelRMSKineticModel
The microkinetic model.
- n_coresint
Number of cores to run the sensitivity analysis on. Note that if n > 1, RMS must not have been instantiated before in the python main process because Julia runs into trouble otherwise.
- sample_sizeint
Number of samples for Morris (5 - 25) or Sobol ( > 500) analysis.
- distribution_shapestr (default ‘unif’)
Shape of the parameter distribution to be assumed. Options are uniform distribution between error bounds (‘unif’) and truncated normal distributions (‘truncnorm’). The normal distributions is only truncated to ensure non-negative reaction barriers. The standard deviation for the normal distribution is taken as the standard deviation of the error bounds and the normal distribution’s mean is taken as the baseline parameter in the microkinetic model. Note that a non-uniform distribution may lead to rather strange parameter sampling if Morris sampling is used because it constructs discrete parameter levels within the distribution.
- TODO: The number of levels for the Morris sampling should be an input argument.
- analyse_runs() List[Tuple[ndarray, ndarray]] [source]¶
Calculate mean and variance of the outputs of the sensitivity analysis runs.
- Returns:
- List[Tuple[np.ndarray, np.ndarray]]
Returns a list of tuples (tuple[0] -> mean ; tuple[1] -> variance) of the different sensitivity analysis outputs (these can be aggregate-wise maximum concentrations, fluxes or just concentrations at specific time points).
- static evaluate_salib_parallel(problem, func, nprocs=None)[source]¶
Evaluate model locally in parallel. All detected processors will be used if nprocs is None.
This is a reduced version of SALib’s evaluate_parallel function. We need this reimplementation to better handle the parallelization itself. The size of the class and all parameters given the the individual threads must not become too large. Otherwise, we may be unable to pickle it.
- Parameters:
- problemProblemSpec
The SALib problem spec.
- funcfunction,
The evaluation function.
- nprocsint,
The number of processes.
- get_analysis()[source]¶
Getter for the SALib problem object that contains all raw outputs and results if the analysis was done.
- get_local_sensitivity_samples() Tuple[ndarray, List[int]] [source]¶
Getter for the local sensitivity samples (parameter combinations). Parameters are distorted by their error bounds one-at-a-time from the baseline.
- get_parameter_bounds() List[List[float]] [source]¶
Create the parameter bound list to represent a uniform parameter distribution around the baseline.
- get_parameter_mean_and_std_dev_bounds() List[List[float]] [source]¶
Convert the error bound list to a list of mean, standard deviation, and parameter range to represent a truncated normal distribution around the baseline.
- get_reduced_parameter_mapping()[source]¶
Getter for the mapping between full parameter list and prescreened parameter list.
- morris_sensitivities()[source]¶
Run Morris sensitivity analysis. The number of model evaluations is M = N(p + 1), where N is the number of samples for each parameter and p is the number of parameters (number of reactions + number of aggregates). The number of samples (N) is typically between 5 and 25.
- Returns:
- Returns the sensitivity measures for the maximum and final concentrations for each parameter as a dictionary.
- The measures are:
max_mu: Maximum value of the Morris sensitivity measure mu for the parameter and maximum/final concentrations. max_mu_star: Maximum value of the Morris sensitivity measure mu* for the parameter and maximum/final concentrations. max_sigma: Maximum value of the Morris sensitivity measure sigma for the parameter and maximum/final concentrations.
- one_at_a_time_differences(vertex_fluxes: ndarray, edge_fluxes: ndarray, vertex_threshold: float, edge_threshold: float, flux_replace: float, ref_max: ndarray, ref_final: ndarray)[source]¶
Run one-at-a-time local sensitivity analysis. The parameters are distorted from the base line one at a time by the error bounds provided for each parameter. The maximum change in max concentrations, final concentrations and concentration flux is provided as a result.
- Parameters:
- vertex_fluxesnp.ndarray
The vertex fluxes of the baseline model (the model with all parameters as their default).
- edge_fluxesnp.ndarray
The edge fluxes of the baseline model.
- vertex_thresholdfloat
Vertex fluxes over this values are considered high and reduced to flux_replace. This should remove absolutely large but unimportant changes of the fluxes.
- edge_thresholdfloat
Edge fluxes over this values are considered high and reduced to flux_replace. This should remove absolutely large but unimportant changes of the fluxes.
- flux_replacefloat
The flux replacement value.
- ref_maxnp.ndarray
The maximum concentrations of the baseline model.
- ref_finalnp.ndarray
The final concentrations of the baseline model.
- salib_wrapped_kinetic_modeling(params_set: ndarray)[source]¶
SALib run function for the model evaluation.
- Parameters:
- params_setnp.ndarray
An array containing a set of parameters for the run.
- set_analysis_times(sensitivity_times: List[float])[source]¶
Provide a set of time points which should be considered for the sensitivity analysis.
- set_prescreening_condition(vertex_flux: ndarray, edge_flux: ndarray, vertex_t: float, edge_t: float)[source]¶
Set a prescreeining condition to reduce the parameters sampled during sensitivity analysis. Note: At the moment this will only affect the one-at-a-time analysis.
- sobol_sensitivities()[source]¶
Run Sobol sensitivity analysis (with Saltelli samping). The number of model evaluations is M = N(p + 2), where N is the number of samples for each parameter and p is the number of parameters (number of reactions + number of aggregates). Sample size (N) should be 500 or larger (depending on the number of model parameters).