Skip to main content
`Ctrl`+`K`

# SALib.sample.morris.local module

class SALib.sample.morris.local.LocalOptimisation

  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

    Adds extra indices for the combinatorial problem.

    Parameters:

      - indices (tuple)

      - distance_matrix (numpy.ndarray (M,M))

    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

    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

    Get the indices that belong to the maximum distance in distances

    Parameters:

      - indices_list (list) – list of tuples

      - distances (numpy.ndarray) – size M

      - i (int)

      - m (int)

    Return type:

      list

  sum_distances(indices: Tuple, distance_matrix: ndarray) → ndarray

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

    Parameters:

      - indices (tuple)

      - distance_matrix (numpy.ndarray (M,M))

    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.