SALib.sample.morris.local module#

class SALib.sample.morris.local.LocalOptimisation[source]#

Bases: Strategy

Implements the local optimisation algorithm using the Strategy interface

Methods

add_indices(indices, distance_matrix)

Adds extra indices for the combinatorial problem.

check_input_sample(input_sample, num_params, ...)

Check the input_sample is valid

compile_output(input_sample, num_samples, ...)

Picks the trajectories from the input

compute_distance(m, l)

Compute distance between two trajectories

compute_distance_matrix(input_sample, ...[, ...])

Computes the distance between each and every trajectory

find_local_maximum(input_sample, N, ...[, ...])

Find the most different trajectories in the input sample using a local approach

get_max_sum_ind(indices_list, distances, i, m)

Get the indices that belong to the maximum distance in distances

run_checks(number_samples, k_choices)

Runs checks on k_choices

sample(input_sample, num_samples, ...[, ...])

Computes the optimum k_choices of trajectories from the input_sample.

sum_distances(indices, distance_matrix)

Calculate combinatorial distance between a select group of trajectories, indicated by indices

add_indices(indices: Tuple, distance_matrix: ndarray) List[source]#

Adds extra indices for the combinatorial problem.

Parameters:

Examples

>>> add_indices((1,2), numpy.array((5,5)))
[(1, 2, 3), (1, 2, 4), (1, 2, 5)]
find_local_maximum(input_sample: ndarray, N: int, num_params: int, k_choices: int, num_groups: int = None) List[source]#

Find the most different trajectories in the input sample using a local approach

An alternative by Ruano et al. (2012) for the brute force approach as originally proposed by Campolongo et al. (2007). The method should improve the speed with which an optimal set of trajectories is found tremendously for larger sample sizes.

Parameters:
  • input_sample (np.ndarray)

  • N (int) – The number of trajectories

  • num_params (int) – The number of factors

  • k_choices (int) – The number of optimal trajectories to return

  • num_groups (int, default=None) – The number of groups

Return type:

list

get_max_sum_ind(indices_list: List[Tuple], distances: ndarray, i: str | int, m: str | int) Tuple[source]#

Get the indices that belong to the maximum distance in distances

Parameters:
Return type:

list

sum_distances(indices: Tuple, distance_matrix: ndarray) ndarray[source]#

Calculate combinatorial distance between a select group of trajectories, indicated by indices

Parameters:
Return type:

numpy.ndarray

Notes

This function can perhaps be quickened by calculating the sum of the distances. The calculated distances, as they are right now, are only used in a relative way. Purely summing distances would lead to the same result, at a perhaps quicker rate.