original_docstring: the first and second value in ``function_values``
          must reflect two mirrored solutions.
  
          Mirrored solutions must have been sampled
          in direction / in opposite direction of
          the previous mean shift, respectively.
          
docstring: the first and second value in ``function_values``
  must reflect two mirrored solutions.
  
  Mirrored solutions must have been sampled
  in direction / in opposite direction of
  the previous mean shift, respectively.
docstring_tokens: the first and second value in ` ` function_values ` ` must reflect two mirrored solutions . Mirrored solutions must have been sampled in direction / in opposite direction of the previous mean shift respectively .
code: def update(self, es, function_values, **kwargs):
          """the first and second value in ``function_values``
          must reflect two mirrored solutions.
  
          Mirrored solutions must have been sampled
          in direction / in opposite direction of
          the previous mean shift, respectively.
          """
          # On the linear function, the two mirrored samples lead
          # to a sharp increase of the condition of the covariance matrix,
          # unless we have negative weights (which we have now by default).
          # Otherwise they should not be used to update the covariance
          # matrix, if the step-size inreases quickly.
          if self.initialized is not True:  # try again
              self.initialize(es.N, es.opts)
          if self.initialized is not True:
              utils.print_warning("dimension not known, damping set to 4",
                  'update', 'CMAAdaptSigmaTPA')
              self.initialized = True
          if 1 < 3:
              f_vals = np.asarray(function_values)
              z = sum(f_vals < f_vals[1]) - sum(f_vals < f_vals[0])
              z /= len(f_vals) - 1  # z in [-1, 1]
          elif 1 < 3:
              # use the ranking difference of the mirrors for adaptation
              # damp = 5 should be fine
              z = np.nonzero(es.fit.idx == 1)[0][0] - np.nonzero(es.fit.idx == 0)[0][0]
              z /= es.popsize - 1  # z in [-1, 1]
          self.s = (1 - self.sp.c) * self.s + self.sp.c * np.sign(z) * np.abs(z)**self.sp.z_exponent
          if self.s > 0:
              es.sigma *= np.exp(self.s / self.sp.dampup)
          else:
              es.sigma *= np.exp(self.s / self.sp.dampdown)
          #es.more_to_write.append(10**z)
code_tokens: def update ( self , es , function_values , ** kwargs ) : if self . initialized is not True : self . initialize ( es . N , es . opts ) if self . initialized is not True : utils . print_warning ( "dimension not known, damping set to 4" , 'update' , 'CMAAdaptSigmaTPA' ) self . initialized = True if 1 < 3 : f_vals = np . asarray ( function_values ) z = sum ( f_vals < f_vals [ 1 ] ) - sum ( f_vals < f_vals [ 0 ] ) z /= len ( f_vals ) - 1 elif 1 < 3 : z = np . nonzero ( es . fit . idx == 1 ) [ 0 ] [ 0 ] - np . nonzero ( es . fit . idx == 0 ) [ 0 ] [ 0 ] z /= es . popsize - 1 self . s = ( 1 - self . sp . c ) * self . s + self . sp . c * np . sign ( z ) * np . abs ( z ) ** self . sp . z_exponent if self . s > 0 : es . sigma *= np . exp ( self . s / self . sp . dampup ) else : es . sigma *= np . exp ( self . s / self . sp . dampdown )
short_docstring: the first and second value in ``function_values``
  must reflect two mirrored solutions.
short_docstring_tokens: the first and second value in ` ` function_values ` ` must reflect two mirrored solutions .
comment: """the first and second value in ``function_values``
          must reflect two mirrored solutions.
  
          Mirrored solutions must have been sampled
          in direction / in opposite direction of
          the previous mean shift, respectively.
          """$SEP$# On the linear function, the two mirrored samples lead$SEP$# to a sharp increase of the condition of the covariance matrix,$SEP$# unless we have negative weights (which we have now by default).$SEP$# Otherwise they should not be used to update the covariance$SEP$# matrix, if the step-size inreases quickly.$SEP$# try again$SEP$# z in [-1, 1]$SEP$# use the ranking difference of the mirrors for adaptation$SEP$# damp = 5 should be fine$SEP$# z in [-1, 1]$SEP$#es.more_to_write.append(10**z)