Base class¶
melissa.server.sensitivity_analysis.sensitivity_analysis_server¶
SensitivityAnalysisServer¶
Bases: BaseServer
SensitivityAnalysisServer class extends the BaseServer class and provides specialized
functionalities for sensitivity analysis. The primary tasks of this class include:
- Generating parameters and scripts using pick-freeze sampling.
- Calculating statistical moments with the
IterativeSensitivityMartinezmethod. - Overriding or redefining abstract methods.
Parameters¶
- config_dict (
Dict[str, Any]): A dictionary containing configuration settings for initializing the sensitivity analysis server.
Attributes¶
- sobol_op (
bool): Indicates if Sobol sensitivity analysis is enabled. - second_order (
bool): Flag to activate second order for parameter sampling during pick-freeze. - __mean (
bool): Flag for computing the mean as part of the statistical analysis. - __variance (
bool): Flag for computing the variance as part of the statistical analysis. - __skewness (
bool): Flag for computing the skewness as part of the statistical analysis. - __kurtosis (
bool): Flag for computing the kurtosis as part of the statistical analysis. - __seen_ranks (
Set[int]): Set of ranks corresponding to clients that have been processed. - __checkpoint_count (
int): Counter for the number of checkpoints performed. - __checkpoint_interval (
int): Interval at which checkpoints are taken, specified in the configuration. - __max_order (
int): The maximum statistical moment order to compute (For example, mean = 1, variance = 2, etc.). - __melissa_moments (
Dict[tuple, IterativeMoments]): Dictionary to store statistical moments for each field, rank, and time step. - __pick_freeze_matrix (
List[List[Union[int, float]]]): Matrix to freeze parameters for Sobol computations(used if Sobol analysis is enabled). - __melissa_sobol (
Dict[tuple, IterativeSensitivityMartinez]): Dictionary to store Sobol sensitivity indices for each field, rank, and time step, if enabled.
__unimplemented_stats(sa_config)
¶
No implementation available for the following yet.
start()
¶
The main entrypoint for the server events.
__get_cached_sobol_data(pdata)
¶
__gather_data(local_vect_sizes, d_buffer)
¶
Gathers data from all ranks to rank 0 using MPI's Gatherv function.
Parameters:¶
- local_vect_sizes (
NDArray[np.int32]): An array containing the size of the data vector per rank. - d_buffer (
NDArray[np.float64]): An array containing the local data to be gathered.
Returns:¶
NDArray[np.float64]: An array with the gathered data at rank 0.
__gather_and_write_moments(field, global_vect_size, local_vect_sizes, stat_type, values_fn)
¶
Gathers data from all ranks based on the specified statistical type, and writes the results.
Parameters:¶
- field (
str): The field for which the data is to be gathered. - global_vect_size (
int): The size of the global vector. - local_vect_sizes (
NDArray[np.int32]): An array containing the size of the data vector per rank. - stat_type (
str): A string specifying the type of statistics to gather (called per moment. For example,mean). - values_fn (
Callable): A function that takes__melissa_momentsobject which callsget_stat_type()already defined. (called per moment. For example,lambda m: m.get_mean()).
__gather_and_write_sobol(field, global_vect_size, local_vect_sizes)
¶
Gathers sobol data from all ranks, and writes the results.
Parameters:¶
- field (
str): The field for which the data is to be gathered. - global_vect_size (
int): The size of the global vector. - local_vect_sizes (
NDArray[np.int32]): An array containing the size of the data vector per rank.
Others¶
melissa.server.sensitivity_analysis.sensitivity_analysis_server¶
FieldMetadata¶
A class to store and manage metadata for a field.
Parameters¶
- size (
int): The number of local vectors i.e client ranks.
Attributes¶
- local_vect_sizes (
NDArray): An array containing the local vector sizes for each process. - global_vect_size (
int): The total global vector size, calculated as the sum.
compute_global_size()
¶
Computes the global vector size by summing.