class_docstr: Powell Direction Search optimization,
  adapted from scipy.optimize.fmin_powell.
      
class_docstr_tok: ["Powell","Direction","Search","optimization",",","adapted","from","scipy.optimize.fmin_powell","."]
docstr: perform a single optimization iteration
  
  Args:
      cost (func, default=None): objective, of form ``y = cost(x, *ExtraArgs)``,
        where ``x`` is a candidate solution vector
      ExtraArgs (tuple, default=None): tuple of positional arguments required to
        evaluate the objective
  
  Returns:
      None
  
  Notes:
      - This method accepts additional ``kwds`` that are specific for the current
        solver, as detailed in the ``_process_inputs`` method.
          
docstr_tok: ["perform","a","single","optimization","iteration","Args",":","cost","(","func",",","default=None",")",":","objective",",","of","form","``","y","=","cost","(","x",",","*","ExtraArgs",")","``",",","where","``","x","``","is","a","candidate","solution","vector","ExtraArgs","(","tuple",",","default=None",")",":","tuple","of","positional","arguments","required","to","evaluate","the","objective","Returns",":","None","Notes",":","-","This","method","accepts","additional","``","kwds","``","that","are","specific","for","the","current","solver",",","as","detailed","in","the","``","_process_inputs","``","method","."]
code: def _Step(self, cost=None, ExtraArgs=None, **kwds):
      """perform a single optimization iteration
  
      Args:
          cost (func, default=None): objective, of form ``y = cost(x, *ExtraArgs)``,
            where ``x`` is a candidate solution vector
          ExtraArgs (tuple, default=None): tuple of positional arguments required to
            evaluate the objective
  
      Returns:
          None
  
      Notes:
          - This method accepts additional ``kwds`` that are specific for the current
            solver, as detailed in the ``_process_inputs`` method.
      """
      # process and activate input settings
      settings = self._process_inputs(kwds)
      # (hardwired: due to python exec'ing to locals())
      callback = (
          settings["callback"] if "callback" in settings else None
      )
      disp = settings["disp"] if "disp" in settings else False
      xtol = settings["xtol"] if "xtol" in settings else self.xtol
      imax = settings["imax"] if "imax" in settings else self.imax
  
      # HACK to enable not explicitly calling _decorate_objective
      cost = self._bootstrap_objective(cost, ExtraArgs)
  
      if (
          self._useStrictRange
      ):  # XXX: necessary? or handled by wrap_nested?
          from mystic.constraints import and_
  
          constraints = and_(
              self._constraints,
              self._strictbounds,
              onfail=self._strictbounds,
          )
      else:
          constraints = self._constraints
  
      direc = (
          self._direc
      )  # XXX: throws Error if direc=None after generation=0
      x = self.population[0][:]  # bestSolution
      fval = self.popEnergy[0]  # bestEnergy
      self.__internals[0] = self.__internals[0][:]  # decouple x1 from x
      x1, fx, bigind, delta = self.__internals
      init = False  # flag to do 0th iteration 'post-initialization'
  
      if not len(self._stepmon):  # do generation = 0
          init = True
          x = asfarray(x).flatten()
          x = asfarray(constraints(x))
          N = len(x)  # XXX: this should be equal to self.nDim
          rank = len(x.shape)
          if not -1 < rank < 2:
              raise ValueError(
                  "Initial guess must be a scalar or rank-1 sequence."
              )
  
          if direc is None:
              direc = eye(N, dtype=float)
          else:
              direc = asarray(direc, dtype=float)
          fval = squeeze(cost(x))
          if self._maxiter != 0:
              self._stepmon(x, fval, self.id)  # get initial values
              # if savefrequency matches, then save state
              self._AbstractSolver__save_state()
  
      elif not self.generations:  # do generations = 1
          ilist = range(len(x))
          x1 = x.copy()
          # do initial "second half" of solver step
          fx = fval
          bigind = 0
          delta = 0.0
          for i in ilist:
              direc1 = self._direc[i]
              fx2 = fval
              fval, x, direc1 = _linesearch_powell(
                  cost, x, direc1, tol=xtol * 100, maxiter=imax
              )
              isnan = numpy.isinf(fx2) & numpy.isinf(fval)
              if not isnan and (fx2 - fval) > delta:
                  delta = fx2 - fval
                  bigind = i
  
              # apply constraints
              x = asfarray(constraints(x))  # XXX: use self._map?
          # decouple from 'best' energy
          self.energy_history = self.energy_history + [fval]
  
      else:  # do generations > 1
          # Construct the extrapolated point
          direc1 = x - x1
          x2 = 2 * x - x1
          x1 = x.copy()
          fx2 = squeeze(cost(x2))
  
          if fx > fx2:
              t = 2.0 * (fx + fx2 - 2.0 * fval)
              temp = fx - fval - delta
              t *= temp * temp
              temp = fx - fx2
              t -= delta * temp * temp
              if t < 0.0:
                  fval, x, direc1 = _linesearch_powell(
                      cost, x, direc1, tol=xtol * 100, maxiter=imax
                  )
                  direc[bigind] = direc[-1]
                  direc[-1] = direc1
  
          #        x = asfarray(constraints(x))
  
          self._direc = direc
          self.population[0] = x  # bestSolution
          self.popEnergy[0] = fval  # bestEnergy
          self.energy_history = None  # resync with 'best' energy
          self._stepmon(x, fval, self.id)  # get ith values
          # if savefrequency matches, then save state
          self._AbstractSolver__save_state()
  
          fx = fval
          bigind = 0
          delta = 0.0
          ilist = range(len(x))
          for i in ilist:
              direc1 = direc[i]
              fx2 = fval
              fval, x, direc1 = _linesearch_powell(
                  cost, x, direc1, tol=xtol * 100, maxiter=imax
              )
              isnan = numpy.isinf(fx2) & numpy.isinf(fval)
              if not isnan and (fx2 - fval) > delta:
                  delta = fx2 - fval
                  bigind = i
  
              # apply constraints
              x = asfarray(constraints(x))  # XXX: use self._map?
  
          # decouple from 'best' energy
          self.energy_history = self.energy_history + [fval]
  
      self.__internals = [x1, fx, bigind, delta]
      self._direc = direc
      self.population[0] = x  # bestSolution
      self.popEnergy[0] = fval  # bestEnergy
  
      # do callback
      if callback is not None:
          callback(self.bestSolution)
      # initialize termination conditions, if needed
      if init:
          self._termination(self)  # XXX: at generation 0 or always?
      return
  
imports: from mystic.tools import wrap_function, unpair, wrap_nested
  from mystic.tools import wrap_bounds, wrap_penalty, reduced
  import numpy
  from numpy import eye, zeros, shape, asarray, absolute, asfarray
  from numpy import clip, squeeze
  from mystic._scipy060optimize import brent
  from mystic.abstract_solver import AbstractSolver
label_desc: Use image node_id 4 for calling the PowellDirectionalSolver obj's underlying member method code with example usage: obj._Step(cost, ExtraArgs) without return types