class_docstr: Implements the local optimisation algorithm using the Strategy interface
class_docstr_tok: ["Implements","the","local","optimisation","algorithm","using","the","Strategy","interface"]
docstr: 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
  
  Returns
  -------
  list
docstr_tok: ["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","Returns","--","--","--","-","list"]
code: def find_local_maximum(
      self,
      input_sample: np.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
  
      Returns
      -------
      list
      """
      distance_matrix = self.compute_distance_matrix(
          input_sample,
          N,
          num_params,
          num_groups,
          local_optimization=True,
      )
  
      tot_indices_list = []
      tot_max_array = np.zeros(k_choices - 1)
  
      maxima_template = np.zeros(len(distance_matrix))
      # Loop over `k_choices`, i starts at 1
      for i in range(1, k_choices):
          indices_list = []
          row_maxima_i = maxima_template.copy()
  
          for row_nr, row in enumerate(distance_matrix):
              indices = tuple(row.argsort()[-i:][::-1]) + (row_nr,)
              row_maxima_i[row_nr] = self.sum_distances(
                  indices, distance_matrix
              )
              indices_list.append(indices)
  
          # Find the indices belonging to the maximum distance
          i_max_ind = self.get_max_sum_ind(
              indices_list, row_maxima_i, i, 0
          )
  
          # Loop 'm' (called loop 'k' in Ruano)
          m_max_ind = i_max_ind
          # m starts at 1
          m = 1
  
          while m <= k_choices - i - 1:
              m_ind = self.add_indices(m_max_ind, distance_matrix)
  
              len_m_ind = len(m_ind)
  
              m_maxima = np.zeros(len_m_ind)
  
              for n in range(len_m_ind):
                  m_maxima[n] = self.sum_distances(
                      m_ind[n], distance_matrix
                  )
  
              m_max_ind = self.get_max_sum_ind(m_ind, m_maxima, i, m)
  
              m += 1
  
          tot_indices_list.append(m_max_ind)
          tot_max_array[i - 1] = self.sum_distances(
              m_max_ind, distance_matrix
          )
  
      tot_max = self.get_max_sum_ind(
          tot_indices_list, tot_max_array, "tot", "tot"
      )
      return sorted(tot_max)
  
file_path: SALib/src/SALib/sample/morris/local.py
imports: from itertools import combinations
  import numpy
  from typing import List, Tuple, Union
  from .strategy import Strategy
label_desc: Use image node_id 2 for calling the LocalOptimisation obj's underlying member method code with example usage: obj.find_local_maximum(input_sample, N, num_params, k_choices, num_groups) and returns: sorted