class_docstr: AbstractSolver base class for mystic optimizers.
      
class_docstr_tok: ["AbstractSolver","base","class","for","mystic","optimizers","."]
docstr: set the cost function for the optimization
  
  input::
      - cost is the objective function, of the form y = cost(x, *ExtraArgs),
        where x is a candidate solution, and ExtraArgs is the tuple of positional
        arguments required to evaluate the objective.
  
  note::
      this method decorates the objective with bounds, penalties, monitors, etc
code: def SetObjective(self, cost, ExtraArgs=None):  # callback=None/False ?
      """set the cost function for the optimization
  
      input::
          - cost is the objective function, of the form y = cost(x, *ExtraArgs),
            where x is a candidate solution, and ExtraArgs is the tuple of positional
            arguments required to evaluate the objective.
  
      note::
          this method decorates the objective with bounds, penalties, monitors, etc
      """
      _cost, _raw, _args = self._cost
      # check if need to 'wrap' or can return the stored cost
      if (cost is None or cost is _raw or cost is _cost) and (
          ExtraArgs is None or ExtraArgs is _args
      ):
          return
      # get cost and args if None was given
      if cost is None:
          cost = _raw
      args = _args if ExtraArgs is None else ExtraArgs
      args = () if args is None else args
      # quick validation check (so doesn't screw up internals)
      if not isvalid(cost, [0] * self.nDim, *args):
          try:
              call = cost.__call__
          except AttributeError:  # raise new error for non-callables
              cost(*args)
          validate(cost, None, *args)
      # val = len(args) + 1  #XXX: 'klepto.validate' for better error?
      # msg = '%s() invalid number of arguments (%d given)' % (name, val)
      # raise TypeError(msg)
      # hold on to the 'raw' cost function
      self._cost = (None, cost, ExtraArgs)
      self._live = False
      return
  
imports: import random
  import numpy
  from numpy import inf, shape, asarray, absolute, asfarray, seterr
  from mystic.tools import wrap_function, wrap_nested, wrap_reducer
  from mystic.tools import wrap_bounds, wrap_penalty, reduced
  from klepto import isvalid, validate
  from collections.abc import Callable
label_desc: Use image node_id 32 for calling the AbstractSolver obj's underlying member method code with example usage: obj.SetObjective(cost, ExtraArgs) without return types