cma API Reference

Covariance Matrix Adaptation Evolution Strategy (CMA-ES) for non-linear numerical optimization.

cma.AugmentedLagrangian
Python Library Documentation: class AugmentedLagrangian in module cma.constraints_handler

class AugmentedLagrangian(builtins.object)
 |  AugmentedLagrangian(dimension, equality=False)
 |
 |  Augmented Lagrangian with adaptation of the coefficients
 |
 |  for minimization, implemented after Atamna et al FOGA 2017,
 |  Algorithm 1 and Sect 8.2, https://hal.inria.fr/hal-01455379/document.
 |
 |  `cma.ConstrainedFitnessAL` provides a (more) user-friendly interface to
 |  the `AugmentedLagrangian` class.
 |
 |  Input `dimension` is the search space dimension, boolean `equality`
 |  may be an iterable of length of number of constraints indicating the
 |  type for each constraint.
 |
 |  Below, the objective function value is denoted as ``f = f(x)``, the
 |  constraints values as ``g = g(x) <= 0``, the penalties compute to
 |  ``penalties(x) = self(g(x)) = lam g + mu g^2 / 2`` (if g > -lam / mu) for
 |  each element of g, as returned by calling the instance with g as argument.
 |
 |  The penalized "fitness" value ``f + sum(self(g))`` shall be minimized.
 |  lam and mu are the Lagrange multipliers or coefficients.
 |
 |  An additional method, `set_coefficients` allows to initialize the
 |  Lagrange multipliers from data.
 |
 |  A short example (and doctest):
 |
 |  >>> import cma
 |  >>> from cma.constraints_handler import AugmentedLagrangian, PopulationEvaluator
 |  >>> m = 2  # number of constraints
 |  >>> def objective(x):
 |  ...     return sum(x[m:]**2) + sum((x[:m] - 1)**2) - m
 |  >>> def constraints(x):
 |  ...     return x[:m]
 |  >>> es = cma.CMAEvolutionStrategy(3 * [1], 1, {
 |  ...          'termination_callback': lambda es: sum(es.mean**2) < 1e-8})  #doctest: +ELLIPSIS
 |  (3_w,7)-aCMA-ES...
 |  >>> al = AugmentedLagrangian(es.N)  # lam and mu still need to be set
 |  >>> # al.chi_domega = 1.15  # is the new default, which seems to give better results than the original value
 |  >>> # al.lam, al.mu = ...  # we could set the initial Lagrange coefficients here
 |  >>> while not es.stop():
 |  ...     eva = PopulationEvaluator(objective, constraints)(es.ask(), m=es.mean)
 |  ...     al.set_coefficients(eva.F, eva.G)  # set lam and mu, not part of the original algorithm
 |  ...     al.update(eva.m['f'], eva.m['g'])
 |  ...     es.tell(eva.X, [f + sum(al(g)) for f, g in zip(eva.F, eva.G)])
 |  >>> if es.result.evaluations > 3100:
 |  ...     print("evaluations %d !< 3100. 1500 is normal, 2700 happens rarely" % es.result.evaluations)
 |  >>> assert 'callback' in es.stop()
 |  >>> assert len(eva.feasibility_ratios) == m
 |  >>> assert sum(eva.feasibility_ratios < 0) == sum(eva.feasibility_ratios > 1) == 0
 |
 |  Details: the input `dimension` is needed to compute the default change
 |  rate `chi_domega` (if ``chi_domega is None``), to compute initial
 |  coefficients and to compare between h and g to update mu. The default
 |  dependency of `chi_domega` on the dimension seems to be however
 |  suboptimal. Setting ``self.chi_domega = 1.15`` as is the current
 |  default seems to give better results than the original setting.
 |
 |  More testing based on the simpler `ConstrainedFitnessAL` interface:
 |
 |  >>> import cma
 |  >>> for algorithm, evals in zip((0, 1, 2, 3), (2000, 2200, 1500, 1800)):
 |  ...     alf = cma.ConstrainedFitnessAL(cma.ff.sphere, lambda x: [x[0] + 1], 3,
 |  ...                                    find_feasible_first=True)
 |  ...     _ = alf.al.set_algorithm(algorithm)
 |  ...     alf.al.logging = False
 |  ...     x, es = cma.fmin2(alf, 3 * [1], 0.1, {'verbose':-9, 'seed':algorithm},  # verbosity+seed for doctest only
 |  ...                       callback=alf.update)
 |  ...     assert sum((es.mean - [-1, 0, 0])**2) < 1e-9, (algorithm, es.mean)
 |  ...     assert es.countevals < evals, (algorithm, es.countevals)
 |  ...     assert alf.best_feas.f < 10, (algorithm, str(alf.best_feas))
 |  ...     # print(algorithm, es.countevals, ) #alf.best_feas.__dict__)
 |
 |  Methods defined here:
 |
 |  __call__(self, g)
 |      return `list` of AL penalties for constraints values in `g`.
 |
 |      Penalties are zero in the optimum and can be negative down to
 |      ``-lam**2 / mu / 2``.
 |
 |  __init__(self, dimension, equality=False)
 |      use `set_algorithm()` and ``set_...()`` methods to change defaults
 |
 |  muminus2(self, g, i, threshold=0.05)
 |      provisorial function to correct mu minus condition, original is `True`
 |
 |  muminus3(self, g, i, threshold=0.9)
 |      return `True` if mu should be reduced, else `False`.
 |
 |      If mu is large, the augmented function is steeper on the infeasible
 |      side. Consequently, typically g < 0 and, if the constraint is
 |      active, some solution will still be infeasible. If this is the
 |      case, we decrease mu.
 |
 |      TODO: if more than 50% are infeasible, we may not want to decrease
 |      mu further? This usually does not happen, because we increase mu
 |      when g > 0. However, if the constraint is a nonsmooth 1/2^n sector,
 |      the feasiblity ratio goes inevitably to 1/2^n.
 |
 |  muminus4(self, g, i, threshold=0.9)
 |      return `True` if mu should be reduced, else `False`
 |
 |  muplus2(self, g, i, threshold=0.4)
 |      provisorial function to correct mu plus condition, original is `True`
 |
 |  muplus3(self, g, i, threshold=0.95)
 |      return `True` if mu should be increased, else `False`.
 |
 |      TODO: because the stationary condition is g == 0, it seems
 |      unreasonable to always increase mu when g > 0?
 |
 |  muplus4(self, g, i, threshold=0.95)
 |      return `True` if mu should be increased, else `False`
 |
 |  set_algorithm(self, algorithm=None)
 |      if algorithm not `None`, set it and return self,
 |
 |      otherwise return current algorithm value which should be an integer.
 |
 |      Values < 1 are the (new) default, 1 == Atamna et al 2017, 2 == modified 1.
 |
 |  set_atamna2017(self)
 |      Atamna et al 2017 parameter settings
 |
 |  set_coefficients(self, F, G)
 |      compute initial coefficients based on some f- and g-values.
 |
 |      The formulas to set the coefficients::
 |
 |          lam = iqr(f) / (n * iqr(g))
 |          mu = 2 * iqr(f) / (5 * n * (iqr(g) + iqr(g**2)))
 |
 |      are taken out of thin air and not thoroughly tested. They are
 |      additionally protected against division by zero.
 |
 |      Each row of `G` represents the constraints of one sample measure.
 |
 |      Set lam and mu until a population contains more than 10% infeasible
 |      and more than 10% feasible at the same time. Afterwards, this at least...?...
 |
 |  set_dufosse2020(self)
 |      Dufosse & Hansen 2020 parameter settings
 |
 |  set_m(self, m)
 |      initialize attributes which depend on the number of constraints.
 |
 |      This requires the `lam` attribute to be `None` and deletes all
 |      previously set or adapted `mu` coefficients.
 |
 |  update(self, f, g)
 |      f is a scalar, g is a vector.
 |
 |      Update Lagrange multipliers based on Atamna et al 2017. f and g are
 |      supposed to have been computed from the distribution mean.
 |
 |      Details: do nothing if Lagrange coefficients `lam` were not yet set.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  count_initialized
 |      number of constraints with initialized coefficients
 |
 |  feasibility_ratios
 |      or bias for equality constraints, versatile interface may change
 |
 |  is_initialized
 |
 |  isequality
 |      bool array, `True` if `i`-th constraint is an equality constraint
 |
 |  m
 |      number of constraints, raise `TypeError` if not set yet
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.BoundDomainTransform
Python Library Documentation: class BoundDomainTransform in module cma.boundary_handler

class BoundDomainTransform(builtins.object)
 |  BoundDomainTransform(function, boundaries)
 |
 |  create a `callable` with unbounded domain from a function with bounded domain,
 |
 |  for example an objective or constraints function. The new "unbounded"
 |  `callable` maps ``x`` to ``function(self.transform(x))``, first
 |  "projecting" the input (e.g., candidate solutions) into the bounded
 |  domain with `transform` before to evaluate the result on the original
 |  function. The "projection" is smooth and differentiable, namely
 |  coordinate-wise piecewise linear or quadratic. The "projection" is not
 |  idempotent.
 |
 |  Bounds are passed as ``boundaries = [lower_bounds, upper_bounds]``
 |  where each ``*_bounds`` can be `None`, or a scalar, or an iterable (a
 |  vector) whose values can be `None` too. If the iterable has fewer
 |  values than the solutions, the last value is recycled, if it has more
 |  values, trailing values are ignored.
 |
 |  For example, ``boundaries = [None, [0, 0, None]]`` means no lower
 |  bounds and an upper bound of zero for the first two variables.
 |
 |  Example:
 |
 |  >>> import cma
 |  >>> fun = cma.boundary_handler.BoundDomainTransform(
 |  ...             cma.ff.sphere,  # is composed with fun.transform into fun
 |  ...             [[0.02, 0.01], None])  # boundaries for the "original" problem
 |  >>> x, es = cma.fmin2(fun, 3 * [0.5], 0.5, {'verbose':-9})
 |  >>> assert all(x - 1e-4 < [-0.03, -0.04, -0.04])  # x is in the unbounded domain
 |  >>> print("solution in the original (bounded) domain = {}"
 |  ...       .format(fun.transform(es.result.xfavorite)))
 |  solution in the original (bounded) domain = [0.02 0.01 0.01]
 |
 |  The original function can be accessed and called via the attribute
 |  ``function`` like ``fun.function(...)``. For code simplicity,
 |  attributes of ``function`` are "inherited" to ``fun``.
 |
 |  Details: the resulting function has a repetitive landscape with a
 |  period slightly larger than twice the boundary interval. The
 |  ``BoundDomainTransform(function,...)`` instance emulates the original function
 |  on attribute access by calling ``__getattr__``. To access shadowed
 |  attributes or for debugging, replace ``.attrname`` with
 |  ``.function.attrname``.
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  __getattr__(self, name)
 |      return ``getattr(self.function, name)`` when ``not hasattr(self, name)``.
 |
 |      This emulates the `function` interface, kinda like blind inheritance.
 |
 |  __init__(self, function, boundaries)
 |      return a callable that evaluates `function` only within `boundaries`
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.BoundNone
Python Library Documentation: class BoundNone in module cma.boundary_handler

class BoundNone(BoundaryHandlerBase)
 |  BoundNone(bounds=None)
 |
 |  no boundaries
 |
 |  Method resolution order:
 |      BoundNone
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, bounds=None)
 |      `bounds` can be ``None`` or ``[lb, ub]``
 |
 |      where ``lb`` and ``ub`` are either ``None`` or a vector (which can have
 |      ``None`` entries).
 |
 |      On return, the ``bounds`` attribute of ``self`` are the bounds in a
 |      normalized form.
 |
 |      To compute bounds for any dimension, the last entry of bounds is
 |      then recycled for variables with ``indices >= len(bounds[i]) for i
 |      in (0,1)``.
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  __call__(self, solutions, *args, **kwargs)
 |      return penalty or list of penalties, by default zero(s).
 |
 |      This interface seems too specifically tailored to the derived
 |      BoundPenalty class, it should maybe change.
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  inverse(self, y, copy_if_changed=True)
 |      inverse of repair if it exists, at least it should hold
 |      ``repair == repair o inverse o repair``
 |
 |  repair(self, x, copy_if_changed=True)
 |      projects infeasible values on the domain bound, might be
 |      overwritten by derived class
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  update(self, *args, **kwargs)
 |      end-iteration callback of boundary handler (abstract/empty)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.BoundPenalty
Python Library Documentation: class BoundPenalty in module cma.boundary_handler

class BoundPenalty(BoundaryHandlerBase)
 |  BoundPenalty(bounds=None)
 |
 |  Compute a bound penalty and update coordinate-wise penalty weights.
 |
 |  An instance must be updated each iteration using the `update` method.
 |
 |  Details:
 |
 |  - The penalty computes like ``sum(w[i] * (x[i]-xfeas[i])**2)``,
 |    where ``xfeas`` is the closest feasible (in-bounds) solution from
 |    ``x``. The weight ``w[i]`` should be updated during each iteration
 |    using the update method.
 |
 |  Example how this boundary handler is used with `cma.fmin` via the
 |  options (`CMAOptions`) of the class `cma.CMAEvolutionStrategy`:
 |
 |  >>> import cma
 |  >>> res = cma.fmin(cma.ff.elli, 6 * [0.9], 0.1,
 |  ...     {'BoundaryHandler': cma.BoundPenalty,
 |  ...      'bounds': [-1, 1],
 |  ...      'tolflatfitness': 10,
 |  ...      'fixed_variables': {0: 0.012, 2:0.234}
 |  ...     })  # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=...
 |  >>> if res[1] >= 13.76: print(res)  # should never happen
 |
 |  Reference: Hansen et al 2009, A Method for Handling Uncertainty...
 |  IEEE TEC, with addendum, see
 |  https://ieeexplore.ieee.org/abstract/document/4634579
 |  https://hal.inria.fr/inria-00276216/file/TEC2008.pdf
 |
 |  **todo**: implement a more generic interface, where this becomes a
 |  fitness wrapper which adds the desired penalty and the `update`
 |  method is used as callback argument for `fmin` like::
 |
 |      f = cma.BoundPenalty(cma.ff.elli, bounds=[-1, 1])
 |      res = cma.fmin(f, 6 * [1], callback=f.update)
 |
 |  where callback functions should receive the same arguments as
 |  `tell`, namely an `CMAEvolutionStrategy` instance, an array of the
 |  current solutions and their respective f-values. Such change is
 |  relatively involved. Consider also that bounds are related with the
 |  geno- to phenotype transformation.
 |
 |  Method resolution order:
 |      BoundPenalty
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, archive, gp)
 |      returns the boundary violation penalty for `x`,
 |      where `x` is a single solution or a list or np.array of solutions.
 |
 |  __init__(self, bounds=None)
 |      Argument bounds can be `None` or ``bounds[0]`` and ``bounds[1]``
 |      are lower  and upper domain boundaries, each is either `None` or
 |      a scalar or a `list` or `np.array` of appropriate size.
 |
 |  feasible_ratio(self, solutions)
 |      counts for each coordinate the number of feasible values in
 |      ``solutions`` and returns an `np.array` of length
 |      ``len(solutions[0])`` with the ratios.
 |
 |  repair(self, x, copy_if_changed=True)
 |      sets out-of-bounds components of ``x`` on the bounds.
 |
 |      TODO: unify with BoundaryHandlerBase.repair
 |
 |  update(self, function_values, es)
 |      updates the weights for computing a boundary penalty.
 |
 |      Arguments
 |      =========
 |      ``function_values``:
 |          all function values of recent population of solutions
 |      ``es``:
 |          `CMAEvolutionStrategy` object instance, in particular
 |          mean and variances and the methods from the attribute
 |          `gp` of type `GenoPheno` are used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  inverse(self, y, copy_if_changed=True)
 |      inverse of repair if it exists, at least it should hold
 |      ``repair == repair o inverse o repair``
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.BoundTransform
Python Library Documentation: class BoundTransform in module cma.boundary_handler

class BoundTransform(BoundaryHandlerBase)
 |  BoundTransform(bounds=None)
 |
 |  Handle boundaries by a smooth, piecewise linear and quadratic
 |  transformation into the feasible domain.
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> from cma.boundary_handler import BoundTransform
 |  >>> from cma import fitness_transformations as ft
 |  >>> veq = cma.utilities.math.Mh.vequals_approximately
 |  >>> b = BoundTransform([0, None])
 |  >>> assert b.bounds == [[0], None]
 |  >>> assert veq(b.repair([-0.1, 0, 1, 1.2]), np.array([0.0125, 0.0125, 1, 1.2])), b.repair([-0.1, 0, 1, 1.2])
 |  >>> assert b.is_in_bounds([0, 0.5, 1])
 |  >>> assert veq(b.transform([-1, 0, 1, 2]), [0.9, 0.0125,  1,  2  ]), b.transform([-1, 0, 1, 2])
 |  >>> bounded_sphere = ft.ComposedFunction([
 |  ...         cma.ff.sphere,
 |  ...         BoundTransform([[], 5 * [-1] + [np.inf]]).transform
 |  ...     ])
 |  >>> o1 = cma.fmin(bounded_sphere, 6 * [-2], 0.5)  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> o2 = cma.fmin(cma.ff.sphere, 6 * [-2], 0.5, options={
 |  ...    'BoundaryHandler': cma.boundary_handler.BoundTransform,
 |  ...    'bounds': [[], 5 * [-1] + [np.inf]] })  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> assert o1[1] < 5 + 1e-8 and o2[1] < 5 + 1e-8
 |  >>> b = BoundTransform([-np.random.rand(120), np.random.rand(120)])
 |  >>> for i in range(0, 100, 9):
 |  ...     x = (-i-1) * np.random.rand(120) + i * np.random.randn(120)
 |  ...     x_to_b = b.repair(x)
 |  ...     x2 = b.inverse(x_to_b)
 |  ...     x2_to_b = b.repair(x2)
 |  ...     x3 = b.inverse(x2_to_b)
 |  ...     x3_to_b = b.repair(x3)
 |  ...     assert veq(x_to_b, x2_to_b)
 |  ...     assert veq(x2, x3)
 |  ...     assert veq(x2_to_b, x3_to_b)
 |  >>> for _ in range(5):
 |  ...     lb = np.random.randn(4)
 |  ...     ub = lb + 1e-7 + np.random.rand(4)
 |  ...     b = BoundTransform([lb, ub])
 |  ...     for x in [np.random.randn(4) / np.sqrt(np.random.rand(4)) for _ in range(22)]:
 |  ...         assert all(lb <= b.transform(x)), (lb, ub, b.__dict__)
 |  ...         assert all(b.transform(x) <= ub), (lb, ub, b.__dict__)
 |
 |  Details: this class uses ``class BoxConstraintsLinQuadTransformation``
 |
 |  Method resolution order:
 |      BoundTransform
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, bounds=None)
 |      Argument bounds can be `None` or ``bounds[0]`` and ``bounds[1]``
 |      are lower and upper domain boundaries, each is either `None` or
 |      a scalar or a list or array of appropriate size.
 |
 |  inverse(self, x, copy_if_changed=True)
 |      inverse transform of ``x`` from the bounded domain.
 |
 |  repair(self, x, copy_if_changed=True)
 |      transforms ``x`` into the bounded domain.
 |
 |  transform(self, x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  __call__(self, solutions, *args, **kwargs)
 |      return penalty or list of penalties, by default zero(s).
 |
 |      This interface seems too specifically tailored to the derived
 |      BoundPenalty class, it should maybe change.
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  update(self, *args, **kwargs)
 |      end-iteration callback of boundary handler (abstract/empty)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.CMA
Python Library Documentation: class CMAEvolutionStrategy in module cma.evolution_strategy

class CMAEvolutionStrategy(cma.interfaces.OOOptimizer)
 |  CMAEvolutionStrategy(x0, sigma0, inopts=None, options=None)
 |
 |  CMA-ES stochastic optimizer class with ask-and-tell interface.
 |
 |  Calling Sequences
 |  =================
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0, opts)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0).optimize(objective_fct)``
 |
 |  - ::
 |
 |      res = CMAEvolutionStrategy(x0, sigma0,
 |                              opts).optimize(objective_fct).result
 |
 |  Arguments
 |  =========
 |  `x0`
 |      initial solution, starting point. `x0` is given as "phenotype"
 |      which means, if::
 |
 |          opts = {'transformation': [transform, inverse]}
 |
 |      is given and ``inverse is None``, the initial mean is not
 |      consistent with `x0` in that ``transform(mean)`` does not
 |      equal to `x0` unless ``transform(mean)`` equals ``mean``.
 |  `sigma0`
 |      initial standard deviation.  The problem variables should
 |      have been scaled, such that a single standard deviation
 |      on all variables is useful and the optimum is expected to
 |      lie within about `x0` +- ``3*sigma0``. Often one wants to
 |      check for solutions close to the initial point. This allows,
 |      for example, for an easier check of consistency of the
 |      objective function and its interfacing with the optimizer.
 |      In this case, a much smaller `sigma0` is advisable.
 |  `opts`
 |      options, a dictionary with optional settings,
 |      see class `CMAOptions`.
 |
 |  Main interface / usage
 |  ======================
 |  The interface is inherited from the generic `OOOptimizer`
 |  class (see also there). An object instance is generated from::
 |
 |      es = cma.CMAEvolutionStrategy(8 * [0.5], 0.2)
 |
 |  The least verbose interface is via the optimize method::
 |
 |      es.optimize(objective_func)
 |      res = es.result
 |
 |  More verbosely, the optimization is done using the
 |  methods `stop`, `ask`, and `tell`::
 |
 |      while not es.stop():
 |          solutions = es.ask()
 |          es.tell(solutions, [cma.ff.rosen(s) for s in solutions])
 |          es.disp()
 |      es.result_pretty()
 |
 |
 |  where `ask` delivers new candidate solutions and `tell` updates
 |  the `optim` instance by passing the respective function values
 |  (the objective function `cma.ff.rosen` can be replaced by any
 |  properly defined objective function, see `cma.ff` for more
 |  examples).
 |
 |  To change an option, for example a termination condition to
 |  continue the optimization, call::
 |
 |      es.opts.set({'tolfacupx': 1e4})
 |
 |  The class `CMAEvolutionStrategy` also provides::
 |
 |      (solutions, func_values) = es.ask_and_eval(objective_func)
 |
 |  and an entire optimization can also be written like::
 |
 |      while not es.stop():
 |          es.tell(*es.ask_and_eval(objective_func))
 |
 |  Besides for termination criteria, in CMA-ES only the ranks of the
 |  `func_values` are relevant.
 |
 |  Attributes and Properties
 |  =========================
 |  - `inputargs`: passed input arguments
 |  - `inopts`: passed options
 |  - `opts`: actually used options, some of them can be changed any
 |    time via ``opts.set``, see class `CMAOptions`
 |  - `popsize`: population size lambda, number of candidate
 |    solutions returned by `ask` ()
 |  - `logger`: a `CMADataLogger` instance utilized by `optimize`
 |
 |  Examples
 |  ========
 |  Super-short example, with output shown:
 |
 |  >>> import cma
 |  >>> # construct an object instance in 4-D, sigma0=1:
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1, {'seed':234})
 |  ...      # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=234...)
 |
 |  and optimize the ellipsoid function
 |
 |  >>> es.optimize(cma.ff.elli, verb_disp=1)  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 2.09...
 |  >>> assert len(es.result) >= 8, es.result
 |  >>> assert es.result.fbest < 1e-9, es.result
 |
 |  The optimization loop can also be written explicitly:
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1)  # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=...
 |  >>> while not es.stop():
 |  ...    X = es.ask()
 |  ...    es.tell(X, [cma.ff.elli(x) for x in X])
 |  ...    es.disp()  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 ...
 |
 |  achieving the same result as above.
 |
 |  An example with lower bounds (at zero) and handling infeasible
 |  solutions:
 |
 |  >>> import numpy as np
 |  >>> es = cma.CMAEvolutionStrategy(10 * [0.2], 0.5,
 |  ...         {'bounds': [0, np.inf]})  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> while not es.stop():
 |  ...     fit, X = [], []
 |  ...     while len(X) < es.popsize:
 |  ...         curr_fit = None
 |  ...         while curr_fit in (None, np.nan):
 |  ...             x = es.ask(1)[0]
 |  ...             curr_fit = cma.ff.somenan(x, cma.ff.elli) # might return np.nan
 |  ...         X.append(x)
 |  ...         fit.append(curr_fit)
 |  ...     es.tell(X, fit)
 |  ...     es.logger.add()
 |  ...     es.disp()  #doctest: +ELLIPSIS
 |  Itera...
 |  >>>
 |  >>> assert es.result.fbest < 1e-9, es.result
 |  >>> assert es.result.evals_best < 9000, es.result  # by internal termination
 |  >>> # es.logger.plot()  # will plot data
 |  >>> # cma.s.figshow()  # display plot window
 |
 |  An example with user-defined transformation, in this case to realize
 |  a lower bound of 2.
 |
 |  >>> import warnings
 |  >>> with warnings.catch_warnings(record=True) as warns:
 |  ...     es = cma.CMAEvolutionStrategy(5 * [3], 0.1,
 |  ...                 {"transformation": [lambda x: x**2+1.2, None],
 |  ...                  "ftarget": 1e-7 + 5.54781521192,
 |  ...                  "verbose": -2,})
 |  >>> warns[0].message  # doctest:+ELLIPSIS
 |  UserWarning('in class GenoPheno: user defined transformations have not been tested thoroughly (...
 |  >>> warns[1].message  # doctest:+ELLIPSIS
 |  UserWarning('computed initial point...
 |  >>> es.optimize(cma.ff.rosen, verb_disp=0)  #doctest: +ELLIPSIS
 |  <cma...
 |  >>> assert cma.ff.rosen(es.result.xbest) < 1e-7 + 5.54781521192, es.result
 |  >>> assert es.result.evals_best < 3300, es.result
 |
 |  The inverse transformation is (only) necessary if the `BoundPenalty`
 |  boundary handler is used at the same time.
 |
 |  The `CMAEvolutionStrategy` class also provides a default logger
 |  (cave: files are overwritten when the logger is used with the same
 |  filename prefix):
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [0.2], 0.5, {'verb_disp': 0})
 |  >>> es.logger.disp_header()  # annotate the print of disp
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> while not es.stop():
 |  ...     X = es.ask()
 |  ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |  ...     es.logger.add()  # log current iteration
 |  ...     es.logger.disp([-1])  # display info for last iteration   #doctest: +ELLIPSIS
 |      1  ...
 |  >>> es.logger.disp_header()
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> # es.logger.plot() # will make a plot
 |
 |  Example implementing restarts with increasing popsize (IPOP):
 |
 |  >>> bestever = cma.optimization_tools.BestSolution()
 |  >>> for lam in 10 * 2**np.arange(8):  # 10, 20, 40, 80, ..., 10 * 2**7
 |  ...     es = cma.CMAEvolutionStrategy(6 - 8 * np.random.rand(4),  # 4-D
 |  ...                                   5,  # initial std sigma0
 |  ...                                   {'popsize': lam,  # options
 |  ...                                    'verb_append': bestever.evalsall})
 |  ...     # logger = cma.CMADataLogger().register(es, append=bestever.evalsall)
 |  ...     while not es.stop():
 |  ...         X = es.ask()    # get list of new solutions
 |  ...         fit = [cma.ff.rastrigin(x) for x in X]  # evaluate each solution
 |  ...         es.tell(X, fit) # besides for termination only the ranking in fit is used
 |  ...
 |  ...         # display some output
 |  ...         # logger.add()  # add a "data point" to the log, writing in files
 |  ...         es.disp()  # uses option verb_disp with default 100
 |  ...
 |  ...     print('termination:', es.stop())
 |  ...     cma.s.pprint(es.best.__dict__)
 |  ...
 |  ...     bestever.update(es.best)
 |  ...
 |  ...     # show a plot
 |  ...     # logger.plot();
 |  ...     if bestever.f < 1e-8:  # global optimum was hit
 |  ...         break  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> assert es.result.fbest < 1e-8, es.result
 |
 |  On the Rastrigin function, usually after five restarts the global
 |  optimum is located.
 |
 |  Using the `multiprocessing` module, we can evaluate the function in
 |  parallel with a simple modification of the example (however
 |  multiprocessing seems not always reliable):
 |
 |  >>> from cma.fitness_functions import elli  # cannot be an instance method
 |  >>> from cma.optimization_tools import EvalParallel2
 |  >>> es = cma.CMAEvolutionStrategy(22 * [0.0], 1.0, {'maxiter':10})  # doctest:+ELLIPSIS
 |  (6_w,13)-aCMA-ES (mu_w=...
 |  >>> with EvalParallel2(elli, es.popsize + 1) as eval_all:
 |  ...     while not es.stop():
 |  ...         X = es.ask()
 |  ...         es.tell(X, eval_all(X))
 |  ...         es.disp()
 |  ...         # es.logger.add()  # doctest:+ELLIPSIS
 |  Iterat...
 |
 |  The final example shows how to resume:
 |
 |  >>> import pickle
 |  >>>
 |  >>> es0 = cma.CMAEvolutionStrategy(12 * [0.1],  # a new instance, 12-D
 |  ...                                0.12)         # initial std sigma0
 |  ...   #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> es0.optimize(cma.ff.rosen, iterations=100)  #doctest: +ELLIPSIS
 |  I...
 |  >>> s = es0.pickle_dumps()  # return pickle.dumps(es) with safeguards
 |  >>> # save string s to file like open(filename, 'wb').write(s)
 |  >>> del es0  # let's start fresh
 |  >>> # s = open(filename, 'rb').read()  # load string s from file
 |  >>> es = pickle.loads(s)  # read back es instance from string
 |  >>> # resuming
 |  >>> es.optimize(cma.ff.rosen, verb_disp=200)  #doctest: +ELLIPSIS
 |    200 ...
 |  >>> assert es.result.evals_best < 15000, es.result
 |  >>> assert cma.s.Mh.vequals_approximately(es.result.xbest, 12 * [1], 1e-5), es.result
 |  >>> assert len(es.result) >= 8, es.result
 |
 |  Details
 |  =======
 |  The following two enhancements are implemented, the latter is only
 |  turned on by default for very small population sizes.
 |
 |  *Active CMA* is implemented with option ``CMA_active`` and
 |  conducts an update of the covariance matrix with negative weights.
 |  The negative update is implemented, such that positive definiteness
 |  is guarantied. A typical speed up factor (number of f-evaluations)
 |  is between 1.1 and two.
 |
 |  References: Jastrebski and Arnold, Improving evolution strategies
 |  through active covariance matrix adaptation, CEC 2006.
 |  Hansen, The CMA evolution strategy: a tutorial, arXiv 2016.
 |
 |  *Selective mirroring* is implemented with option ``CMA_mirrors``
 |  in the method `get_mirror` and `get_selective_mirrors`.
 |  The method `ask_and_eval` (used by `fmin`) will then sample
 |  selectively mirrored vectors within the iteration
 |  (``CMA_mirrormethod==1``). Otherwise, or if ``CMA_mirromethod==2``,
 |  selective mirrors are injected for the next iteration.
 |  In selective mirroring, only the worst solutions are mirrored. With
 |  the default small number of mirrors, *pairwise selection* (where at
 |  most one of the two mirrors contribute to the update of the
 |  distribution mean) is implicitly guarantied under selective
 |  mirroring and therefore not explicitly implemented.
 |
 |  Update: pairwise selection for injected mirrors is also applied in the
 |  covariance matrix update: for all injected solutions, as for those from
 |  TPA, this is now implemented in that the recombination weights are
 |  constrained to be nonnegative for injected solutions in the covariance
 |  matrix (otherwise recombination weights are anyway nonnegative). This
 |  is a precaution to prevent failure when injected solutions are
 |  systematically bad (see e.g. https://github.com/CMA-ES/pycma/issues/124),
 |  but may not be "optimal" for mirrors.
 |
 |  References: Brockhoff et al, PPSN 2010, Auger et al, GECCO 2011.
 |
 |  :See also: `fmin` (), `OOOptimizer`, `CMAOptions`, `plot` (), `ask` (),
 |      `tell` (), `ask_and_eval` ()
 |
 |  Method resolution order:
 |      CMAEvolutionStrategy
 |      cma.interfaces.OOOptimizer
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, x0, sigma0, inopts=None, options=None)
 |      see class `CMAEvolutionStrategy`
 |
 |      `options` is for consistency with `fmin2` options and is only
 |      in effect if ``inopts is None``.
 |
 |  alleviate_conditioning(self, condition=1000000000000.0)
 |      pass conditioning of `C` to linear transformation in `self.gp`.
 |
 |      Argument `condition` defines the limit condition number above
 |      which the action is taken.
 |
 |      >>> import cma
 |      >>> for dd in [0, 1]:
 |      ...     es = cma.CMA(2 * [1], 0.1, {'CMA_diagonal_decoding' : dd, 'verbose':-9})
 |      ...     es = es.optimize(cma.ff.elli, iterations=4)
 |      ...     es.alleviate_conditioning(1.01)  # check that alleviation_conditioning "works"
 |      ...     assert all(es.sigma_vec.scaling == [1, 1]), es.sigma_vec.scaling
 |      ...     assert es.sm.condition_number <= 1.01, es.sm.C
 |
 |      Details: the action applies only if `self.gp.isidentity`. Then,
 |      the covariance matrix `C` is set (back) to identity and a
 |      respective linear transformation is "added" to `self.gp`.
 |
 |  alleviate_conditioning_in_coordinates(self, condition=100000000.0)
 |      pass scaling from `C` to `sigma_vec`.
 |
 |      As a result, `C` is a correlation matrix, i.e., all diagonal
 |      entries of `C` are `1`.
 |
 |  ask(self, number=None, xmean=None, sigma_fac=1, gradf=None, args=(), **kwargs)
 |      get/sample new candidate solutions.
 |
 |      Solutions are sampled from a multi-variate
 |      normal distribution and transformed to f-representation
 |      (phenotype) to be evaluated.
 |
 |      Arguments
 |      ---------
 |          `number`
 |              number of returned solutions, by default the
 |              population size ``popsize`` (AKA ``lambda``).
 |          `xmean`
 |              distribution mean, phenotyp?
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `gradf`
 |              gradient, ``len(gradf(x)) == len(x)``, if
 |              ``gradf is not None`` the third solution in the
 |              returned list is "sampled" in supposedly Newton
 |              direction ``np.dot(C, gradf(xmean, *args))``.
 |          `args`
 |              additional arguments passed to gradf
 |          `kwargs`
 |              if `ignore_integer_variables` do not change integer
 |              variables at all which is in particular useful when a small
 |              mutation is added to a given solution and integer values
 |              are not supposed to be disturbed at all and/or moved across
 |              a plateau boundary.
 |
 |      Return
 |      ------
 |      A list of N-dimensional candidate solutions to be evaluated
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy([0,0,0,0], 0.3)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop() and es.best.f > 1e-6:
 |      ...     X = es.ask()  # get list of new solutions
 |      ...     fit = [cma.ff.rosen(x) for x in X]  # call fct with each solution
 |      ...     es.tell(X, fit)  # feed values
 |
 |      :See: `ask_and_eval`, `ask_geno`, `tell`
 |
 |  ask_and_eval(self, func, args=(), gradf=None, number=None, xmean=None, sigma_fac=1, evaluations=1, aggregation=<function median at 0x000002897F5C4170>, kappa=1, parallel_mode=False)
 |      sample `number` solutions and evaluate them on `func`.
 |
 |      Each solution ``s`` is resampled until
 |      ``self.is_feasible(s, func(s)) is True``.
 |
 |      Arguments
 |      ---------
 |      `func`:
 |          objective function, ``func(x)`` accepts a `numpy.ndarray`
 |          and returns a scalar ``if not parallel_mode``. Else returns a
 |          `list` of scalars from a `list` of `numpy.ndarray`.
 |      `args`:
 |          additional parameters for `func`
 |      `gradf`:
 |          gradient of objective function, ``g = gradf(x, *args)``
 |          must satisfy ``len(g) == len(x)``
 |      `number`:
 |          number of solutions to be sampled, by default
 |          population size ``popsize`` (AKA lambda)
 |      `xmean`:
 |          mean for sampling the solutions, by default ``self.mean``.
 |      `sigma_fac`:
 |          multiplier for sampling width, standard deviation, for example
 |          to get a small perturbation of solution `xmean`
 |      `evaluations`:
 |          number of evaluations for each sampled solution
 |      `aggregation`:
 |          function that aggregates `evaluations` values to
 |          as single value.
 |      `kappa`:
 |          multiplier used for the evaluation of the solutions, in
 |          that ``func(m + kappa*(x - m))`` is the f-value for ``x``.
 |
 |      Return
 |      ------
 |      ``(X, fit)``, where
 |
 |      - `X`: list of solutions
 |      - `fit`: list of respective function values
 |
 |      Details
 |      -------
 |      While ``not self.is_feasible(x, func(x))`` new solutions are
 |      sampled. By default
 |      ``self.is_feasible == cma.feasible == lambda x, f: f not in (None, np.nan)``.
 |      The argument to `func` can be freely modified within `func`.
 |
 |      Depending on the ``CMA_mirrors`` option, some solutions are not
 |      sampled independently but as mirrors of other bad solutions. This
 |      is a simple derandomization that can save 10-30% of the
 |      evaluations in particular with small populations, for example on
 |      the cigar function.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> x0, sigma0 = 8 * [10], 1  # 8-D
 |      >>> es = cma.CMAEvolutionStrategy(x0, sigma0)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> while not es.stop():
 |      ...     X, fit = es.ask_and_eval(cma.ff.elli)  # handles NaN with resampling
 |      ...     es.tell(X, fit)  # pass on fitness values
 |      ...     es.disp(20) # print every 20-th iteration  #doctest: +ELLIPSIS
 |      Iterat #Fevals...
 |      >>> print('terminated on ' + str(es.stop()))  #doctest: +ELLIPSIS
 |      terminated on ...
 |
 |      A single iteration step can be expressed in one line, such that
 |      an entire optimization after initialization becomes::
 |
 |          while not es.stop():
 |              es.tell(*es.ask_and_eval(cma.ff.elli))
 |
 |  ask_geno(self, number=None, xmean=None, sigma_fac=1, ignore_integer_variables=False)
 |      get new candidate solutions in genotyp.
 |
 |      Solutions are sampled from a multi-variate normal distribution.
 |
 |      Arguments are
 |          `number`
 |              number of returned solutions, by default the
 |              population size `popsize` (AKA lambda).
 |          `xmean`
 |              distribution mean
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `ignore_integer_variables`
 |              allows to not change integer variables at all which is in
 |              particular useful when a (small) mutation is added to a
 |              given solution.
 |
 |      `ask_geno` returns a list of N-dimensional candidate solutions
 |      in genotyp representation and is called by `ask`.
 |
 |      Details: updates the sample distribution if needed and might
 |      change the geno-pheno transformation during this update.
 |
 |      :See: `ask`, `ask_and_eval`
 |
 |  disp(self, modulo=None, overwrite=None)
 |      print current state variables in a single-line.
 |
 |      Prints only if ``iteration_counter % modulo == 0``.
 |      Overwrites the line after iteration `overwrite`.
 |
 |      :See also: `disp_annotation`.
 |
 |  disp_annotation(self)
 |      print annotation line for `disp` ()
 |
 |  feed_for_resume(self, X, function_values)
 |      Resume a run using the solution history.
 |
 |      CAVEAT: this hasn't been thoroughly tested or in intensive use.
 |
 |      Given all "previous" candidate solutions and their respective
 |      function values, the state of a `CMAEvolutionStrategy` object
 |      can be reconstructed from this history. This is the purpose of
 |      function `feed_for_resume`.
 |
 |      Arguments
 |      ---------
 |      `X`:
 |        (all) solution points in chronological order, phenotypic
 |        representation. The number of points must be a multiple
 |        of popsize.
 |      `function_values`:
 |        respective objective function values
 |
 |      Details
 |      -------
 |      `feed_for_resume` can be called repeatedly with only parts of
 |      the history. The part must have the length of a multiple
 |      of the population size.
 |      `feed_for_resume` feeds the history in popsize-chunks into `tell`.
 |      The state of the random number generator might not be
 |      reconstructed, but this would be only relevant for the future.
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |
 |          # prepare
 |          (x0, sigma0) = ... # initial values from previous trial
 |          X = ... # list of generated solutions from a previous trial
 |          f = ... # respective list of f-values
 |
 |          # resume
 |          es = cma.CMAEvolutionStrategy(x0, sigma0)
 |          es.feed_for_resume(X, f)
 |
 |          # continue with func as objective function
 |          while not es.stop():
 |              X = es.ask()
 |              es.tell(X, [func(x) for x in X])
 |
 |
 |      Credits to Dirk Bueche and Fabrice Marchal for the feeding idea.
 |
 |      :See also: class `CMAEvolutionStrategy` for a simple dump/load
 |          to resume.
 |
 |  get_mirror(self, x, preserve_length=False)
 |      return ``_round_int_variables(pheno(self.mean - (geno(x) - self.mean)))``
 |
 |      and update `sent_solutions` and `_round_integer_variables.archive` archives.
 |
 |      >>> import numpy as np, cma
 |      >>> es = cma.CMAEvolutionStrategy(np.random.randn(3), 1)  #doctest: +ELLIPSIS
 |      (3_w,...
 |      >>> x = np.random.randn(3)
 |      >>> assert cma.utilities.math.Mh.vequals_approximately(es.mean - (x - es.mean), es.get_mirror(x, preserve_length=True))
 |      >>> x = es.ask(1)[0]
 |      >>> vals = (es.get_mirror(x) - es.mean) / (x - es.mean)
 |      >>> assert cma.utilities.math.Mh.equals_approximately(sum(vals), len(vals) * vals[0])
 |
 |      TODO: this implementation is yet experimental.
 |
 |      TODO: this implementation includes geno-pheno transformation,
 |      however in general GP-transformation should be separated from
 |      specific code.
 |
 |      Selectively mirrored sampling improves to a moderate extend but
 |      overadditively with active CMA for quite understandable reasons.
 |
 |      Optimal number of mirrors are suprisingly small: 1,2,3 for
 |      maxlam=7,13,20 where 3,6,10 are the respective maximal possible
 |      mirrors that must be clearly suboptimal.
 |
 |  get_new_mean(self, X, F, G=None)
 |      return an updated mean based on the input arguments,
 |
 |      namely, the solutions `X` and the ranking implied by `F` and `G`.
 |      `G` is only used if the constraints handling is active. Elements of
 |      `X` are transformed to the genotype as by default, with repair and
 |      with accessing the sent solutions archive.
 |
 |      This method is meant to give a headsup _before_ to call `tell` of
 |      what the updated mean will be and can be useful, for example, for
 |      constraints surrogates.
 |
 |  get_selective_mirrors(self, number=None)
 |      get mirror genotypic directions from worst solutions.
 |
 |      Details:
 |
 |      To be called after the mean has been updated.
 |
 |      Takes the last ``number=sp.lam_mirr`` entries in the
 |      ``self.pop[self.fit.idx]`` as solutions to be mirrored.
 |
 |      Do not take a mirror if it is suspected to stem from a
 |      previous mirror in order to not go endlessly back and forth.
 |
 |  inject(self, solutions, force=None)
 |      inject list of one or several genotypic solution(s).
 |
 |      This is the preferable way to pass outside proposal solutions
 |      into `CMAEvolutionStrategy`. Passing (bad) solutions directly
 |      via `tell` is likely to fail when ``CMA_active is True`` as by
 |      default.
 |
 |      Unless ``force is True``, the `solutions` are used as direction
 |      relative to the distribution mean to compute a new candidate
 |      solution returned in method `ask_geno` which in turn is used in
 |      method `ask`. Even when ``force is True``, the update in `tell`
 |      takes later care of possibly trimming the update vector.
 |
 |      `inject` is to be called before `ask` or after `tell` and can be
 |      called repeatedly.
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(4 * [1], 2)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop():
 |      ...     es.inject([4 * [0.0]])
 |      ...     X = es.ask()
 |      ...     if es.countiter == 0:
 |      ...         assert X[0][0] == X[0][1]  # injected sol. is on the diagonal
 |      ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |
 |      Details: injected solutions are not used in the "active" update which
 |      would decrease variance in the covariance matrix in this direction.
 |
 |  limit_integer_relative_deltas(self, dX, threshold=None, recombination_weight_condition=None)
 |      versatile: limit absolute values of int-coordinates in vector list `dX`
 |
 |       relative to the current sample standard deviations and by default
 |       only when the respective recombination weight is negative.
 |
 |      This function is currently not in effect (called with threshold=inf)
 |      and not guarantied to stay as is.
 |
 |      ``dX == pop_sorted - mold`` where ``pop_sorted`` is a genotype.
 |
 |      ``threshold=2.3`` by default.
 |
 |      A 2.3-sigma threshold affects 2 x 1.1% of the unmodified
 |      (nonsorted) normal samples.
 |
 |  mahalanobis_norm(self, dx)
 |      return Mahalanobis norm based on the current sample
 |      distribution.
 |
 |      The norm is based on Covariance matrix ``C`` times ``sigma**2``,
 |      and includes ``sigma_vec``. The expected Mahalanobis distance to
 |      the sample mean is about ``sqrt(dimension)``.
 |
 |      Argument
 |      --------
 |      `dx`, a *genotype* difference to the distribution mean. As `dx` is
 |      interpreted as a difference to the mean, the return value does not
 |      depend on the current mean.
 |
 |      Example
 |      -------
 |      >>> import cma, numpy
 |      >>> es = cma.CMAEvolutionStrategy(numpy.ones(10), 1)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> xx = numpy.random.randn(2, 10)
 |      >>> d = es.mahalanobis_norm(es.gp.geno(xx[0]-xx[1]))
 |
 |      `d` is the distance "in" the true sample distribution,
 |      sampled points have a typical distance of ``sqrt(2*es.N)``,
 |      where ``es.N`` is the dimension, and an expected distance of
 |      close to ``sqrt(N)`` to the sample mean. In the example,
 |      `d` is the Euclidean distance, because C = I and sigma = 1.
 |
 |  manage_plateaus(self, sigma_fac=1.5, sample_fraction=0.5)
 |      increase `sigma` by `sigma_fac` in case of a plateau.
 |
 |      A plateau is assumed to be present if the best sample and
 |      ``popsize * sample_fraction``-th best sample have the same
 |      fitness.
 |
 |      Example:
 |
 |      >>> import cma
 |      >>> def f(X):
 |      ...     return (len(X) - 1) * [1] + [2]
 |      >>> es = cma.CMAEvolutionStrategy(4 * [0], 5, {'verbose':-9, 'tolflatfitness':1e4})
 |      >>> while not es.stop():
 |      ...     X = es.ask()
 |      ...     es.tell(X, f(X))
 |      ...     es.manage_plateaus()
 |      >>> if es.sigma < 1.5**es.countiter: print((es.sigma, 1.5**es.countiter, es.stop()))
 |
 |  pickle_dumps(self)
 |      return ``pickle.dumps(self)``,
 |
 |      if necessary remove unpickleable (and also unnecessary) local
 |      function reference beforehand.
 |
 |      The resulting `bytes` string-object can be saved to a file like::
 |
 |          import cma
 |          es = cma.CMAEvolutionStrategy(3 * [1], 1)
 |          es.optimize(cma.ff.elli, iterations=22)
 |          filename = 'es-pickle-test'
 |          open(filename, 'wb').write(es.pickle_dumps())
 |
 |      and recovered like::
 |
 |          import pickle
 |          es = pickle.load(open(filename, 'rb'))
 |
 |      or::
 |
 |          es = pickle.loads(open(filename, 'rb').read())
 |          es.optimize(cma.ff.elli, iterations=22)  # continue optimizing
 |
 |  plot(self, *args, **kwargs)
 |      plot current state variables using `matplotlib`.
 |
 |      This calls `self.logger.plot`, see `cma.CMADataLogger.plot` to see all
 |      valid keyword arguments.
 |
 |  random_rescale_to_mahalanobis(self, x)
 |      change `x` like for injection, all on genotypic level
 |
 |  repair_genotype(self, x, copy_if_changed=False)
 |      make sure that solutions fit to the sample distribution.
 |
 |      This interface is versatile and likely to change.
 |
 |      We currently assume that this is idempotent.
 |
 |      The Mahalanobis distance ``x - self.mean`` is clipping at
 |      ``N**0.5 + 2 * N / (N + 2)``, but the specific repair
 |      mechanism may change in future.
 |
 |  reset_options(self, **kwargs)
 |      clear termination and set any `CMAOptions` passed via
 |
 |      keyword arguments or like ``**opts_dict``. The validity of the option
 |      names is checked, the validity of the values is not checked.
 |
 |      Some resettings will not be effective. For those with a ``'#v'``
 |      flag in their description, the effectiveness is guarantied. See
 |      `CMAOptions`.
 |
 |      Return `self`, the new options are in ``self.opts``.
 |
 |  result_pretty(self, number_of_restarts=0, time_str=None, fbestever=None)
 |      pretty print result.
 |
 |      Returns `result` of ``self``.
 |
 |  stop(self, check=True, ignore_list=(), check_in_same_iteration=False, get_value=None)
 |      return the termination status as dictionary.
 |
 |      With ``check == False``, the termination conditions are not checked
 |      and the status might not reflect the current situation.
 |      ``check_on_same_iteration == False`` (new) does not re-check during
 |      the same iteration. When termination options are manually changed,
 |      it must be set to `True` to advance afterwards.
 |      ``stop().clear()`` removes the currently active termination
 |      conditions.
 |
 |      As a convenience feature, keywords in `ignore_list` are removed from
 |      the conditions.
 |
 |      If `get_value` is set to a condition name (not the empty string),
 |      `stop` does not update the termination dictionary but returns the
 |      measured value that would be compared to the threshold. This only
 |      works for some conditions, like 'tolx'. If the condition name is
 |      not known or cannot be computed, `None` is returned and no warning
 |      is issued.
 |
 |      Testing `get_value` functionality:
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(2 * [1], 1e4, {'verbose': -9})
 |      >>> with warnings.catch_warnings(record=True) as w:
 |      ...     es.stop(get_value='tolx')  # triggers zero iteration warning
 |      ...     assert len(w) == 1, [str(wi) for wi in w]
 |      >>> es = es.optimize(cma.ff.sphere, iterations=4)
 |      >>> assert 1e3 < es.stop(get_value='tolx') < 1e4, es.stop(get_value='tolx')
 |      >>> assert es.stop() == {}
 |      >>> assert es.stop(get_value='catch 22') is None
 |
 |  tell(self, solutions, function_values, check_points=None, copy=False, constraints_values=None)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  tell2(self, solutions, function_values, constraints_values=None, check_points=None, copy=False)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  to_phenotype(self, solution, *args, **kwargs)
 |      return integer-rounded phenotype depending on `round_integer_variables` module setting.
 |
 |      Without further arguments, `self.gp.pheno` is called with
 |      ``copy=True, into_bounds=self.boundary_handler.repair`` as
 |      additional arguments, otherwise ``*args, **kwargs`` are passed
 |      to `self.gp.pheno`.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  condition_number
 |      condition number of the statistical-model sampler.
 |
 |      Details: neither encoding/decoding from `sigma_vec`-scaling nor
 |      `gp`-transformation are taken into account for this computation.
 |
 |  isotropic_mean_shift
 |      normalized last mean shift, under random selection N(0,I)
 |
 |      distributed.
 |
 |      Caveat: while it is finite and close to sqrt(n) under random
 |      selection, the length of the normalized mean shift under
 |      *systematic* selection (e.g. on a linear function) tends to
 |      infinity for mueff -> infty. Hence it must be used with great
 |      care for large mueff.
 |
 |  popsize
 |      number of samples by default returned by `ask` ()
 |
 |  result
 |      return a `CMAEvolutionStrategyResult2` class instance.
 |
 |      :See: `cma.evolution_strategy.CMAEvolutionStrategyResult2`
 |          or try ``help(...result)`` on the ``result`` property
 |          of an `CMAEvolutionStrategy` instance or an
 |          `CMAEvolutionStrategyResult2` instance.
 |
 |  stds
 |      return array of coordinate-wise standard deviations (phenotypic).
 |
 |      Takes into account geno-phenotype transformation, step-size,
 |      diagonal decoding, and the covariance matrix. Only the latter three
 |      apply to `self.mean`.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from cma.interfaces.OOOptimizer:
 |
 |  initialize(self)
 |      (re-)set to the initial state
 |
 |  optimize(self, objective_fct, maxfun=None, iterations=None, min_iterations=1, args=(), verb_disp=None, callback=None, n_jobs=0, **kwargs)
 |      find minimizer of ``objective_fct``.
 |
 |      CAVEAT: the return value for `optimize` has changed to ``self``,
 |      allowing for a call like::
 |
 |          solver = OOOptimizer(x0).optimize(f)
 |
 |      and investigate the state of the solver.
 |
 |      Arguments
 |      ---------
 |
 |      ``objective_fct``: f(x: array_like) -> float
 |          function be to minimized
 |      ``maxfun``: number
 |          maximal number of function evaluations
 |      ``iterations``: number
 |          number of (maximal) iterations, while ``not self.stop()``,
 |          it can be useful to conduct only one iteration at a time.
 |      ``min_iterations``: number
 |          minimal number of iterations, even if ``not self.stop()``
 |      ``args``: sequence_like
 |          arguments passed to ``objective_fct``
 |      ``verb_disp``: number
 |          print to screen every ``verb_disp`` iteration, if `None`
 |          the value from ``self.logger`` is "inherited", if
 |          available.
 |      ``callback``: callable or list of callables
 |          callback function called like ``callback(self)`` or
 |          a list of call back functions called in the same way. If
 |          available, ``self.logger.add`` is added to this list.
 |          TODO: currently there is no way to prevent this other than
 |          changing the code of `_prepare_callback_list`.
 |      ``n_jobs=0``: number of processes to be acquired for
 |          multiprocessing to parallelize calls to `objective_fct`.
 |          Must be >1 to expect any speed-up or `None` or `-1`, which
 |          both default to the number of available CPUs. The default
 |          ``n_jobs=0`` avoids the use of multiprocessing altogether.
 |
 |      ``return self``, that is, the `OOOptimizer` instance.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(7 * [0.1], 0.1
 |      ...              ).optimize(cma.ff.rosen, verb_disp=100)
 |      ...                   #doctest: +ELLIPSIS
 |      (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 7 (seed=...)
 |      Iterat #Fevals   function value  axis ratio  sigma ...
 |          1      9 ...
 |          2     18 ...
 |          3     27 ...
 |        100    900 ...
 |      >>> cma.s.Mh.vequals_approximately(es.result[0], 7 * [1], 1e-5)
 |      True
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from cma.interfaces.OOOptimizer:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.CMADataLogger
Python Library Documentation: class CMADataLogger in module cma.logger

class CMADataLogger(cma.interfaces.BaseDataLogger)
 |  CMADataLogger(name_prefix='outcmaes\\', modulo=1, append=False, expensive_modulo=1)
 |
 |  data logger for class `CMAEvolutionStrategy`.
 |
 |  The logger is identified by its name prefix and (over-)writes or
 |  reads according data files. Therefore, the logger must be
 |  considered as *global* variable with unpredictable side effects,
 |  if two loggers with the same name and on the same working folder
 |  are used at the same time.
 |
 |  Examples
 |  ========
 |  ::
 |
 |      import cma
 |
 |      es = cma.CMAEvolutionStrategy(12 * [3], 4)
 |      es.optimize(cma.ff.elli, callback=es.logger.plot)
 |
 |  plots into the current `matplotlib` figure (or opens one if none
 |  exists) via a generic callback. ``es.optimize`` already adds by default
 |  ``es.logger.add`` to its callback list to add data to the logger. This
 |  call::
 |
 |      x, es = cma.fmin2(cma.ff.elli, 12 * [3], 4, {'verb_plot': 1})
 |
 |  is very similar, but plots hard-coded into figure number 324::
 |
 |      es = cma.CMAEvolutionStrategy(...)
 |      logger = cma.CMADataLogger().register(es)
 |      while not es.stop():
 |          ...
 |          logger.add()  # add can also take an argument
 |
 |      logger.plot() # or a short cut can be used:
 |      cma.plot()  # plot data from logger with default name into new figure
 |
 |      logger2 = cma.CMADataLogger('just_another_filename_prefix').load()
 |      logger2.plot()
 |      logger2.disp()
 |
 |      import cma
 |      from matplotlib.pylab import *
 |      res = cma.fmin(cma.ff.sphere, rand(10), 1e-0)
 |      logger = res[-1]  # the CMADataLogger
 |      logger.load()  # by "default" data are on disk
 |      semilogy(logger.f[:,0], logger.f[:,5])  # plot f versus iteration, see file header
 |      cma.s.figshow()
 |
 |  Details
 |  =======
 |  After loading data, the logger has the attributes `xmean`, `xrecent`,
 |  `std`, `f`, `D` and `corrspec` corresponding to ``xmean``,
 |  ``xrecentbest``, ``stddev``, ``fit``, ``axlen`` and ``axlencorr``
 |  filename trails.
 |
 |  :See: `disp` (), `plot` ()
 |
 |  Method resolution order:
 |      CMADataLogger
 |      cma.interfaces.BaseDataLogger
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, name_prefix='outcmaes\\', modulo=1, append=False, expensive_modulo=1)
 |      initialize logging of data from a `CMAEvolutionStrategy` instance.
 |
 |      Default ``modulo=1`` means logging with each call of `add`. If
 |      ``append is True`` data is appended to already existing data of a
 |      logger with the same name. Additional eigendecompositions are
 |      allowed only every `expensive_modulo`-th logged iteration.
 |
 |  add(self, es=None, more_data=(), modulo=None)
 |      append some logging data from `CMAEvolutionStrategy` class instance `es`,
 |      if ``number_of_times_called % modulo`` equals to zero, never if ``modulo==0``.
 |
 |      ``more_data`` is a list of additional data to be recorded where each
 |      data entry must have the same length.
 |
 |      When used for a different optimizer class, this function can be
 |      (easily?) adapted by changing the assignments under INTERFACE
 |      in the implemention.
 |
 |  disp(self, idx=100)
 |      displays selected data from (files written by) the class
 |      `CMADataLogger`.
 |
 |      Arguments
 |      ---------
 |         `idx`
 |             indices corresponding to rows in the data file;
 |             if idx is a scalar (int), the first two, then every idx-th,
 |             and the last three rows are displayed. Too large index
 |             values are removed. If ``idx=='header'``, the header
 |             line is printed.
 |
 |      Example
 |      -------
 |      >>> import cma, numpy as np
 |      >>> res = cma.fmin(cma.ff.elli, 7 * [0.1], 1, {'verb_disp':1e9})  # generate data
 |      ...  #doctest: +ELLIPSIS
 |      (4...
 |      >>> assert res[1] < 1e-9
 |      >>> assert res[2] < 4400
 |      >>> l = cma.CMADataLogger()  # == res[-1], logger with default name, "points to" above data
 |      >>> l.disp([0,-1])  # first and last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(20)  # some first/last and every 20-th line
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(np.r_[0:999999:100, -1]) # every 100-th and last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(np.r_[0, -10:0]) # first and ten last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> cma.disp(l.name_prefix, np.r_[0:9999999:100, -10:])  # the same as l.disp(...)
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |
 |      Details
 |      -------
 |      The data line with the best f-value is displayed as last line.
 |
 |      Use `CMADataLogger.disp` if the logger does not have the default
 |      name.
 |
 |      :See: `CMADataLogger.disp`, `CMADataLogger.disp`
 |
 |  disp_header(self)
 |
 |  downsampling(self, factor=10, first=3, switch=True, verbose=False)
 |      rude downsampling of a `CMADataLogger` data file by `factor`,
 |      keeping also the first `first` entries. This function is a
 |      stump and subject to future changes. Return self.
 |
 |      Arguments
 |      ---------
 |         - `factor` -- downsampling factor
 |         - `first` -- keep first `first` entries
 |         - `switch` -- switch the new logger to the downsampled logger
 |              original_name+'down'
 |
 |      Details
 |      -------
 |      ``self.name_prefix+'down'`` files are written
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |          cma.downsampling()  # takes outcma/cma* files
 |          cma.plot('outcma/cmadown')
 |
 |  figclose(self)
 |
 |  initialize(self, modulo=None)
 |      reset logger, overwrite original files, `modulo`: log only every modulo call
 |
 |  load(self, filenameprefix=None)
 |      load (or reload) data from output files, `load` is called in
 |      `plot` and `disp`.
 |
 |      Argument `filenameprefix` is the filename prefix of data to be
 |      loaded (5-8 files), by default ``'outcmaes/'`` (where / stands
 |      for the OS-specific path seperator).
 |
 |      Return self with (added) attributes `xrecent`, `xmean`,
 |      `f`, `D`, `std`, `corrspec`, `sigvec`.
 |
 |  plot(self, fig=None, iabscissa=0, iteridx=None, plot_mean=False, foffset=1e-19, x_opt=None, fontsize=7, downsample_to=10000000.0, xsemilog=False, xnormalize=False, xtransform=None, fshift=0, addcols=None, load=True, message='', remove_sigma=True, normalize_scaling=False, **kwargs)
 |      plot data from a `CMADataLogger` using files written by the logger.
 |
 |      Arguments
 |      ---------
 |      `fig`: figure number, by default starting from 325
 |
 |      `iabscissa` or `abscissa`: ``0 ==>`` plot versus iteration count,
 |      ``1 ==>`` plot versus function evaluation number
 |
 |      `iteridx`: the iteration indices to plot, e.g. ``range(100)`` for
 |      the first 100 evaluations.
 |
 |      ``plot_mean in (True, False, 'log', 'lin', 'linear', 'only')`` indicates
 |      whether and how to plot the mean (possibly instead the current best)
 |
 |      `foffset:float` a small value added to f values to improve log-plot
 |      appearance.
 |
 |      `downsample_to`: number of data lines to use at most
 |
 |      `x_opt`: plot x-values as a difference to another solution and/or
 |      select a subset of variables to plot.
 |
 |      If `x_opt` is a nonnegative `int`, it is interpreted as
 |      iteration number and the difference of ``x`` to the respective
 |      (closest but not larger) iteration is plotted.
 |
 |      If `x_opt` is a negative `int` the respective index rather than
 |      the iteration is used. Namely and in particular, ``x_opt=0``
 |      subtracts the initial solution ``X0`` and ``x_opt=-1``
 |      subtracts the final solution of the data.
 |
 |      If ``len(x_opt) == dimension`` or `x_opt` is a float, the
 |      difference to `x_opt` is plotted.
 |
 |      Otherwise: ``x_opt[0]`` defines the indices of the variables to
 |      be plotted where ``x_opt[1]``, if present, is subtracted.
 |
 |      `xsemilog:bool`: customized semilog plot for x-values
 |
 |      `xnormalize:bool`: divide x-values by standard deviations, may show stationary
 |          behavior when the optimum is in zero
 |
 |      `xtransform:callable` is a function that returns transformed x-values,
 |      applied before `x_opt` is subtracted and `xnormalize` is done.
 |
 |      `fshift:float` is added to all displayed fitness values
 |
 |      `addcols:int` is the number of added columns for additional subplots
 |
 |      `load:bool=True`: load/reload data before to try plotting. Useful
 |      as a `CMADataLogger` instance itself does not load data by default.
 |
 |      `message:str`: a message text appearing in the plot
 |
 |      `remove_sigma`: disregard `sigma` when plotting individual standard
 |      deviations.
 |
 |      `normalize_scaling`: plot axis scaling normalized with the geometric
 |      average in each iteration.
 |
 |      Return `CMADataLogger` itself.
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |          logger = cma.CMADataLogger()  # with default name
 |          logger.plot()
 |          cma.s.figsave('fig325.png')  # save current figure
 |          logger.figclose()  # or cma.s.figclose()
 |
 |      Details
 |      -------
 |      Data from codes in other languages (C, Java, Matlab, Scilab) have the same
 |      format and can be plotted just the same.
 |
 |      Dependencies: matlabplotlib.pyplot
 |
 |      :See: `cma.plot` alias `cma.logger.plot`
 |
 |  plot_all(self, fig=None, iabscissa=0, iteridx=None, foffset=1e-19, x_opt=None, fontsize=7)
 |      Obsolete: plot data from a `CMADataLogger` (using the files written by the logger).
 |
 |      Superseded by `CMADataLogger.plot`
 |
 |      Arguments
 |      ---------
 |      See `CMADataLogger.plot`
 |
 |      Return `CMADataLogger` itself.
 |
 |  plot_axes_scaling(self, iabscissa=0, normalize=False)
 |
 |  plot_correlations(self, iabscissa=0, name='corrspec')
 |      spectrum of correlation or precision matrix and percentiles of off-diagonal entries
 |
 |  plot_divers(self, iabscissa=0, foffset=1e-19, fshift=0, message=None)
 |      plot fitness, sigma, axis ratio...
 |
 |      :param iabscissa: 0 means vs evaluations, 1 means vs iterations
 |      :param foffset: added to f-value after abs(f) is taken
 |
 |      :See: `plot`
 |
 |  plot_estimated_errors(self, x_opt=None, markerscaler=10, log_threshold=0.05, dim_exponent=1, multiplier=None, plot_kwargs={})
 |      [WIP] experimental
 |
 |      `multiplier` takes dimension and mueff as input and computes the error
 |      multiplier. The soon to be expired default value was ``dim**0.5 * 3
 |      / min((popsize, 3 * dim + 15))``.
 |
 |      The trust is defined as ``-max_i(Delta log(sigma * D_ii))`` and is high when all axes diminish.
 |
 |  plot_mean(self, iabscissa=0, x_opt=None, annotations=None, xsemilog=None, xnormalize=None)
 |
 |  plot_sensitivities(self, plot_absolute=False, gradf=None)
 |      [WIP] experimental
 |
 |      Plot IQR(f) / IQR(std_i). The donimator is computed as 1.349 x
 |      std_i x sqrt(n). The sqrt(n) accounts for the effect of the
 |      changes in all other variables on f.
 |
 |  plot_sigvec(self, iabscissa=0, idx=None)
 |      plot (outer) scaling from diagonal decoding.
 |
 |      ``iabscissa=1`` plots vs function evaluations
 |
 |      `idx` picks variables to plot if len(idx) < N, otherwise it picks
 |      iteration indices (in case, after downsampling).
 |
 |  plot_stds(self, iabscissa=0, idx=None, remove_sigma=True)
 |      ``iabscissa=1`` means vs function evaluations, `idx` picks variables to plot
 |
 |  plot_xrecent(self, iabscissa=0, x_opt=None, annotations=None, xsemilog=None, xnormalize=None)
 |
 |  popsize(self, data_field='f')
 |      return median popsize from iteration and evaluation data
 |
 |  register(self, es, append=None, modulo=None)
 |      register a `CMAEvolutionStrategy` instance for logging,
 |      ``append=True`` appends to previous data logged under the same name,
 |      by default previous data are overwritten.
 |
 |  save(self, name=None)
 |      data are saved to disk the moment they are added
 |
 |  save_to(self, nameprefix, switch=False)
 |      saves logger data to a different set of files, for
 |      ``switch=True`` also the loggers name prefix is switched to
 |      the new value
 |
 |  select_data(self, iteration_indices)
 |      keep only data of `iteration_indices`
 |
 |  zip(self, filename=None, unique=True)
 |      write logger data to file ``filename [+ ...] + '.tar.gz'``.
 |
 |      `filename` defaults to ``self.name_prefix``.
 |
 |      When `unique` is true, `filename` is furnished with a unique time
 |      stamp.
 |
 |      Return the path (relative or absolute) of the output file.
 |
 |      This function does in essence just ``tar -czf filename.tar.gz folder``
 |      where ``folder`` defaults to the current plot data folder and
 |      ``filename`` is created to be unique.
 |
 |      TODO: we may want to be able to add a time stamp to the folder name
 |      too, to prevent conficts later?
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  data
 |      return dictionary with data.
 |
 |      If data entries are None or incomplete, consider calling
 |      ``.load().data`` to (re-)load the data from files first.
 |
 |  mueff
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  default_prefix = r'outcmaes\'
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from cma.interfaces.BaseDataLogger:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.CMAEvolutionStrategy
Python Library Documentation: class CMAEvolutionStrategy in module cma.evolution_strategy

class CMAEvolutionStrategy(cma.interfaces.OOOptimizer)
 |  CMAEvolutionStrategy(x0, sigma0, inopts=None, options=None)
 |
 |  CMA-ES stochastic optimizer class with ask-and-tell interface.
 |
 |  Calling Sequences
 |  =================
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0, opts)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0).optimize(objective_fct)``
 |
 |  - ::
 |
 |      res = CMAEvolutionStrategy(x0, sigma0,
 |                              opts).optimize(objective_fct).result
 |
 |  Arguments
 |  =========
 |  `x0`
 |      initial solution, starting point. `x0` is given as "phenotype"
 |      which means, if::
 |
 |          opts = {'transformation': [transform, inverse]}
 |
 |      is given and ``inverse is None``, the initial mean is not
 |      consistent with `x0` in that ``transform(mean)`` does not
 |      equal to `x0` unless ``transform(mean)`` equals ``mean``.
 |  `sigma0`
 |      initial standard deviation.  The problem variables should
 |      have been scaled, such that a single standard deviation
 |      on all variables is useful and the optimum is expected to
 |      lie within about `x0` +- ``3*sigma0``. Often one wants to
 |      check for solutions close to the initial point. This allows,
 |      for example, for an easier check of consistency of the
 |      objective function and its interfacing with the optimizer.
 |      In this case, a much smaller `sigma0` is advisable.
 |  `opts`
 |      options, a dictionary with optional settings,
 |      see class `CMAOptions`.
 |
 |  Main interface / usage
 |  ======================
 |  The interface is inherited from the generic `OOOptimizer`
 |  class (see also there). An object instance is generated from::
 |
 |      es = cma.CMAEvolutionStrategy(8 * [0.5], 0.2)
 |
 |  The least verbose interface is via the optimize method::
 |
 |      es.optimize(objective_func)
 |      res = es.result
 |
 |  More verbosely, the optimization is done using the
 |  methods `stop`, `ask`, and `tell`::
 |
 |      while not es.stop():
 |          solutions = es.ask()
 |          es.tell(solutions, [cma.ff.rosen(s) for s in solutions])
 |          es.disp()
 |      es.result_pretty()
 |
 |
 |  where `ask` delivers new candidate solutions and `tell` updates
 |  the `optim` instance by passing the respective function values
 |  (the objective function `cma.ff.rosen` can be replaced by any
 |  properly defined objective function, see `cma.ff` for more
 |  examples).
 |
 |  To change an option, for example a termination condition to
 |  continue the optimization, call::
 |
 |      es.opts.set({'tolfacupx': 1e4})
 |
 |  The class `CMAEvolutionStrategy` also provides::
 |
 |      (solutions, func_values) = es.ask_and_eval(objective_func)
 |
 |  and an entire optimization can also be written like::
 |
 |      while not es.stop():
 |          es.tell(*es.ask_and_eval(objective_func))
 |
 |  Besides for termination criteria, in CMA-ES only the ranks of the
 |  `func_values` are relevant.
 |
 |  Attributes and Properties
 |  =========================
 |  - `inputargs`: passed input arguments
 |  - `inopts`: passed options
 |  - `opts`: actually used options, some of them can be changed any
 |    time via ``opts.set``, see class `CMAOptions`
 |  - `popsize`: population size lambda, number of candidate
 |    solutions returned by `ask` ()
 |  - `logger`: a `CMADataLogger` instance utilized by `optimize`
 |
 |  Examples
 |  ========
 |  Super-short example, with output shown:
 |
 |  >>> import cma
 |  >>> # construct an object instance in 4-D, sigma0=1:
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1, {'seed':234})
 |  ...      # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=234...)
 |
 |  and optimize the ellipsoid function
 |
 |  >>> es.optimize(cma.ff.elli, verb_disp=1)  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 2.09...
 |  >>> assert len(es.result) >= 8, es.result
 |  >>> assert es.result.fbest < 1e-9, es.result
 |
 |  The optimization loop can also be written explicitly:
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1)  # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=...
 |  >>> while not es.stop():
 |  ...    X = es.ask()
 |  ...    es.tell(X, [cma.ff.elli(x) for x in X])
 |  ...    es.disp()  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 ...
 |
 |  achieving the same result as above.
 |
 |  An example with lower bounds (at zero) and handling infeasible
 |  solutions:
 |
 |  >>> import numpy as np
 |  >>> es = cma.CMAEvolutionStrategy(10 * [0.2], 0.5,
 |  ...         {'bounds': [0, np.inf]})  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> while not es.stop():
 |  ...     fit, X = [], []
 |  ...     while len(X) < es.popsize:
 |  ...         curr_fit = None
 |  ...         while curr_fit in (None, np.nan):
 |  ...             x = es.ask(1)[0]
 |  ...             curr_fit = cma.ff.somenan(x, cma.ff.elli) # might return np.nan
 |  ...         X.append(x)
 |  ...         fit.append(curr_fit)
 |  ...     es.tell(X, fit)
 |  ...     es.logger.add()
 |  ...     es.disp()  #doctest: +ELLIPSIS
 |  Itera...
 |  >>>
 |  >>> assert es.result.fbest < 1e-9, es.result
 |  >>> assert es.result.evals_best < 9000, es.result  # by internal termination
 |  >>> # es.logger.plot()  # will plot data
 |  >>> # cma.s.figshow()  # display plot window
 |
 |  An example with user-defined transformation, in this case to realize
 |  a lower bound of 2.
 |
 |  >>> import warnings
 |  >>> with warnings.catch_warnings(record=True) as warns:
 |  ...     es = cma.CMAEvolutionStrategy(5 * [3], 0.1,
 |  ...                 {"transformation": [lambda x: x**2+1.2, None],
 |  ...                  "ftarget": 1e-7 + 5.54781521192,
 |  ...                  "verbose": -2,})
 |  >>> warns[0].message  # doctest:+ELLIPSIS
 |  UserWarning('in class GenoPheno: user defined transformations have not been tested thoroughly (...
 |  >>> warns[1].message  # doctest:+ELLIPSIS
 |  UserWarning('computed initial point...
 |  >>> es.optimize(cma.ff.rosen, verb_disp=0)  #doctest: +ELLIPSIS
 |  <cma...
 |  >>> assert cma.ff.rosen(es.result.xbest) < 1e-7 + 5.54781521192, es.result
 |  >>> assert es.result.evals_best < 3300, es.result
 |
 |  The inverse transformation is (only) necessary if the `BoundPenalty`
 |  boundary handler is used at the same time.
 |
 |  The `CMAEvolutionStrategy` class also provides a default logger
 |  (cave: files are overwritten when the logger is used with the same
 |  filename prefix):
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [0.2], 0.5, {'verb_disp': 0})
 |  >>> es.logger.disp_header()  # annotate the print of disp
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> while not es.stop():
 |  ...     X = es.ask()
 |  ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |  ...     es.logger.add()  # log current iteration
 |  ...     es.logger.disp([-1])  # display info for last iteration   #doctest: +ELLIPSIS
 |      1  ...
 |  >>> es.logger.disp_header()
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> # es.logger.plot() # will make a plot
 |
 |  Example implementing restarts with increasing popsize (IPOP):
 |
 |  >>> bestever = cma.optimization_tools.BestSolution()
 |  >>> for lam in 10 * 2**np.arange(8):  # 10, 20, 40, 80, ..., 10 * 2**7
 |  ...     es = cma.CMAEvolutionStrategy(6 - 8 * np.random.rand(4),  # 4-D
 |  ...                                   5,  # initial std sigma0
 |  ...                                   {'popsize': lam,  # options
 |  ...                                    'verb_append': bestever.evalsall})
 |  ...     # logger = cma.CMADataLogger().register(es, append=bestever.evalsall)
 |  ...     while not es.stop():
 |  ...         X = es.ask()    # get list of new solutions
 |  ...         fit = [cma.ff.rastrigin(x) for x in X]  # evaluate each solution
 |  ...         es.tell(X, fit) # besides for termination only the ranking in fit is used
 |  ...
 |  ...         # display some output
 |  ...         # logger.add()  # add a "data point" to the log, writing in files
 |  ...         es.disp()  # uses option verb_disp with default 100
 |  ...
 |  ...     print('termination:', es.stop())
 |  ...     cma.s.pprint(es.best.__dict__)
 |  ...
 |  ...     bestever.update(es.best)
 |  ...
 |  ...     # show a plot
 |  ...     # logger.plot();
 |  ...     if bestever.f < 1e-8:  # global optimum was hit
 |  ...         break  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> assert es.result.fbest < 1e-8, es.result
 |
 |  On the Rastrigin function, usually after five restarts the global
 |  optimum is located.
 |
 |  Using the `multiprocessing` module, we can evaluate the function in
 |  parallel with a simple modification of the example (however
 |  multiprocessing seems not always reliable):
 |
 |  >>> from cma.fitness_functions import elli  # cannot be an instance method
 |  >>> from cma.optimization_tools import EvalParallel2
 |  >>> es = cma.CMAEvolutionStrategy(22 * [0.0], 1.0, {'maxiter':10})  # doctest:+ELLIPSIS
 |  (6_w,13)-aCMA-ES (mu_w=...
 |  >>> with EvalParallel2(elli, es.popsize + 1) as eval_all:
 |  ...     while not es.stop():
 |  ...         X = es.ask()
 |  ...         es.tell(X, eval_all(X))
 |  ...         es.disp()
 |  ...         # es.logger.add()  # doctest:+ELLIPSIS
 |  Iterat...
 |
 |  The final example shows how to resume:
 |
 |  >>> import pickle
 |  >>>
 |  >>> es0 = cma.CMAEvolutionStrategy(12 * [0.1],  # a new instance, 12-D
 |  ...                                0.12)         # initial std sigma0
 |  ...   #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> es0.optimize(cma.ff.rosen, iterations=100)  #doctest: +ELLIPSIS
 |  I...
 |  >>> s = es0.pickle_dumps()  # return pickle.dumps(es) with safeguards
 |  >>> # save string s to file like open(filename, 'wb').write(s)
 |  >>> del es0  # let's start fresh
 |  >>> # s = open(filename, 'rb').read()  # load string s from file
 |  >>> es = pickle.loads(s)  # read back es instance from string
 |  >>> # resuming
 |  >>> es.optimize(cma.ff.rosen, verb_disp=200)  #doctest: +ELLIPSIS
 |    200 ...
 |  >>> assert es.result.evals_best < 15000, es.result
 |  >>> assert cma.s.Mh.vequals_approximately(es.result.xbest, 12 * [1], 1e-5), es.result
 |  >>> assert len(es.result) >= 8, es.result
 |
 |  Details
 |  =======
 |  The following two enhancements are implemented, the latter is only
 |  turned on by default for very small population sizes.
 |
 |  *Active CMA* is implemented with option ``CMA_active`` and
 |  conducts an update of the covariance matrix with negative weights.
 |  The negative update is implemented, such that positive definiteness
 |  is guarantied. A typical speed up factor (number of f-evaluations)
 |  is between 1.1 and two.
 |
 |  References: Jastrebski and Arnold, Improving evolution strategies
 |  through active covariance matrix adaptation, CEC 2006.
 |  Hansen, The CMA evolution strategy: a tutorial, arXiv 2016.
 |
 |  *Selective mirroring* is implemented with option ``CMA_mirrors``
 |  in the method `get_mirror` and `get_selective_mirrors`.
 |  The method `ask_and_eval` (used by `fmin`) will then sample
 |  selectively mirrored vectors within the iteration
 |  (``CMA_mirrormethod==1``). Otherwise, or if ``CMA_mirromethod==2``,
 |  selective mirrors are injected for the next iteration.
 |  In selective mirroring, only the worst solutions are mirrored. With
 |  the default small number of mirrors, *pairwise selection* (where at
 |  most one of the two mirrors contribute to the update of the
 |  distribution mean) is implicitly guarantied under selective
 |  mirroring and therefore not explicitly implemented.
 |
 |  Update: pairwise selection for injected mirrors is also applied in the
 |  covariance matrix update: for all injected solutions, as for those from
 |  TPA, this is now implemented in that the recombination weights are
 |  constrained to be nonnegative for injected solutions in the covariance
 |  matrix (otherwise recombination weights are anyway nonnegative). This
 |  is a precaution to prevent failure when injected solutions are
 |  systematically bad (see e.g. https://github.com/CMA-ES/pycma/issues/124),
 |  but may not be "optimal" for mirrors.
 |
 |  References: Brockhoff et al, PPSN 2010, Auger et al, GECCO 2011.
 |
 |  :See also: `fmin` (), `OOOptimizer`, `CMAOptions`, `plot` (), `ask` (),
 |      `tell` (), `ask_and_eval` ()
 |
 |  Method resolution order:
 |      CMAEvolutionStrategy
 |      cma.interfaces.OOOptimizer
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, x0, sigma0, inopts=None, options=None)
 |      see class `CMAEvolutionStrategy`
 |
 |      `options` is for consistency with `fmin2` options and is only
 |      in effect if ``inopts is None``.
 |
 |  alleviate_conditioning(self, condition=1000000000000.0)
 |      pass conditioning of `C` to linear transformation in `self.gp`.
 |
 |      Argument `condition` defines the limit condition number above
 |      which the action is taken.
 |
 |      >>> import cma
 |      >>> for dd in [0, 1]:
 |      ...     es = cma.CMA(2 * [1], 0.1, {'CMA_diagonal_decoding' : dd, 'verbose':-9})
 |      ...     es = es.optimize(cma.ff.elli, iterations=4)
 |      ...     es.alleviate_conditioning(1.01)  # check that alleviation_conditioning "works"
 |      ...     assert all(es.sigma_vec.scaling == [1, 1]), es.sigma_vec.scaling
 |      ...     assert es.sm.condition_number <= 1.01, es.sm.C
 |
 |      Details: the action applies only if `self.gp.isidentity`. Then,
 |      the covariance matrix `C` is set (back) to identity and a
 |      respective linear transformation is "added" to `self.gp`.
 |
 |  alleviate_conditioning_in_coordinates(self, condition=100000000.0)
 |      pass scaling from `C` to `sigma_vec`.
 |
 |      As a result, `C` is a correlation matrix, i.e., all diagonal
 |      entries of `C` are `1`.
 |
 |  ask(self, number=None, xmean=None, sigma_fac=1, gradf=None, args=(), **kwargs)
 |      get/sample new candidate solutions.
 |
 |      Solutions are sampled from a multi-variate
 |      normal distribution and transformed to f-representation
 |      (phenotype) to be evaluated.
 |
 |      Arguments
 |      ---------
 |          `number`
 |              number of returned solutions, by default the
 |              population size ``popsize`` (AKA ``lambda``).
 |          `xmean`
 |              distribution mean, phenotyp?
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `gradf`
 |              gradient, ``len(gradf(x)) == len(x)``, if
 |              ``gradf is not None`` the third solution in the
 |              returned list is "sampled" in supposedly Newton
 |              direction ``np.dot(C, gradf(xmean, *args))``.
 |          `args`
 |              additional arguments passed to gradf
 |          `kwargs`
 |              if `ignore_integer_variables` do not change integer
 |              variables at all which is in particular useful when a small
 |              mutation is added to a given solution and integer values
 |              are not supposed to be disturbed at all and/or moved across
 |              a plateau boundary.
 |
 |      Return
 |      ------
 |      A list of N-dimensional candidate solutions to be evaluated
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy([0,0,0,0], 0.3)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop() and es.best.f > 1e-6:
 |      ...     X = es.ask()  # get list of new solutions
 |      ...     fit = [cma.ff.rosen(x) for x in X]  # call fct with each solution
 |      ...     es.tell(X, fit)  # feed values
 |
 |      :See: `ask_and_eval`, `ask_geno`, `tell`
 |
 |  ask_and_eval(self, func, args=(), gradf=None, number=None, xmean=None, sigma_fac=1, evaluations=1, aggregation=<function median at 0x000002897F5C4170>, kappa=1, parallel_mode=False)
 |      sample `number` solutions and evaluate them on `func`.
 |
 |      Each solution ``s`` is resampled until
 |      ``self.is_feasible(s, func(s)) is True``.
 |
 |      Arguments
 |      ---------
 |      `func`:
 |          objective function, ``func(x)`` accepts a `numpy.ndarray`
 |          and returns a scalar ``if not parallel_mode``. Else returns a
 |          `list` of scalars from a `list` of `numpy.ndarray`.
 |      `args`:
 |          additional parameters for `func`
 |      `gradf`:
 |          gradient of objective function, ``g = gradf(x, *args)``
 |          must satisfy ``len(g) == len(x)``
 |      `number`:
 |          number of solutions to be sampled, by default
 |          population size ``popsize`` (AKA lambda)
 |      `xmean`:
 |          mean for sampling the solutions, by default ``self.mean``.
 |      `sigma_fac`:
 |          multiplier for sampling width, standard deviation, for example
 |          to get a small perturbation of solution `xmean`
 |      `evaluations`:
 |          number of evaluations for each sampled solution
 |      `aggregation`:
 |          function that aggregates `evaluations` values to
 |          as single value.
 |      `kappa`:
 |          multiplier used for the evaluation of the solutions, in
 |          that ``func(m + kappa*(x - m))`` is the f-value for ``x``.
 |
 |      Return
 |      ------
 |      ``(X, fit)``, where
 |
 |      - `X`: list of solutions
 |      - `fit`: list of respective function values
 |
 |      Details
 |      -------
 |      While ``not self.is_feasible(x, func(x))`` new solutions are
 |      sampled. By default
 |      ``self.is_feasible == cma.feasible == lambda x, f: f not in (None, np.nan)``.
 |      The argument to `func` can be freely modified within `func`.
 |
 |      Depending on the ``CMA_mirrors`` option, some solutions are not
 |      sampled independently but as mirrors of other bad solutions. This
 |      is a simple derandomization that can save 10-30% of the
 |      evaluations in particular with small populations, for example on
 |      the cigar function.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> x0, sigma0 = 8 * [10], 1  # 8-D
 |      >>> es = cma.CMAEvolutionStrategy(x0, sigma0)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> while not es.stop():
 |      ...     X, fit = es.ask_and_eval(cma.ff.elli)  # handles NaN with resampling
 |      ...     es.tell(X, fit)  # pass on fitness values
 |      ...     es.disp(20) # print every 20-th iteration  #doctest: +ELLIPSIS
 |      Iterat #Fevals...
 |      >>> print('terminated on ' + str(es.stop()))  #doctest: +ELLIPSIS
 |      terminated on ...
 |
 |      A single iteration step can be expressed in one line, such that
 |      an entire optimization after initialization becomes::
 |
 |          while not es.stop():
 |              es.tell(*es.ask_and_eval(cma.ff.elli))
 |
 |  ask_geno(self, number=None, xmean=None, sigma_fac=1, ignore_integer_variables=False)
 |      get new candidate solutions in genotyp.
 |
 |      Solutions are sampled from a multi-variate normal distribution.
 |
 |      Arguments are
 |          `number`
 |              number of returned solutions, by default the
 |              population size `popsize` (AKA lambda).
 |          `xmean`
 |              distribution mean
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `ignore_integer_variables`
 |              allows to not change integer variables at all which is in
 |              particular useful when a (small) mutation is added to a
 |              given solution.
 |
 |      `ask_geno` returns a list of N-dimensional candidate solutions
 |      in genotyp representation and is called by `ask`.
 |
 |      Details: updates the sample distribution if needed and might
 |      change the geno-pheno transformation during this update.
 |
 |      :See: `ask`, `ask_and_eval`
 |
 |  disp(self, modulo=None, overwrite=None)
 |      print current state variables in a single-line.
 |
 |      Prints only if ``iteration_counter % modulo == 0``.
 |      Overwrites the line after iteration `overwrite`.
 |
 |      :See also: `disp_annotation`.
 |
 |  disp_annotation(self)
 |      print annotation line for `disp` ()
 |
 |  feed_for_resume(self, X, function_values)
 |      Resume a run using the solution history.
 |
 |      CAVEAT: this hasn't been thoroughly tested or in intensive use.
 |
 |      Given all "previous" candidate solutions and their respective
 |      function values, the state of a `CMAEvolutionStrategy` object
 |      can be reconstructed from this history. This is the purpose of
 |      function `feed_for_resume`.
 |
 |      Arguments
 |      ---------
 |      `X`:
 |        (all) solution points in chronological order, phenotypic
 |        representation. The number of points must be a multiple
 |        of popsize.
 |      `function_values`:
 |        respective objective function values
 |
 |      Details
 |      -------
 |      `feed_for_resume` can be called repeatedly with only parts of
 |      the history. The part must have the length of a multiple
 |      of the population size.
 |      `feed_for_resume` feeds the history in popsize-chunks into `tell`.
 |      The state of the random number generator might not be
 |      reconstructed, but this would be only relevant for the future.
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |
 |          # prepare
 |          (x0, sigma0) = ... # initial values from previous trial
 |          X = ... # list of generated solutions from a previous trial
 |          f = ... # respective list of f-values
 |
 |          # resume
 |          es = cma.CMAEvolutionStrategy(x0, sigma0)
 |          es.feed_for_resume(X, f)
 |
 |          # continue with func as objective function
 |          while not es.stop():
 |              X = es.ask()
 |              es.tell(X, [func(x) for x in X])
 |
 |
 |      Credits to Dirk Bueche and Fabrice Marchal for the feeding idea.
 |
 |      :See also: class `CMAEvolutionStrategy` for a simple dump/load
 |          to resume.
 |
 |  get_mirror(self, x, preserve_length=False)
 |      return ``_round_int_variables(pheno(self.mean - (geno(x) - self.mean)))``
 |
 |      and update `sent_solutions` and `_round_integer_variables.archive` archives.
 |
 |      >>> import numpy as np, cma
 |      >>> es = cma.CMAEvolutionStrategy(np.random.randn(3), 1)  #doctest: +ELLIPSIS
 |      (3_w,...
 |      >>> x = np.random.randn(3)
 |      >>> assert cma.utilities.math.Mh.vequals_approximately(es.mean - (x - es.mean), es.get_mirror(x, preserve_length=True))
 |      >>> x = es.ask(1)[0]
 |      >>> vals = (es.get_mirror(x) - es.mean) / (x - es.mean)
 |      >>> assert cma.utilities.math.Mh.equals_approximately(sum(vals), len(vals) * vals[0])
 |
 |      TODO: this implementation is yet experimental.
 |
 |      TODO: this implementation includes geno-pheno transformation,
 |      however in general GP-transformation should be separated from
 |      specific code.
 |
 |      Selectively mirrored sampling improves to a moderate extend but
 |      overadditively with active CMA for quite understandable reasons.
 |
 |      Optimal number of mirrors are suprisingly small: 1,2,3 for
 |      maxlam=7,13,20 where 3,6,10 are the respective maximal possible
 |      mirrors that must be clearly suboptimal.
 |
 |  get_new_mean(self, X, F, G=None)
 |      return an updated mean based on the input arguments,
 |
 |      namely, the solutions `X` and the ranking implied by `F` and `G`.
 |      `G` is only used if the constraints handling is active. Elements of
 |      `X` are transformed to the genotype as by default, with repair and
 |      with accessing the sent solutions archive.
 |
 |      This method is meant to give a headsup _before_ to call `tell` of
 |      what the updated mean will be and can be useful, for example, for
 |      constraints surrogates.
 |
 |  get_selective_mirrors(self, number=None)
 |      get mirror genotypic directions from worst solutions.
 |
 |      Details:
 |
 |      To be called after the mean has been updated.
 |
 |      Takes the last ``number=sp.lam_mirr`` entries in the
 |      ``self.pop[self.fit.idx]`` as solutions to be mirrored.
 |
 |      Do not take a mirror if it is suspected to stem from a
 |      previous mirror in order to not go endlessly back and forth.
 |
 |  inject(self, solutions, force=None)
 |      inject list of one or several genotypic solution(s).
 |
 |      This is the preferable way to pass outside proposal solutions
 |      into `CMAEvolutionStrategy`. Passing (bad) solutions directly
 |      via `tell` is likely to fail when ``CMA_active is True`` as by
 |      default.
 |
 |      Unless ``force is True``, the `solutions` are used as direction
 |      relative to the distribution mean to compute a new candidate
 |      solution returned in method `ask_geno` which in turn is used in
 |      method `ask`. Even when ``force is True``, the update in `tell`
 |      takes later care of possibly trimming the update vector.
 |
 |      `inject` is to be called before `ask` or after `tell` and can be
 |      called repeatedly.
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(4 * [1], 2)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop():
 |      ...     es.inject([4 * [0.0]])
 |      ...     X = es.ask()
 |      ...     if es.countiter == 0:
 |      ...         assert X[0][0] == X[0][1]  # injected sol. is on the diagonal
 |      ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |
 |      Details: injected solutions are not used in the "active" update which
 |      would decrease variance in the covariance matrix in this direction.
 |
 |  limit_integer_relative_deltas(self, dX, threshold=None, recombination_weight_condition=None)
 |      versatile: limit absolute values of int-coordinates in vector list `dX`
 |
 |       relative to the current sample standard deviations and by default
 |       only when the respective recombination weight is negative.
 |
 |      This function is currently not in effect (called with threshold=inf)
 |      and not guarantied to stay as is.
 |
 |      ``dX == pop_sorted - mold`` where ``pop_sorted`` is a genotype.
 |
 |      ``threshold=2.3`` by default.
 |
 |      A 2.3-sigma threshold affects 2 x 1.1% of the unmodified
 |      (nonsorted) normal samples.
 |
 |  mahalanobis_norm(self, dx)
 |      return Mahalanobis norm based on the current sample
 |      distribution.
 |
 |      The norm is based on Covariance matrix ``C`` times ``sigma**2``,
 |      and includes ``sigma_vec``. The expected Mahalanobis distance to
 |      the sample mean is about ``sqrt(dimension)``.
 |
 |      Argument
 |      --------
 |      `dx`, a *genotype* difference to the distribution mean. As `dx` is
 |      interpreted as a difference to the mean, the return value does not
 |      depend on the current mean.
 |
 |      Example
 |      -------
 |      >>> import cma, numpy
 |      >>> es = cma.CMAEvolutionStrategy(numpy.ones(10), 1)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> xx = numpy.random.randn(2, 10)
 |      >>> d = es.mahalanobis_norm(es.gp.geno(xx[0]-xx[1]))
 |
 |      `d` is the distance "in" the true sample distribution,
 |      sampled points have a typical distance of ``sqrt(2*es.N)``,
 |      where ``es.N`` is the dimension, and an expected distance of
 |      close to ``sqrt(N)`` to the sample mean. In the example,
 |      `d` is the Euclidean distance, because C = I and sigma = 1.
 |
 |  manage_plateaus(self, sigma_fac=1.5, sample_fraction=0.5)
 |      increase `sigma` by `sigma_fac` in case of a plateau.
 |
 |      A plateau is assumed to be present if the best sample and
 |      ``popsize * sample_fraction``-th best sample have the same
 |      fitness.
 |
 |      Example:
 |
 |      >>> import cma
 |      >>> def f(X):
 |      ...     return (len(X) - 1) * [1] + [2]
 |      >>> es = cma.CMAEvolutionStrategy(4 * [0], 5, {'verbose':-9, 'tolflatfitness':1e4})
 |      >>> while not es.stop():
 |      ...     X = es.ask()
 |      ...     es.tell(X, f(X))
 |      ...     es.manage_plateaus()
 |      >>> if es.sigma < 1.5**es.countiter: print((es.sigma, 1.5**es.countiter, es.stop()))
 |
 |  pickle_dumps(self)
 |      return ``pickle.dumps(self)``,
 |
 |      if necessary remove unpickleable (and also unnecessary) local
 |      function reference beforehand.
 |
 |      The resulting `bytes` string-object can be saved to a file like::
 |
 |          import cma
 |          es = cma.CMAEvolutionStrategy(3 * [1], 1)
 |          es.optimize(cma.ff.elli, iterations=22)
 |          filename = 'es-pickle-test'
 |          open(filename, 'wb').write(es.pickle_dumps())
 |
 |      and recovered like::
 |
 |          import pickle
 |          es = pickle.load(open(filename, 'rb'))
 |
 |      or::
 |
 |          es = pickle.loads(open(filename, 'rb').read())
 |          es.optimize(cma.ff.elli, iterations=22)  # continue optimizing
 |
 |  plot(self, *args, **kwargs)
 |      plot current state variables using `matplotlib`.
 |
 |      This calls `self.logger.plot`, see `cma.CMADataLogger.plot` to see all
 |      valid keyword arguments.
 |
 |  random_rescale_to_mahalanobis(self, x)
 |      change `x` like for injection, all on genotypic level
 |
 |  repair_genotype(self, x, copy_if_changed=False)
 |      make sure that solutions fit to the sample distribution.
 |
 |      This interface is versatile and likely to change.
 |
 |      We currently assume that this is idempotent.
 |
 |      The Mahalanobis distance ``x - self.mean`` is clipping at
 |      ``N**0.5 + 2 * N / (N + 2)``, but the specific repair
 |      mechanism may change in future.
 |
 |  reset_options(self, **kwargs)
 |      clear termination and set any `CMAOptions` passed via
 |
 |      keyword arguments or like ``**opts_dict``. The validity of the option
 |      names is checked, the validity of the values is not checked.
 |
 |      Some resettings will not be effective. For those with a ``'#v'``
 |      flag in their description, the effectiveness is guarantied. See
 |      `CMAOptions`.
 |
 |      Return `self`, the new options are in ``self.opts``.
 |
 |  result_pretty(self, number_of_restarts=0, time_str=None, fbestever=None)
 |      pretty print result.
 |
 |      Returns `result` of ``self``.
 |
 |  stop(self, check=True, ignore_list=(), check_in_same_iteration=False, get_value=None)
 |      return the termination status as dictionary.
 |
 |      With ``check == False``, the termination conditions are not checked
 |      and the status might not reflect the current situation.
 |      ``check_on_same_iteration == False`` (new) does not re-check during
 |      the same iteration. When termination options are manually changed,
 |      it must be set to `True` to advance afterwards.
 |      ``stop().clear()`` removes the currently active termination
 |      conditions.
 |
 |      As a convenience feature, keywords in `ignore_list` are removed from
 |      the conditions.
 |
 |      If `get_value` is set to a condition name (not the empty string),
 |      `stop` does not update the termination dictionary but returns the
 |      measured value that would be compared to the threshold. This only
 |      works for some conditions, like 'tolx'. If the condition name is
 |      not known or cannot be computed, `None` is returned and no warning
 |      is issued.
 |
 |      Testing `get_value` functionality:
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(2 * [1], 1e4, {'verbose': -9})
 |      >>> with warnings.catch_warnings(record=True) as w:
 |      ...     es.stop(get_value='tolx')  # triggers zero iteration warning
 |      ...     assert len(w) == 1, [str(wi) for wi in w]
 |      >>> es = es.optimize(cma.ff.sphere, iterations=4)
 |      >>> assert 1e3 < es.stop(get_value='tolx') < 1e4, es.stop(get_value='tolx')
 |      >>> assert es.stop() == {}
 |      >>> assert es.stop(get_value='catch 22') is None
 |
 |  tell(self, solutions, function_values, check_points=None, copy=False, constraints_values=None)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  tell2(self, solutions, function_values, constraints_values=None, check_points=None, copy=False)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  to_phenotype(self, solution, *args, **kwargs)
 |      return integer-rounded phenotype depending on `round_integer_variables` module setting.
 |
 |      Without further arguments, `self.gp.pheno` is called with
 |      ``copy=True, into_bounds=self.boundary_handler.repair`` as
 |      additional arguments, otherwise ``*args, **kwargs`` are passed
 |      to `self.gp.pheno`.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  condition_number
 |      condition number of the statistical-model sampler.
 |
 |      Details: neither encoding/decoding from `sigma_vec`-scaling nor
 |      `gp`-transformation are taken into account for this computation.
 |
 |  isotropic_mean_shift
 |      normalized last mean shift, under random selection N(0,I)
 |
 |      distributed.
 |
 |      Caveat: while it is finite and close to sqrt(n) under random
 |      selection, the length of the normalized mean shift under
 |      *systematic* selection (e.g. on a linear function) tends to
 |      infinity for mueff -> infty. Hence it must be used with great
 |      care for large mueff.
 |
 |  popsize
 |      number of samples by default returned by `ask` ()
 |
 |  result
 |      return a `CMAEvolutionStrategyResult2` class instance.
 |
 |      :See: `cma.evolution_strategy.CMAEvolutionStrategyResult2`
 |          or try ``help(...result)`` on the ``result`` property
 |          of an `CMAEvolutionStrategy` instance or an
 |          `CMAEvolutionStrategyResult2` instance.
 |
 |  stds
 |      return array of coordinate-wise standard deviations (phenotypic).
 |
 |      Takes into account geno-phenotype transformation, step-size,
 |      diagonal decoding, and the covariance matrix. Only the latter three
 |      apply to `self.mean`.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from cma.interfaces.OOOptimizer:
 |
 |  initialize(self)
 |      (re-)set to the initial state
 |
 |  optimize(self, objective_fct, maxfun=None, iterations=None, min_iterations=1, args=(), verb_disp=None, callback=None, n_jobs=0, **kwargs)
 |      find minimizer of ``objective_fct``.
 |
 |      CAVEAT: the return value for `optimize` has changed to ``self``,
 |      allowing for a call like::
 |
 |          solver = OOOptimizer(x0).optimize(f)
 |
 |      and investigate the state of the solver.
 |
 |      Arguments
 |      ---------
 |
 |      ``objective_fct``: f(x: array_like) -> float
 |          function be to minimized
 |      ``maxfun``: number
 |          maximal number of function evaluations
 |      ``iterations``: number
 |          number of (maximal) iterations, while ``not self.stop()``,
 |          it can be useful to conduct only one iteration at a time.
 |      ``min_iterations``: number
 |          minimal number of iterations, even if ``not self.stop()``
 |      ``args``: sequence_like
 |          arguments passed to ``objective_fct``
 |      ``verb_disp``: number
 |          print to screen every ``verb_disp`` iteration, if `None`
 |          the value from ``self.logger`` is "inherited", if
 |          available.
 |      ``callback``: callable or list of callables
 |          callback function called like ``callback(self)`` or
 |          a list of call back functions called in the same way. If
 |          available, ``self.logger.add`` is added to this list.
 |          TODO: currently there is no way to prevent this other than
 |          changing the code of `_prepare_callback_list`.
 |      ``n_jobs=0``: number of processes to be acquired for
 |          multiprocessing to parallelize calls to `objective_fct`.
 |          Must be >1 to expect any speed-up or `None` or `-1`, which
 |          both default to the number of available CPUs. The default
 |          ``n_jobs=0`` avoids the use of multiprocessing altogether.
 |
 |      ``return self``, that is, the `OOOptimizer` instance.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(7 * [0.1], 0.1
 |      ...              ).optimize(cma.ff.rosen, verb_disp=100)
 |      ...                   #doctest: +ELLIPSIS
 |      (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 7 (seed=...)
 |      Iterat #Fevals   function value  axis ratio  sigma ...
 |          1      9 ...
 |          2     18 ...
 |          3     27 ...
 |        100    900 ...
 |      >>> cma.s.Mh.vequals_approximately(es.result[0], 7 * [1], 1e-5)
 |      True
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from cma.interfaces.OOOptimizer:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.CMAOptions
Python Library Documentation: class CMAOptions in module cma.options_parameters

class CMAOptions(builtins.dict)
 |  CMAOptions(s=None, **kwargs)
 |
 |  a dictionary with the available options and their default values
 |  for class `CMAEvolutionStrategy`.
 |
 |  ``CMAOptions()`` returns a `dict` with all available options and their
 |  default values with a comment string.
 |
 |  ``CMAOptions('verb')`` returns a subset of recognized options that
 |  contain 'verb' in there keyword name or (default) value or
 |  description.
 |
 |  ``CMAOptions(opts)`` returns the subset of recognized options in
 |  ``dict(opts)``.
 |
 |  Option values can be "written" in a string and, when passed to `fmin2`
 |  or `CMAEvolutionStrategy`, are evaluated using "N" and "popsize" as
 |  known values for dimension and population size (sample size, number
 |  of new solutions per iteration). All default option values are given
 |  as such a string.
 |
 |  Details
 |  -------
 |  `CMAOptions` entries starting with ``tol`` are termination
 |  "tolerances".
 |
 |  For `tolstagnation`, the median over the first and the second half
 |  of at least `tolstagnation` iterations are compared for both, the
 |  per-iteration best and per-iteration median function value.
 |
 |  Example
 |  -------
 |  ::
 |
 |      import cma
 |      cma.CMAOptions('tol')
 |
 |  is a shortcut for ``cma.CMAOptions().match('tol')`` that returns all
 |  options that contain 'tol' in their name or description.
 |
 |  To set an option::
 |
 |      import cma
 |      opts = cma.CMAOptions()
 |      opts.set('tolfun', 1e-12)
 |      opts['tolx'] = 1e-11
 |
 |  todo: this class is overly complex and should be re-written, possibly
 |  with reduced functionality.
 |
 |  :See also: `fmin2` (), `CMAEvolutionStrategy`, `CMAParameters`
 |
 |  Method resolution order:
 |      CMAOptions
 |      builtins.dict
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, key, default=None, loc=None)
 |      evaluate and return the value of option `key` on the fly, or
 |      return those options whose name or description contains `key`,
 |      case disregarded.
 |
 |      Details
 |      -------
 |      Keys that contain `filename` are not evaluated.
 |      For ``loc==None``, `self` is used as environment
 |      but this does not define ``N``.
 |
 |      :See: `eval()`, `evalall()`
 |
 |  __init__(self, s=None, **kwargs)
 |      return an `CMAOptions` instance.
 |
 |      Return default options if ``s is None and not kwargs``,
 |      or all options whose name or description contains `s`, if
 |      `s` is a (search) string (case is disregarded in the match),
 |      or with entries from dictionary `s` as options,
 |      or with kwargs as options if ``s is None``,
 |      in any of the latter cases not complemented with default options
 |      or settings.
 |
 |      Returns: see above.
 |
 |      Details: as several options start with ``'s'``, ``s=value`` is
 |      not valid as an option setting.
 |
 |  amend_integer_options(self, dimension, inopts)
 |      amend options when integer variables are indicated
 |
 |  amend_integer_variables(self, dimension)
 |      remove fixed variables from the integer variable index list
 |
 |      and change the index values accordingly to refer to a genotype.
 |      Create an `'_pheno_integer_variables'` entry of the same length but
 |      with the unchanged index values.
 |
 |  check(self, options=None)
 |      check for ambiguous keys and move attributes into dict
 |
 |  check_attributes(self, opts=None)
 |      check for attributes and moves them into the dictionary
 |
 |  check_values(self, options=None)
 |
 |  complement(self)
 |      add all missing options with their default values
 |
 |  corrected_key(self, key)
 |      return the matching valid key, if ``key.lower()`` is a unique
 |      starting sequence to identify the valid key, ``else None``
 |
 |  eval(self, key, default=None, loc=None, correct_key=True)
 |      Evaluates and sets the specified option value in
 |      environment `loc`. Many options need ``N`` to be defined in
 |      `loc`, some need `popsize`.
 |
 |      Details
 |      -------
 |      Keys that contain 'filename' are not evaluated.
 |      For `loc` is None, the self-dict is used as environment
 |
 |      :See: `evalall()`, `__call__`
 |
 |  evalall(self, loc=None, defaults=None)
 |      Evaluates all option values in environment `loc`.
 |
 |      :See: `eval()`
 |
 |  from_namedtuple(self, t)
 |      update options from a `collections.namedtuple`.
 |      :See also: `to_namedtuple`
 |
 |  init(self, dict_or_str, val=None, warn=True)
 |      initialize one or several options.
 |
 |      Arguments
 |      ---------
 |          `dict_or_str`
 |              a dictionary if ``val is None``, otherwise a key.
 |              If `val` is provided `dict_or_str` must be a valid key.
 |          `val`
 |              value for key
 |
 |      Details
 |      -------
 |      Only known keys are accepted. Known keys are in `CMAOptions.defaults()`
 |
 |  match(self, s='')
 |      return all options that match, in the name or the description,
 |      with string `s`, case is disregarded.
 |
 |      Example: ``cma.CMAOptions().match('verb')`` returns the verbosity
 |      options.
 |
 |  pprint(self, linebreak=80)
 |
 |  set(self, dic, val=None, force=False)
 |      assign versatile options.
 |
 |      Method `CMAOptions.versatile_options` () gives the versatile
 |      options, use `init()` to set the others.
 |
 |      Arguments
 |      ---------
 |          `dic`
 |              either a dictionary or a key. In the latter
 |              case, `val` must be provided
 |          `val`
 |              value for `key`, approximate match is sufficient
 |          `force`
 |              force setting of non-versatile options, use with caution
 |
 |      This method will be most probably used with the ``opts`` attribute of
 |      a `CMAEvolutionStrategy` instance.
 |
 |  set_integer_min_std(self, N, mueff)
 |      set lower std bounds for integer variables.
 |
 |      Uses the above defined `integer_std_lower_bound` function which can
 |      be reassigned.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  defaults()
 |      return a dictionary with default option values and description
 |
 |  versatile_options()
 |      return list of options that can be changed at any time (not
 |      only be initialized).
 |
 |      Consider that this list might not be entirely up
 |      to date.
 |
 |      The string ' #v ' in the default value indicates a versatile
 |      option that can be changed any time, however a string will not
 |      necessarily be evaluated again.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  settable
 |      return the subset of those options that are settable at any
 |      time.
 |
 |      Settable options are in `versatile_options` (), but the
 |      list might be incomplete.
 |
 |  to_namedtuple
 |      return options as const attributes of the returned object,
 |      only useful for inspection.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.dict:
 |
 |  __contains__(self, key, /)
 |      True if the dictionary has the specified key, else False.
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __ior__(self, value, /)
 |      Return self|=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the dict keys.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(...)
 |      D.__sizeof__() -> size of D in memory, in bytes
 |
 |  clear(...)
 |      D.clear() -> None.  Remove all items from D.
 |
 |  copy(...)
 |      D.copy() -> a shallow copy of D
 |
 |  get(self, key, default=None, /)
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  items(...)
 |      D.items() -> a set-like object providing a view on D's items
 |
 |  keys(...)
 |      D.keys() -> a set-like object providing a view on D's keys
 |
 |  pop(...)
 |      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
 |
 |      If the key is not found, return the default if given; otherwise,
 |      raise a KeyError.
 |
 |  popitem(self, /)
 |      Remove and return a (key, value) pair as a 2-tuple.
 |
 |      Pairs are returned in LIFO (last-in, first-out) order.
 |      Raises KeyError if the dict is empty.
 |
 |  setdefault(self, key, default=None, /)
 |      Insert key with a value of default if key is not in the dictionary.
 |
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  update(...)
 |      D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
 |      If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
 |      If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
 |      In either case, this is followed by: for k in F:  D[k] = F[k]
 |
 |  values(...)
 |      D.values() -> an object providing a view on D's values
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.dict:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  fromkeys(iterable, value=None, /)
 |      Create a new dictionary with keys from iterable and values set to value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.dict:
 |
 |  __new__(*args, **kwargs) class method of builtins.dict
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.dict:
 |
 |  __hash__ = None
cma.ConstrainedFitnessAL
Python Library Documentation: class ConstrainedFitnessAL in module cma.constraints_handler

class ConstrainedFitnessAL(builtins.object)
 |  ConstrainedFitnessAL(fun, constraints, dimension=None, which='best', find_feasible_first=False, get_solution=<function _get_favorite_solution at 0x000002897FF1BEC0>, logging=None, archives=(<function _g_pos_max at 0x0000028978AEF560>, <function _g_pos_sum at 0x000002897F66E520>, <function _g_pos_squared_sum at 0x000002897FF1B1A0>))
 |
 |  Construct an unconstrained objective function from constraints.
 |
 |  This class constructs an unconstrained "fitness" function (to be
 |  minimized) from an objective function and an inequality constraints
 |  function (which returns a list of constraint values). An
 |  equality constraint ``h(x) == 0`` must be expressed as two inequality
 |  constraints like ``[h(x) - eps, -h(x) - eps]`` with ``eps >= 0``.
 |  Non-positive values <= 0 are considered feasible.
 |
 |  The `update` method of the class instance needs to be called after each
 |  iteration. Depending on the setting of `which`, `update` may call
 |  ``get_solution(es)`` which shall return the solution to be used for the
 |  constraints handling update, by default ``_get_favorite_solution ==
 |  lambda es: es.ask(1, sigma_fac=0)[0]``. The additional evaluation of
 |  objective and constraints is avoided by the default ``which='best'``,
 |  using the best solution in the current iteration.
 |
 |  `find_feasible_first` optimizes to get a feasible solution first, which
 |  only works if no equality constraints are implemented. For this reason
 |  the default is `False`.
 |
 |  Minimal example (verbosity set for doctesting):
 |
 |  >>> import cma
 |  >>> def constraints(x):  # define the constraint
 |  ...     return [x[0] + 1, x[1]]  # shall be <= 0
 |  >>> cfun = cma.ConstrainedFitnessAL(cma.ff.sphere, constraints,
 |  ...                                 find_feasible_first=True)
 |  >>> es = cma.CMAEvolutionStrategy(3 * [1.1], 0.1,
 |  ...                   {'tolstagnation': 0, 'verbose':-9})  # verbosity for doctest only
 |  >>> es = es.optimize(cfun, callback=cfun.update)
 |  >>> x = es.result.xfavorite
 |
 |  The best `x` return value of `cma.fmin2` may not be useful, because
 |  the underlying function changes over time. Therefore, we use
 |  `es.result.xfavorite`, which is still not guarantied to be a feasible
 |  solution. Alternatively, `cfun.best_feas.x` contains the best evaluated
 |  feasible solution. However, this is not necessarily expected to be a
 |  good solution, see below.
 |
 |  >>> assert sum((x - [-1, 0, 0])**2) < 1e-9, x
 |  >>> assert es.countevals < 2200, es.countevals
 |  >>> assert cfun.best_feas.f < 10, str(cfun.best_feas)
 |  >>> # print(es.countevals, cfun.best_feas.__dict__)
 |
 |  To find a final feasible solution (close to `es.result.xfavorite`) we
 |  can use the current `CMAEvolutionStrategy` instance `es`:
 |
 |  >>> x = cfun.find_feasible(es)  # uses es.optimize to find (another) feasible solution
 |  >>> assert constraints(x)[0] <= 0, (x, cfun.best_feas.x)
 |  >>> assert cfun.best_feas.f < 1 + 2e-6, str(cfun.best_feas)
 |  >>> assert len(cfun.archives) == 3
 |  >>> assert cma.ConstrainedFitnessAL(cma.ff.sphere, constraints, archives=False).archives == []
 |
 |  Details: The fitness, to be minimized, is changing over time such that
 |  the overall minimal value does not indicate the best solution.
 |
 |  The construction is based on the `AugmentedLagrangian` class. If, as by
 |  default, ``self.finding_feasible is False``, the fitness equals ``f(x)
 |  + sum_i (lam_i x g_i + mu_i x g_i / 2)`` where ``g_i = max(g_i(x),
 |  -lam_i / mu_i)`` and lam_i and mu_i are generally positive and
 |  dynamically adapted coefficients. Only lam_i can change the position of
 |  the optimum in the feasible domain (and hence must converge to the
 |  right value).
 |
 |  When ``self.finding_feasible is True``, the fitness equals to ``sum_i
 |  (g_i > 0) x g_i^2`` and omits ``f + sum_i lam_i g_i`` altogether.
 |  Whenever a feasible solution is found, the `finding_feasible` flag is
 |  reset to `False`.
 |
 |  `find_feasible(es)` sets ``finding_feasible = True`` and uses
 |  `es.optimize` to optimize `self.__call__`. This works well with
 |  `CMAEvolutionStrategy` but may easily fail with solvers that do not
 |  consistently pass over the optimum in search space but approach the
 |  optimum from one side only. This is not advisable if the feasible
 |  domain has zero volume, e.g. when `g` models an equality like
 |  ``g = lambda x: [h(x), -h(x)]``.
 |
 |  An equality constraint, h(x) = 0, cannot be handled like h**2 <= 0,
 |  because the Augmented Lagrangian requires the derivative at h == 0 to
 |  be non-zero. Using abs(h) <= 0 leads to divergence of coefficient mu
 |  and the condition number. The best way is apparently using the two
 |  inequality constraints [h <= 0, -h <= 0], which seems to work perfectly
 |  well. The underlying `AugmentedLagrangian` class also accepts equality
 |  constraints.
 |
 |  Methods defined here:
 |
 |  __call__(self, x)
 |      return AL fitness, append f and g values to `self.F` and `self.G`.
 |
 |      If `self.finding_feasible`, `fun(x)` is not called and ``f = np.nan``.
 |
 |  __init__(self, fun, constraints, dimension=None, which='best', find_feasible_first=False, get_solution=<function _get_favorite_solution at 0x000002897FF1BEC0>, logging=None, archives=(<function _g_pos_max at 0x0000028978AEF560>, <function _g_pos_sum at 0x000002897F66E520>, <function _g_pos_squared_sum at 0x000002897FF1B1A0>))
 |      constructor with lazy initialization.
 |
 |      If ``which in ['mean', 'solution']``, `get_solution` is called
 |      (with the argument passed to the `update` method) to determine the
 |      solution used to update the AL coefficients.
 |
 |      If `find_feasible_first`, only the constraints are optimized until
 |      the first (fully) feasible solution is found.
 |
 |      `logging` is the iteration gap for logging constraints related
 |      data, in `AugmentedLagrangian`. 0 means no logging and negative
 |      values have unspecified behavior.
 |
 |      `archives` are the aggregator functions for constraints for
 |      non-dominated biobjective archives. By default, the second
 |      objective is ``max(g_+)``, ``sum(g_+)`` or ``sum(g_+^2)``,
 |      respectively. ``archives=True`` invokes the same behavior.
 |      ``archives=False`` or an empty `tupel` prevents maintaining
 |      archives.
 |
 |  find_feasible(self, es, termination=('maxiter', 'maxfevals'), aggregator=None)
 |      find feasible solution by calling ``es.optimize(self)``.
 |
 |      Return best ever feasible solution `self.best_feas.x`.
 |      See also `self.best_feas.info`.
 |
 |      `aggregator`, defaulting to `self.find_feasible_aggregator`, is the
 |      constraints aggregation function used as objective function to be
 |      minimized. `aggregator` takes as input all constraint values and
 |      returns a value <= 0 if and only if the solution is feasible.
 |
 |      Terminate when either (another) feasible solution was found or any
 |      of the `termination` keys is matched in `es.stop()`.
 |
 |  initialize(self, dimension)
 |      set search space dimension explicitely
 |
 |  log_in_es(self, es, f, g)
 |      a hack to have something in the cma-logger divers plot.
 |
 |      Append the sum of positive g-values and the number of infeasible
 |      constraints, displayed like 10**(number/10) (mapping [0, 10] to [1,
 |      10]) if number < 10, to `es.more_to_write`.
 |
 |  reset(self)
 |      reset dynamic components
 |
 |  set_mu_lam(self, mu, lam)
 |      set AL coefficients
 |
 |  update(self, es)
 |      update AL coefficients, may be used as callback to `OOOptimizer.optimize`.
 |
 |      TODO: decide what happens when `__call__` was never called:
 |            ignore (as for now) or update based on xfavorite by calling self(xfavorite),
 |            assuming that update was called on purpose?
 |            When method is not best, it should work without even call self(xfavorite).
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  al
 |      `AugmentedLagrangian` class instance
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  archive_aggregators = (<function _g_pos_max>, <function _g_pos_sum>, <...
cma.GlueArguments
Python Library Documentation: class GlueArguments in module cma.fitness_transformations

class GlueArguments(Function)
 |  GlueArguments(fitness_function, *args, **kwargs)
 |
 |  deprecated, use `functools.partial` or
 |  `cma.fitness_transformations.partial` instead, which has the same
 |  functionality and interface.
 |
 |  from a `callable` return a `callable` with arguments attached.
 |
 |
 |  An ellipsoid function with condition number ``1e4`` is created by
 |  ``felli1e4 = cma.s.ft.GlueArguments(cma.ff.elli, cond=1e4)``.
 |
 |  >>> import cma
 |  >>> f = cma.fitness_transformations.GlueArguments(cma.ff.elli,
 |  ...                                               cond=1e1)
 |  >>> assert f([1, 2]) == 1**2 + 1e1 * 2**2
 |
 |  Method resolution order:
 |      GlueArguments
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args, **kwargs)
 |      call function with at least one additional argument and
 |      attached args and kwargs.
 |
 |  __init__(self, fitness_function, *args, **kwargs)
 |      define function, ``args``, and ``kwargs``.
 |
 |      ``args`` are appended to arguments passed in the call, ``kwargs``
 |      are updated with keyword arguments passed in the call.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.NoiseHandler
Python Library Documentation: class NoiseHandler in module cma.optimization_tools

class NoiseHandler(builtins.object)
 |  NoiseHandler(N, maxevals=[1, 1, 1], aggregate=<function median at 0x000002897F5C4170>, reevals=None, epsilon=1e-07, parallel=False)
 |
 |  Noise handling according to [Hansen et al 2009, A Method for
 |  Handling Uncertainty in Evolutionary Optimization...]
 |
 |  The interface of this class is yet versatile and subject to changes.
 |
 |  The noise handling follows closely [Hansen et al 2009] in the
 |  measurement part, but the implemented treatment is slightly
 |  different: for ``noiseS > 0``, ``evaluations`` (time) and sigma are
 |  increased by ``alpha``. For ``noiseS < 0``, ``evaluations`` (time)
 |  is decreased by ``alpha**(1/4)``.
 |
 |  The (second) parameter ``evaluations`` defines the maximal number
 |  of evaluations for a single fitness computation. If it is a list,
 |  the smallest element defines the minimal number and if the list has
 |  three elements, the median value is the start value for
 |  ``evaluations``.
 |
 |  `NoiseHandler` serves to control the noise via steps-size
 |  increase and number of re-evaluations, for example via `fmin` or
 |  with `ask_and_eval`.
 |
 |  Examples
 |  --------
 |  Minimal example together with `fmin` on a non-noisy function:
 |
 |  >>> import cma
 |  >>> res = cma.fmin(cma.ff.elli, 7 * [1], 1, noise_handler=cma.NoiseHandler(7))  #doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,...
 |  >>> assert res[1] < 1e-8
 |  >>> res = cma.fmin(cma.ff.elli, 6 * [1], 1, {'AdaptSigma':cma.sigma_adaptation.CMAAdaptSigmaTPA},
 |  ...          noise_handler=cma.NoiseHandler(6))  #doctest: +ELLIPSIS
 |  (4_w,...
 |  >>> assert res[1] < 1e-8
 |
 |  in dimension 7 (which needs to be given tice). More verbose example
 |  in the optimization loop with a noisy function defined in ``func``:
 |
 |  >>> import cma, numpy as np
 |  >>> func = lambda x: cma.ff.sphere(x) * (1 + 4 * np.random.randn() / len(x))  # cma.ff.noisysphere
 |  >>> es = cma.CMAEvolutionStrategy(np.ones(10), 1)  #doctest: +ELLIPSIS
 |  (5_w,10)-aCMA-ES (mu_w=3.2,...
 |  >>> nh = cma.NoiseHandler(es.N, maxevals=[1, 1, 30])
 |  >>> while not es.stop():
 |  ...     X, fit_vals = es.ask_and_eval(func, evaluations=nh.evaluations)
 |  ...     es.tell(X, fit_vals)  # prepare for next iteration
 |  ...     es.sigma *= nh(X, fit_vals, func, es.ask)  # see method __call__
 |  ...     es.countevals += nh.evaluations_just_done  # this is a hack, not important though
 |  ...     es.logger.add(more_data = [nh.evaluations, nh.noiseS])  # add a data point
 |  ...     es.disp()
 |  ...     # nh.maxevals = ...  it might be useful to start with smaller values and then increase
 |  ...                # doctest: +ELLIPSIS
 |  Iterat...
 |  >>> print(es.stop())
 |  ...                # doctest: +ELLIPSIS
 |  {...
 |  >>> print(es.result[-2])  # take mean value, the best solution is totally off
 |  ...                # doctest: +ELLIPSIS
 |  [...
 |  >>> assert sum(es.result[-2]**2) < 1e-9
 |  >>> print(X[np.argmin(fit_vals)])  # not bad, but probably worse than the mean
 |  ...                # doctest: +ELLIPSIS
 |  [...
 |
 |  >>> # es.logger.plot()
 |
 |
 |  The command ``logger.plot()`` will plot the logged data.
 |
 |  The noise options of fmin` control a `NoiseHandler` instance
 |  similar to this example. The command ``cma.CMAOptions('noise')``
 |  lists in effect the parameters of `__init__` apart from
 |  ``aggregate``.
 |
 |  Details
 |  -------
 |  The parameters reevals, theta, c_s, and alpha_t are set differently
 |  than in the original publication, see method `__init__`. For a
 |  very small population size, say popsize <= 5, the measurement
 |  technique based on rank changes is likely to fail.
 |
 |  Missing Features
 |  ----------------
 |  In case no noise is found, ``self.lam_reeval`` should be adaptive
 |  and get at least as low as 1 (however the possible savings from this
 |  are rather limited). Another option might be to decide during the
 |  first call by a quantitative analysis of fitness values whether
 |  ``lam_reeval`` is set to zero. More generally, an automatic noise
 |  mode detection might also set the covariance matrix learning rates
 |  to smaller values.
 |
 |  :See also: `fmin`, `CMAEvolutionStrategy.ask_and_eval`
 |
 |  Methods defined here:
 |
 |  __call__(self, X, fit, func, ask=None, args=())
 |      proceed with noise measurement, set anew attributes ``evaluations``
 |      (proposed number of evaluations to "treat" noise) and ``evaluations_just_done``
 |      and return a factor for increasing sigma.
 |
 |      Parameters
 |      ----------
 |      ``X``
 |          a list/sequence/vector of solutions
 |      ``fit``
 |          the respective list of function values
 |      ``func``
 |          the objective function, ``fit[i]`` corresponds to
 |          ``func(X[i], *args)``
 |      ``ask``
 |          a method to generate a new, slightly disturbed solution. The
 |          argument is (only) mandatory if ``epsilon`` is not zero, see
 |          `__init__`.
 |      ``args``
 |          optional additional arguments to ``func``
 |
 |      Details
 |      -------
 |      Calls the methods `reeval`, `update_measure` and ``treat` in
 |      this order. ``self.evaluations`` is adapted within the method
 |      `treat`.
 |
 |  __init__(self, N, maxevals=[1, 1, 1], aggregate=<function median at 0x000002897F5C4170>, reevals=None, epsilon=1e-07, parallel=False)
 |      Parameters are:
 |
 |      ``N``
 |          dimension, (only) necessary to adjust the internal
 |          "alpha"-parameters
 |      ``maxevals``
 |          maximal value for ``self.evaluations``, where
 |          ``self.evaluations`` function calls are aggregated for
 |          noise treatment. With ``maxevals == 0`` the noise
 |          handler is (temporarily) "switched off". If `maxevals`
 |          is a list, min value and (for >2 elements) median are
 |          used to define minimal and initial value of
 |          ``self.evaluations``. Choosing ``maxevals > 1`` is only
 |          reasonable, if also the original ``fit`` values (that
 |          are passed to `__call__`) are computed by aggregation of
 |          ``self.evaluations`` values (otherwise the values are
 |          not comparable), as it is done within `fmin`.
 |      ``aggregate``
 |          function to aggregate single f-values to a 'fitness', e.g.
 |          ``np.median``.
 |      ``reevals``
 |          number of solutions to be reevaluated for noise
 |          measurement, can be a float, by default set to ``2 +
 |          popsize/20``, where ``popsize = len(fit)`` in
 |          ``__call__``. zero switches noise handling off.
 |      ``epsilon``
 |          multiplier for perturbation of the reevaluated solutions
 |      ``parallel``
 |          a single f-call with all resampled solutions
 |
 |      :See also: `fmin`, `CMAOptions`, `CMAEvolutionStrategy.ask_and_eval`
 |
 |  indices(self, fit)
 |      return the set of indices to be reevaluated for noise
 |      measurement.
 |
 |      Given the first values are the earliest, this is a useful policy
 |      also with a time changing objective.
 |
 |  reeval(self, X, fit, func, ask, args=())
 |      store two fitness lists, `fit` and ``fitre`` reevaluating some
 |      solutions in `X`.
 |      ``self.evaluations`` evaluations are done for each reevaluated
 |      fitness value.
 |      See `__call__`, where `reeval` is called.
 |
 |  treat(self)
 |      adapt self.evaluations depending on the current measurement
 |      value and return ``sigma_fac in (1.0, self.alphasigma)``
 |
 |  update_measure(self)
 |      updated noise level measure using two fitness lists ``self.fit`` and
 |      ``self.fitre``, return ``self.noiseS, all_individual_measures``.
 |
 |      Assumes that ``self.idx`` contains the indices where the fitness
 |      lists differ.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.ScaleCoordinates
Python Library Documentation: class ScaleCoordinates in module cma.fitness_transformations

class ScaleCoordinates(ComposedFunction)
 |  ScaleCoordinates(fitness_function, multipliers=None, zero=None, upper=None, lower=None, from_lower_upper=(0, 1))
 |
 |  compose a (fitness) function with a preceding scaling and offset.
 |
 |  Scaling interface
 |  -----------------
 |  After ``fun2 = cma.ScaleCoordinates(fun, multipliers, zero)``, we have
 |  ``fun2(x) == fun(multipliers * (x - zero))``, where the vector size of
 |  `multipliers` and `zero` is adapated to the size of `x`, in case by
 |  recycling their last entry. This awkwardly asks to pass the `zero`
 |  argument of the preimage space where it has little meaning. Hence more
 |  conveniently,
 |  ``fun2 = cma.ScaleCoordinates(fun, multipliers, lower=lower)`` gets
 |  ``fun2(x) == fun(multipliers * x + lower)``.
 |
 |  Domain interface (lower and upper variable values)
 |  --------------------------------------------------
 |  Let ``u`` and ``l`` be vectors (or a scalar) of (approximate) lower and
 |  upper variable values, respectively. After
 |  ``fun2 = cma.ScaleCoordinates(fun, upper=u, lower=l)`` we have
 |  ``fun2(x) == fun(l + (u - l) * x)``. Now, passing 0 as ``x[i]`` to
 |  ``fun2`` evaluates ``fun`` at ``l[i]`` while passing 1 evaluates
 |  ``fun`` at ``u[i]``.
 |
 |  To match the size of ``x``, the sizes of ``u`` and ``l`` are shortened
 |  or their last entry is recycled if necessary.
 |
 |  The default value for `lower` is zero in which case `upper` just
 |  becomes a scaling multiplier.
 |
 |  Bounding the search domain of ``fun2`` to ``[0, 1]`` now bounds ``fun``
 |  to the domain ``[l, u]``. The ``'bounds'`` option of `CMAOptions`
 |  allows to set these bounds.
 |
 |  More general, the affine transformation is defined such that
 |  ``x[i]==from_lower_upper[0]`` evaluates ``fun`` at ``l[i]`` and
 |  ``x[i]==from_lower_upper[1]`` evaluates ``fun`` at ``u[i]`` where
 |  ``from_lower_upper == [0, 1]`` by default.
 |
 |  Examples and Doctest
 |  --------------------
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> fun = cma.ScaleCoordinates(cma.ff.sphere, upper=[30, 1])
 |  >>> bool(fun([1, 1]) == 30**2 + 1**2)
 |  True
 |  >>> fun.transform([1, 1]).tolist(), fun.transform([0.2, 0.2]).tolist()
 |  ([30.0, 1.0], [6.0, 0.2])
 |  >>> fun.inverse(fun.transform([0.1, 0.3])).tolist()
 |  [0.1, 0.3]
 |  >>> fun = cma.ScaleCoordinates(cma.ff.sphere, upper=[31, 3], lower=[1, 2])
 |  >>> bool(-1e-9 < fun([1, -1]) - (31**2 + 1**2) < 1e-9)
 |  True
 |  >>> f = cma.ScaleCoordinates(cma.ff.sphere, [100, 1])
 |  >>> assert f[0] == cma.ff.sphere  # first element of f-composition
 |  >>> assert f(range(1, 6)) == 100**2 + sum([x**2 for x in range(2, 6)])
 |  >>> assert f([2.1]) == 210**2 == f(2.1)
 |  >>> assert f(20 * [1]) == 100**2 + 19
 |  >>> assert np.all(f.inverse(f.scale_and_offset([1, 2, 3, 4])) ==
 |  ...               np.asarray([1, 2, 3, 4]))
 |  >>> f = cma.ScaleCoordinates(f, [-2, 7], [2, 3, 4]) # last is recycled
 |  >>> bool(f([5, 6]) == sum(x**2 for x in [100 * -2 * (5 - 2), 7 * (6 - 3)]))
 |  True
 |
 |  See also these [Practical Hints](https://cma-es.github.io/cmaes_sourcecode_page.html#practical)
 |  for encoding variables.
 |
 |  Method resolution order:
 |      ScaleCoordinates
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, fitness_function, multipliers=None, zero=None, upper=None, lower=None, from_lower_upper=(0, 1))
 |      :param fitness_function: a `callable` object
 |      :param multipliers: coordinate-wise multipliers.
 |      :param zero: defines a new zero in preimage space, that is,
 |          calling the `ScaleCoordinates` instance returns
 |          ``fitness_function(multipliers * (x - zero))``.
 |      :param upper: variable value to which from_lower_upper[1] maps.
 |      :param lower: variable value to which from_lower_upper[0] maps.
 |
 |      Only either `multipliers` or 'upper` can be passed. If `zero` is
 |      passed then `upper` and `lower` are ignored. The arguments
 |      ``multipliers``, ``zero``, ``upper`` and ``lower`` can be vectors
 |      or scalars, superfluous trailing elements are ignored and the last
 |      element is recycled if needed to fit the length of the later given
 |      input.
 |
 |      `from_lower_upper` is `(0, 1)` by default and defines the preimage
 |      values which are mapped to `lower` and `upper`, respectively
 |      (unless `multipliers` or `zero` are given). These two preimage
 |      values are always the same for all coordinates.
 |
 |      Details
 |      -------
 |      The `upper` and `lower` and `from_lower_upper` parameters are used
 |      to assign `multipliers` and `zero` such that the transformation is
 |      then always computed from the latter two only.
 |
 |  inverse(self, x)
 |      inverse of coordinate-wise affine transformation
 |      ``y / multipliers + zero``
 |
 |  scale_and_offset(self, x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.cma_default_options_
Python Library Documentation: function cma_default_options_ in module cma.options_parameters

cma_default_options_(AdaptSigma='True  # or False or any CMAAdaptSigmaBase class e.g. CMAAdaptSigmaTPA, CMAAdaptSigmaCSA', CMA_active='True  # negative update, conducted after the original update', CMA_active_injected='0  #v weight multiplier for negative weights of injected solutions', CMA_cmean='1  # learning rate for the mean value', CMA_const_trace='False  # normalize trace, 1, True, "arithm", "geom", "aeig", "geig" are valid', CMA_diagonal='0*100*N/popsize**0.5  # nb of iterations with diagonal covariance matrix, True for always', CMA_diagonal_decoding='0  # learning rate multiplier for additional diagonal update', CMA_eigenmethod='np.linalg.eigh  # or cma.utilities.math.eig or pygsl.eigen.eigenvectors', CMA_elitist='False  #v or "initial" or True, elitism likely impairs global search performance', CMA_injections_threshold_keep_len='1  #v keep length if Mahalanobis length is below the given relative threshold', CMA_mirrors='popsize < 6  # values <0.5 are interpreted as fraction, values >1 as numbers (rounded), for `True` about 0.16 is used', CMA_mirrormethod='2  # 0=unconditional, 1=selective, 2=selective with delay', CMA_mu='None  # parents selection parameter, default is popsize // 2', CMA_on='1  # multiplier for all covariance matrix updates', CMA_sampler='None  # a class or instance that implements the interface of `cma.interfaces.StatisticalModelSamplerWithZeroMeanBaseClass`', CMA_sampler_options='{}  # options passed to `CMA_sampler` class init as keyword arguments', CMA_rankmu='1.0  # multiplier for rank-mu update learning rate of covariance matrix', CMA_rankone='1.0  # multiplier for rank-one update learning rate of covariance matrix', CMA_recombination_weights='None  # a list, see class RecombinationWeights, overwrites CMA_mu and popsize options', CMA_dampsvec_fac='np.inf  # tentative and subject to changes, 0.5 would be a "default" damping for sigma vector update', CMA_dampsvec_fade='0.1  # tentative fading out parameter for sigma vector update', CMA_teststds='None  # factors for non-isotropic initial distr. of C, mainly for test purpose, see CMA_stds for production', CMA_stds='None  # multipliers for sigma0 in each coordinate (not represented in C), or use `cma.ScaleCoordinates` instead', CSA_dampfac='1  #v positive multiplier for step-size damping, 0.3 is close to optimal on the sphere', CSA_damp_mueff_exponent='None  # exponent for mueff/N, by default 0.5 and 1 if CSA_squared, zero means no dependency of damping on mueff, useful with CSA_disregard_length option', CSA_disregard_length='False  #v True is untested, also changes respective parameters', CSA_clip_length_value='None  #v poorly tested, [0, 0] means const length N**0.5, [-1, 1] allows a variation of +- N/(N+2), etc.', CSA_squared='False  #v use squared length for sigma-adaptation ', CSA_invariant_path='False  #v pc is invariant and ps (default) is unbiased', TPA_dampfac='1  #v positive multiplier for step-size damping with TPA', stall_sigma_change_on_divergence_iterations='False  #v number of iterations of median worsenings threshold at which the sigma change is stalled; the default may become 2', BoundaryHandler='BoundTransform  # or BoundPenalty, unused when ``bounds in (None, [None, None])``', bounds='[None, None]  # lower (=bounds[0]) and upper domain boundaries, each a scalar or a list/vector', conditioncov_alleviate='[1e8, 1e12]  # when to alleviate the condition in the coordinates and in main axes', eval_final_mean='True  # evaluate the final mean, which is a favorite return candidate', fixed_variables='None  # dictionary with index-value pairs like {0:1.1, 2:0.1} that are not optimized', ftarget='-inf  #v target function value, minimization', integer_variables='[]  # index list, invokes basic integer handling by setting minstd of integer variables if it was not given and by integer centering', is_feasible='is_feasible  #v a function that computes feasibility, by default lambda x, f: f not in (None, np.nan)', maxfevals='inf  #v maximum number of function evaluations', maxiter='100 + 150 * (N+3)**2 // popsize**0.5  #v maximum number of iterations', mean_shift_line_samples='False #v sample two new solutions colinear to previous mean shift', mindx='0  #v minimal std in any arbitrary direction, cave interference with tol*', minstd='0  #v minimal std (scalar or vector) in any coordinate direction, cave interference with tol*', maxstd='None  #v maximal std (scalar or vector) in any coordinate direction', maxstd_boundrange='1/3  # maximal std relative to bound_range per coordinate, overruled by maxstd', pc_line_samples='False #v one line sample along the evolution path pc', popsize='4 + 3 * math.log(N)  # population size, AKA lambda, int(popsize) is the number of new solution per iteration', popsize_factor='1  # multiplier for popsize, convenience option to increase default popsize', randn='np.random.randn  #v randn(lam, N) must return an np.array of shape (lam, N), see also cma.utilities.math.randhss', scaling_of_variables='None  # deprecated, rather use fitness_transformations.ScaleCoordinates instead (or CMA_stds). WAS: Scale for each variable in that effective_sigma0 = sigma0*scaling. Internally the variables are divided by scaling_of_variables and sigma is unchanged, default is `np.ones(N)`', seed='time  # random number seed for `numpy.random`; `None` and `0` equate to `time`, `np.nan` means "do nothing", see also option "randn"', signals_filename='cma_signals.in  # read versatile options from this file which contains a single options dict, e.g. ``{"timeout": 0}`` to stop right away, some string-values are recognized, e.g. "np.inf" is valid, use `None` or `""` for no file', termination_callback='[]  #v a function or list of functions returning True for termination, called in `stop` with `self` as argument, could be abused for side effects', timeout='inf  #v stop if timeout seconds are exceeded, the string "2.5 * 60**2" evaluates to 2 hours and 30 minutes', tolconditioncov='1e14  #v stop if the condition of the covariance matrix is above `tolconditioncov`', tolfacupx='1e3  #v termination when step-size increases by tolfacupx (diverges). That is, the initial step-size was chosen far too small and better solutions were found far away from the initial solution x0', tolupsigma='1e20  #v sigma/sigma0 > tolupsigma * max(eivenvals(C)**0.5) indicates "creeping behavior" with usually minor improvements', tolflatfitness='1  #v iterations tolerated with flat fitness before termination', tolfun='1e-11  #v termination criterion: tolerance in function value, quite useful', tolfunhist='1e-12  #v termination criterion: tolerance in function value history', tolfunrel='0  #v termination criterion: relative tolerance in function value: Delta f current < tolfunrel * (median0 - median_min)', tolstagnation='int(100 + 100 * N**1.5 / popsize)  #v termination if no improvement over tolstagnation iterations', tolxstagnation='[1e-9, 20, 0.1]  #v termination thresholds for Delta of [mean, iterations, iterations fraction], the latter two are summed; trigger termination if Dmean stays below the threshold over Diter iterations, pass `False` or a negative value to turn off tolxstagnation', tolx='1e-11  #v termination criterion: tolerance in x-changes', transformation='None  # deprecated, use a wrapper like those in cma.fitness_transformations instead.', typical_x='None  # deprecated, use `cma.fitness_transformations.Shifted` instead', updatecovwait='None  #v number of iterations without distribution update, name is subject to future changes', verbose='3  #v verbosity e.g. of initial/final message and logging,\n -1 is very quiet, <=-9 is maximally quiet, <=-10 ignores the signals_filename', verb_append='0  # initial evaluation counter, if append, do not overwrite output files', verb_disp='100  #v verbosity: display console output every verb_disp iteration', verb_disp_overwrite='inf  #v start overwriting after given iteration', verb_filenameprefix='outcmaes\\  # output path (folder) and filenames prefix', verb_log='1  #v verbosity: write data to files every verb_log iteration, writing can be time critical on fast to evaluate functions', verb_log_expensive='N * (N <= 50)  # allow to execute eigendecomposition for logging every verb_log_expensive iteration, 0 or False for never', verb_plot='0  #v in fmin2(): plot() is called every verb_plot iteration', verb_time='True  #v output timings on console', vv='{}  #? versatile set or dictionary for hacking purposes, value found in self.opts["vv"]')
    use this function to get keyword completion for `CMAOptions`.

    ``cma.CMAOptions('substr')`` provides even substring search.

    returns default options as a `dict` (not a `cma.CMAOptions` `dict`).
cma.disp
Python Library Documentation: function disp in module cma.logger

disp(name=None, idx=None)
    displays selected data from (files written by) the class
    `CMADataLogger`.

    The call ``cma.disp(name, idx)`` is a shortcut for
    ``cma.CMADataLogger(name).disp(idx)``.

    Arguments
    ---------
    `name`
        name of the logger, filename prefix, `None` evaluates to
        the default ``'outcma/cma'``
    `idx`
        indices corresponding to rows in the data file; by
        default the first five, then every 100-th, and the last
        10 rows. Too large index values are removed.

    The best ever observed iteration is also printed by default.

    Examples
    --------
    ::

       import cma
       from numpy import r_
       # assume some data are available from previous runs
       cma.disp(None, r_[0, -1])  # first and last
       cma.disp(None, r_[0:int(1e9):100, -1]) # every 100-th and last
       cma.disp(idx=r_[0, -10:0]) # first and ten last
       cma.disp(idx=r_[0:int(1e9):1000, -10:0])

    :See: `CMADataLogger.disp`
cma.ff
Python Library Documentation: FitnessFunctions in module cma.fitness_functions object

class FitnessFunctions(builtins.object)
 |  collection of objective functions.
 |
 |  Methods defined here:
 |
 |  __init__(self)
 |
 |  absplussin(self, x)
 |      multimodal function with the global optimum at x_i = -1.152740846
 |
 |  branin(self, x)
 |
 |  bukin(self, x)
 |      Bukin function from Wikipedia, generalized simplistically from 2-D.
 |
 |      http://en.wikipedia.org/wiki/Test_functions_for_optimization
 |
 |  cigar(self, x, rot=0, cond=1000000.0, noise=0)
 |      Cigar test objective function
 |
 |  cigtab(self, y)
 |      Cigtab test objective function
 |
 |  cigtab2(self, x, condition=100000000.0, n_axes=None)
 |      cigtab with 1 + 5% long and short axes.
 |
 |      `n_axes: int`, if > 0, sets the number of long as well as short
 |      axes to `n_axes`, respectively.
 |
 |  cornerelli(self, x)
 |
 |  cornerellirot(self, x)
 |
 |  cornersphere(self, x)
 |      Sphere (squared norm) test objective function constraint to the corner
 |
 |  diagonal_cigar(self, x, cond=1000000.0)
 |
 |  diffpow(self, x, rot=0)
 |      Diffpow test objective function
 |
 |  dixonprice(self, x)
 |      Dixon-Price function.
 |
 |      The function has a local attractor at ``[1/3, 0, ..., 0]`` which
 |      starts to dominate for dimensions larger than about five. The
 |      global optimum is ``[1, 0.70710678, ...]`` with the limit of 1/2
 |      for increasing index.
 |
 |      >>> import cma
 |      >>> def xstar(n):
 |      ...     return [2**-((2**i - 2) / 2**i) for i in range(1, n + 1)]
 |      >>> assert cma.ff.dixonprice(xstar(4)) < 1e-11, cma.ff.dixonprice(xstar(4))
 |
 |      see https://al-roomi.org/benchmarks/unconstrained/n-dimensions/236-dixon-price-s-function
 |
 |  elli(self, x, rot=0, xoffset=0, cond=1000000.0, actuator_noise=0.0, beta_noise=0, both=False)
 |      Ellipsoid test objective function
 |
 |  elliconstraint(self, x, cfac=100000000.0, tough=True, cond=1000000.0)
 |      ellipsoid test objective function with "constraints"
 |
 |  ellihalfrot(self, x, frac=0.5, cond1=1000000.0, cond2=1000000.0)
 |      return ellirot(x[:N2]) + elli(x[N2:]) where ``N2`` is roughly ``frac*len(x)``
 |
 |  ellirot(self, x, cond=1000000.0)
 |
 |  elliwithoneconstraint(self, x, idx=[-1])
 |
 |  epslow(self, fun, eps=1e-07, Neff=<function FitnessFunctions.<lambda> at 0x000002890B487240>)
 |
 |  epslowsphere(self, x, eps=1e-07, Neff=<function FitnessFunctions.<lambda> at 0x000002890B487C40>)
 |      TODO: define as wrapper
 |
 |  flat(self, x)
 |
 |  fun_as_arg(self, x, *args)
 |      ``fun_as_arg(x, fun, *more_args)`` calls ``fun(x, *more_args)``.
 |
 |      Use case::
 |
 |          fmin(cma.fun_as_arg, args=(fun,), gradf=grad_numerical)
 |
 |      calls fun_as_args(x, args) and grad_numerical(x, fun, args=args)
 |
 |  goldsteinprice(self, x)
 |
 |  grad_cigar(self, x, *args)
 |
 |  grad_elli(self, x, *args)
 |
 |  grad_numerical(self, x, func, epsilon=None)
 |      symmetric gradient
 |
 |  grad_rosen(self, x, *args)
 |
 |  grad_sphere(self, x, *args)
 |
 |  grad_tablet(self, x, *args)
 |
 |  grad_to_one(self, x, *args)
 |
 |  griewank(self, x)
 |
 |  halfelli(self, x)
 |
 |  happycat(self, x, alpha=0.125)
 |      a difficult sharp ridge type function.
 |
 |      Proposed by HG Beyer.
 |
 |  hyperelli(self, x)
 |
 |  levy(self, x)
 |      a rather benign multimodal function.
 |
 |      xopt == ones, fopt == 0.0
 |
 |  lincon(self, x, theta=0.01)
 |      ridge like linear function with one linear constraint
 |
 |  linear(self, x)
 |
 |  lineard(self, x)
 |
 |  noise(self, x, func=<function FitnessFunctions.sphere at 0x000002890B487560>, fac=10, expon=1)
 |
 |  noiseC(self, x, func=<function FitnessFunctions.sphere at 0x000002890B487560>, fac=10, expon=0.8)
 |
 |  noisysphere(self, x, noise=2.1e-09, cond=1.0, noise_offset=0.1)
 |      noise=10 does not work with default popsize, ``cma.NoiseHandler(dimension, 1e7)`` helps
 |
 |  normalSkew(self, f)
 |
 |  optprob(self, x)
 |
 |  partsphere(self, x)
 |      Sphere (squared norm) test objective function
 |
 |  pnorm(self, x, p=0.5)
 |
 |  powel_singular(self, x)
 |
 |  rand(self, x)
 |      Random test objective function
 |
 |  rastrigin(self, x)
 |      Rastrigin test objective function
 |
 |  ridge(self, x, expo=2)
 |
 |  ridgecircle(self, x, expo=0.5)
 |      a difficult sharp ridge type function.
 |
 |      A modified implementation of HG Beyers `happycat`.
 |
 |  rosen(self, x, alpha=100.0)
 |      Rosenbrock test objective function, x0=0
 |
 |  rosen0(self, x, alpha=100.0)
 |      Rosenbrock test objective function with optimum in all-zeros, x0=-1
 |
 |  rosen_chained(self, x, alpha=100.0)
 |
 |  rosen_nesterov(self, x, rho=100)
 |      needs exponential number of steps in a non-increasing
 |      f-sequence.
 |
 |      x_0 = (-1,1,...,1)
 |      See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock
 |      Function"
 |
 |  rosenelli(self, x)
 |
 |  rot(self, x, fun, rot=1, args=())
 |      returns ``fun(rotation(x), *args)``, ie. `fun` applied to a rotated argument
 |
 |  schaffer(self, x)
 |      Schaffer function x0 in [-100..100]
 |
 |  schwefel2_22(self, x)
 |      Schwefel 2.22 function
 |
 |  schwefelelli(self, x)
 |
 |  schwefelmult(self, x, pen_fac=10000.0)
 |      multimodal Schwefel function with domain -500..500
 |
 |  sectorsphere(self, x)
 |      asymmetric Sphere (squared norm) test objective function
 |
 |  somenan(self, x, fun, p=0.1)
 |      returns sometimes np.nan, otherwise fun(x)
 |
 |  sphere(self, x)
 |      Sphere (squared norm) test objective function
 |
 |  sphere_pos(self, x)
 |      Sphere (squared norm) test objective function
 |
 |  spherew(self, x)
 |      Sphere (squared norm) with sum x_i = 1 test objective function
 |
 |  spherewithnconstraints(self, x)
 |
 |  spherewithoneconstraint(self, x)
 |
 |  styblinski_tang(self, x)
 |      in [-5, 5]
 |      found also in Lazar and Jarre 2016, optimum in f(-2.903534...)=0
 |
 |  subspace_sphere(self, x, visible_ratio=0.5)
 |
 |  tablet(self, x, cond=1000000.0, rot=0)
 |      Tablet test objective function
 |
 |  trid(self, x)
 |
 |  twoaxes(self, y, cond=1000000.0)
 |      Cigtab test objective function
 |
 |  xinsheyang2(self, x, termination_friendly=True)
 |      a multimodal function which is rather unsolvable in larger dimension.
 |
 |      >>> import functools
 |      >>> import numpy as np
 |      >>> import cma
 |      >>> f = functools.partial(cma.ff.xinsheyang2, termination_friendly=False)
 |      >>> X = [(i * [0] + (4 - i) * [1.24]) for i in range(5)]
 |      >>> for x in X: print(x)
 |      [1.24, 1.24, 1.24, 1.24]
 |      [0, 1.24, 1.24, 1.24]
 |      [0, 0, 1.24, 1.24]
 |      [0, 0, 0, 1.24]
 |      [0, 0, 0, 0]
 |      >>> ' '.join(['{0:.3}'.format(f(x)) for x in X])  # [np.round(f(x), 3) for x in X]
 |      '0.091 0.186 0.336 0.456 0.0'
 |
 |      One needs to solve a trinary deceptive function where f-value (to
 |      be minimized) is monotonuously decreasing with increasing distance
 |      to the global optimum >= 1. That is, the global optimum is
 |      surrounded by 3^n - 1 local optima that have the better values the
 |      further they are away from the global optimum.
 |
 |      Conclusion: it is a rather suspicious sign if an algorithm finds the global
 |      optimum of this function in larger dimension.
 |
 |      See also http://benchmarkfcns.xyz/benchmarkfcns/xinsheyangn2fcn.html
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  binval(x, foffset=None)
 |      return ``sum_i(0 if (optimum[0] <= x[i] <= optimum[1]) else 2**i)``
 |
 |      to be minimized and add `binary_foffset` at the optimum.
 |
 |      Details: the result is computed as `int`, because in dimension > 54
 |      a `float` representation can not account for the least sensitive
 |      bit anymore. Because we minimize, this is not necessarily a big
 |      problem.
 |
 |  leadingones(x, foffset=None)
 |      return ``len(x) - nb of leading-ones-in-x`` to be minimized,
 |
 |      where only values in [optimum[0], optimum[1]] are considered to be
 |      "equal to" 1 and add `binary_foffset` at the optimum.
 |
 |  onemax(x, foffset=None)
 |      return ``sum_i(0 if (optimum[0] <= x[i] <= optimum[1]) else 1)``
 |
 |      to be minimized and add `binary_foffset` at the optimum.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  BBOB
 |      BBOB noiseless testbed.
 |
 |      The optimisation test functions are represented as classes `F1` to
 |      `F24` (and `F101` to `F130`).
 |
 |      This module implements the class `BBOBFunction` and
 |      sub-classes:
 |
 |      * class `BBOBNfreeFunction` which have all the methods common to the
 |        classes `F1` to `F24`
 |      * classes `BBOBGaussFunction`, `BBOBCauchyFunction`,
 |        `BBOBUniformFunction` which have methods in classes from
 |        `F101` to `F130`
 |
 |      Module attributes:
 |
 |      * `dictbbob` is a dictionary such that dictbbob[2] contains
 |        the test function class F2 and f2 = dictbbob[2]() returns
 |        the instance 0 of the test function that can be
 |        called as f2([1,2,3]).
 |      * `nfreeIDs` == range(1,25) indices for the noiseless functions that can be
 |        found in dictbbob
 |      * `noisyIDs` == range(101, 131) indices for the noisy functions that can be
 |        found in dictbbob. We have nfreeIDs + noisyIDs == sorted(dictbbob.keys())
 |      * `nfreeinfos` function infos
 |
 |      Examples:
 |
 |      >>> from cma import bbobbenchmarks as bn
 |
 |      This does not work with ``python -OO``::
 |
 |          >> for s in bn.nfreeinfos:
 |          ..    print(s)
 |          1: Noise-free Sphere function
 |          2: Separable ellipsoid with monotone transformation
 |          <BLANKLINE>
 |              Parameter: condition number (default 1e6)
 |          <BLANKLINE>
 |          <BLANKLINE>
 |          3: Rastrigin with monotone transformation separable "condition" 10
 |          4: skew Rastrigin-Bueche, condition 10, skew-"condition" 100
 |          5: Linear slope
 |          6: Attractive sector function
 |          7: Step-ellipsoid, condition 100, noise-free
 |          8: Rosenbrock noise-free
 |          9: Rosenbrock, rotated
 |          10: Ellipsoid with monotone transformation, condition 1e6
 |          11: Discus (tablet) with monotone transformation, condition 1e6
 |          12: Bent cigar with asymmetric space distortion, condition 1e6
 |          13: Sharp ridge
 |          14: Sum of different powers, between x^2 and x^6, noise-free
 |          15: Rastrigin with asymmetric non-linear distortion, "condition" 10
 |          16: Weierstrass, condition 100
 |          17: Schaffers F7 with asymmetric non-linear transformation, condition 10
 |          18: Schaffers F7 with asymmetric non-linear transformation, condition 1000
 |          19: F8F2 sum of Griewank-Rosenbrock 2-D blocks, noise-free
 |          20: Schwefel with tridiagonal variable transformation
 |          21: Gallagher with 101 Gaussian peaks, condition up to 1000, one global rotation, noise-free
 |          22: Gallagher with 21 Gaussian peaks, condition up to 1000, one global rotation
 |          23: Katsuura function
 |          24: Lunacek bi-Rastrigin, condition 100
 |          <BLANKLINE>
 |              in PPSN 2008, Rastrigin part rotated and scaled
 |          <BLANKLINE>
 |          <BLANKLINE>
 |
 |      >>> f3 = bn.F3(13)  # instantiate instance 13 of function f3
 |      >>> float(f3([0, 1, 2])) # short-cut for f3.evaluate([0, 1, 2]) # doctest:+ELLIPSIS
 |      59.8733529...
 |      >>> print(bn.instantiate(5)[1])  # returns function instance and optimal f-value
 |      51.53
 |      >>> print(bn.nfreeIDs) # list noise-free functions
 |      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
 |      >>> for i in bn.nfreeIDs: # evaluate all noiseless functions once
 |      ...    print(bn.instantiate(i)[0]([0., 0., 0., 0.])) # doctest:+ELLIPSIS
 |      -77.2745459...
 |      6180022.8217...
 |      92.987750752...
 |      92.987750752...
 |      140.51011761...
 |      70877.955412...
 |      -72.550520219...
 |      33355.792472...
 |      -339.94
 |      4374717.4934...
 |      15631566.348...
 |      4715481.086...
 |      550.59978390...
 |      -17.299175622...
 |      27.363312851...
 |      -227.82783352...
 |      -24.330591878...
 |      131.42015934...
 |      40.710373742...
 |      6160.8178292...
 |      376.74688954...
 |      107.83042676...
 |      220.48226655...
 |      106.09476738...
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  evaluations = 0
cma.fmin
Python Library Documentation: function fmin in module cma.evolution_strategy

fmin(objective_function, x0, sigma0, *posargs, **kwargs)
    DEPRECATED: use `fmin2` instead.

    `fmin` will remain fully functional and be maintained in the foreseeable future.

    Return
    ======
    Return the list provided in `CMAEvolutionStrategy.result` appended
    with termination conditions, an `OOOptimizer` and a `BaseDataLogger`::

        res = es.result + (es.stop(), es, logger)

    where
        - ``res[0]`` (``xbest``) -- best evaluated solution
        - ``res[1]`` (``fbest``) -- respective function value
        - ``res[2]`` (``evals_best``) -- respective number of function evaluations
        - ``res[3]`` (``evaluations``) -- number of overall conducted objective function evaluations
        - ``res[4]`` (``iterations``) -- number of overall conducted iterations
        - ``res[5]`` (``xfavorite``) -- mean of the final sample distribution
        - ``res[6]`` (``stds``) -- effective stds of the final sample distribution
        - ``res[-3]`` (``stop``) -- termination condition(s) in a dictionary
        - ``res[-2]`` (``es``) -- class `CMAEvolutionStrategy` instance
        - ``res[-1]`` (``logger``) -- class `CMADataLogger` instance == es.logger

    The successor `fmin2` is an alias for::

        res = fmin(...)
        return res[0], res[-2]

    For descriptions of the input arguments see `fmin2`.

    For completness, recovering the output of `fmin` from `fmin2`::

        es = fmin2(...)[1]  # fmin2(...)[0] is es.result.xbest
        return es.result + (es.stop(), es, es.logger)

    The best found solution is equally available under::

        fmin(...)[0]
        fmin2(...)[0]
        fmin2(...)[1].result[0]
        fmin2(...)[1].result.xbest
        fmin2(...)[1].best.x

    The incumbent, current estimate for the optimum is available under::

        fmin(...)[5]
        fmin2(...)[1].result[5]
        fmin2(...)[1].result.xfavorite

    Examples
    ========
    The following example calls `fmin` optimizing the Rosenbrock function
    in 10-D with initial solution 0.1 and initial step-size 0.5. The
    options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'CMA_diagonal':100, 'seed':1234, 'verb_time':0}
    >>>
    >>> res = cma.fmin(cma.ff.rosen, [0.1] * 10, 0.3, options)  #doctest: +ELLIPSIS
    (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 10 (seed=1234...)
       Covariance matrix is diagonal for 100 iterations (1/ccov=26...
    Iterat #Fevals   function value  axis ratio  sigma ...
        1     10 ...
    termination on {'tolfun': 1e-11} ...
    final/bestever f-value = ...
    >>> assert res[1] < 1e-12  # f-value of best found solution
    >>> assert res[2] < 8000  # evaluations

    The above call is pretty much equivalent with the slightly more
    verbose call::

        res = cma.CMAEvolutionStrategy([0.1] * 10, 0.3,
                    options=options).optimize(cma.ff.rosen).result

    where `optimize` returns a `CMAEvolutionStrategy` instance. The
    following example calls `fmin` optimizing the Rastrigin function
    in 3-D with random initial solution in [-2,2], initial step-size 0.5
    and the BIPOP restart strategy (that progressively increases population).
    The options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'seed':12345, 'verb_time':0, 'ftarget': 1e-8}
    >>>
    >>> res = cma.fmin(cma.ff.rastrigin, lambda : 2. * np.random.rand(3) - 1, 0.5,
    ...                options, restarts=9, bipop=True)  #doctest: +ELLIPSIS
    (3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=12345...

    In either case, the method::

        cma.plot();

    (based on `matplotlib.pyplot`) produces a plot of the run and, if
    necessary::

        cma.s.figshow()

    shows the plot in a window. Finally::

        cma.s.figsave('myfirstrun')  # figsave from matplotlib.pyplot

    will save the figure in a png.

    We can use the gradient like

    >>> import cma, warnings
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter('ignore', category=cma.warnings_and_exceptions.NeverTestedWarning)
    ...     res = cma.fmin(cma.ff.rosen, np.zeros(10), 0.1,
    ...             options = {'ftarget':1e-8,},
    ...             gradf=cma.ff.grad_rosen,
    ...         )  #doctest: +ELLIPSIS
    (5_w,...
    >>> assert cma.ff.rosen(res[0]) < 1e-8
    >>> assert res[2] < 3600  # 1% are > 3300
    >>> assert res[3] < 3600  # 1% are > 3300

    If solution can only be comparatively ranked, either use
    `CMAEvolutionStrategy` directly or the objective accepts a list
    of solutions as input:

    >>> def parallel_sphere(X): return [cma.ff.sphere(x) for x in X]
    >>> x, es = cma.fmin2(None, 3 * [0], 0.1, {'verbose': -9},
    ...                   parallel_objective=parallel_sphere)
    >>> assert es.result[1] < 1e-9

    :See also: `CMAEvolutionStrategy`, `OOOptimizer.optimize`, `plot`,
        `CMAOptions`, `scipy.optimize.fmin`
cma.fmin2
Python Library Documentation: function fmin2 in module cma.evolution_strategy

fmin2(objective_function, x0, sigma0, options=None, args=(), gradf=None, restarts=0, restart_from_best=False, incpopsize=2, eval_initial_x=False, parallel_objective=None, noise_handler=None, noise_change_sigma_exponent=1, noise_kappa_exponent=0, bipop=False, callback=None, init_callback=None, constraints=None)
    functional interface to the stochastic optimizer CMA-ES
    for non-convex function minimization.

    Return the `tuple` ``(xbest, es)`` where ``es`` is a
    `CMAEvolutionStrategy` instance, see in particular ``es.result`` and
    ``es.result_pretty()`` for detailed results.


    Calling Sequences
    =================
    ``x, es = fmin2(objective_function, x0, sigma0)``
        minimizes ``objective_function`` starting at ``x0`` and with
        standard deviation ``sigma0`` (step-size)
    ``x, es = fmin2(objective_function, x0, sigma0, options={'ftarget': 1e-5})``
        minimizes ``objective_function`` up to target function value 1e-5,
        which is typically useful for benchmarking.
    ``x, es = fmin2(objective_function, x0, sigma0, args=('f',))``
        minimizes ``objective_function`` called with an additional
        argument ``'f'``.
    ``x, es = fmin2(objective_function, x0, sigma0, options={'ftarget':1e-5, 'popsize':40})``
        uses additional options ``ftarget`` and ``popsize``
    ``x, es = fmin2(objective_function, esobj, None, options={'maxfevals': 1e5})``
        uses the `CMAEvolutionStrategy` object instance ``esobj`` to
        optimize ``objective_function``, similar to ``esobj.optimize()``.

    Less recommended calling patterns are::

        es = cma.fmin2(...)[1]  # `es` contains all available information
        x = cma.fmin2(...)[0]   # keep only the best evaluated solution

    Arguments
    =========
    The order of arguments is kept for historical reasons.

    ``objective_function``
        called as ``objective_function(x, *args)`` to be minimized. ``x``
        is a one-dimensional `numpy.ndarray`. See also the
        `parallel_objective` argument. ``objective_function`` can return
        `numpy.NaN`, which is interpreted as outright rejection of solution
        ``x`` and invokes an immediate resampling and (re-)evaluation of a
        new solution not counting as function evaluation. The attribute
        ``variable_annotations`` is passed into the
        ``CMADataLogger.persistent_communication_dict``. See also
        ``constraints`` below.
    ``x0``
        list or `numpy.ndarray`, initial guess of minimum solution
        before the application of the geno-phenotype transformation
        according to the ``transformation`` option.  It can also be a
        callable that is called (without input argument) before each
        restart to yield the initial guess such that each restart may start
        from a different place. Otherwise, ``x0`` can also be a
        `cma.CMAEvolutionStrategy` object instance, in that case ``sigma0``
        can be ``None``.
    ``sigma0``
        scalar, initial standard deviation in each coordinate.
        ``sigma0`` should be about 1/4th of the search domain width
        (where the optimum is to be expected). The variables in
        ``objective_function`` should be scaled such that they
        presumably have similar sensitivity.
        See also `ScaleCoordinates`.
    ``options``
        a dictionary with additional options passed to the constructor
        of class ``CMAEvolutionStrategy``, see ``cma.CMAOptions`` ()
        for a list of available options.
    ``args=()``
        arguments to be used to call the ``objective_function``
    ``gradf=None``
        gradient of f, where ``len(gradf(x, *args)) == len(x)``.
        ``gradf`` is called once in each iteration if
        ``gradf is not None``.
    ``restarts=0``
        number of restarts with increasing population size, see also
        parameter ``incpopsize``. For the time being (this may change in
        future) ``restarts`` can also be a `dict` where the keys
        ``maxrestarts=9`` and ``maxfevals=np.inf`` are interpreted. An
        empty `dict` is interpreted as ``restarts=0``. An IPOP-CMA-ES
        restart is invoked if ``restarts > 0`` or ``restarts['maxrestarts']
        > 0`` and if ``current_evals < min((restarts['maxfevals'],
        options['maxfevals']))`` and neither the ``'ftarget'`` nor the
        ``termination_callback`` option was triggered;
        ``restarts['maxfevals']`` does not terminate *during* the run or
        restart; to restart from different points (recommended), pass
        ``x0`` as a `callable`; see also parameter ``bipop``.
    ``restart_from_best=False``
        which point to restart from
    ``incpopsize=2``
        multiplier for increasing the population size ``popsize`` before
        each restart
    ``parallel_objective``
        an objective function that accepts a list of `numpy.ndarray` as
        input and returns a `list`, which is mostly used instead of
        `objective_function`, but for the initial (also initial
        elitist) and the final evaluations unless
        ``not callable(objective_function)``. If ``parallel_objective``
        is given, the ``objective_function`` (first argument) may be
        ``None``.
    ``eval_initial_x=None``
        evaluate initial solution, for ``None`` only with elitist option
    ``noise_handler=None``
        must be `True` or a `cma.NoiseHandler` class or instance to invoke
        noise handling. The latter gives control over the specific settings
        for the noise handling, see ``help(cma.NoiseHandler)``.
    ``noise_change_sigma_exponent=1``
        exponent for the sigma increment provided by the noise handler for
        additional noise treatment. 0 means no sigma change.
    ``noise_evaluations_as_kappa=0``
        instead of applying reevaluations, the "number of evaluations"
        is (ab)used as scaling factor kappa (experimental).
    ``bipop=False``
        if ``bool(bipop) is True``, run as BIPOP-CMA-ES; BIPOP is a special
        restart strategy switching between two population sizings - small
        (relative to the large population size and with varying initial
        sigma, the first run is accounted on the "small" budget) and large
        (progressively increased as in IPOP). This makes the algorithm
        potentially solve both, functions with many regularly or
        irregularly arranged local optima (the latter by frequently
        restarting with small populations). Small populations are
        (re-)started as long as the cumulated budget_small is smaller than
        `bipop` x max(1, budget_large). For the `bipop` parameter to
        actually conduct restarts also with the larger population size,
        select a non-zero number of (IPOP) restarts; the recommended
        setting is ``restarts <= 9`` and `x0` passed as a `callable`
        that generates randomized initial solutions. Small-population
        restarts do not count into the total restart count.
    ``callback=None``
        `callable` or list of callables called at the end of each
        iteration with the current `CMAEvolutionStrategy` instance
        as argument.
    ``init_callback=None``
        `callable` or list of callables called at the end of initialization
        of the `CMAEvolutionStrategy` instance with this instance as
        argument (like `callback`). This allows to reassign attributes
        without a corresponding `CMAOption`. For example,
        ``es.integer_centering = lambda *args: None`` disables integer
        centering (which is enabled by default when ``integer_variables``
        are given in the `options`) or ``es.integer_centering =
        cma.integer_centering.IntCentering(es, correct_bias=False)``
        disables its bias correction.
    ``constraints``
        A function that takes a solution `x` as input and returns a list of
        constraint values desired to become <= 0.

    Optional Arguments
    ==================
    All values in the `options` dictionary are evaluated if they are of
    type `str`, besides `verb_filenameprefix`, see class `CMAOptions` for
    details. The full list is available by calling ``cma.CMAOptions()``.

    >>> import cma
    >>> cma.CMAOptions()  #doctest: +ELLIPSIS
    {...

    Subsets of options can be displayed, for example like
    ``cma.CMAOptions('tol')``, or ``cma.CMAOptions('bound')``,
    see also class `CMAOptions`.

    Details
    =======
    This function is an interface to the class `CMAEvolutionStrategy`. The
    latter class should be used when full control over the iteration loop
    of the optimizer is desired.

    Examples
    ========
    The following example calls `fmin2` optimizing the Rosenbrock function
    in 10-D with initial solution 0.1 and initial step-size 0.5. The
    options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'CMA_diagonal':100, 'seed':1234, 'verb_time':0}
    >>>
    >>> x, es = cma.fmin2(cma.ff.rosen, [0.1] * 10, 0.3, options)  #doctest: +ELLIPSIS
    (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 10 (seed=1234...)
       Covariance matrix is diagonal for 100 iterations (1/ccov=26...
    Iterat #Fevals   function value  axis ratio  sigma ...
        1     10 ...
    termination on {'tolfun': 1e-11} ...
    final/bestever f-value = ...
    >>> assert es.result.fbest < 1e-12  # f-value of best found solution
    >>> assert es.result.evaluations < 8000  # evaluations

    The above call is pretty much equivalent with the slightly more
    verbose call::

        es = cma.CMAEvolutionStrategy([0.1] * 10, 0.3,
                    options=options).optimize(cma.ff.rosen)
        x = es.result.xbest

    where `optimize` returns the `CMAEvolutionStrategy` instance. The
    following example calls `fmin2` optimizing the Rastrigin function
    in 3-D with random initial solution in [-2,2], initial step-size 0.5
    and the BIPOP restart strategy (that progressively increases population).
    The options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'seed':12345, 'verb_time':0, 'ftarget': 1e-8}
    >>>
    >>> x, es = cma.fmin2(cma.ff.rastrigin, lambda : 2. * np.random.rand(3) - 1, 0.5,
    ...                   options, restarts=9, bipop=True)  #doctest: +ELLIPSIS
    (3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=12345...

    In either case, the method::

        cma.plot();

    (based on `matplotlib.pyplot`) produces a plot of the run and, if
    necessary::

        cma.s.figshow()

    shows the plot in a window. Finally::

        cma.s.figsave('myfirstrun')  # figsave from matplotlib.pyplot

    will save the figure in a png. The figure data can be saved like::

        es.logger.zip()

    We can use the gradient like

    >>> import cma, warnings
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter('ignore', category=cma.warnings_and_exceptions.NeverTestedWarning)
    ...     x, es = cma.fmin2(cma.ff.rosen, np.zeros(10), 0.1,
    ...             options = {'ftarget':1e-8,},
    ...             gradf=cma.ff.grad_rosen,
    ...         )  #doctest: +ELLIPSIS
    (5_w,...
    >>> assert cma.ff.rosen(es.result.xbest) < 1e-8
    >>> assert es.result.evals_best < 3600  # 1% are > 3300
    >>> assert es.result.evaluations < 3600  # 1% are > 3300

    If solutions can only be comparatively ranked, either use
    `CMAEvolutionStrategy` directly via `ask` and `tell` or a "parallel"
    objective function accepting a list of solutions as input which
    returns, for example, the solution ranks:

    >>> def parallel_sphere(X): return [cma.ff.sphere(x) for x in X]
    >>> x, es = cma.fmin2(None, 3 * [0], 0.1, {'verbose': -9},
    ...                   parallel_objective=parallel_sphere)
    >>> assert es.result.fbest < 1e-9

    :See also: `CMAEvolutionStrategy`, `OOOptimizer.optimize`, `plot`,
        `CMAOptions`, `scipy.optimize.fmin`
cma.fmin_con
Python Library Documentation: function fmin_con in module cma.evolution_strategy

fmin_con(objective_function, x0, sigma0, g=<function no_constraints at 0x000002890B3FE480>, h=<function no_constraints at 0x000002890B3FE480>, post_optimization=False, archiving=True, **kwargs)
    DEPRECATED: use `cma.ConstrainedFitnessAL` or `cma.fmin_con2` instead.

    Optimize f with constraints g (inequalities) and h (equalities).

    Construct an Augmented Lagrangian instance ``f_aug_lag`` of the type
    `cma.constraints_handler.AugmentedLagrangian` from `objective_function`
    and `g` and `h`.

    Equality constraints should preferably be passed as two inequality
    constraints like ``[h - eps, -h - eps]``, with eps >= 0. When eps > 0,
    also feasible solution tracking can succeed.

    Return a `tuple` ``es.results.xfavorite:numpy.array, es:CMAEvolutionStrategy``,
    where ``es == cma.fmin2(f_aug_lag, x0, sigma0, **kwargs)[1]``.

    Depending on ``kwargs['logging']`` and on the verbosity settings in
    ``kwargs['options']``, the `AugmentedLagrangian` writes (hidden)
    logging files.

    The second return value:`CMAEvolutionStrategy` has an (additional)
    attribute ``best_feasible`` which contains the information about the
    best feasible solution in the ``best_feasible.info`` dictionary, given
    any feasible solution was found. This only works with inequality
    constraints (equality constraints are wrongly interpreted as inequality
    constraints).

    If `post_optimization` is set to True, then the attribute ``best_feasible``
    of the second return value will be updated with the best feasible solution obtained by
    optimizing the sum of the positive constraints squared starting from
    the point ``es.results.xfavorite``. Additionally, the first return value will
    be the best feasible solution obtained in post-optimization.

    In case when equality constraints are present and a "feasible" solution is requested,
    then `post_optimization` must be a strictly positive float indicating the error
    on the inequality constraints.

    The second return value:`CMAEvolutionStrategy` has also a
    `con_archives` attribute which is nonempty if `archiving`. The last
    element of each archive is the best feasible solution if there was any.

    See `cma.fmin2` for the further parameters ``**kwargs``.

    >>> import cma
    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 3 * [0], 1, g=lambda x: [1 - x[0]**2, -(1 - x[0]**2) - 1e-6],
    ...             options={'termination_callback': lambda es: -1e-5 < sum(es.mean**2) - 1 < 1e-5,
    ...                      'verbose':-9})
    >>> assert 'callback' in es.stop()
    >>> assert es.result.evaluations < 1500  # 10%-ish above 1000, 1%-ish above 1300
    >>> assert (sum(es.mean**2) - 1)**2 < 1e-9, es.mean

    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 2 * [0], 1, g=lambda x: [1 - x[0]**2],
    ...             options={'termination_callback': lambda es: -1e-8 < sum(es.mean**2) - 1 < 1e-8,
    ...                      'seed':1, 'verbose':-9})
    >>> assert es.best_feasible.f < 1 + 1e-5, es.best_feasible.f
    >>> ".info attribute dictionary keys: {0}".format(sorted(es.best_feasible.info))
    ".info attribute dictionary keys: ['f', 'g', 'g_al', 'x']"

    Details: this is a versatile function subject to changes. It is possible to access
    the `AugmentedLagrangian` instance like

    >>> al = es.augmented_lagrangian
    >>> isinstance(al, cma.constraints_handler.AugmentedLagrangian)
    True
    >>> # al.logger.plot()  # plots the evolution of AL coefficients

    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 2 * [0], 1, g=lambda x: [y+1 for y in x],
    ...             post_optimization=True, options={"verbose": -9})
    >>> assert all(y <= -1 for y in x)  # assert feasibility of x
cma.fmin_con2
Python Library Documentation: function fmin_con2 in module cma.evolution_strategy

fmin_con2(objective_function, x0, sigma0, constraints=<function no_constraints at 0x000002890B3FE480>, find_feasible_first=False, find_feasible_final=False, kwargs_confit=None, **kwargs_fmin)
    optimize f with inequality constraints g.

    `constraints` is a function that returns a list of constraints values,
    where feasibility means <= 0. An equality constraint ``h(x) == 0`` can
    be expressed as two inequality constraints like ``[h(x) - eps, -h(x) -
    eps]`` with ``eps >= 0``.

    `find_feasible_...` arguments toggle to search for a feasible solution
    before and after the constrained problem is optimized. Because this can
    not work with equality constraints, where the feasible domain has zero
    volume, find-feasible arguments are `False` by default.

    `kwargs_confit` are keyword arguments to instantiate
    `constraints_handler.ConstrainedFitnessAL` which is optimized and
    returned as `objective_function` attribute in the second return
    argument (type `CMAEvolutionStrategy`).

    Other and further keyword arguments are passed (in ``**kwargs_fmin``)
    to `cma.fmin2`.

    Consider using `ConstrainedFitnessAL` directly instead of `fmin_con2`.
cma.fmin_lq_surr
Python Library Documentation: function fmin_lq_surr in module cma.evolution_strategy

fmin_lq_surr(objective_function, x0, sigma0, options=None, **kwargs)
    minimize `objective_function` with lq-CMA-ES.

    See ``help(cma.fmin)`` for the input parameter descriptions where
    `parallel_objective` is not available and noise-related options may
    fail.

    Returns the tuple ``xbest, es`` similar to `fmin2`, however `xbest`
    takes into account only some of the recent history and not all
    evaluations. `es.result` is partly based on surrogate f-values and may
    hence be confusing. In particular, `es.best` contains the solution with
    the best _surrogate_ value (which is usually of little interest). See
    `fmin_lq_surr2` for a fix.

    As in general, `es.result.xfavorite` is considered the best available
    estimate of the optimal solution.

    Example code
    ------------

    >>> import cma
    >>> x, es = cma.fmin_lq_surr(cma.ff.rosen, 2 * [0], 0.1,
    ...                          {'verbose':-9,  # verbosity for doctesting
    ...                           'ftarget':1e-2, 'seed':11})
    >>> assert 'ftarget' in es.stop(), (es.stop(), es.result_pretty())
    >>> assert es.result.evaluations < 90, es.result.evaluations  # can be 137 depending on seed

    Details
    -------
    lq-CMA-ES builds a linear or quadratic (global) model as a surrogate to
    try to circumvent evaluations of the objective function, see link below.

    This function calls `fmin2` with a surrogate as ``parallel_objective``
    argument. The model is kept the same for each restart. Use
    `fmin_lq_surr2` if this is not desirable.

    ``kwargs['callback']`` is modified by appending a callable that injects
    ``model.xopt``. This can be prevented by passing `callback=False` or
    adding `False` as an element of the callback list (see also `cma.fmin`).

    ``parallel_objective`` is assigned to a surrogate model instance of
    ``cma.fitness_models.SurrogatePopulation``.

    `es.countevals` is updated from the `evaluations` attribute of the
    constructed surrogate to count only "true" evaluations.

    See https://cma-es.github.io/lq-cma for references and details about
    the algorithm.
cma.fmin_lq_surr2
Python Library Documentation: function fmin_lq_surr2 in module cma.evolution_strategy

fmin_lq_surr2(objective_function, x0, sigma0, options=None, inject=True, restarts=0, incpopsize=2, keep_model=False, not_evaluated=<ufunc 'isnan'>, callback=None)
    minimize `objective_function` with lq-CMA-ES.

    `x0` is the initial solution or can be a callable that returns an
    initial solution (different for each restarted run). See ``cma.fmin``
    for further input documentations and ``cma.CMAOptions()`` for the
    available options.

    `inject` determines whether the best solution of the model is
    reinjected in each iteration. By default, a new surrogate model is used
    after each restart (``keep_model=False``) and the population size is
    multiplied by a factor of two (``incpopsize=2``) like in IPOP-CMA-ES
    (see also ``help(cma.fmin)``).

    Returns the tuple ``xbest, es`` like `fmin2`. As in general,
    `es.result.xfavorite` (and `es.mean` as genotype) is considered the
    best available estimate of the optimal solution.

    Example code
    ------------

    >>> import cma
    >>> x, es = cma.fmin_lq_surr2(cma.ff.rosen, 2 * [0], 0.1,
    ...                           {'verbose':-9,  # verbosity for doctesting
    ...                            'ftarget':1e-2, 'seed':3})
    >>> assert 'ftarget' in es.stop(), (es.stop(), es.result_pretty())
    >>> assert es.result.evaluations < 90, es.result.evaluations  # can be >130? depending on seed
    >>> assert es.countiter < 60, es.countiter

    Details
    -------
    lq-CMA-ES builds a linear or quadratic (global) model as a surrogate to
    circumvent evaluations of the objective function, see link below.

    This code uses the ask-and-tell interface to CMA-ES via the class
    `CMAEvolutionStrategy` to the `options` `dict` is passed.

    To pass additional arguments to the objective function use
    `functools.partial`.

    `not_evaluated` must return `True` if a value indicates (by convention
    of `cma.fitness_models.SurrogatePopulation.EvaluationManager.fvalues`)
    a missing "true" evaluation of the `objective_function`.

    See https://cma-es.github.io/lq-cma for references and details about
    the algorithm.
cma.plot
Python Library Documentation: function plot in module cma.logger

plot(name=None, fig=None, abscissa=0, downsample_to=3000.0, xnormalize=None, **kwargs)
    plot data from files written by a `CMADataLogger`,

    see `cma.CMADataLogger.plot` to see all valid keyword arguments.

    ``cma.plot()`` plots the data from the default output folder (which is
    by default always overwritten). ``cma.plot(name, **argsdict)`` is a
    shortcut for ``cma.CMADataLogger(name).plot(**argsdict)``.

    `name` is the filename prefix of the logger, `None` evaluates to the
    default ``'outcmaes/'`` (hence writing in a subfolder).

    The explictly given arguments are for backwards compatibility of their
    default setting and may disappear. All arguments are documented in
    `CMADataLogger.plot`.

        Arguments
        ---------
        `fig`: figure number, by default starting from 325

        `iabscissa` or `abscissa`: ``0 ==>`` plot versus iteration count,
        ``1 ==>`` plot versus function evaluation number

        `iteridx`: the iteration indices to plot, e.g. ``range(100)`` for
        the first 100 evaluations.

        ``plot_mean in (True, False, 'log', 'lin', 'linear', 'only')`` indicates
        whether and how to plot the mean (possibly instead the current best)

        `foffset:float` a small value added to f values to improve log-plot
        appearance.

        `downsample_to`: number of data lines to use at most

        `x_opt`: plot x-values as a difference to another solution and/or
        select a subset of variables to plot.

        If `x_opt` is a nonnegative `int`, it is interpreted as
        iteration number and the difference of ``x`` to the respective
        (closest but not larger) iteration is plotted.

        If `x_opt` is a negative `int` the respective index rather than
        the iteration is used. Namely and in particular, ``x_opt=0``
        subtracts the initial solution ``X0`` and ``x_opt=-1``
        subtracts the final solution of the data.

        If ``len(x_opt) == dimension`` or `x_opt` is a float, the
        difference to `x_opt` is plotted.

        Otherwise: ``x_opt[0]`` defines the indices of the variables to
        be plotted where ``x_opt[1]``, if present, is subtracted.

        `xsemilog:bool`: customized semilog plot for x-values

        `xnormalize:bool`: divide x-values by standard deviations, may show stationary
            behavior when the optimum is in zero

        `xtransform:callable` is a function that returns transformed x-values,
        applied before `x_opt` is subtracted and `xnormalize` is done.

        `fshift:float` is added to all displayed fitness values

        `addcols:int` is the number of added columns for additional subplots

        `load:bool=True`: load/reload data before to try plotting. Useful
        as a `CMADataLogger` instance itself does not load data by default.

        `message:str`: a message text appearing in the plot

        `remove_sigma`: disregard `sigma` when plotting individual standard
        deviations.

        `normalize_scaling`: plot axis scaling normalized with the geometric
        average in each iteration.

        Return `CMADataLogger` itself.

        Example
        -------
        ::

            import cma
            logger = cma.CMADataLogger()  # with default name
            logger.plot()
            cma.s.figsave('fig325.png')  # save current figure
            logger.figclose()  # or cma.s.figclose()

        Details
        -------
        Data from codes in other languages (C, Java, Matlab, Scilab) have the same
        format and can be plotted just the same.

        Dependencies: matlabplotlib.pyplot

        :See: `cma.plot` alias `cma.logger.plot`
cma.plot_zip
Python Library Documentation: function plot_zip in module cma.logger

plot_zip(name=None, filename=None, unique=True)
    create tar file ``filename [+ ...] + '.tar.gz'`` of folder `name`.

    The resulting tar file serves to recreate the current `cma.plot`
    elsewhere.

    `name` defaults to the folder plotted with `cma.plot` by default.
    `filename` defaults to `name` while adding a unique time stamp if
    `unique` is true.

    Return the path of the created file (may be absolute or relative).

    Details
    =======

    This is a convenience replacement for executing ``tar -czf
    filename.tar.gz name`` in a system shell where ``name`` defaults to the
    default plot data folder and ``filename`` is created to be unique.

    This function calls `CMADataLogger.zip` to do the real work.
cma.test
Error rendering doc: No Python documentation found for 'type "import cma.test" to access the `test` module of `cma`'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
cma.version_info
Python Library Documentation: tuple object

class tuple(object)
 |  tuple(iterable=(), /)
 |
 |  Built-in immutable sequence.
 |
 |  If no argument is given, the constructor returns an empty tuple.
 |  If iterable is specified the tuple is initialized from iterable's items.
 |
 |  If the argument is a tuple, the return value is the same object.
 |
 |  Built-in subclasses:
 |      asyncgen_hooks
 |      UnraisableHookArgs
 |
 |  Methods defined here:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
cma.evolution_strategy.BoundNone
Python Library Documentation: class BoundNone in module cma.boundary_handler

class BoundNone(BoundaryHandlerBase)
 |  BoundNone(bounds=None)
 |
 |  no boundaries
 |
 |  Method resolution order:
 |      BoundNone
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, bounds=None)
 |      `bounds` can be ``None`` or ``[lb, ub]``
 |
 |      where ``lb`` and ``ub`` are either ``None`` or a vector (which can have
 |      ``None`` entries).
 |
 |      On return, the ``bounds`` attribute of ``self`` are the bounds in a
 |      normalized form.
 |
 |      To compute bounds for any dimension, the last entry of bounds is
 |      then recycled for variables with ``indices >= len(bounds[i]) for i
 |      in (0,1)``.
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  __call__(self, solutions, *args, **kwargs)
 |      return penalty or list of penalties, by default zero(s).
 |
 |      This interface seems too specifically tailored to the derived
 |      BoundPenalty class, it should maybe change.
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  inverse(self, y, copy_if_changed=True)
 |      inverse of repair if it exists, at least it should hold
 |      ``repair == repair o inverse o repair``
 |
 |  repair(self, x, copy_if_changed=True)
 |      projects infeasible values on the domain bound, might be
 |      overwritten by derived class
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  update(self, *args, **kwargs)
 |      end-iteration callback of boundary handler (abstract/empty)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.evolution_strategy.BoundPenalty
Python Library Documentation: class BoundPenalty in module cma.boundary_handler

class BoundPenalty(BoundaryHandlerBase)
 |  BoundPenalty(bounds=None)
 |
 |  Compute a bound penalty and update coordinate-wise penalty weights.
 |
 |  An instance must be updated each iteration using the `update` method.
 |
 |  Details:
 |
 |  - The penalty computes like ``sum(w[i] * (x[i]-xfeas[i])**2)``,
 |    where ``xfeas`` is the closest feasible (in-bounds) solution from
 |    ``x``. The weight ``w[i]`` should be updated during each iteration
 |    using the update method.
 |
 |  Example how this boundary handler is used with `cma.fmin` via the
 |  options (`CMAOptions`) of the class `cma.CMAEvolutionStrategy`:
 |
 |  >>> import cma
 |  >>> res = cma.fmin(cma.ff.elli, 6 * [0.9], 0.1,
 |  ...     {'BoundaryHandler': cma.BoundPenalty,
 |  ...      'bounds': [-1, 1],
 |  ...      'tolflatfitness': 10,
 |  ...      'fixed_variables': {0: 0.012, 2:0.234}
 |  ...     })  # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=...
 |  >>> if res[1] >= 13.76: print(res)  # should never happen
 |
 |  Reference: Hansen et al 2009, A Method for Handling Uncertainty...
 |  IEEE TEC, with addendum, see
 |  https://ieeexplore.ieee.org/abstract/document/4634579
 |  https://hal.inria.fr/inria-00276216/file/TEC2008.pdf
 |
 |  **todo**: implement a more generic interface, where this becomes a
 |  fitness wrapper which adds the desired penalty and the `update`
 |  method is used as callback argument for `fmin` like::
 |
 |      f = cma.BoundPenalty(cma.ff.elli, bounds=[-1, 1])
 |      res = cma.fmin(f, 6 * [1], callback=f.update)
 |
 |  where callback functions should receive the same arguments as
 |  `tell`, namely an `CMAEvolutionStrategy` instance, an array of the
 |  current solutions and their respective f-values. Such change is
 |  relatively involved. Consider also that bounds are related with the
 |  geno- to phenotype transformation.
 |
 |  Method resolution order:
 |      BoundPenalty
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, archive, gp)
 |      returns the boundary violation penalty for `x`,
 |      where `x` is a single solution or a list or np.array of solutions.
 |
 |  __init__(self, bounds=None)
 |      Argument bounds can be `None` or ``bounds[0]`` and ``bounds[1]``
 |      are lower  and upper domain boundaries, each is either `None` or
 |      a scalar or a `list` or `np.array` of appropriate size.
 |
 |  feasible_ratio(self, solutions)
 |      counts for each coordinate the number of feasible values in
 |      ``solutions`` and returns an `np.array` of length
 |      ``len(solutions[0])`` with the ratios.
 |
 |  repair(self, x, copy_if_changed=True)
 |      sets out-of-bounds components of ``x`` on the bounds.
 |
 |      TODO: unify with BoundaryHandlerBase.repair
 |
 |  update(self, function_values, es)
 |      updates the weights for computing a boundary penalty.
 |
 |      Arguments
 |      =========
 |      ``function_values``:
 |          all function values of recent population of solutions
 |      ``es``:
 |          `CMAEvolutionStrategy` object instance, in particular
 |          mean and variances and the methods from the attribute
 |          `gp` of type `GenoPheno` are used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  inverse(self, y, copy_if_changed=True)
 |      inverse of repair if it exists, at least it should hold
 |      ``repair == repair o inverse o repair``
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.evolution_strategy.BoundTransform
Python Library Documentation: class BoundTransform in module cma.boundary_handler

class BoundTransform(BoundaryHandlerBase)
 |  BoundTransform(bounds=None)
 |
 |  Handle boundaries by a smooth, piecewise linear and quadratic
 |  transformation into the feasible domain.
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> from cma.boundary_handler import BoundTransform
 |  >>> from cma import fitness_transformations as ft
 |  >>> veq = cma.utilities.math.Mh.vequals_approximately
 |  >>> b = BoundTransform([0, None])
 |  >>> assert b.bounds == [[0], None]
 |  >>> assert veq(b.repair([-0.1, 0, 1, 1.2]), np.array([0.0125, 0.0125, 1, 1.2])), b.repair([-0.1, 0, 1, 1.2])
 |  >>> assert b.is_in_bounds([0, 0.5, 1])
 |  >>> assert veq(b.transform([-1, 0, 1, 2]), [0.9, 0.0125,  1,  2  ]), b.transform([-1, 0, 1, 2])
 |  >>> bounded_sphere = ft.ComposedFunction([
 |  ...         cma.ff.sphere,
 |  ...         BoundTransform([[], 5 * [-1] + [np.inf]]).transform
 |  ...     ])
 |  >>> o1 = cma.fmin(bounded_sphere, 6 * [-2], 0.5)  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> o2 = cma.fmin(cma.ff.sphere, 6 * [-2], 0.5, options={
 |  ...    'BoundaryHandler': cma.boundary_handler.BoundTransform,
 |  ...    'bounds': [[], 5 * [-1] + [np.inf]] })  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> assert o1[1] < 5 + 1e-8 and o2[1] < 5 + 1e-8
 |  >>> b = BoundTransform([-np.random.rand(120), np.random.rand(120)])
 |  >>> for i in range(0, 100, 9):
 |  ...     x = (-i-1) * np.random.rand(120) + i * np.random.randn(120)
 |  ...     x_to_b = b.repair(x)
 |  ...     x2 = b.inverse(x_to_b)
 |  ...     x2_to_b = b.repair(x2)
 |  ...     x3 = b.inverse(x2_to_b)
 |  ...     x3_to_b = b.repair(x3)
 |  ...     assert veq(x_to_b, x2_to_b)
 |  ...     assert veq(x2, x3)
 |  ...     assert veq(x2_to_b, x3_to_b)
 |  >>> for _ in range(5):
 |  ...     lb = np.random.randn(4)
 |  ...     ub = lb + 1e-7 + np.random.rand(4)
 |  ...     b = BoundTransform([lb, ub])
 |  ...     for x in [np.random.randn(4) / np.sqrt(np.random.rand(4)) for _ in range(22)]:
 |  ...         assert all(lb <= b.transform(x)), (lb, ub, b.__dict__)
 |  ...         assert all(b.transform(x) <= ub), (lb, ub, b.__dict__)
 |
 |  Details: this class uses ``class BoxConstraintsLinQuadTransformation``
 |
 |  Method resolution order:
 |      BoundTransform
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, bounds=None)
 |      Argument bounds can be `None` or ``bounds[0]`` and ``bounds[1]``
 |      are lower and upper domain boundaries, each is either `None` or
 |      a scalar or a list or array of appropriate size.
 |
 |  inverse(self, x, copy_if_changed=True)
 |      inverse transform of ``x`` from the bounded domain.
 |
 |  repair(self, x, copy_if_changed=True)
 |      transforms ``x`` into the bounded domain.
 |
 |  transform(self, x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  __call__(self, solutions, *args, **kwargs)
 |      return penalty or list of penalties, by default zero(s).
 |
 |      This interface seems too specifically tailored to the derived
 |      BoundPenalty class, it should maybe change.
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  update(self, *args, **kwargs)
 |      end-iteration callback of boundary handler (abstract/empty)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.evolution_strategy.CMAAdaptSigmaBase
Python Library Documentation: class CMAAdaptSigmaBase in module cma.sigma_adaptation

class CMAAdaptSigmaBase(builtins.object)
 |  CMAAdaptSigmaBase(*args, **kwargs)
 |
 |  step-size adaptation base class, implement `hsig` (for stalling
 |  distribution update) functionality via an isotropic evolution path.
 |
 |  Details: `hsig` or `_update_ps` must be called before the sampling
 |  distribution is changed. `_update_ps` depends heavily on
 |  `cma.CMAEvolutionStrategy`.
 |
 |  Methods defined here:
 |
 |  __init__(self, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  update(self, es, **kwargs)
 |      change `es.sigma` in place, deprecated?
 |
 |  update2(self, es, **kwargs)
 |      return sigma change factor and update self.delta.
 |
 |      ``self.delta == sigma/sigma0`` accumulates all past changes
 |      starting from `1.0`.
 |
 |      Unlike `update`, `update2` is not supposed to change attributes
 |      in `es`, specifically it should not change `es.sigma`.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAAdaptSigmaCSA
Python Library Documentation: class CMAAdaptSigmaCSA in module cma.sigma_adaptation

class CMAAdaptSigmaCSA(CMAAdaptSigmaBase)
 |  CMAAdaptSigmaCSA(**kwargs)
 |
 |  CSA cumulative step-size adaptation AKA path length control.
 |
 |  As of 2017, CSA is considered as the default step-size control method
 |  within CMA-ES.
 |
 |  Method resolution order:
 |      CMAAdaptSigmaCSA
 |      CMAAdaptSigmaBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, **kwargs)
 |      postpone initialization to a method call where dimension and mueff should be known.
 |
 |  initialize(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  update(self, es, **kwargs)
 |      call ``self._update_ps(es)`` and update ``es.sigma``.
 |
 |      Legacy method replaced by `update2`.
 |
 |  update2(self, es, **kwargs)
 |      call ``self._update_ps(es)`` and update self.delta.
 |
 |      Return change factor of self.delta.
 |
 |      From input `es`, either attribute ``N`` or ``const.chiN`` is used and ``path_for_sigma_update``.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAAdaptSigmaBase:
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAAdaptSigmaBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAAdaptSigmaDistanceProportional
Python Library Documentation: class CMAAdaptSigmaDistanceProportional in module cma.sigma_adaptation

class CMAAdaptSigmaDistanceProportional(CMAAdaptSigmaBase)
 |  CMAAdaptSigmaDistanceProportional(coefficient=1.2, **kwargs)
 |
 |  artificial setting of ``sigma`` proportional to ||m||,
 |
 |  specifically ``sigma = coefficient * mueff * norm(mean) / n / c_m``.
 |
 |  The optimal `coefficient` in infinite dimension is ``1.253 = (pi/2)**0.5``,
 |  the optimal mueff is ``lambda / pi``, hence the optimal phi is ``pi/2 x
 |  lambda / pi / 2 = lambda / 4`` where exp(-phi/n) is the (log-)expected
 |  converence rate per iteration.
 |
 |  This is mainly useful for test purposes, e.g. to simulate optimal progress
 |  rates.
 |
 |  Method resolution order:
 |      CMAAdaptSigmaDistanceProportional
 |      CMAAdaptSigmaBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, coefficient=1.2, **kwargs)
 |      pass coefficient multiplier for normalized step-size
 |
 |  update(self, es, **kwargs)
 |      update ``es.sigma`` by calling `update2`.
 |
 |  update2(self, es, **kwargs)
 |      return sigma update factor.
 |
 |      Uses attributes ``.N``, ``.sp.weights.mueff``, ``.mean``, and
 |      ``.sp.cmean`` of input `es`.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAAdaptSigmaBase:
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAAdaptSigmaBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAAdaptSigmaMedianImprovement
Python Library Documentation: class CMAAdaptSigmaMedianImprovement in module cma.sigma_adaptation

class CMAAdaptSigmaMedianImprovement(CMAAdaptSigmaBase)
 |  CMAAdaptSigmaMedianImprovement(**kwargs)
 |
 |  Compares median fitness to the 27%tile fitness of the
 |  previous iteration, see Ait ElHara et al, GECCO 2013.
 |
 |  >>> import cma
 |  >>> es = cma.CMAEvolutionStrategy(3 * [1], 1,
 |  ... {'AdaptSigma':cma.sigma_adaptation.CMAAdaptSigmaMedianImprovement,
 |  ...  'verbose': -9})
 |  >>> assert es.optimize(cma.ff.elli).result[1] < 1e-9
 |  >>> assert es.result[2] < 2000
 |
 |  Method resolution order:
 |      CMAAdaptSigmaMedianImprovement
 |      CMAAdaptSigmaBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  initialize(self, es)
 |      late initialization using attributes ``N`` and ``popsize``
 |
 |  update(self, es, **kwargs)
 |      change `es.sigma` in place, deprecated?
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAAdaptSigmaBase:
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  update2(self, es, **kwargs)
 |      return sigma change factor and update self.delta.
 |
 |      ``self.delta == sigma/sigma0`` accumulates all past changes
 |      starting from `1.0`.
 |
 |      Unlike `update`, `update2` is not supposed to change attributes
 |      in `es`, specifically it should not change `es.sigma`.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAAdaptSigmaBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAAdaptSigmaNone
Python Library Documentation: class CMAAdaptSigmaNone in module cma.sigma_adaptation

class CMAAdaptSigmaNone(CMAAdaptSigmaBase)
 |  CMAAdaptSigmaNone(*args, **kwargs)
 |
 |  constant step-size sigma
 |
 |  Method resolution order:
 |      CMAAdaptSigmaNone
 |      CMAAdaptSigmaBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  update(self, es, **kwargs)
 |      no update, ``es.sigma`` remains constant.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAAdaptSigmaBase:
 |
 |  __init__(self, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  update2(self, es, **kwargs)
 |      return sigma change factor and update self.delta.
 |
 |      ``self.delta == sigma/sigma0`` accumulates all past changes
 |      starting from `1.0`.
 |
 |      Unlike `update`, `update2` is not supposed to change attributes
 |      in `es`, specifically it should not change `es.sigma`.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAAdaptSigmaBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAAdaptSigmaTPA
Python Library Documentation: class CMAAdaptSigmaTPA in module cma.sigma_adaptation

class CMAAdaptSigmaTPA(CMAAdaptSigmaBase)
 |  CMAAdaptSigmaTPA(dimension=None, opts=None, **kwargs)
 |
 |  two point adaptation for step-size sigma.
 |
 |  Relies on a specific sampling of the first two offspring, whose
 |  objective function value ranks are used to decide on the step-size
 |  change, see `update` for the specifics.
 |
 |  Example
 |  =======
 |
 |  >>> import cma
 |  >>> cma.CMAOptions('adapt').pprint()  # doctest: +ELLIPSIS
 |   AdaptSigma='True...
 |  >>> es = cma.CMAEvolutionStrategy(10 * [0.2], 0.1,
 |  ...     {'AdaptSigma': cma.sigma_adaptation.CMAAdaptSigmaTPA,
 |  ...      'ftarget': 1e-8})  # doctest: +ELLIPSIS
 |  (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 10 (seed=...
 |  >>> es.optimize(cma.ff.rosen)  # doctest: +ELLIPSIS
 |  Iter...
 |  >>> assert 'ftarget' in es.stop()
 |  >>> assert es.result[1] <= 1e-8  # should coincide with the above
 |  >>> assert es.result[2] < 6500  # typically < 5500
 |
 |  References: loosely based on Hansen 2008, CMA-ES with Two-Point
 |  Step-Size Adaptation, more tightly based on Hansen et al. 2014,
 |  How to Assess Step-Size Adaptation Mechanisms in Randomized Search.
 |
 |  Method resolution order:
 |      CMAAdaptSigmaTPA
 |      CMAAdaptSigmaBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, dimension=None, opts=None, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  check_consistency(self, es)
 |      make consistency checks with a `CMAEvolutionStrategy` instance
 |      as input
 |
 |  initialize(self, N=None, opts=None)
 |      late initialization.
 |
 |      :param N: a `CMAEvolutionStrategy` instance or the dimension for backward compatibility
 |      :param opts: used for hacking
 |
 |  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.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAAdaptSigmaBase:
 |
 |  hsig(self, es)
 |      return "OK-signal" for rank-one update, `True` (OK) or `False`
 |      (stall rank-one update), based on the length of an evolution path
 |
 |  initialize_base(self, es)
 |      set parameters and state variable based on dimension,
 |      mueff and possibly further options.
 |
 |  update2(self, es, **kwargs)
 |      return sigma change factor and update self.delta.
 |
 |      ``self.delta == sigma/sigma0`` accumulates all past changes
 |      starting from `1.0`.
 |
 |      Unlike `update`, `update2` is not supposed to change attributes
 |      in `es`, specifically it should not change `es.sigma`.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAAdaptSigmaBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMADataLogger
Python Library Documentation: class CMADataLogger in module cma.logger

class CMADataLogger(cma.interfaces.BaseDataLogger)
 |  CMADataLogger(name_prefix='outcmaes\\', modulo=1, append=False, expensive_modulo=1)
 |
 |  data logger for class `CMAEvolutionStrategy`.
 |
 |  The logger is identified by its name prefix and (over-)writes or
 |  reads according data files. Therefore, the logger must be
 |  considered as *global* variable with unpredictable side effects,
 |  if two loggers with the same name and on the same working folder
 |  are used at the same time.
 |
 |  Examples
 |  ========
 |  ::
 |
 |      import cma
 |
 |      es = cma.CMAEvolutionStrategy(12 * [3], 4)
 |      es.optimize(cma.ff.elli, callback=es.logger.plot)
 |
 |  plots into the current `matplotlib` figure (or opens one if none
 |  exists) via a generic callback. ``es.optimize`` already adds by default
 |  ``es.logger.add`` to its callback list to add data to the logger. This
 |  call::
 |
 |      x, es = cma.fmin2(cma.ff.elli, 12 * [3], 4, {'verb_plot': 1})
 |
 |  is very similar, but plots hard-coded into figure number 324::
 |
 |      es = cma.CMAEvolutionStrategy(...)
 |      logger = cma.CMADataLogger().register(es)
 |      while not es.stop():
 |          ...
 |          logger.add()  # add can also take an argument
 |
 |      logger.plot() # or a short cut can be used:
 |      cma.plot()  # plot data from logger with default name into new figure
 |
 |      logger2 = cma.CMADataLogger('just_another_filename_prefix').load()
 |      logger2.plot()
 |      logger2.disp()
 |
 |      import cma
 |      from matplotlib.pylab import *
 |      res = cma.fmin(cma.ff.sphere, rand(10), 1e-0)
 |      logger = res[-1]  # the CMADataLogger
 |      logger.load()  # by "default" data are on disk
 |      semilogy(logger.f[:,0], logger.f[:,5])  # plot f versus iteration, see file header
 |      cma.s.figshow()
 |
 |  Details
 |  =======
 |  After loading data, the logger has the attributes `xmean`, `xrecent`,
 |  `std`, `f`, `D` and `corrspec` corresponding to ``xmean``,
 |  ``xrecentbest``, ``stddev``, ``fit``, ``axlen`` and ``axlencorr``
 |  filename trails.
 |
 |  :See: `disp` (), `plot` ()
 |
 |  Method resolution order:
 |      CMADataLogger
 |      cma.interfaces.BaseDataLogger
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, name_prefix='outcmaes\\', modulo=1, append=False, expensive_modulo=1)
 |      initialize logging of data from a `CMAEvolutionStrategy` instance.
 |
 |      Default ``modulo=1`` means logging with each call of `add`. If
 |      ``append is True`` data is appended to already existing data of a
 |      logger with the same name. Additional eigendecompositions are
 |      allowed only every `expensive_modulo`-th logged iteration.
 |
 |  add(self, es=None, more_data=(), modulo=None)
 |      append some logging data from `CMAEvolutionStrategy` class instance `es`,
 |      if ``number_of_times_called % modulo`` equals to zero, never if ``modulo==0``.
 |
 |      ``more_data`` is a list of additional data to be recorded where each
 |      data entry must have the same length.
 |
 |      When used for a different optimizer class, this function can be
 |      (easily?) adapted by changing the assignments under INTERFACE
 |      in the implemention.
 |
 |  disp(self, idx=100)
 |      displays selected data from (files written by) the class
 |      `CMADataLogger`.
 |
 |      Arguments
 |      ---------
 |         `idx`
 |             indices corresponding to rows in the data file;
 |             if idx is a scalar (int), the first two, then every idx-th,
 |             and the last three rows are displayed. Too large index
 |             values are removed. If ``idx=='header'``, the header
 |             line is printed.
 |
 |      Example
 |      -------
 |      >>> import cma, numpy as np
 |      >>> res = cma.fmin(cma.ff.elli, 7 * [0.1], 1, {'verb_disp':1e9})  # generate data
 |      ...  #doctest: +ELLIPSIS
 |      (4...
 |      >>> assert res[1] < 1e-9
 |      >>> assert res[2] < 4400
 |      >>> l = cma.CMADataLogger()  # == res[-1], logger with default name, "points to" above data
 |      >>> l.disp([0,-1])  # first and last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(20)  # some first/last and every 20-th line
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(np.r_[0:999999:100, -1]) # every 100-th and last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> l.disp(np.r_[0, -10:0]) # first and ten last
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |      >>> cma.disp(l.name_prefix, np.r_[0:9999999:100, -10:])  # the same as l.disp(...)
 |      ...  #doctest: +ELLIPSIS
 |      Iterat Nfevals  function value    axis ratio maxstd  minstd...
 |
 |      Details
 |      -------
 |      The data line with the best f-value is displayed as last line.
 |
 |      Use `CMADataLogger.disp` if the logger does not have the default
 |      name.
 |
 |      :See: `CMADataLogger.disp`, `CMADataLogger.disp`
 |
 |  disp_header(self)
 |
 |  downsampling(self, factor=10, first=3, switch=True, verbose=False)
 |      rude downsampling of a `CMADataLogger` data file by `factor`,
 |      keeping also the first `first` entries. This function is a
 |      stump and subject to future changes. Return self.
 |
 |      Arguments
 |      ---------
 |         - `factor` -- downsampling factor
 |         - `first` -- keep first `first` entries
 |         - `switch` -- switch the new logger to the downsampled logger
 |              original_name+'down'
 |
 |      Details
 |      -------
 |      ``self.name_prefix+'down'`` files are written
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |          cma.downsampling()  # takes outcma/cma* files
 |          cma.plot('outcma/cmadown')
 |
 |  figclose(self)
 |
 |  initialize(self, modulo=None)
 |      reset logger, overwrite original files, `modulo`: log only every modulo call
 |
 |  load(self, filenameprefix=None)
 |      load (or reload) data from output files, `load` is called in
 |      `plot` and `disp`.
 |
 |      Argument `filenameprefix` is the filename prefix of data to be
 |      loaded (5-8 files), by default ``'outcmaes/'`` (where / stands
 |      for the OS-specific path seperator).
 |
 |      Return self with (added) attributes `xrecent`, `xmean`,
 |      `f`, `D`, `std`, `corrspec`, `sigvec`.
 |
 |  plot(self, fig=None, iabscissa=0, iteridx=None, plot_mean=False, foffset=1e-19, x_opt=None, fontsize=7, downsample_to=10000000.0, xsemilog=False, xnormalize=False, xtransform=None, fshift=0, addcols=None, load=True, message='', remove_sigma=True, normalize_scaling=False, **kwargs)
 |      plot data from a `CMADataLogger` using files written by the logger.
 |
 |      Arguments
 |      ---------
 |      `fig`: figure number, by default starting from 325
 |
 |      `iabscissa` or `abscissa`: ``0 ==>`` plot versus iteration count,
 |      ``1 ==>`` plot versus function evaluation number
 |
 |      `iteridx`: the iteration indices to plot, e.g. ``range(100)`` for
 |      the first 100 evaluations.
 |
 |      ``plot_mean in (True, False, 'log', 'lin', 'linear', 'only')`` indicates
 |      whether and how to plot the mean (possibly instead the current best)
 |
 |      `foffset:float` a small value added to f values to improve log-plot
 |      appearance.
 |
 |      `downsample_to`: number of data lines to use at most
 |
 |      `x_opt`: plot x-values as a difference to another solution and/or
 |      select a subset of variables to plot.
 |
 |      If `x_opt` is a nonnegative `int`, it is interpreted as
 |      iteration number and the difference of ``x`` to the respective
 |      (closest but not larger) iteration is plotted.
 |
 |      If `x_opt` is a negative `int` the respective index rather than
 |      the iteration is used. Namely and in particular, ``x_opt=0``
 |      subtracts the initial solution ``X0`` and ``x_opt=-1``
 |      subtracts the final solution of the data.
 |
 |      If ``len(x_opt) == dimension`` or `x_opt` is a float, the
 |      difference to `x_opt` is plotted.
 |
 |      Otherwise: ``x_opt[0]`` defines the indices of the variables to
 |      be plotted where ``x_opt[1]``, if present, is subtracted.
 |
 |      `xsemilog:bool`: customized semilog plot for x-values
 |
 |      `xnormalize:bool`: divide x-values by standard deviations, may show stationary
 |          behavior when the optimum is in zero
 |
 |      `xtransform:callable` is a function that returns transformed x-values,
 |      applied before `x_opt` is subtracted and `xnormalize` is done.
 |
 |      `fshift:float` is added to all displayed fitness values
 |
 |      `addcols:int` is the number of added columns for additional subplots
 |
 |      `load:bool=True`: load/reload data before to try plotting. Useful
 |      as a `CMADataLogger` instance itself does not load data by default.
 |
 |      `message:str`: a message text appearing in the plot
 |
 |      `remove_sigma`: disregard `sigma` when plotting individual standard
 |      deviations.
 |
 |      `normalize_scaling`: plot axis scaling normalized with the geometric
 |      average in each iteration.
 |
 |      Return `CMADataLogger` itself.
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |          logger = cma.CMADataLogger()  # with default name
 |          logger.plot()
 |          cma.s.figsave('fig325.png')  # save current figure
 |          logger.figclose()  # or cma.s.figclose()
 |
 |      Details
 |      -------
 |      Data from codes in other languages (C, Java, Matlab, Scilab) have the same
 |      format and can be plotted just the same.
 |
 |      Dependencies: matlabplotlib.pyplot
 |
 |      :See: `cma.plot` alias `cma.logger.plot`
 |
 |  plot_all(self, fig=None, iabscissa=0, iteridx=None, foffset=1e-19, x_opt=None, fontsize=7)
 |      Obsolete: plot data from a `CMADataLogger` (using the files written by the logger).
 |
 |      Superseded by `CMADataLogger.plot`
 |
 |      Arguments
 |      ---------
 |      See `CMADataLogger.plot`
 |
 |      Return `CMADataLogger` itself.
 |
 |  plot_axes_scaling(self, iabscissa=0, normalize=False)
 |
 |  plot_correlations(self, iabscissa=0, name='corrspec')
 |      spectrum of correlation or precision matrix and percentiles of off-diagonal entries
 |
 |  plot_divers(self, iabscissa=0, foffset=1e-19, fshift=0, message=None)
 |      plot fitness, sigma, axis ratio...
 |
 |      :param iabscissa: 0 means vs evaluations, 1 means vs iterations
 |      :param foffset: added to f-value after abs(f) is taken
 |
 |      :See: `plot`
 |
 |  plot_estimated_errors(self, x_opt=None, markerscaler=10, log_threshold=0.05, dim_exponent=1, multiplier=None, plot_kwargs={})
 |      [WIP] experimental
 |
 |      `multiplier` takes dimension and mueff as input and computes the error
 |      multiplier. The soon to be expired default value was ``dim**0.5 * 3
 |      / min((popsize, 3 * dim + 15))``.
 |
 |      The trust is defined as ``-max_i(Delta log(sigma * D_ii))`` and is high when all axes diminish.
 |
 |  plot_mean(self, iabscissa=0, x_opt=None, annotations=None, xsemilog=None, xnormalize=None)
 |
 |  plot_sensitivities(self, plot_absolute=False, gradf=None)
 |      [WIP] experimental
 |
 |      Plot IQR(f) / IQR(std_i). The donimator is computed as 1.349 x
 |      std_i x sqrt(n). The sqrt(n) accounts for the effect of the
 |      changes in all other variables on f.
 |
 |  plot_sigvec(self, iabscissa=0, idx=None)
 |      plot (outer) scaling from diagonal decoding.
 |
 |      ``iabscissa=1`` plots vs function evaluations
 |
 |      `idx` picks variables to plot if len(idx) < N, otherwise it picks
 |      iteration indices (in case, after downsampling).
 |
 |  plot_stds(self, iabscissa=0, idx=None, remove_sigma=True)
 |      ``iabscissa=1`` means vs function evaluations, `idx` picks variables to plot
 |
 |  plot_xrecent(self, iabscissa=0, x_opt=None, annotations=None, xsemilog=None, xnormalize=None)
 |
 |  popsize(self, data_field='f')
 |      return median popsize from iteration and evaluation data
 |
 |  register(self, es, append=None, modulo=None)
 |      register a `CMAEvolutionStrategy` instance for logging,
 |      ``append=True`` appends to previous data logged under the same name,
 |      by default previous data are overwritten.
 |
 |  save(self, name=None)
 |      data are saved to disk the moment they are added
 |
 |  save_to(self, nameprefix, switch=False)
 |      saves logger data to a different set of files, for
 |      ``switch=True`` also the loggers name prefix is switched to
 |      the new value
 |
 |  select_data(self, iteration_indices)
 |      keep only data of `iteration_indices`
 |
 |  zip(self, filename=None, unique=True)
 |      write logger data to file ``filename [+ ...] + '.tar.gz'``.
 |
 |      `filename` defaults to ``self.name_prefix``.
 |
 |      When `unique` is true, `filename` is furnished with a unique time
 |      stamp.
 |
 |      Return the path (relative or absolute) of the output file.
 |
 |      This function does in essence just ``tar -czf filename.tar.gz folder``
 |      where ``folder`` defaults to the current plot data folder and
 |      ``filename`` is created to be unique.
 |
 |      TODO: we may want to be able to add a time stamp to the folder name
 |      too, to prevent conficts later?
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  data
 |      return dictionary with data.
 |
 |      If data entries are None or incomplete, consider calling
 |      ``.load().data`` to (re-)load the data from files first.
 |
 |  mueff
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  default_prefix = r'outcmaes\'
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from cma.interfaces.BaseDataLogger:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAEvolutionStrategy
Python Library Documentation: class CMAEvolutionStrategy in module cma.evolution_strategy

class CMAEvolutionStrategy(cma.interfaces.OOOptimizer)
 |  CMAEvolutionStrategy(x0, sigma0, inopts=None, options=None)
 |
 |  CMA-ES stochastic optimizer class with ask-and-tell interface.
 |
 |  Calling Sequences
 |  =================
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0, opts)``
 |
 |  - ``es = CMAEvolutionStrategy(x0, sigma0).optimize(objective_fct)``
 |
 |  - ::
 |
 |      res = CMAEvolutionStrategy(x0, sigma0,
 |                              opts).optimize(objective_fct).result
 |
 |  Arguments
 |  =========
 |  `x0`
 |      initial solution, starting point. `x0` is given as "phenotype"
 |      which means, if::
 |
 |          opts = {'transformation': [transform, inverse]}
 |
 |      is given and ``inverse is None``, the initial mean is not
 |      consistent with `x0` in that ``transform(mean)`` does not
 |      equal to `x0` unless ``transform(mean)`` equals ``mean``.
 |  `sigma0`
 |      initial standard deviation.  The problem variables should
 |      have been scaled, such that a single standard deviation
 |      on all variables is useful and the optimum is expected to
 |      lie within about `x0` +- ``3*sigma0``. Often one wants to
 |      check for solutions close to the initial point. This allows,
 |      for example, for an easier check of consistency of the
 |      objective function and its interfacing with the optimizer.
 |      In this case, a much smaller `sigma0` is advisable.
 |  `opts`
 |      options, a dictionary with optional settings,
 |      see class `CMAOptions`.
 |
 |  Main interface / usage
 |  ======================
 |  The interface is inherited from the generic `OOOptimizer`
 |  class (see also there). An object instance is generated from::
 |
 |      es = cma.CMAEvolutionStrategy(8 * [0.5], 0.2)
 |
 |  The least verbose interface is via the optimize method::
 |
 |      es.optimize(objective_func)
 |      res = es.result
 |
 |  More verbosely, the optimization is done using the
 |  methods `stop`, `ask`, and `tell`::
 |
 |      while not es.stop():
 |          solutions = es.ask()
 |          es.tell(solutions, [cma.ff.rosen(s) for s in solutions])
 |          es.disp()
 |      es.result_pretty()
 |
 |
 |  where `ask` delivers new candidate solutions and `tell` updates
 |  the `optim` instance by passing the respective function values
 |  (the objective function `cma.ff.rosen` can be replaced by any
 |  properly defined objective function, see `cma.ff` for more
 |  examples).
 |
 |  To change an option, for example a termination condition to
 |  continue the optimization, call::
 |
 |      es.opts.set({'tolfacupx': 1e4})
 |
 |  The class `CMAEvolutionStrategy` also provides::
 |
 |      (solutions, func_values) = es.ask_and_eval(objective_func)
 |
 |  and an entire optimization can also be written like::
 |
 |      while not es.stop():
 |          es.tell(*es.ask_and_eval(objective_func))
 |
 |  Besides for termination criteria, in CMA-ES only the ranks of the
 |  `func_values` are relevant.
 |
 |  Attributes and Properties
 |  =========================
 |  - `inputargs`: passed input arguments
 |  - `inopts`: passed options
 |  - `opts`: actually used options, some of them can be changed any
 |    time via ``opts.set``, see class `CMAOptions`
 |  - `popsize`: population size lambda, number of candidate
 |    solutions returned by `ask` ()
 |  - `logger`: a `CMADataLogger` instance utilized by `optimize`
 |
 |  Examples
 |  ========
 |  Super-short example, with output shown:
 |
 |  >>> import cma
 |  >>> # construct an object instance in 4-D, sigma0=1:
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1, {'seed':234})
 |  ...      # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=234...)
 |
 |  and optimize the ellipsoid function
 |
 |  >>> es.optimize(cma.ff.elli, verb_disp=1)  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 2.09...
 |  >>> assert len(es.result) >= 8, es.result
 |  >>> assert es.result.fbest < 1e-9, es.result
 |
 |  The optimization loop can also be written explicitly:
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [1], 1)  # doctest: +ELLIPSIS
 |  (4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=...
 |  >>> while not es.stop():
 |  ...    X = es.ask()
 |  ...    es.tell(X, [cma.ff.elli(x) for x in X])
 |  ...    es.disp()  # doctest: +ELLIPSIS
 |  Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 |      1      8 ...
 |
 |  achieving the same result as above.
 |
 |  An example with lower bounds (at zero) and handling infeasible
 |  solutions:
 |
 |  >>> import numpy as np
 |  >>> es = cma.CMAEvolutionStrategy(10 * [0.2], 0.5,
 |  ...         {'bounds': [0, np.inf]})  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> while not es.stop():
 |  ...     fit, X = [], []
 |  ...     while len(X) < es.popsize:
 |  ...         curr_fit = None
 |  ...         while curr_fit in (None, np.nan):
 |  ...             x = es.ask(1)[0]
 |  ...             curr_fit = cma.ff.somenan(x, cma.ff.elli) # might return np.nan
 |  ...         X.append(x)
 |  ...         fit.append(curr_fit)
 |  ...     es.tell(X, fit)
 |  ...     es.logger.add()
 |  ...     es.disp()  #doctest: +ELLIPSIS
 |  Itera...
 |  >>>
 |  >>> assert es.result.fbest < 1e-9, es.result
 |  >>> assert es.result.evals_best < 9000, es.result  # by internal termination
 |  >>> # es.logger.plot()  # will plot data
 |  >>> # cma.s.figshow()  # display plot window
 |
 |  An example with user-defined transformation, in this case to realize
 |  a lower bound of 2.
 |
 |  >>> import warnings
 |  >>> with warnings.catch_warnings(record=True) as warns:
 |  ...     es = cma.CMAEvolutionStrategy(5 * [3], 0.1,
 |  ...                 {"transformation": [lambda x: x**2+1.2, None],
 |  ...                  "ftarget": 1e-7 + 5.54781521192,
 |  ...                  "verbose": -2,})
 |  >>> warns[0].message  # doctest:+ELLIPSIS
 |  UserWarning('in class GenoPheno: user defined transformations have not been tested thoroughly (...
 |  >>> warns[1].message  # doctest:+ELLIPSIS
 |  UserWarning('computed initial point...
 |  >>> es.optimize(cma.ff.rosen, verb_disp=0)  #doctest: +ELLIPSIS
 |  <cma...
 |  >>> assert cma.ff.rosen(es.result.xbest) < 1e-7 + 5.54781521192, es.result
 |  >>> assert es.result.evals_best < 3300, es.result
 |
 |  The inverse transformation is (only) necessary if the `BoundPenalty`
 |  boundary handler is used at the same time.
 |
 |  The `CMAEvolutionStrategy` class also provides a default logger
 |  (cave: files are overwritten when the logger is used with the same
 |  filename prefix):
 |
 |  >>> es = cma.CMAEvolutionStrategy(4 * [0.2], 0.5, {'verb_disp': 0})
 |  >>> es.logger.disp_header()  # annotate the print of disp
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> while not es.stop():
 |  ...     X = es.ask()
 |  ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |  ...     es.logger.add()  # log current iteration
 |  ...     es.logger.disp([-1])  # display info for last iteration   #doctest: +ELLIPSIS
 |      1  ...
 |  >>> es.logger.disp_header()
 |  Iterat Nfevals  function value    axis ratio maxstd  minstd
 |  >>> # es.logger.plot() # will make a plot
 |
 |  Example implementing restarts with increasing popsize (IPOP):
 |
 |  >>> bestever = cma.optimization_tools.BestSolution()
 |  >>> for lam in 10 * 2**np.arange(8):  # 10, 20, 40, 80, ..., 10 * 2**7
 |  ...     es = cma.CMAEvolutionStrategy(6 - 8 * np.random.rand(4),  # 4-D
 |  ...                                   5,  # initial std sigma0
 |  ...                                   {'popsize': lam,  # options
 |  ...                                    'verb_append': bestever.evalsall})
 |  ...     # logger = cma.CMADataLogger().register(es, append=bestever.evalsall)
 |  ...     while not es.stop():
 |  ...         X = es.ask()    # get list of new solutions
 |  ...         fit = [cma.ff.rastrigin(x) for x in X]  # evaluate each solution
 |  ...         es.tell(X, fit) # besides for termination only the ranking in fit is used
 |  ...
 |  ...         # display some output
 |  ...         # logger.add()  # add a "data point" to the log, writing in files
 |  ...         es.disp()  # uses option verb_disp with default 100
 |  ...
 |  ...     print('termination:', es.stop())
 |  ...     cma.s.pprint(es.best.__dict__)
 |  ...
 |  ...     bestever.update(es.best)
 |  ...
 |  ...     # show a plot
 |  ...     # logger.plot();
 |  ...     if bestever.f < 1e-8:  # global optimum was hit
 |  ...         break  #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> assert es.result.fbest < 1e-8, es.result
 |
 |  On the Rastrigin function, usually after five restarts the global
 |  optimum is located.
 |
 |  Using the `multiprocessing` module, we can evaluate the function in
 |  parallel with a simple modification of the example (however
 |  multiprocessing seems not always reliable):
 |
 |  >>> from cma.fitness_functions import elli  # cannot be an instance method
 |  >>> from cma.optimization_tools import EvalParallel2
 |  >>> es = cma.CMAEvolutionStrategy(22 * [0.0], 1.0, {'maxiter':10})  # doctest:+ELLIPSIS
 |  (6_w,13)-aCMA-ES (mu_w=...
 |  >>> with EvalParallel2(elli, es.popsize + 1) as eval_all:
 |  ...     while not es.stop():
 |  ...         X = es.ask()
 |  ...         es.tell(X, eval_all(X))
 |  ...         es.disp()
 |  ...         # es.logger.add()  # doctest:+ELLIPSIS
 |  Iterat...
 |
 |  The final example shows how to resume:
 |
 |  >>> import pickle
 |  >>>
 |  >>> es0 = cma.CMAEvolutionStrategy(12 * [0.1],  # a new instance, 12-D
 |  ...                                0.12)         # initial std sigma0
 |  ...   #doctest: +ELLIPSIS
 |  (5_w,...
 |  >>> es0.optimize(cma.ff.rosen, iterations=100)  #doctest: +ELLIPSIS
 |  I...
 |  >>> s = es0.pickle_dumps()  # return pickle.dumps(es) with safeguards
 |  >>> # save string s to file like open(filename, 'wb').write(s)
 |  >>> del es0  # let's start fresh
 |  >>> # s = open(filename, 'rb').read()  # load string s from file
 |  >>> es = pickle.loads(s)  # read back es instance from string
 |  >>> # resuming
 |  >>> es.optimize(cma.ff.rosen, verb_disp=200)  #doctest: +ELLIPSIS
 |    200 ...
 |  >>> assert es.result.evals_best < 15000, es.result
 |  >>> assert cma.s.Mh.vequals_approximately(es.result.xbest, 12 * [1], 1e-5), es.result
 |  >>> assert len(es.result) >= 8, es.result
 |
 |  Details
 |  =======
 |  The following two enhancements are implemented, the latter is only
 |  turned on by default for very small population sizes.
 |
 |  *Active CMA* is implemented with option ``CMA_active`` and
 |  conducts an update of the covariance matrix with negative weights.
 |  The negative update is implemented, such that positive definiteness
 |  is guarantied. A typical speed up factor (number of f-evaluations)
 |  is between 1.1 and two.
 |
 |  References: Jastrebski and Arnold, Improving evolution strategies
 |  through active covariance matrix adaptation, CEC 2006.
 |  Hansen, The CMA evolution strategy: a tutorial, arXiv 2016.
 |
 |  *Selective mirroring* is implemented with option ``CMA_mirrors``
 |  in the method `get_mirror` and `get_selective_mirrors`.
 |  The method `ask_and_eval` (used by `fmin`) will then sample
 |  selectively mirrored vectors within the iteration
 |  (``CMA_mirrormethod==1``). Otherwise, or if ``CMA_mirromethod==2``,
 |  selective mirrors are injected for the next iteration.
 |  In selective mirroring, only the worst solutions are mirrored. With
 |  the default small number of mirrors, *pairwise selection* (where at
 |  most one of the two mirrors contribute to the update of the
 |  distribution mean) is implicitly guarantied under selective
 |  mirroring and therefore not explicitly implemented.
 |
 |  Update: pairwise selection for injected mirrors is also applied in the
 |  covariance matrix update: for all injected solutions, as for those from
 |  TPA, this is now implemented in that the recombination weights are
 |  constrained to be nonnegative for injected solutions in the covariance
 |  matrix (otherwise recombination weights are anyway nonnegative). This
 |  is a precaution to prevent failure when injected solutions are
 |  systematically bad (see e.g. https://github.com/CMA-ES/pycma/issues/124),
 |  but may not be "optimal" for mirrors.
 |
 |  References: Brockhoff et al, PPSN 2010, Auger et al, GECCO 2011.
 |
 |  :See also: `fmin` (), `OOOptimizer`, `CMAOptions`, `plot` (), `ask` (),
 |      `tell` (), `ask_and_eval` ()
 |
 |  Method resolution order:
 |      CMAEvolutionStrategy
 |      cma.interfaces.OOOptimizer
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, x0, sigma0, inopts=None, options=None)
 |      see class `CMAEvolutionStrategy`
 |
 |      `options` is for consistency with `fmin2` options and is only
 |      in effect if ``inopts is None``.
 |
 |  alleviate_conditioning(self, condition=1000000000000.0)
 |      pass conditioning of `C` to linear transformation in `self.gp`.
 |
 |      Argument `condition` defines the limit condition number above
 |      which the action is taken.
 |
 |      >>> import cma
 |      >>> for dd in [0, 1]:
 |      ...     es = cma.CMA(2 * [1], 0.1, {'CMA_diagonal_decoding' : dd, 'verbose':-9})
 |      ...     es = es.optimize(cma.ff.elli, iterations=4)
 |      ...     es.alleviate_conditioning(1.01)  # check that alleviation_conditioning "works"
 |      ...     assert all(es.sigma_vec.scaling == [1, 1]), es.sigma_vec.scaling
 |      ...     assert es.sm.condition_number <= 1.01, es.sm.C
 |
 |      Details: the action applies only if `self.gp.isidentity`. Then,
 |      the covariance matrix `C` is set (back) to identity and a
 |      respective linear transformation is "added" to `self.gp`.
 |
 |  alleviate_conditioning_in_coordinates(self, condition=100000000.0)
 |      pass scaling from `C` to `sigma_vec`.
 |
 |      As a result, `C` is a correlation matrix, i.e., all diagonal
 |      entries of `C` are `1`.
 |
 |  ask(self, number=None, xmean=None, sigma_fac=1, gradf=None, args=(), **kwargs)
 |      get/sample new candidate solutions.
 |
 |      Solutions are sampled from a multi-variate
 |      normal distribution and transformed to f-representation
 |      (phenotype) to be evaluated.
 |
 |      Arguments
 |      ---------
 |          `number`
 |              number of returned solutions, by default the
 |              population size ``popsize`` (AKA ``lambda``).
 |          `xmean`
 |              distribution mean, phenotyp?
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `gradf`
 |              gradient, ``len(gradf(x)) == len(x)``, if
 |              ``gradf is not None`` the third solution in the
 |              returned list is "sampled" in supposedly Newton
 |              direction ``np.dot(C, gradf(xmean, *args))``.
 |          `args`
 |              additional arguments passed to gradf
 |          `kwargs`
 |              if `ignore_integer_variables` do not change integer
 |              variables at all which is in particular useful when a small
 |              mutation is added to a given solution and integer values
 |              are not supposed to be disturbed at all and/or moved across
 |              a plateau boundary.
 |
 |      Return
 |      ------
 |      A list of N-dimensional candidate solutions to be evaluated
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy([0,0,0,0], 0.3)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop() and es.best.f > 1e-6:
 |      ...     X = es.ask()  # get list of new solutions
 |      ...     fit = [cma.ff.rosen(x) for x in X]  # call fct with each solution
 |      ...     es.tell(X, fit)  # feed values
 |
 |      :See: `ask_and_eval`, `ask_geno`, `tell`
 |
 |  ask_and_eval(self, func, args=(), gradf=None, number=None, xmean=None, sigma_fac=1, evaluations=1, aggregation=<function median at 0x000002897F5C4170>, kappa=1, parallel_mode=False)
 |      sample `number` solutions and evaluate them on `func`.
 |
 |      Each solution ``s`` is resampled until
 |      ``self.is_feasible(s, func(s)) is True``.
 |
 |      Arguments
 |      ---------
 |      `func`:
 |          objective function, ``func(x)`` accepts a `numpy.ndarray`
 |          and returns a scalar ``if not parallel_mode``. Else returns a
 |          `list` of scalars from a `list` of `numpy.ndarray`.
 |      `args`:
 |          additional parameters for `func`
 |      `gradf`:
 |          gradient of objective function, ``g = gradf(x, *args)``
 |          must satisfy ``len(g) == len(x)``
 |      `number`:
 |          number of solutions to be sampled, by default
 |          population size ``popsize`` (AKA lambda)
 |      `xmean`:
 |          mean for sampling the solutions, by default ``self.mean``.
 |      `sigma_fac`:
 |          multiplier for sampling width, standard deviation, for example
 |          to get a small perturbation of solution `xmean`
 |      `evaluations`:
 |          number of evaluations for each sampled solution
 |      `aggregation`:
 |          function that aggregates `evaluations` values to
 |          as single value.
 |      `kappa`:
 |          multiplier used for the evaluation of the solutions, in
 |          that ``func(m + kappa*(x - m))`` is the f-value for ``x``.
 |
 |      Return
 |      ------
 |      ``(X, fit)``, where
 |
 |      - `X`: list of solutions
 |      - `fit`: list of respective function values
 |
 |      Details
 |      -------
 |      While ``not self.is_feasible(x, func(x))`` new solutions are
 |      sampled. By default
 |      ``self.is_feasible == cma.feasible == lambda x, f: f not in (None, np.nan)``.
 |      The argument to `func` can be freely modified within `func`.
 |
 |      Depending on the ``CMA_mirrors`` option, some solutions are not
 |      sampled independently but as mirrors of other bad solutions. This
 |      is a simple derandomization that can save 10-30% of the
 |      evaluations in particular with small populations, for example on
 |      the cigar function.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> x0, sigma0 = 8 * [10], 1  # 8-D
 |      >>> es = cma.CMAEvolutionStrategy(x0, sigma0)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> while not es.stop():
 |      ...     X, fit = es.ask_and_eval(cma.ff.elli)  # handles NaN with resampling
 |      ...     es.tell(X, fit)  # pass on fitness values
 |      ...     es.disp(20) # print every 20-th iteration  #doctest: +ELLIPSIS
 |      Iterat #Fevals...
 |      >>> print('terminated on ' + str(es.stop()))  #doctest: +ELLIPSIS
 |      terminated on ...
 |
 |      A single iteration step can be expressed in one line, such that
 |      an entire optimization after initialization becomes::
 |
 |          while not es.stop():
 |              es.tell(*es.ask_and_eval(cma.ff.elli))
 |
 |  ask_geno(self, number=None, xmean=None, sigma_fac=1, ignore_integer_variables=False)
 |      get new candidate solutions in genotyp.
 |
 |      Solutions are sampled from a multi-variate normal distribution.
 |
 |      Arguments are
 |          `number`
 |              number of returned solutions, by default the
 |              population size `popsize` (AKA lambda).
 |          `xmean`
 |              distribution mean
 |          `sigma_fac`
 |              multiplier for internal sample width (standard
 |              deviation)
 |          `ignore_integer_variables`
 |              allows to not change integer variables at all which is in
 |              particular useful when a (small) mutation is added to a
 |              given solution.
 |
 |      `ask_geno` returns a list of N-dimensional candidate solutions
 |      in genotyp representation and is called by `ask`.
 |
 |      Details: updates the sample distribution if needed and might
 |      change the geno-pheno transformation during this update.
 |
 |      :See: `ask`, `ask_and_eval`
 |
 |  disp(self, modulo=None, overwrite=None)
 |      print current state variables in a single-line.
 |
 |      Prints only if ``iteration_counter % modulo == 0``.
 |      Overwrites the line after iteration `overwrite`.
 |
 |      :See also: `disp_annotation`.
 |
 |  disp_annotation(self)
 |      print annotation line for `disp` ()
 |
 |  feed_for_resume(self, X, function_values)
 |      Resume a run using the solution history.
 |
 |      CAVEAT: this hasn't been thoroughly tested or in intensive use.
 |
 |      Given all "previous" candidate solutions and their respective
 |      function values, the state of a `CMAEvolutionStrategy` object
 |      can be reconstructed from this history. This is the purpose of
 |      function `feed_for_resume`.
 |
 |      Arguments
 |      ---------
 |      `X`:
 |        (all) solution points in chronological order, phenotypic
 |        representation. The number of points must be a multiple
 |        of popsize.
 |      `function_values`:
 |        respective objective function values
 |
 |      Details
 |      -------
 |      `feed_for_resume` can be called repeatedly with only parts of
 |      the history. The part must have the length of a multiple
 |      of the population size.
 |      `feed_for_resume` feeds the history in popsize-chunks into `tell`.
 |      The state of the random number generator might not be
 |      reconstructed, but this would be only relevant for the future.
 |
 |      Example
 |      -------
 |      ::
 |
 |          import cma
 |
 |          # prepare
 |          (x0, sigma0) = ... # initial values from previous trial
 |          X = ... # list of generated solutions from a previous trial
 |          f = ... # respective list of f-values
 |
 |          # resume
 |          es = cma.CMAEvolutionStrategy(x0, sigma0)
 |          es.feed_for_resume(X, f)
 |
 |          # continue with func as objective function
 |          while not es.stop():
 |              X = es.ask()
 |              es.tell(X, [func(x) for x in X])
 |
 |
 |      Credits to Dirk Bueche and Fabrice Marchal for the feeding idea.
 |
 |      :See also: class `CMAEvolutionStrategy` for a simple dump/load
 |          to resume.
 |
 |  get_mirror(self, x, preserve_length=False)
 |      return ``_round_int_variables(pheno(self.mean - (geno(x) - self.mean)))``
 |
 |      and update `sent_solutions` and `_round_integer_variables.archive` archives.
 |
 |      >>> import numpy as np, cma
 |      >>> es = cma.CMAEvolutionStrategy(np.random.randn(3), 1)  #doctest: +ELLIPSIS
 |      (3_w,...
 |      >>> x = np.random.randn(3)
 |      >>> assert cma.utilities.math.Mh.vequals_approximately(es.mean - (x - es.mean), es.get_mirror(x, preserve_length=True))
 |      >>> x = es.ask(1)[0]
 |      >>> vals = (es.get_mirror(x) - es.mean) / (x - es.mean)
 |      >>> assert cma.utilities.math.Mh.equals_approximately(sum(vals), len(vals) * vals[0])
 |
 |      TODO: this implementation is yet experimental.
 |
 |      TODO: this implementation includes geno-pheno transformation,
 |      however in general GP-transformation should be separated from
 |      specific code.
 |
 |      Selectively mirrored sampling improves to a moderate extend but
 |      overadditively with active CMA for quite understandable reasons.
 |
 |      Optimal number of mirrors are suprisingly small: 1,2,3 for
 |      maxlam=7,13,20 where 3,6,10 are the respective maximal possible
 |      mirrors that must be clearly suboptimal.
 |
 |  get_new_mean(self, X, F, G=None)
 |      return an updated mean based on the input arguments,
 |
 |      namely, the solutions `X` and the ranking implied by `F` and `G`.
 |      `G` is only used if the constraints handling is active. Elements of
 |      `X` are transformed to the genotype as by default, with repair and
 |      with accessing the sent solutions archive.
 |
 |      This method is meant to give a headsup _before_ to call `tell` of
 |      what the updated mean will be and can be useful, for example, for
 |      constraints surrogates.
 |
 |  get_selective_mirrors(self, number=None)
 |      get mirror genotypic directions from worst solutions.
 |
 |      Details:
 |
 |      To be called after the mean has been updated.
 |
 |      Takes the last ``number=sp.lam_mirr`` entries in the
 |      ``self.pop[self.fit.idx]`` as solutions to be mirrored.
 |
 |      Do not take a mirror if it is suspected to stem from a
 |      previous mirror in order to not go endlessly back and forth.
 |
 |  inject(self, solutions, force=None)
 |      inject list of one or several genotypic solution(s).
 |
 |      This is the preferable way to pass outside proposal solutions
 |      into `CMAEvolutionStrategy`. Passing (bad) solutions directly
 |      via `tell` is likely to fail when ``CMA_active is True`` as by
 |      default.
 |
 |      Unless ``force is True``, the `solutions` are used as direction
 |      relative to the distribution mean to compute a new candidate
 |      solution returned in method `ask_geno` which in turn is used in
 |      method `ask`. Even when ``force is True``, the update in `tell`
 |      takes later care of possibly trimming the update vector.
 |
 |      `inject` is to be called before `ask` or after `tell` and can be
 |      called repeatedly.
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(4 * [1], 2)  #doctest: +ELLIPSIS
 |      (4_w,...
 |      >>> while not es.stop():
 |      ...     es.inject([4 * [0.0]])
 |      ...     X = es.ask()
 |      ...     if es.countiter == 0:
 |      ...         assert X[0][0] == X[0][1]  # injected sol. is on the diagonal
 |      ...     es.tell(X, [cma.ff.sphere(x) for x in X])
 |
 |      Details: injected solutions are not used in the "active" update which
 |      would decrease variance in the covariance matrix in this direction.
 |
 |  limit_integer_relative_deltas(self, dX, threshold=None, recombination_weight_condition=None)
 |      versatile: limit absolute values of int-coordinates in vector list `dX`
 |
 |       relative to the current sample standard deviations and by default
 |       only when the respective recombination weight is negative.
 |
 |      This function is currently not in effect (called with threshold=inf)
 |      and not guarantied to stay as is.
 |
 |      ``dX == pop_sorted - mold`` where ``pop_sorted`` is a genotype.
 |
 |      ``threshold=2.3`` by default.
 |
 |      A 2.3-sigma threshold affects 2 x 1.1% of the unmodified
 |      (nonsorted) normal samples.
 |
 |  mahalanobis_norm(self, dx)
 |      return Mahalanobis norm based on the current sample
 |      distribution.
 |
 |      The norm is based on Covariance matrix ``C`` times ``sigma**2``,
 |      and includes ``sigma_vec``. The expected Mahalanobis distance to
 |      the sample mean is about ``sqrt(dimension)``.
 |
 |      Argument
 |      --------
 |      `dx`, a *genotype* difference to the distribution mean. As `dx` is
 |      interpreted as a difference to the mean, the return value does not
 |      depend on the current mean.
 |
 |      Example
 |      -------
 |      >>> import cma, numpy
 |      >>> es = cma.CMAEvolutionStrategy(numpy.ones(10), 1)  #doctest: +ELLIPSIS
 |      (5_w,...
 |      >>> xx = numpy.random.randn(2, 10)
 |      >>> d = es.mahalanobis_norm(es.gp.geno(xx[0]-xx[1]))
 |
 |      `d` is the distance "in" the true sample distribution,
 |      sampled points have a typical distance of ``sqrt(2*es.N)``,
 |      where ``es.N`` is the dimension, and an expected distance of
 |      close to ``sqrt(N)`` to the sample mean. In the example,
 |      `d` is the Euclidean distance, because C = I and sigma = 1.
 |
 |  manage_plateaus(self, sigma_fac=1.5, sample_fraction=0.5)
 |      increase `sigma` by `sigma_fac` in case of a plateau.
 |
 |      A plateau is assumed to be present if the best sample and
 |      ``popsize * sample_fraction``-th best sample have the same
 |      fitness.
 |
 |      Example:
 |
 |      >>> import cma
 |      >>> def f(X):
 |      ...     return (len(X) - 1) * [1] + [2]
 |      >>> es = cma.CMAEvolutionStrategy(4 * [0], 5, {'verbose':-9, 'tolflatfitness':1e4})
 |      >>> while not es.stop():
 |      ...     X = es.ask()
 |      ...     es.tell(X, f(X))
 |      ...     es.manage_plateaus()
 |      >>> if es.sigma < 1.5**es.countiter: print((es.sigma, 1.5**es.countiter, es.stop()))
 |
 |  pickle_dumps(self)
 |      return ``pickle.dumps(self)``,
 |
 |      if necessary remove unpickleable (and also unnecessary) local
 |      function reference beforehand.
 |
 |      The resulting `bytes` string-object can be saved to a file like::
 |
 |          import cma
 |          es = cma.CMAEvolutionStrategy(3 * [1], 1)
 |          es.optimize(cma.ff.elli, iterations=22)
 |          filename = 'es-pickle-test'
 |          open(filename, 'wb').write(es.pickle_dumps())
 |
 |      and recovered like::
 |
 |          import pickle
 |          es = pickle.load(open(filename, 'rb'))
 |
 |      or::
 |
 |          es = pickle.loads(open(filename, 'rb').read())
 |          es.optimize(cma.ff.elli, iterations=22)  # continue optimizing
 |
 |  plot(self, *args, **kwargs)
 |      plot current state variables using `matplotlib`.
 |
 |      This calls `self.logger.plot`, see `cma.CMADataLogger.plot` to see all
 |      valid keyword arguments.
 |
 |  random_rescale_to_mahalanobis(self, x)
 |      change `x` like for injection, all on genotypic level
 |
 |  repair_genotype(self, x, copy_if_changed=False)
 |      make sure that solutions fit to the sample distribution.
 |
 |      This interface is versatile and likely to change.
 |
 |      We currently assume that this is idempotent.
 |
 |      The Mahalanobis distance ``x - self.mean`` is clipping at
 |      ``N**0.5 + 2 * N / (N + 2)``, but the specific repair
 |      mechanism may change in future.
 |
 |  reset_options(self, **kwargs)
 |      clear termination and set any `CMAOptions` passed via
 |
 |      keyword arguments or like ``**opts_dict``. The validity of the option
 |      names is checked, the validity of the values is not checked.
 |
 |      Some resettings will not be effective. For those with a ``'#v'``
 |      flag in their description, the effectiveness is guarantied. See
 |      `CMAOptions`.
 |
 |      Return `self`, the new options are in ``self.opts``.
 |
 |  result_pretty(self, number_of_restarts=0, time_str=None, fbestever=None)
 |      pretty print result.
 |
 |      Returns `result` of ``self``.
 |
 |  stop(self, check=True, ignore_list=(), check_in_same_iteration=False, get_value=None)
 |      return the termination status as dictionary.
 |
 |      With ``check == False``, the termination conditions are not checked
 |      and the status might not reflect the current situation.
 |      ``check_on_same_iteration == False`` (new) does not re-check during
 |      the same iteration. When termination options are manually changed,
 |      it must be set to `True` to advance afterwards.
 |      ``stop().clear()`` removes the currently active termination
 |      conditions.
 |
 |      As a convenience feature, keywords in `ignore_list` are removed from
 |      the conditions.
 |
 |      If `get_value` is set to a condition name (not the empty string),
 |      `stop` does not update the termination dictionary but returns the
 |      measured value that would be compared to the threshold. This only
 |      works for some conditions, like 'tolx'. If the condition name is
 |      not known or cannot be computed, `None` is returned and no warning
 |      is issued.
 |
 |      Testing `get_value` functionality:
 |
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(2 * [1], 1e4, {'verbose': -9})
 |      >>> with warnings.catch_warnings(record=True) as w:
 |      ...     es.stop(get_value='tolx')  # triggers zero iteration warning
 |      ...     assert len(w) == 1, [str(wi) for wi in w]
 |      >>> es = es.optimize(cma.ff.sphere, iterations=4)
 |      >>> assert 1e3 < es.stop(get_value='tolx') < 1e4, es.stop(get_value='tolx')
 |      >>> assert es.stop() == {}
 |      >>> assert es.stop(get_value='catch 22') is None
 |
 |  tell(self, solutions, function_values, check_points=None, copy=False, constraints_values=None)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  tell2(self, solutions, function_values, constraints_values=None, check_points=None, copy=False)
 |      pass objective function values to prepare for next iteration.
 |
 |      This core procedure of the CMA-ES algorithm updates all state
 |      variables, in particular the two evolution paths, the distribution
 |      mean, the covariance matrix and a step-size.
 |
 |      CAVEAT: the argument positions are different for `tell` and `tell2`.
 |
 |      Arguments
 |      ---------
 |      `solutions`
 |          list or array of candidate solution points (of
 |          type `numpy.ndarray`), most presumably before
 |          delivered by method `ask()` or `ask_and_eval()`.
 |      `function_values`
 |          list or array of objective function values
 |          corresponding to the respective points. Beside for termination
 |          decisions, only the ranking of values in `function_values`
 |          is used.
 |      `constraints_values`
 |          can be used as _positional_ argument in 3rd position only with
 |          `tell2`. A list of inequality constraints values for each
 |          solution in `solutions`. Feasible solutions have a nonpositive
 |          value of all constraints.
 |      `check_points`
 |          If ``check_points is None``, only solutions that are not generated
 |          by `ask()` are possibly clipped (recommended). ``False`` does not clip
 |          any solution (not recommended).
 |          If ``True``, clips solutions that realize long steps (i.e. also
 |          those that are unlikely to be generated with `ask()`). `check_points`
 |          can be a list of indices to be checked in solutions.
 |      `copy`
 |          ``solutions`` can be modified in this routine, if ``copy is False``
 |
 |      Details
 |      -------
 |      `tell()` updates the parameters of the multivariate
 |      normal search distribution, namely covariance matrix and
 |      step-size and updates also the attributes ``countiter`` and
 |      ``countevals``. To check the points for consistency is quadratic
 |      in the dimension (like sampling points).
 |
 |      Bugs
 |      ----
 |      The effect of changing the solutions delivered by `ask()`
 |      depends on whether boundary handling is applied. With boundary
 |      handling, modifications are disregarded. This is necessary to
 |      apply the default boundary handling that uses unrepaired
 |      solutions but might change in future.
 |
 |      Example
 |      -------
 |
 |      >>> import cma
 |      >>> func = cma.ff.sphere  # choose objective function
 |      >>> funb = cma.BoundDomainTransform(func, [1, None])  # set bounds
 |      >>> def cons(x):  # define constraints
 |      ...     return [2 - x[0]]
 |      >>> consb = cma.BoundDomainTransform(cons, [1, None])
 |      >>> es = cma.CMAEvolutionStrategy(np.random.rand(2) / 3, 1.5)  # doctest:+ELLIPSIS
 |      (3_...
 |      >>> while not es.stop():
 |      ...    X = es.ask()
 |      ...    es.tell2(X, [funb(x) for x in X], [consb(x) for x in X])
 |      >>> assert all(funb.transform(es.best_feasible.x) >= [2 - 1e-5, 1 - 1e-5])
 |      >>> assert all(funb.transform(es.best_feasible.x) <= [2 + 1e-5, 1 + 1e-5])
 |
 |      The value of `es.result.xbest` is not reliable with constraints,
 |      because a dynamic augmented Lagrangian is optimized. Instead, use
 |      `es.result.xfavorite` or `es.best_feasible.x`.
 |
 |      :See: class `CMAEvolutionStrategy`, `ask`, `ask_and_eval`, `fmin`
 |
 |  to_phenotype(self, solution, *args, **kwargs)
 |      return integer-rounded phenotype depending on `round_integer_variables` module setting.
 |
 |      Without further arguments, `self.gp.pheno` is called with
 |      ``copy=True, into_bounds=self.boundary_handler.repair`` as
 |      additional arguments, otherwise ``*args, **kwargs`` are passed
 |      to `self.gp.pheno`.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  condition_number
 |      condition number of the statistical-model sampler.
 |
 |      Details: neither encoding/decoding from `sigma_vec`-scaling nor
 |      `gp`-transformation are taken into account for this computation.
 |
 |  isotropic_mean_shift
 |      normalized last mean shift, under random selection N(0,I)
 |
 |      distributed.
 |
 |      Caveat: while it is finite and close to sqrt(n) under random
 |      selection, the length of the normalized mean shift under
 |      *systematic* selection (e.g. on a linear function) tends to
 |      infinity for mueff -> infty. Hence it must be used with great
 |      care for large mueff.
 |
 |  popsize
 |      number of samples by default returned by `ask` ()
 |
 |  result
 |      return a `CMAEvolutionStrategyResult2` class instance.
 |
 |      :See: `cma.evolution_strategy.CMAEvolutionStrategyResult2`
 |          or try ``help(...result)`` on the ``result`` property
 |          of an `CMAEvolutionStrategy` instance or an
 |          `CMAEvolutionStrategyResult2` instance.
 |
 |  stds
 |      return array of coordinate-wise standard deviations (phenotypic).
 |
 |      Takes into account geno-phenotype transformation, step-size,
 |      diagonal decoding, and the covariance matrix. Only the latter three
 |      apply to `self.mean`.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from cma.interfaces.OOOptimizer:
 |
 |  initialize(self)
 |      (re-)set to the initial state
 |
 |  optimize(self, objective_fct, maxfun=None, iterations=None, min_iterations=1, args=(), verb_disp=None, callback=None, n_jobs=0, **kwargs)
 |      find minimizer of ``objective_fct``.
 |
 |      CAVEAT: the return value for `optimize` has changed to ``self``,
 |      allowing for a call like::
 |
 |          solver = OOOptimizer(x0).optimize(f)
 |
 |      and investigate the state of the solver.
 |
 |      Arguments
 |      ---------
 |
 |      ``objective_fct``: f(x: array_like) -> float
 |          function be to minimized
 |      ``maxfun``: number
 |          maximal number of function evaluations
 |      ``iterations``: number
 |          number of (maximal) iterations, while ``not self.stop()``,
 |          it can be useful to conduct only one iteration at a time.
 |      ``min_iterations``: number
 |          minimal number of iterations, even if ``not self.stop()``
 |      ``args``: sequence_like
 |          arguments passed to ``objective_fct``
 |      ``verb_disp``: number
 |          print to screen every ``verb_disp`` iteration, if `None`
 |          the value from ``self.logger`` is "inherited", if
 |          available.
 |      ``callback``: callable or list of callables
 |          callback function called like ``callback(self)`` or
 |          a list of call back functions called in the same way. If
 |          available, ``self.logger.add`` is added to this list.
 |          TODO: currently there is no way to prevent this other than
 |          changing the code of `_prepare_callback_list`.
 |      ``n_jobs=0``: number of processes to be acquired for
 |          multiprocessing to parallelize calls to `objective_fct`.
 |          Must be >1 to expect any speed-up or `None` or `-1`, which
 |          both default to the number of available CPUs. The default
 |          ``n_jobs=0`` avoids the use of multiprocessing altogether.
 |
 |      ``return self``, that is, the `OOOptimizer` instance.
 |
 |      Example
 |      -------
 |      >>> import cma
 |      >>> es = cma.CMAEvolutionStrategy(7 * [0.1], 0.1
 |      ...              ).optimize(cma.ff.rosen, verb_disp=100)
 |      ...                   #doctest: +ELLIPSIS
 |      (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 7 (seed=...)
 |      Iterat #Fevals   function value  axis ratio  sigma ...
 |          1      9 ...
 |          2     18 ...
 |          3     27 ...
 |        100    900 ...
 |      >>> cma.s.Mh.vequals_approximately(es.result[0], 7 * [1], 1e-5)
 |      True
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from cma.interfaces.OOOptimizer:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAEvolutionStrategyResult
Python Library Documentation: class CMAEvolutionStrategyResult in module cma.evolution_strategy

class CMAEvolutionStrategyResult(CMAEvolutionStrategyResult)
 |  CMAEvolutionStrategyResult(xbest, fbest, evals_best, evaluations, iterations, xfavorite, stds, stop)
 |
 |  A results tuple from `CMAEvolutionStrategy` property ``result``.
 |
 |  This tuple contains in the given position and as attribute
 |
 |  - 0 ``xbest`` best solution evaluated
 |  - 1 ``fbest`` objective function value of best solution
 |  - 2 ``evals_best`` evaluation count when ``xbest`` was evaluated
 |  - 3 ``evaluations`` evaluations overall done
 |  - 4 ``iterations``
 |  - 5 ``xfavorite`` distribution mean in "phenotype" space, to be
 |    considered as current best estimate of the optimum
 |  - 6 ``stds`` effective standard deviations, can be used to
 |    compute a lower bound on the expected coordinate-wise distance
 |    to the true optimum, which is (very) approximately stds[i] *
 |    dimension**0.5 / min(mueff, dimension) / 1.5 / 5 ~ std_i *
 |    dimension**0.5 / min(popsize / 2, dimension) / 5, where
 |    dimension = CMAEvolutionStrategy.N and mueff =
 |    CMAEvolutionStrategy.sp.weights.mueff ~ 0.3 * popsize.
 |  - 7 ``stop`` termination conditions in a dictionary
 |
 |  The penalized best solution of the last completed iteration can be
 |  accessed via attribute ``pop_sorted[0]`` of `CMAEvolutionStrategy`
 |  and the respective objective function value via ``fit.fit[0]``.
 |
 |  Details:
 |
 |  - This class is of purely declarative nature and for providing
 |    this docstring. It does not provide any further functionality.
 |  - ``list(.fit.idx).index(0)`` is the index of the first sampled
 |    solution of the last completed iteration in ``pop_sorted``.
 |
 |  Method resolution order:
 |      CMAEvolutionStrategyResult
 |      CMAEvolutionStrategyResult
 |      builtins.tuple
 |      builtins.object
 |
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CMAEvolutionStrategyResult:
 |
 |  __getnewargs__(self) from collections.CMAEvolutionStrategyResult
 |      Return self as a plain tuple.  Used by copy and pickle.
 |
 |  __repr__(self) from collections.CMAEvolutionStrategyResult
 |      Return a nicely formatted representation string
 |
 |  _asdict(self) from collections.CMAEvolutionStrategyResult
 |      Return a new dict which maps field names to their values.
 |
 |  _replace(self, /, **kwds) from collections.CMAEvolutionStrategyResult
 |      Return a new CMAEvolutionStrategyResult object replacing specified fields with new values
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from CMAEvolutionStrategyResult:
 |
 |  _make(iterable) from collections.CMAEvolutionStrategyResult
 |      Make a new CMAEvolutionStrategyResult object from a sequence or iterable
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from CMAEvolutionStrategyResult:
 |
 |  __new__(_cls, xbest, fbest, evals_best, evaluations, iterations, xfavorite, stds, stop) from namedtuple_CMAEvolutionStrategyResult.CMAEvolutionStrategyResult
 |      Create new instance of CMAEvolutionStrategyResult(xbest, fbest, evals_best, evaluations, iterations, xfavorite, stds, stop)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CMAEvolutionStrategyResult:
 |
 |  xbest
 |      Alias for field number 0
 |
 |  fbest
 |      Alias for field number 1
 |
 |  evals_best
 |      Alias for field number 2
 |
 |  evaluations
 |      Alias for field number 3
 |
 |  iterations
 |      Alias for field number 4
 |
 |  xfavorite
 |      Alias for field number 5
 |
 |  stds
 |      Alias for field number 6
 |
 |  stop
 |      Alias for field number 7
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from CMAEvolutionStrategyResult:
 |
 |  __match_args__ = ('xbest', 'fbest', 'evals_best', 'evaluations', 'iter...
 |
 |  _field_defaults = {}
 |
 |  _fields = ('xbest', 'fbest', 'evals_best', 'evaluations', 'iterations'...
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.tuple:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.tuple:
 |
 |  __class_getitem__(...)
 |      See PEP 585
cma.evolution_strategy.CMAEvolutionStrategyResult2
Python Library Documentation: class CMAEvolutionStrategyResult2 in module cma.evolution_strategy

class CMAEvolutionStrategyResult2(builtins.object)
 |  CMAEvolutionStrategyResult2(xbest, fbest, evals_best, best_feasible, evaluations, iterations, xfavorite, stds, stop)
 |
 |  A results class.
 |
 |    This class is of rather declarative nature allowing to access the result in
 |    its attributes after running an optimization. Additionally, the class
 |    provides a `names` and an `asdict` property.
 |
 |    >>> import cma
 |    >>> es = cma.CMA(2 * [1], .1, {'verbose': -9}).optimize(cma.ff.sphere, 4, iterations=5)
 |    >>> isinstance(es.result, cma.evolution_strategy.CMAEvolutionStrategyResult2)
 |    True
 |
 |    The easiest ways to examine the results visually is by ``list(es.result)``
 |    or like
 |
 |    >>> es.result.asdict  # doctest: +ELLIPSIS
 |    {'xbest':...
 |
 |    We can also check the available attribute names like
 |
 |    >>> es.result.names  # doctest: +ELLIPSIS
 |    ['xbest', 'fbest',...
 |
 |    and then check a value like
 |
 |    >>> float(es.result.xbest[0]) < 10
 |    True
 |
 |    Otherwise, the result class acts largely like a `dataclass` and like the
 |    original `namedtuple` `CMAEvolutionStrategyResult`, however with
 |    _additional_ attributes: as of 2025 the `.best_feasible` attribute has been
 |    added. For backward compatibility, index access of the original entries is
 |    possible but discouraged, like
 |
 |    >>> es.result[1] == es.result[-7] == es.result.fbest  # deprecated
 |    True
 |
 |    The nine result attributes are:
 |
 |    ``xbest`` best solution evaluated, this may not reflect a good solution
 |    under noise or with a changing fitness function like in the constrained
 |    case.
 |
 |    ``fbest`` objective function value of the best solution
 |
 |    ``evals_best`` evaluation count when ``xbest`` was evaluated
 |
 |    ``best_feasible`` is a dictionary with the keys ``'x', 'f', 'evals'``
 |    (and possibly others), the feasible counterparts to ``xbest, fbest,
 |    evals_best``. This is particularly useful with constraints.
 |    ``best_feasible`` is not accessible by index.
 |
 |    ``evaluations`` overall done
 |
 |    ``iterations`` overall done
 |
 |    ``xfavorite`` final distribution mean in "phenotype" space, considered
 |    to be the current best estimate of the optimum.
 |
 |    ``stds`` effective final standard deviations, can be used to compute a
 |    lower bound on the expected coordinate-wise distance to the true
 |    optimum, which is (very!) approximately ``stds[i] * dim**0.5 * 3 /
 |    np.minimum(popsize, 3 * dim + 15)`` (was: ``stds[i] * dimension**0.5 /
 |    min(mueff, dimension) / 1.5 / 5 ~ stds[i] * dimension**0.5 /
 |    min(popsize / 2, dimension) / 5``, where dimension =
 |    CMAEvolutionStrategy.N and mueff =
 |    CMAEvolutionStrategy.sp.weights.mueff ~ 0.3 * popsize).
 |
 |  ``stop`` termination conditions in a dictionary.
 |
 |    CAVEAT: in contrast to a named tuple, this class iterates over items, not
 |    values, hence ``dict(es.result)`` works as expected. ``list(es.result)`` is
 |    not backward compatible (providing a list of values without keys seems
 |    rather pointless given the values are not homogenuous). The previous value
 |    of ``list(es.result)`` can be obtained by ``[r[1] for r in es.result]``.
 |
 |    While not provided in this class, the (penalized-)best solution
 |    of the last completed iteration can be accessed via the attribute
 |    ``.pop_sorted[0]`` of `CMAEvolutionStrategy` and the respective
 |    objective function value via ``.fit.fit[0]``.
 |
 |    Details:
 |
 |    - in addition to ``._asdict()`` and ``dir(.)`` (which works rather
 |      poorly) for the old `CMAEvolutionStrategyResult`, viewing with
 |      ``dict(.)`` and ``.asdict`` works for this class too.
 |    - ``list(CMA.fit.idx).index(i)`` is the index of the i-ths sampled solution
 |      of the last completed iteration in ``pop_sorted``. In other words, it is
 |      the (original) index of the i+1-th best solution.
 |
 |    Technical details:
 |
 |    - The class allows to have new attributes while keeping backward
 |      compatible index access of the original eight attributes of the
 |      `namedtuple` `CMAEvolutionStrategyResult`. ``es.result[-8]`` still
 |      equals ``es.result[0]``. Newly introduced attributes are ignored in
 |      this count and cannot be accessed by position index. Index access
 |      is discouraged.
 |    - inheriting from a `list` would work too, but we would have the list
 |      methods as additional attributes.
 |
 |  Methods defined here:
 |
 |  __getitem__(self, i)
 |      for backward compatibility, access by the (old) index works too,
 |      this is supposed to stay as is forever.
 |
 |  __init__(self, xbest, fbest, evals_best, best_feasible, evaluations, iterations, xfavorite, stds, stop)
 |      set attributes with the arguments resembling `namedtuple` or `dataclass`
 |
 |  __iter__(self)
 |      return iterator over names
 |
 |  __len__(self)
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  __str__(self)
 |      string representation of self.
 |
 |      arrays come without commata like ``'[val1 val2 ...]'``, however in a `dict`
 |      they look like `repr(.)` like ``'array([val1, val2, ...])'``.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  asdict
 |
 |  names
 |      list of attribute names
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.CMAOptions
Python Library Documentation: class CMAOptions in module cma.options_parameters

class CMAOptions(builtins.dict)
 |  CMAOptions(s=None, **kwargs)
 |
 |  a dictionary with the available options and their default values
 |  for class `CMAEvolutionStrategy`.
 |
 |  ``CMAOptions()`` returns a `dict` with all available options and their
 |  default values with a comment string.
 |
 |  ``CMAOptions('verb')`` returns a subset of recognized options that
 |  contain 'verb' in there keyword name or (default) value or
 |  description.
 |
 |  ``CMAOptions(opts)`` returns the subset of recognized options in
 |  ``dict(opts)``.
 |
 |  Option values can be "written" in a string and, when passed to `fmin2`
 |  or `CMAEvolutionStrategy`, are evaluated using "N" and "popsize" as
 |  known values for dimension and population size (sample size, number
 |  of new solutions per iteration). All default option values are given
 |  as such a string.
 |
 |  Details
 |  -------
 |  `CMAOptions` entries starting with ``tol`` are termination
 |  "tolerances".
 |
 |  For `tolstagnation`, the median over the first and the second half
 |  of at least `tolstagnation` iterations are compared for both, the
 |  per-iteration best and per-iteration median function value.
 |
 |  Example
 |  -------
 |  ::
 |
 |      import cma
 |      cma.CMAOptions('tol')
 |
 |  is a shortcut for ``cma.CMAOptions().match('tol')`` that returns all
 |  options that contain 'tol' in their name or description.
 |
 |  To set an option::
 |
 |      import cma
 |      opts = cma.CMAOptions()
 |      opts.set('tolfun', 1e-12)
 |      opts['tolx'] = 1e-11
 |
 |  todo: this class is overly complex and should be re-written, possibly
 |  with reduced functionality.
 |
 |  :See also: `fmin2` (), `CMAEvolutionStrategy`, `CMAParameters`
 |
 |  Method resolution order:
 |      CMAOptions
 |      builtins.dict
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, key, default=None, loc=None)
 |      evaluate and return the value of option `key` on the fly, or
 |      return those options whose name or description contains `key`,
 |      case disregarded.
 |
 |      Details
 |      -------
 |      Keys that contain `filename` are not evaluated.
 |      For ``loc==None``, `self` is used as environment
 |      but this does not define ``N``.
 |
 |      :See: `eval()`, `evalall()`
 |
 |  __init__(self, s=None, **kwargs)
 |      return an `CMAOptions` instance.
 |
 |      Return default options if ``s is None and not kwargs``,
 |      or all options whose name or description contains `s`, if
 |      `s` is a (search) string (case is disregarded in the match),
 |      or with entries from dictionary `s` as options,
 |      or with kwargs as options if ``s is None``,
 |      in any of the latter cases not complemented with default options
 |      or settings.
 |
 |      Returns: see above.
 |
 |      Details: as several options start with ``'s'``, ``s=value`` is
 |      not valid as an option setting.
 |
 |  amend_integer_options(self, dimension, inopts)
 |      amend options when integer variables are indicated
 |
 |  amend_integer_variables(self, dimension)
 |      remove fixed variables from the integer variable index list
 |
 |      and change the index values accordingly to refer to a genotype.
 |      Create an `'_pheno_integer_variables'` entry of the same length but
 |      with the unchanged index values.
 |
 |  check(self, options=None)
 |      check for ambiguous keys and move attributes into dict
 |
 |  check_attributes(self, opts=None)
 |      check for attributes and moves them into the dictionary
 |
 |  check_values(self, options=None)
 |
 |  complement(self)
 |      add all missing options with their default values
 |
 |  corrected_key(self, key)
 |      return the matching valid key, if ``key.lower()`` is a unique
 |      starting sequence to identify the valid key, ``else None``
 |
 |  eval(self, key, default=None, loc=None, correct_key=True)
 |      Evaluates and sets the specified option value in
 |      environment `loc`. Many options need ``N`` to be defined in
 |      `loc`, some need `popsize`.
 |
 |      Details
 |      -------
 |      Keys that contain 'filename' are not evaluated.
 |      For `loc` is None, the self-dict is used as environment
 |
 |      :See: `evalall()`, `__call__`
 |
 |  evalall(self, loc=None, defaults=None)
 |      Evaluates all option values in environment `loc`.
 |
 |      :See: `eval()`
 |
 |  from_namedtuple(self, t)
 |      update options from a `collections.namedtuple`.
 |      :See also: `to_namedtuple`
 |
 |  init(self, dict_or_str, val=None, warn=True)
 |      initialize one or several options.
 |
 |      Arguments
 |      ---------
 |          `dict_or_str`
 |              a dictionary if ``val is None``, otherwise a key.
 |              If `val` is provided `dict_or_str` must be a valid key.
 |          `val`
 |              value for key
 |
 |      Details
 |      -------
 |      Only known keys are accepted. Known keys are in `CMAOptions.defaults()`
 |
 |  match(self, s='')
 |      return all options that match, in the name or the description,
 |      with string `s`, case is disregarded.
 |
 |      Example: ``cma.CMAOptions().match('verb')`` returns the verbosity
 |      options.
 |
 |  pprint(self, linebreak=80)
 |
 |  set(self, dic, val=None, force=False)
 |      assign versatile options.
 |
 |      Method `CMAOptions.versatile_options` () gives the versatile
 |      options, use `init()` to set the others.
 |
 |      Arguments
 |      ---------
 |          `dic`
 |              either a dictionary or a key. In the latter
 |              case, `val` must be provided
 |          `val`
 |              value for `key`, approximate match is sufficient
 |          `force`
 |              force setting of non-versatile options, use with caution
 |
 |      This method will be most probably used with the ``opts`` attribute of
 |      a `CMAEvolutionStrategy` instance.
 |
 |  set_integer_min_std(self, N, mueff)
 |      set lower std bounds for integer variables.
 |
 |      Uses the above defined `integer_std_lower_bound` function which can
 |      be reassigned.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  defaults()
 |      return a dictionary with default option values and description
 |
 |  versatile_options()
 |      return list of options that can be changed at any time (not
 |      only be initialized).
 |
 |      Consider that this list might not be entirely up
 |      to date.
 |
 |      The string ' #v ' in the default value indicates a versatile
 |      option that can be changed any time, however a string will not
 |      necessarily be evaluated again.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  settable
 |      return the subset of those options that are settable at any
 |      time.
 |
 |      Settable options are in `versatile_options` (), but the
 |      list might be incomplete.
 |
 |  to_namedtuple
 |      return options as const attributes of the returned object,
 |      only useful for inspection.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.dict:
 |
 |  __contains__(self, key, /)
 |      True if the dictionary has the specified key, else False.
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __ior__(self, value, /)
 |      Return self|=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the dict keys.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(...)
 |      D.__sizeof__() -> size of D in memory, in bytes
 |
 |  clear(...)
 |      D.clear() -> None.  Remove all items from D.
 |
 |  copy(...)
 |      D.copy() -> a shallow copy of D
 |
 |  get(self, key, default=None, /)
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  items(...)
 |      D.items() -> a set-like object providing a view on D's items
 |
 |  keys(...)
 |      D.keys() -> a set-like object providing a view on D's keys
 |
 |  pop(...)
 |      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
 |
 |      If the key is not found, return the default if given; otherwise,
 |      raise a KeyError.
 |
 |  popitem(self, /)
 |      Remove and return a (key, value) pair as a 2-tuple.
 |
 |      Pairs are returned in LIFO (last-in, first-out) order.
 |      Raises KeyError if the dict is empty.
 |
 |  setdefault(self, key, default=None, /)
 |      Insert key with a value of default if key is not in the dictionary.
 |
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  update(...)
 |      D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
 |      If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
 |      If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
 |      In either case, this is followed by: for k in F:  D[k] = F[k]
 |
 |  values(...)
 |      D.values() -> an object providing a view on D's values
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.dict:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  fromkeys(iterable, value=None, /)
 |      Create a new dictionary with keys from iterable and values set to value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.dict:
 |
 |  __new__(*args, **kwargs) class method of builtins.dict
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.dict:
 |
 |  __hash__ = None
cma.evolution_strategy.CSA_dampfac_mueff
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.CSA_dampfac_mueff_attenuation_dimension
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.CSA_dampfac_mueff_inner
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.InjectionWarning
Python Library Documentation: class InjectionWarning in module cma.evolution_strategy

class InjectionWarning(builtins.UserWarning)
 |  Injected solutions are not passed to tell as expected
 |
 |  Method resolution order:
 |      InjectionWarning
 |      builtins.UserWarning
 |      builtins.Warning
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors defined here:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.UserWarning:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.UserWarning:
 |
 |  __new__(*args, **kwargs) class method of builtins.UserWarning
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
cma.evolution_strategy.IntegerCentering
Python Library Documentation: class IntegerCentering in module cma.integer_centering

class IntegerCentering(builtins.object)
 |  IntegerCentering(int_indices, method=2, correct_bias=True, repair_into_bounds=True, **kwargs)
 |
 |  round values of int-variables that are different from the int-mean.
 |
 |  This callable class changes a population of solutions in place, in
 |  particular rounding some of the integer variables. The call does not
 |  guaranty to round any or all integer variables. The class assumes that
 |  the fitness function only interprets the rounded values of integer
 |  variables, that is, it assumes that int-variables change the fitness
 |  only if their rounded (genotype) value change. (This may easily become
 |  a wrong assumption if a geno-pheno transformation is applied). The
 |  class tries to correct for the bias introduced by rounding values.
 |
 |  This class should generally be used in combination with a lower bound
 |  on the integer variables along the lines of ``min((0.2,
 |  mueff/dimension))``, as it is induced by passing a nonempty
 |  ``'integer_variables'`` option to `CMAEvolutionStrategy`. Applying
 |  lower bounds alone is generally more effective than applying integer
 |  centering alone.
 |
 |  Class instances have no dynamically changing state variables!
 |
 |  When integer variable indices are passed to `CMAEvolutionStrategy` via
 |  the ``'integer_variables'`` `CMAOptions`, an `IntegerCentering` class
 |  instance is created, and it is called in `CMAEvolutionStrategy.tell`
 |  before the update of the state variables of CMA, passing mu (genotypic)
 |  solutions, like ``int_centering(self.pop_sorted[:self.sp.weights.mu],
 |  self.mean)`` . The call changes the `numpy` arrays of `self.pop_sorted`
 |  in place. The call tries to access the (phenotypic) bounds as defined
 |  in ``es.boundary_handler`` from the constructor argument. Hence it is
 |  expected to fail with a combination of ``bounds`` and
 |  ``fixed_variables`` set in `CMAOptions`.
 |
 |  By default, integer centering is applied, e.g. with `fmin2` or
 |  `CMAEvolutionStrategy`, when the integer variable indices are given
 |  via the ``'integer_variables'`` option. Since v4.3.0, candidate
 |  solutions delivered by `CMAEvolutionStrategy.ask` have rounded values
 |  in all integer variable positions which can be switched off by setting
 |  `cma.evolution_strategy.round_integer_variables` to `False`.
 |
 |  A simple example code:
 |
 |  >>> import cma
 |  >>>
 |  >>> def int1_sphere(x):
 |  ...     return int(x[0] + 0.5 - (x[0] < 0))**2 + 1000 * (sum(xi**2 for xi in x[1:]))
 |
 |  >>> es = cma.CMAEvolutionStrategy(2 * [2], 0.5,
 |  ...             {'integer_variables': [0], 'ftarget': 1e-9, 'verbose': -9})
 |  >>> es = es.optimize(int1_sphere)
 |  >>> # assert 'ftarget' in es.stop(), es.stop()  # fails sometimes (like 1%-ish)
 |  >>> # failure is less likely with options ``'tolfun': 0, 'tolfunhist': 0, 'tolflatfitness': 60``
 |
 |  The following pseudocode shows a direct use case to explicitly see
 |  how/where integer centering is applied, namely before the state
 |  variables are updated in `tell`:
 |
 |  >>> import numpy as np
 |
 |  >>> # set dimension dependent lower bound on sample standard deviations
 |  >>> es = cma.CMAEvolutionStrategy(2 * [2], 0.5,
 |  ...             {'minstd': [0.2, 0], 'popsize_factor': 1.5, 'ftarget': 1e-9, 'verbose': -9})
 |  >>> # when integer_variables were passed in the above options,
 |  >>> # we can inactivate the internal integer centering like
 |  >>> es.integer_centering = lambda *args: args[0] if args else None
 |  >>> ic = cma.integer_centering.IntegerCentering([0])
 |  >>> while not es.stop():
 |  ...     X = es.ask()
 |  ...     F = [int1_sphere(x) for x in X]
 |  ...     # change the mu best solutions in place
 |  ...     _ = ic([X[i] for i in np.argsort(F)[:es.sp.weights.mu]], es.mean)
 |  ...     es.tell(X, F, check_points=False)  # don't check for changes in X
 |  ...     # es.logger.add()
 |  ...     # es.disp()
 |  >>> # assert 'ftarget' in es.stop(), es.stop()  # fails sometimes (like 1%-ish)
 |
 |  Details: The default `method2` was used in the below reference and, as
 |  of version 4.0.0, is activated in `CMAEvolutionStrategy` when
 |  `integer_variables` are given as option.
 |
 |  Reference: Marty et al, LB+IC-CMA-ES: Two simple modifications of
 |  CMA-ES to handle mixed-integer problems. PPSN 2024.
 |
 |  Methods defined here:
 |
 |  __call__(self, solution_list, mean)
 |      round values of int-variables in `solution_list` and correct for bias.
 |
 |      Return `solution_list`, however assignment is deprecated as
 |      `solution_list` is changed in place and, in particular, because we
 |      center usually only the first half of the population.
 |
 |      Variables are only rounded if their rounded value is different from
 |      the mean. Bias correction is only applied if the rounded value is
 |      the same as the rounded value of the mean and only towards the
 |      rounded value of the mean, not away from it.
 |
 |      None of these changes change the rounded variable value.
 |
 |      Details: The bias correction could be applied directly to the mean
 |      after the mean update, as it probably does not have any relevant
 |      effect on the C update. This would require another call or passing
 |      the Delta mean in the return value.
 |
 |  __init__(self, int_indices, method=2, correct_bias=True, repair_into_bounds=True, **kwargs)
 |      `int_indices` can also be a `CMAEvolutionStrategy` or `CMAOptions` instance.
 |      `correct_bias` can be in [0, 1] indicating the fraction of the bias
 |      that should be corrected (but only up to the mean center).
 |
 |      `repair_into_bounds` repairs all solutions before centering is
 |      applied. This does not guaranty solutions to be feasible after
 |      centering in the case when `np.round` can make a solution
 |      infeasible.
 |
 |      Details: When the bias computation and correction is applied only
 |      to the better half of the population (as by default), the value of
 |      `correct_bias` must be smaller than 1 to move the mean toward a
 |      solution that has rank lambda/5 or worse, because ``w_{lambda/5}``
 |      equals roughly ``1/mu`` (``w_{lambda/3}`` equals roughly
 |      ``1/mu/2``).
 |
 |  bound(self, i)
 |      return lower and upper bound on variable `i`, not in use.
 |
 |  callback(self, es)
 |      change `es.pop_sorted` and update `es.mean` accordingly.
 |
 |      Not in use, as this must be ideally done in the middle of `tell`,
 |      that is, neither before nor after `tell`.
 |
 |  get_int_indices(self, es_opts_indices=None)
 |      determine integer variable indices from es or es.opts or
 |
 |      a variable index list or self.
 |
 |  has_bounds(self, which='both')
 |
 |  lower_bounds(self, dimension)
 |      return lower bounds of dimension `dimension` or a scalar.
 |
 |      `dimension` remains the dimension from the first call unless
 |      the ``_lower_bounds`` attribute is reset to `None`.
 |
 |  method1(self, solution_list, mean)
 |      DEPRECATED (experimental and outdated) round values of int-variables in `solution_list` and reduce bias to the mean
 |
 |  method2(self, solution_list, mean)
 |      center (round) values of int-variables of solutions in `solution_list`.
 |
 |      Elements of `solution_list` must accept boolean indexing like ``np.arrays``.
 |
 |      Values are centered iff the centered value differs from the
 |      centered mean. If `correct_bias`, the introduced bias is amended by
 |      changing the other (noncentered) coordinates towards their
 |      int-center (which is the int-center of the mean) too, up to the
 |      fraction `correct_bias`.
 |
 |      CAVEAT/TODO: the bias correction currently doesn't check bounds,
 |      hence it may push feasible solutions out-of-bounds by (i) centering
 |      single solutions and (ii) shifting coordinates towards their
 |      centered value during bias correction. In itself and overall, this
 |      may not be a problem, in particular when `repair` is applied before
 |      or after calling `method2`.
 |
 |  repair(self, solution_list, randomized=True)
 |      set values of int-variables of solutions of `solution_list` into bounds.
 |
 |      Elements of `solution_list` are changed in place after passing them
 |      through ``np.asarray`` and `solution_list` is changed in place too.
 |
 |      When ``randomized is True`` sample the value uniformly between the
 |      bound and the value center (the rounded bound) when the latter is
 |      feasible.
 |
 |  upper_bounds(self, dimension)
 |      return upper bounds of dimension `dimension` or a scalar.
 |
 |      `dimension` remains the dimension from the first call unless
 |      the ``_upper_bounds`` attribute is reset to `None`.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  int_mask
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.Mh
Python Library Documentation: class MathHelperFunctions in module cma.utilities.math

class MathHelperFunctions(builtins.object)
 |  static convenience math helper functions, if the function name
 |  is preceded with an "a", a numpy array is returned
 |
 |  TODO: there is probably no good reason why this should be a class and not a
 |  module.
 |
 |  Static methods defined here:
 |
 |  aclamp(x, upper)
 |
 |  amax(vec, vec_or_scalar)
 |
 |  amin(vec_or_scalar, vec_or_scalar2)
 |
 |  aminmax(val, min_val, max_val)
 |
 |  apenalty_quadlin(x, lower=0, upper=None)
 |      Huber-like smooth penality which starts at lower.
 |
 |      The penalty is zero below lower and affine linear above upper.
 |
 |      Return::
 |
 |          0, if x <= lower
 |          quadratic in x, if lower <= x <= upper
 |          affine linear in x with slope upper - lower, if x >= upper
 |
 |      `upper` defaults to ``lower + 1``.
 |
 |  apos(x, lower=0)
 |      clips argument (scalar or array) from below at lower
 |
 |  cauchy_with_variance_one()
 |
 |  chiN(dimension)
 |      approximation of the expectation of norm(randn(dimension)).
 |
 |      The exact value can be computed by::
 |
 |          from scipy.special import gamma
 |          return 2**0.5 * gamma((self.dimension+1) / 2) / gamma(self.dimension / 2)
 |
 |      The approximation obeys ``chin < chin_hat < (1 + 5e-5) * chin``.
 |
 |      >>> import cma.utilities.math as um
 |      ...
 |      >>> um.Mh.chiN(3) == 1.595769121605731
 |      True
 |      >>> um.Mh.chiN(100) == 9.97503163955105
 |      True
 |      >>> 31.6148721 < um.Mh.chiN(1000) < 31.6148722
 |      True
 |      >>> len(um.MathHelperFunctions._chiN_dict)  # internal checking
 |      102
 |      >>> assert all([-1 / (10*(N+1)**2) < um.Mh.chiN(N) - N**0.5 * (1 - 1. / (4 * N) + 1. / (26 * N**2))
 |      ...            < 1 / (10*(N+1)**2) for N in range(1, len(um.MathHelperFunctions._chiN_dict))])
 |
 |  equals_approximately(a, b, eps=1e-12)
 |
 |  expms(A, eig=<function eigh at 0x000002897F1FEC30>)
 |      matrix exponential for a symmetric matrix
 |
 |  huber2(x, delta, eps=0)
 |      y-shifted Huber function, return huber(x, delta) + delta/2 + eps.
 |
 |      `huber2` maps `x` to ``abs(x) + eps`` if ``abs(x) >= delta`` and
 |      otherwise to a quadratic law of `x` mapping 0 to ``delta/2 + eps``
 |      which makes the first derivative of `huber2` continuous.
 |
 |      Details: `x` may be scalar or a `numpy` array. Setting eps =
 |      -delta/2 recovers the Huber loss.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |      >>> hus = cma.utilities.math.Mh.huber2(np.asarray([
 |      ...     -1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2]), 0.5)
 |      >>> ' '.join(['{0:.2}'.format(n) for n in hus])
 |      '1.0 0.8 0.6 0.41 0.29 0.25 0.29 0.41 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0'
 |
 |  interdecilerange(data, percentile_function=<function percentile at 0x000002897F5C4330>)
 |      return 10% to 90% range width
 |
 |  iqr(data, percentile_function=<function percentile at 0x000002897F5C4330>)
 |      interquartile range
 |
 |  logit10(x, lower=0, upper=1)
 |      map [lower, upper] -> R such that
 |
 |      ::
 |
 |          upper - 10^-x  ->   x, and
 |          lower + 10^-x  ->  -x
 |
 |      for large enough x. By default, simplifies close to `log10(x / (1 - x))`.
 |
 |      >>> from cma.utilities.math import Mh
 |      >>> l, u = -1, 2
 |      >>> print(Mh.logit10([l+0.01, 0.5, u-0.01], l, u))
 |      [-1.9949189  0.         1.9949189]
 |
 |  max(vec, vec_or_scalar)
 |
 |  min(a, b)
 |
 |  minmax(val, min_val, max_val)
 |
 |  norm(vec, expo=2)
 |
 |  prctile(data, p_vals=[0, 25, 50, 75, 100], sorted_=False)
 |      ``prctile(data, 50)`` returns the median, but p_vals can
 |      also be a sequence.
 |
 |      Provides for small samples or extremes IMHO better values than
 |      matplotlib.mlab.prctile or np.percentile, however also slower.
 |
 |  sround(nb)
 |      return stochastic round: int(nb) + (rand()<remainder(nb))
 |
 |  standard_finite_cauchy(size=1)
 |
 |  vequals_approximately(a, b, eps=1e-12)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.evolution_strategy.all_stoppings
Python Library Documentation: list object

class list(object)
 |  list(iterable=(), /)
 |
 |  Built-in mutable sequence.
 |
 |  If no argument is given, the constructor creates a new empty list.
 |  The argument must be an iterable if specified.
 |
 |  Methods defined here:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __hash__ = None
cma.evolution_strategy.archive_after_sent
Python Library Documentation: NoneType object

class NoneType(object)
 |  Methods defined here:
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
cma.evolution_strategy.archive_sent_solutions
Python Library Documentation: bool object

class bool(int)
 |  bool(x) -> bool
 |
 |  Returns True when the argument x is true, False otherwise.
 |  The builtins True and False are the only two instances of the class bool.
 |  The class bool is a subclass of the class int, and cannot be subclassed.
 |
 |  Method resolution order:
 |      bool
 |      int
 |      object
 |
 |  Methods defined here:
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from int:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from int:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from int:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.array
Python Library Documentation: built-in function array in module numpy

array(...)
    array(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0,
          like=None)

    Create an array.

    Parameters
    ----------
    object : array_like
        An array, any object exposing the array interface, an object whose
        ``__array__`` method returns an array, or any (nested) sequence.
        If object is a scalar, a 0-dimensional array containing object is
        returned.
    dtype : data-type, optional
        The desired data-type for the array. If not given, NumPy will try to use
        a default ``dtype`` that can represent the values (by applying promotion
        rules when necessary.)
    copy : bool, optional
        If ``True`` (default), then the array data is copied. If ``None``,
        a copy will only be made if ``__array__`` returns a copy, if obj is
        a nested sequence, or if a copy is needed to satisfy any of the other
        requirements (``dtype``, ``order``, etc.). Note that any copy of
        the data is shallow, i.e., for arrays with object dtype, the new
        array will point to the same objects. See Examples for `ndarray.copy`.
        For ``False`` it raises a ``ValueError`` if a copy cannot be avoided.
        Default: ``True``.
    order : {'K', 'A', 'C', 'F'}, optional
        Specify the memory layout of the array. If object is not an array, the
        newly created array will be in C order (row major) unless 'F' is
        specified, in which case it will be in Fortran order (column major).
        If object is an array the following holds.

        ===== ========= ===================================================
        order  no copy                     copy=True
        ===== ========= ===================================================
        'K'   unchanged F & C order preserved, otherwise most similar order
        'A'   unchanged F order if input is F and not C, otherwise C order
        'C'   C order   C order
        'F'   F order   F order
        ===== ========= ===================================================

        When ``copy=None`` and a copy is made for other reasons, the result is
        the same as if ``copy=True``, with some exceptions for 'A', see the
        Notes section. The default order is 'K'.
    subok : bool, optional
        If True, then sub-classes will be passed-through, otherwise
        the returned array will be forced to be a base-class array (default).
    ndmin : int, optional
        Specifies the minimum number of dimensions that the resulting
        array should have.  Ones will be prepended to the shape as
        needed to meet this requirement.
    like : array_like, optional
        Reference object to allow the creation of arrays which are not
        NumPy arrays. If an array-like passed in as ``like`` supports
        the ``__array_function__`` protocol, the result will be defined
        by it. In this case, it ensures the creation of an array object
        compatible with that passed in via this argument.

        .. versionadded:: 1.20.0

    Returns
    -------
    out : ndarray
        An array object satisfying the specified requirements.

    See Also
    --------
    empty_like : Return an empty array with shape and type of input.
    ones_like : Return an array of ones with shape and type of input.
    zeros_like : Return an array of zeros with shape and type of input.
    full_like : Return a new array with shape of input filled with value.
    empty : Return a new uninitialized array.
    ones : Return a new array setting values to one.
    zeros : Return a new array setting values to zero.
    full : Return a new array of given shape filled with value.
    copy: Return an array copy of the given object.


    Notes
    -----
    When order is 'A' and ``object`` is an array in neither 'C' nor 'F' order,
    and a copy is forced by a change in dtype, then the order of the result is
    not necessarily 'C' as expected. This is likely a bug.

    Examples
    --------
    >>> import numpy as np
    >>> np.array([1, 2, 3])
    array([1, 2, 3])

    Upcasting:

    >>> np.array([1, 2, 3.0])
    array([ 1.,  2.,  3.])

    More than one dimension:

    >>> np.array([[1, 2], [3, 4]])
    array([[1, 2],
           [3, 4]])

    Minimum dimensions 2:

    >>> np.array([1, 2, 3], ndmin=2)
    array([[1, 2, 3]])

    Type provided:

    >>> np.array([1, 2, 3], dtype=complex)
    array([ 1.+0.j,  2.+0.j,  3.+0.j])

    Data-type consisting of more than one element:

    >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
    >>> x['a']
    array([1, 3])

    Creating an array from sub-classes:

    >>> np.array(np.asmatrix('1 2; 3 4'))
    array([[1, 2],
           [3, 4]])

    >>> np.array(np.asmatrix('1 2; 3 4'), subok=True)
    matrix([[1, 2],
            [3, 4]])
cma.evolution_strategy.cma_default_options
Python Library Documentation: CMAOptions in module cma.options_parameters object

class CMAOptions(builtins.dict)
 |  CMAOptions(s=None, **kwargs)
 |
 |  a dictionary with the available options and their default values
 |  for class `CMAEvolutionStrategy`.
 |
 |  ``CMAOptions()`` returns a `dict` with all available options and their
 |  default values with a comment string.
 |
 |  ``CMAOptions('verb')`` returns a subset of recognized options that
 |  contain 'verb' in there keyword name or (default) value or
 |  description.
 |
 |  ``CMAOptions(opts)`` returns the subset of recognized options in
 |  ``dict(opts)``.
 |
 |  Option values can be "written" in a string and, when passed to `fmin2`
 |  or `CMAEvolutionStrategy`, are evaluated using "N" and "popsize" as
 |  known values for dimension and population size (sample size, number
 |  of new solutions per iteration). All default option values are given
 |  as such a string.
 |
 |  Details
 |  -------
 |  `CMAOptions` entries starting with ``tol`` are termination
 |  "tolerances".
 |
 |  For `tolstagnation`, the median over the first and the second half
 |  of at least `tolstagnation` iterations are compared for both, the
 |  per-iteration best and per-iteration median function value.
 |
 |  Example
 |  -------
 |  ::
 |
 |      import cma
 |      cma.CMAOptions('tol')
 |
 |  is a shortcut for ``cma.CMAOptions().match('tol')`` that returns all
 |  options that contain 'tol' in their name or description.
 |
 |  To set an option::
 |
 |      import cma
 |      opts = cma.CMAOptions()
 |      opts.set('tolfun', 1e-12)
 |      opts['tolx'] = 1e-11
 |
 |  todo: this class is overly complex and should be re-written, possibly
 |  with reduced functionality.
 |
 |  :See also: `fmin2` (), `CMAEvolutionStrategy`, `CMAParameters`
 |
 |  Method resolution order:
 |      CMAOptions
 |      builtins.dict
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, key, default=None, loc=None)
 |      evaluate and return the value of option `key` on the fly, or
 |      return those options whose name or description contains `key`,
 |      case disregarded.
 |
 |      Details
 |      -------
 |      Keys that contain `filename` are not evaluated.
 |      For ``loc==None``, `self` is used as environment
 |      but this does not define ``N``.
 |
 |      :See: `eval()`, `evalall()`
 |
 |  __init__(self, s=None, **kwargs)
 |      return an `CMAOptions` instance.
 |
 |      Return default options if ``s is None and not kwargs``,
 |      or all options whose name or description contains `s`, if
 |      `s` is a (search) string (case is disregarded in the match),
 |      or with entries from dictionary `s` as options,
 |      or with kwargs as options if ``s is None``,
 |      in any of the latter cases not complemented with default options
 |      or settings.
 |
 |      Returns: see above.
 |
 |      Details: as several options start with ``'s'``, ``s=value`` is
 |      not valid as an option setting.
 |
 |  amend_integer_options(self, dimension, inopts)
 |      amend options when integer variables are indicated
 |
 |  amend_integer_variables(self, dimension)
 |      remove fixed variables from the integer variable index list
 |
 |      and change the index values accordingly to refer to a genotype.
 |      Create an `'_pheno_integer_variables'` entry of the same length but
 |      with the unchanged index values.
 |
 |  check(self, options=None)
 |      check for ambiguous keys and move attributes into dict
 |
 |  check_attributes(self, opts=None)
 |      check for attributes and moves them into the dictionary
 |
 |  check_values(self, options=None)
 |
 |  complement(self)
 |      add all missing options with their default values
 |
 |  corrected_key(self, key)
 |      return the matching valid key, if ``key.lower()`` is a unique
 |      starting sequence to identify the valid key, ``else None``
 |
 |  eval(self, key, default=None, loc=None, correct_key=True)
 |      Evaluates and sets the specified option value in
 |      environment `loc`. Many options need ``N`` to be defined in
 |      `loc`, some need `popsize`.
 |
 |      Details
 |      -------
 |      Keys that contain 'filename' are not evaluated.
 |      For `loc` is None, the self-dict is used as environment
 |
 |      :See: `evalall()`, `__call__`
 |
 |  evalall(self, loc=None, defaults=None)
 |      Evaluates all option values in environment `loc`.
 |
 |      :See: `eval()`
 |
 |  from_namedtuple(self, t)
 |      update options from a `collections.namedtuple`.
 |      :See also: `to_namedtuple`
 |
 |  init(self, dict_or_str, val=None, warn=True)
 |      initialize one or several options.
 |
 |      Arguments
 |      ---------
 |          `dict_or_str`
 |              a dictionary if ``val is None``, otherwise a key.
 |              If `val` is provided `dict_or_str` must be a valid key.
 |          `val`
 |              value for key
 |
 |      Details
 |      -------
 |      Only known keys are accepted. Known keys are in `CMAOptions.defaults()`
 |
 |  match(self, s='')
 |      return all options that match, in the name or the description,
 |      with string `s`, case is disregarded.
 |
 |      Example: ``cma.CMAOptions().match('verb')`` returns the verbosity
 |      options.
 |
 |  pprint(self, linebreak=80)
 |
 |  set(self, dic, val=None, force=False)
 |      assign versatile options.
 |
 |      Method `CMAOptions.versatile_options` () gives the versatile
 |      options, use `init()` to set the others.
 |
 |      Arguments
 |      ---------
 |          `dic`
 |              either a dictionary or a key. In the latter
 |              case, `val` must be provided
 |          `val`
 |              value for `key`, approximate match is sufficient
 |          `force`
 |              force setting of non-versatile options, use with caution
 |
 |      This method will be most probably used with the ``opts`` attribute of
 |      a `CMAEvolutionStrategy` instance.
 |
 |  set_integer_min_std(self, N, mueff)
 |      set lower std bounds for integer variables.
 |
 |      Uses the above defined `integer_std_lower_bound` function which can
 |      be reassigned.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  defaults()
 |      return a dictionary with default option values and description
 |
 |  versatile_options()
 |      return list of options that can be changed at any time (not
 |      only be initialized).
 |
 |      Consider that this list might not be entirely up
 |      to date.
 |
 |      The string ' #v ' in the default value indicates a versatile
 |      option that can be changed any time, however a string will not
 |      necessarily be evaluated again.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  settable
 |      return the subset of those options that are settable at any
 |      time.
 |
 |      Settable options are in `versatile_options` (), but the
 |      list might be incomplete.
 |
 |  to_namedtuple
 |      return options as const attributes of the returned object,
 |      only useful for inspection.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.dict:
 |
 |  __contains__(self, key, /)
 |      True if the dictionary has the specified key, else False.
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __ior__(self, value, /)
 |      Return self|=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the dict keys.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(...)
 |      D.__sizeof__() -> size of D in memory, in bytes
 |
 |  clear(...)
 |      D.clear() -> None.  Remove all items from D.
 |
 |  copy(...)
 |      D.copy() -> a shallow copy of D
 |
 |  get(self, key, default=None, /)
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  items(...)
 |      D.items() -> a set-like object providing a view on D's items
 |
 |  keys(...)
 |      D.keys() -> a set-like object providing a view on D's keys
 |
 |  pop(...)
 |      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
 |
 |      If the key is not found, return the default if given; otherwise,
 |      raise a KeyError.
 |
 |  popitem(self, /)
 |      Remove and return a (key, value) pair as a 2-tuple.
 |
 |      Pairs are returned in LIFO (last-in, first-out) order.
 |      Raises KeyError if the dict is empty.
 |
 |  setdefault(self, key, default=None, /)
 |      Insert key with a value of default if key is not in the dictionary.
 |
 |      Return the value for key if key is in the dictionary, else default.
 |
 |  update(...)
 |      D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
 |      If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
 |      If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
 |      In either case, this is followed by: for k in F:  D[k] = F[k]
 |
 |  values(...)
 |      D.values() -> an object providing a view on D's values
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.dict:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  fromkeys(iterable, value=None, /)
 |      Create a new dictionary with keys from iterable and values set to value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.dict:
 |
 |  __new__(*args, **kwargs) class method of builtins.dict
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.dict:
 |
 |  __hash__ = None
cma.evolution_strategy.csa_dampdown_fac
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.fmin
Python Library Documentation: function fmin in module cma.evolution_strategy

fmin(objective_function, x0, sigma0, *posargs, **kwargs)
    DEPRECATED: use `fmin2` instead.

    `fmin` will remain fully functional and be maintained in the foreseeable future.

    Return
    ======
    Return the list provided in `CMAEvolutionStrategy.result` appended
    with termination conditions, an `OOOptimizer` and a `BaseDataLogger`::

        res = es.result + (es.stop(), es, logger)

    where
        - ``res[0]`` (``xbest``) -- best evaluated solution
        - ``res[1]`` (``fbest``) -- respective function value
        - ``res[2]`` (``evals_best``) -- respective number of function evaluations
        - ``res[3]`` (``evaluations``) -- number of overall conducted objective function evaluations
        - ``res[4]`` (``iterations``) -- number of overall conducted iterations
        - ``res[5]`` (``xfavorite``) -- mean of the final sample distribution
        - ``res[6]`` (``stds``) -- effective stds of the final sample distribution
        - ``res[-3]`` (``stop``) -- termination condition(s) in a dictionary
        - ``res[-2]`` (``es``) -- class `CMAEvolutionStrategy` instance
        - ``res[-1]`` (``logger``) -- class `CMADataLogger` instance == es.logger

    The successor `fmin2` is an alias for::

        res = fmin(...)
        return res[0], res[-2]

    For descriptions of the input arguments see `fmin2`.

    For completness, recovering the output of `fmin` from `fmin2`::

        es = fmin2(...)[1]  # fmin2(...)[0] is es.result.xbest
        return es.result + (es.stop(), es, es.logger)

    The best found solution is equally available under::

        fmin(...)[0]
        fmin2(...)[0]
        fmin2(...)[1].result[0]
        fmin2(...)[1].result.xbest
        fmin2(...)[1].best.x

    The incumbent, current estimate for the optimum is available under::

        fmin(...)[5]
        fmin2(...)[1].result[5]
        fmin2(...)[1].result.xfavorite

    Examples
    ========
    The following example calls `fmin` optimizing the Rosenbrock function
    in 10-D with initial solution 0.1 and initial step-size 0.5. The
    options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'CMA_diagonal':100, 'seed':1234, 'verb_time':0}
    >>>
    >>> res = cma.fmin(cma.ff.rosen, [0.1] * 10, 0.3, options)  #doctest: +ELLIPSIS
    (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 10 (seed=1234...)
       Covariance matrix is diagonal for 100 iterations (1/ccov=26...
    Iterat #Fevals   function value  axis ratio  sigma ...
        1     10 ...
    termination on {'tolfun': 1e-11} ...
    final/bestever f-value = ...
    >>> assert res[1] < 1e-12  # f-value of best found solution
    >>> assert res[2] < 8000  # evaluations

    The above call is pretty much equivalent with the slightly more
    verbose call::

        res = cma.CMAEvolutionStrategy([0.1] * 10, 0.3,
                    options=options).optimize(cma.ff.rosen).result

    where `optimize` returns a `CMAEvolutionStrategy` instance. The
    following example calls `fmin` optimizing the Rastrigin function
    in 3-D with random initial solution in [-2,2], initial step-size 0.5
    and the BIPOP restart strategy (that progressively increases population).
    The options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'seed':12345, 'verb_time':0, 'ftarget': 1e-8}
    >>>
    >>> res = cma.fmin(cma.ff.rastrigin, lambda : 2. * np.random.rand(3) - 1, 0.5,
    ...                options, restarts=9, bipop=True)  #doctest: +ELLIPSIS
    (3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=12345...

    In either case, the method::

        cma.plot();

    (based on `matplotlib.pyplot`) produces a plot of the run and, if
    necessary::

        cma.s.figshow()

    shows the plot in a window. Finally::

        cma.s.figsave('myfirstrun')  # figsave from matplotlib.pyplot

    will save the figure in a png.

    We can use the gradient like

    >>> import cma, warnings
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter('ignore', category=cma.warnings_and_exceptions.NeverTestedWarning)
    ...     res = cma.fmin(cma.ff.rosen, np.zeros(10), 0.1,
    ...             options = {'ftarget':1e-8,},
    ...             gradf=cma.ff.grad_rosen,
    ...         )  #doctest: +ELLIPSIS
    (5_w,...
    >>> assert cma.ff.rosen(res[0]) < 1e-8
    >>> assert res[2] < 3600  # 1% are > 3300
    >>> assert res[3] < 3600  # 1% are > 3300

    If solution can only be comparatively ranked, either use
    `CMAEvolutionStrategy` directly or the objective accepts a list
    of solutions as input:

    >>> def parallel_sphere(X): return [cma.ff.sphere(x) for x in X]
    >>> x, es = cma.fmin2(None, 3 * [0], 0.1, {'verbose': -9},
    ...                   parallel_objective=parallel_sphere)
    >>> assert es.result[1] < 1e-9

    :See also: `CMAEvolutionStrategy`, `OOOptimizer.optimize`, `plot`,
        `CMAOptions`, `scipy.optimize.fmin`
cma.evolution_strategy.fmin2
Python Library Documentation: function fmin2 in module cma.evolution_strategy

fmin2(objective_function, x0, sigma0, options=None, args=(), gradf=None, restarts=0, restart_from_best=False, incpopsize=2, eval_initial_x=False, parallel_objective=None, noise_handler=None, noise_change_sigma_exponent=1, noise_kappa_exponent=0, bipop=False, callback=None, init_callback=None, constraints=None)
    functional interface to the stochastic optimizer CMA-ES
    for non-convex function minimization.

    Return the `tuple` ``(xbest, es)`` where ``es`` is a
    `CMAEvolutionStrategy` instance, see in particular ``es.result`` and
    ``es.result_pretty()`` for detailed results.


    Calling Sequences
    =================
    ``x, es = fmin2(objective_function, x0, sigma0)``
        minimizes ``objective_function`` starting at ``x0`` and with
        standard deviation ``sigma0`` (step-size)
    ``x, es = fmin2(objective_function, x0, sigma0, options={'ftarget': 1e-5})``
        minimizes ``objective_function`` up to target function value 1e-5,
        which is typically useful for benchmarking.
    ``x, es = fmin2(objective_function, x0, sigma0, args=('f',))``
        minimizes ``objective_function`` called with an additional
        argument ``'f'``.
    ``x, es = fmin2(objective_function, x0, sigma0, options={'ftarget':1e-5, 'popsize':40})``
        uses additional options ``ftarget`` and ``popsize``
    ``x, es = fmin2(objective_function, esobj, None, options={'maxfevals': 1e5})``
        uses the `CMAEvolutionStrategy` object instance ``esobj`` to
        optimize ``objective_function``, similar to ``esobj.optimize()``.

    Less recommended calling patterns are::

        es = cma.fmin2(...)[1]  # `es` contains all available information
        x = cma.fmin2(...)[0]   # keep only the best evaluated solution

    Arguments
    =========
    The order of arguments is kept for historical reasons.

    ``objective_function``
        called as ``objective_function(x, *args)`` to be minimized. ``x``
        is a one-dimensional `numpy.ndarray`. See also the
        `parallel_objective` argument. ``objective_function`` can return
        `numpy.NaN`, which is interpreted as outright rejection of solution
        ``x`` and invokes an immediate resampling and (re-)evaluation of a
        new solution not counting as function evaluation. The attribute
        ``variable_annotations`` is passed into the
        ``CMADataLogger.persistent_communication_dict``. See also
        ``constraints`` below.
    ``x0``
        list or `numpy.ndarray`, initial guess of minimum solution
        before the application of the geno-phenotype transformation
        according to the ``transformation`` option.  It can also be a
        callable that is called (without input argument) before each
        restart to yield the initial guess such that each restart may start
        from a different place. Otherwise, ``x0`` can also be a
        `cma.CMAEvolutionStrategy` object instance, in that case ``sigma0``
        can be ``None``.
    ``sigma0``
        scalar, initial standard deviation in each coordinate.
        ``sigma0`` should be about 1/4th of the search domain width
        (where the optimum is to be expected). The variables in
        ``objective_function`` should be scaled such that they
        presumably have similar sensitivity.
        See also `ScaleCoordinates`.
    ``options``
        a dictionary with additional options passed to the constructor
        of class ``CMAEvolutionStrategy``, see ``cma.CMAOptions`` ()
        for a list of available options.
    ``args=()``
        arguments to be used to call the ``objective_function``
    ``gradf=None``
        gradient of f, where ``len(gradf(x, *args)) == len(x)``.
        ``gradf`` is called once in each iteration if
        ``gradf is not None``.
    ``restarts=0``
        number of restarts with increasing population size, see also
        parameter ``incpopsize``. For the time being (this may change in
        future) ``restarts`` can also be a `dict` where the keys
        ``maxrestarts=9`` and ``maxfevals=np.inf`` are interpreted. An
        empty `dict` is interpreted as ``restarts=0``. An IPOP-CMA-ES
        restart is invoked if ``restarts > 0`` or ``restarts['maxrestarts']
        > 0`` and if ``current_evals < min((restarts['maxfevals'],
        options['maxfevals']))`` and neither the ``'ftarget'`` nor the
        ``termination_callback`` option was triggered;
        ``restarts['maxfevals']`` does not terminate *during* the run or
        restart; to restart from different points (recommended), pass
        ``x0`` as a `callable`; see also parameter ``bipop``.
    ``restart_from_best=False``
        which point to restart from
    ``incpopsize=2``
        multiplier for increasing the population size ``popsize`` before
        each restart
    ``parallel_objective``
        an objective function that accepts a list of `numpy.ndarray` as
        input and returns a `list`, which is mostly used instead of
        `objective_function`, but for the initial (also initial
        elitist) and the final evaluations unless
        ``not callable(objective_function)``. If ``parallel_objective``
        is given, the ``objective_function`` (first argument) may be
        ``None``.
    ``eval_initial_x=None``
        evaluate initial solution, for ``None`` only with elitist option
    ``noise_handler=None``
        must be `True` or a `cma.NoiseHandler` class or instance to invoke
        noise handling. The latter gives control over the specific settings
        for the noise handling, see ``help(cma.NoiseHandler)``.
    ``noise_change_sigma_exponent=1``
        exponent for the sigma increment provided by the noise handler for
        additional noise treatment. 0 means no sigma change.
    ``noise_evaluations_as_kappa=0``
        instead of applying reevaluations, the "number of evaluations"
        is (ab)used as scaling factor kappa (experimental).
    ``bipop=False``
        if ``bool(bipop) is True``, run as BIPOP-CMA-ES; BIPOP is a special
        restart strategy switching between two population sizings - small
        (relative to the large population size and with varying initial
        sigma, the first run is accounted on the "small" budget) and large
        (progressively increased as in IPOP). This makes the algorithm
        potentially solve both, functions with many regularly or
        irregularly arranged local optima (the latter by frequently
        restarting with small populations). Small populations are
        (re-)started as long as the cumulated budget_small is smaller than
        `bipop` x max(1, budget_large). For the `bipop` parameter to
        actually conduct restarts also with the larger population size,
        select a non-zero number of (IPOP) restarts; the recommended
        setting is ``restarts <= 9`` and `x0` passed as a `callable`
        that generates randomized initial solutions. Small-population
        restarts do not count into the total restart count.
    ``callback=None``
        `callable` or list of callables called at the end of each
        iteration with the current `CMAEvolutionStrategy` instance
        as argument.
    ``init_callback=None``
        `callable` or list of callables called at the end of initialization
        of the `CMAEvolutionStrategy` instance with this instance as
        argument (like `callback`). This allows to reassign attributes
        without a corresponding `CMAOption`. For example,
        ``es.integer_centering = lambda *args: None`` disables integer
        centering (which is enabled by default when ``integer_variables``
        are given in the `options`) or ``es.integer_centering =
        cma.integer_centering.IntCentering(es, correct_bias=False)``
        disables its bias correction.
    ``constraints``
        A function that takes a solution `x` as input and returns a list of
        constraint values desired to become <= 0.

    Optional Arguments
    ==================
    All values in the `options` dictionary are evaluated if they are of
    type `str`, besides `verb_filenameprefix`, see class `CMAOptions` for
    details. The full list is available by calling ``cma.CMAOptions()``.

    >>> import cma
    >>> cma.CMAOptions()  #doctest: +ELLIPSIS
    {...

    Subsets of options can be displayed, for example like
    ``cma.CMAOptions('tol')``, or ``cma.CMAOptions('bound')``,
    see also class `CMAOptions`.

    Details
    =======
    This function is an interface to the class `CMAEvolutionStrategy`. The
    latter class should be used when full control over the iteration loop
    of the optimizer is desired.

    Examples
    ========
    The following example calls `fmin2` optimizing the Rosenbrock function
    in 10-D with initial solution 0.1 and initial step-size 0.5. The
    options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'CMA_diagonal':100, 'seed':1234, 'verb_time':0}
    >>>
    >>> x, es = cma.fmin2(cma.ff.rosen, [0.1] * 10, 0.3, options)  #doctest: +ELLIPSIS
    (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 10 (seed=1234...)
       Covariance matrix is diagonal for 100 iterations (1/ccov=26...
    Iterat #Fevals   function value  axis ratio  sigma ...
        1     10 ...
    termination on {'tolfun': 1e-11} ...
    final/bestever f-value = ...
    >>> assert es.result.fbest < 1e-12  # f-value of best found solution
    >>> assert es.result.evaluations < 8000  # evaluations

    The above call is pretty much equivalent with the slightly more
    verbose call::

        es = cma.CMAEvolutionStrategy([0.1] * 10, 0.3,
                    options=options).optimize(cma.ff.rosen)
        x = es.result.xbest

    where `optimize` returns the `CMAEvolutionStrategy` instance. The
    following example calls `fmin2` optimizing the Rastrigin function
    in 3-D with random initial solution in [-2,2], initial step-size 0.5
    and the BIPOP restart strategy (that progressively increases population).
    The options are specified for the usage with the `doctest` module.

    >>> import cma
    >>> # cma.CMAOptions()  # returns all possible options
    >>> options = {'seed':12345, 'verb_time':0, 'ftarget': 1e-8}
    >>>
    >>> x, es = cma.fmin2(cma.ff.rastrigin, lambda : 2. * np.random.rand(3) - 1, 0.5,
    ...                   options, restarts=9, bipop=True)  #doctest: +ELLIPSIS
    (3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=12345...

    In either case, the method::

        cma.plot();

    (based on `matplotlib.pyplot`) produces a plot of the run and, if
    necessary::

        cma.s.figshow()

    shows the plot in a window. Finally::

        cma.s.figsave('myfirstrun')  # figsave from matplotlib.pyplot

    will save the figure in a png. The figure data can be saved like::

        es.logger.zip()

    We can use the gradient like

    >>> import cma, warnings
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter('ignore', category=cma.warnings_and_exceptions.NeverTestedWarning)
    ...     x, es = cma.fmin2(cma.ff.rosen, np.zeros(10), 0.1,
    ...             options = {'ftarget':1e-8,},
    ...             gradf=cma.ff.grad_rosen,
    ...         )  #doctest: +ELLIPSIS
    (5_w,...
    >>> assert cma.ff.rosen(es.result.xbest) < 1e-8
    >>> assert es.result.evals_best < 3600  # 1% are > 3300
    >>> assert es.result.evaluations < 3600  # 1% are > 3300

    If solutions can only be comparatively ranked, either use
    `CMAEvolutionStrategy` directly via `ask` and `tell` or a "parallel"
    objective function accepting a list of solutions as input which
    returns, for example, the solution ranks:

    >>> def parallel_sphere(X): return [cma.ff.sphere(x) for x in X]
    >>> x, es = cma.fmin2(None, 3 * [0], 0.1, {'verbose': -9},
    ...                   parallel_objective=parallel_sphere)
    >>> assert es.result.fbest < 1e-9

    :See also: `CMAEvolutionStrategy`, `OOOptimizer.optimize`, `plot`,
        `CMAOptions`, `scipy.optimize.fmin`
cma.evolution_strategy.fmin_con
Python Library Documentation: function fmin_con in module cma.evolution_strategy

fmin_con(objective_function, x0, sigma0, g=<function no_constraints at 0x000002890B3FE480>, h=<function no_constraints at 0x000002890B3FE480>, post_optimization=False, archiving=True, **kwargs)
    DEPRECATED: use `cma.ConstrainedFitnessAL` or `cma.fmin_con2` instead.

    Optimize f with constraints g (inequalities) and h (equalities).

    Construct an Augmented Lagrangian instance ``f_aug_lag`` of the type
    `cma.constraints_handler.AugmentedLagrangian` from `objective_function`
    and `g` and `h`.

    Equality constraints should preferably be passed as two inequality
    constraints like ``[h - eps, -h - eps]``, with eps >= 0. When eps > 0,
    also feasible solution tracking can succeed.

    Return a `tuple` ``es.results.xfavorite:numpy.array, es:CMAEvolutionStrategy``,
    where ``es == cma.fmin2(f_aug_lag, x0, sigma0, **kwargs)[1]``.

    Depending on ``kwargs['logging']`` and on the verbosity settings in
    ``kwargs['options']``, the `AugmentedLagrangian` writes (hidden)
    logging files.

    The second return value:`CMAEvolutionStrategy` has an (additional)
    attribute ``best_feasible`` which contains the information about the
    best feasible solution in the ``best_feasible.info`` dictionary, given
    any feasible solution was found. This only works with inequality
    constraints (equality constraints are wrongly interpreted as inequality
    constraints).

    If `post_optimization` is set to True, then the attribute ``best_feasible``
    of the second return value will be updated with the best feasible solution obtained by
    optimizing the sum of the positive constraints squared starting from
    the point ``es.results.xfavorite``. Additionally, the first return value will
    be the best feasible solution obtained in post-optimization.

    In case when equality constraints are present and a "feasible" solution is requested,
    then `post_optimization` must be a strictly positive float indicating the error
    on the inequality constraints.

    The second return value:`CMAEvolutionStrategy` has also a
    `con_archives` attribute which is nonempty if `archiving`. The last
    element of each archive is the best feasible solution if there was any.

    See `cma.fmin2` for the further parameters ``**kwargs``.

    >>> import cma
    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 3 * [0], 1, g=lambda x: [1 - x[0]**2, -(1 - x[0]**2) - 1e-6],
    ...             options={'termination_callback': lambda es: -1e-5 < sum(es.mean**2) - 1 < 1e-5,
    ...                      'verbose':-9})
    >>> assert 'callback' in es.stop()
    >>> assert es.result.evaluations < 1500  # 10%-ish above 1000, 1%-ish above 1300
    >>> assert (sum(es.mean**2) - 1)**2 < 1e-9, es.mean

    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 2 * [0], 1, g=lambda x: [1 - x[0]**2],
    ...             options={'termination_callback': lambda es: -1e-8 < sum(es.mean**2) - 1 < 1e-8,
    ...                      'seed':1, 'verbose':-9})
    >>> assert es.best_feasible.f < 1 + 1e-5, es.best_feasible.f
    >>> ".info attribute dictionary keys: {0}".format(sorted(es.best_feasible.info))
    ".info attribute dictionary keys: ['f', 'g', 'g_al', 'x']"

    Details: this is a versatile function subject to changes. It is possible to access
    the `AugmentedLagrangian` instance like

    >>> al = es.augmented_lagrangian
    >>> isinstance(al, cma.constraints_handler.AugmentedLagrangian)
    True
    >>> # al.logger.plot()  # plots the evolution of AL coefficients

    >>> x, es = cma.evolution_strategy.fmin_con(
    ...             cma.ff.sphere, 2 * [0], 1, g=lambda x: [y+1 for y in x],
    ...             post_optimization=True, options={"verbose": -9})
    >>> assert all(y <= -1 for y in x)  # assert feasibility of x
cma.evolution_strategy.fmin_con2
Python Library Documentation: function fmin_con2 in module cma.evolution_strategy

fmin_con2(objective_function, x0, sigma0, constraints=<function no_constraints at 0x000002890B3FE480>, find_feasible_first=False, find_feasible_final=False, kwargs_confit=None, **kwargs_fmin)
    optimize f with inequality constraints g.

    `constraints` is a function that returns a list of constraints values,
    where feasibility means <= 0. An equality constraint ``h(x) == 0`` can
    be expressed as two inequality constraints like ``[h(x) - eps, -h(x) -
    eps]`` with ``eps >= 0``.

    `find_feasible_...` arguments toggle to search for a feasible solution
    before and after the constrained problem is optimized. Because this can
    not work with equality constraints, where the feasible domain has zero
    volume, find-feasible arguments are `False` by default.

    `kwargs_confit` are keyword arguments to instantiate
    `constraints_handler.ConstrainedFitnessAL` which is optimized and
    returned as `objective_function` attribute in the second return
    argument (type `CMAEvolutionStrategy`).

    Other and further keyword arguments are passed (in ``**kwargs_fmin``)
    to `cma.fmin2`.

    Consider using `ConstrainedFitnessAL` directly instead of `fmin_con2`.
cma.evolution_strategy.fmin_lq_surr
Python Library Documentation: function fmin_lq_surr in module cma.evolution_strategy

fmin_lq_surr(objective_function, x0, sigma0, options=None, **kwargs)
    minimize `objective_function` with lq-CMA-ES.

    See ``help(cma.fmin)`` for the input parameter descriptions where
    `parallel_objective` is not available and noise-related options may
    fail.

    Returns the tuple ``xbest, es`` similar to `fmin2`, however `xbest`
    takes into account only some of the recent history and not all
    evaluations. `es.result` is partly based on surrogate f-values and may
    hence be confusing. In particular, `es.best` contains the solution with
    the best _surrogate_ value (which is usually of little interest). See
    `fmin_lq_surr2` for a fix.

    As in general, `es.result.xfavorite` is considered the best available
    estimate of the optimal solution.

    Example code
    ------------

    >>> import cma
    >>> x, es = cma.fmin_lq_surr(cma.ff.rosen, 2 * [0], 0.1,
    ...                          {'verbose':-9,  # verbosity for doctesting
    ...                           'ftarget':1e-2, 'seed':11})
    >>> assert 'ftarget' in es.stop(), (es.stop(), es.result_pretty())
    >>> assert es.result.evaluations < 90, es.result.evaluations  # can be 137 depending on seed

    Details
    -------
    lq-CMA-ES builds a linear or quadratic (global) model as a surrogate to
    try to circumvent evaluations of the objective function, see link below.

    This function calls `fmin2` with a surrogate as ``parallel_objective``
    argument. The model is kept the same for each restart. Use
    `fmin_lq_surr2` if this is not desirable.

    ``kwargs['callback']`` is modified by appending a callable that injects
    ``model.xopt``. This can be prevented by passing `callback=False` or
    adding `False` as an element of the callback list (see also `cma.fmin`).

    ``parallel_objective`` is assigned to a surrogate model instance of
    ``cma.fitness_models.SurrogatePopulation``.

    `es.countevals` is updated from the `evaluations` attribute of the
    constructed surrogate to count only "true" evaluations.

    See https://cma-es.github.io/lq-cma for references and details about
    the algorithm.
cma.evolution_strategy.fmin_lq_surr2
Python Library Documentation: function fmin_lq_surr2 in module cma.evolution_strategy

fmin_lq_surr2(objective_function, x0, sigma0, options=None, inject=True, restarts=0, incpopsize=2, keep_model=False, not_evaluated=<ufunc 'isnan'>, callback=None)
    minimize `objective_function` with lq-CMA-ES.

    `x0` is the initial solution or can be a callable that returns an
    initial solution (different for each restarted run). See ``cma.fmin``
    for further input documentations and ``cma.CMAOptions()`` for the
    available options.

    `inject` determines whether the best solution of the model is
    reinjected in each iteration. By default, a new surrogate model is used
    after each restart (``keep_model=False``) and the population size is
    multiplied by a factor of two (``incpopsize=2``) like in IPOP-CMA-ES
    (see also ``help(cma.fmin)``).

    Returns the tuple ``xbest, es`` like `fmin2`. As in general,
    `es.result.xfavorite` (and `es.mean` as genotype) is considered the
    best available estimate of the optimal solution.

    Example code
    ------------

    >>> import cma
    >>> x, es = cma.fmin_lq_surr2(cma.ff.rosen, 2 * [0], 0.1,
    ...                           {'verbose':-9,  # verbosity for doctesting
    ...                            'ftarget':1e-2, 'seed':3})
    >>> assert 'ftarget' in es.stop(), (es.stop(), es.result_pretty())
    >>> assert es.result.evaluations < 90, es.result.evaluations  # can be >130? depending on seed
    >>> assert es.countiter < 60, es.countiter

    Details
    -------
    lq-CMA-ES builds a linear or quadratic (global) model as a surrogate to
    circumvent evaluations of the objective function, see link below.

    This code uses the ask-and-tell interface to CMA-ES via the class
    `CMAEvolutionStrategy` to the `options` `dict` is passed.

    To pass additional arguments to the objective function use
    `functools.partial`.

    `not_evaluated` must return `True` if a value indicates (by convention
    of `cma.fitness_models.SurrogatePopulation.EvaluationManager.fvalues`)
    a missing "true" evaluation of the `objective_function`.

    See https://cma-es.github.io/lq-cma for references and details about
    the algorithm.
cma.evolution_strategy.get_CMASolutionDict
Python Library Documentation: function get_CMASolutionDict in module cma.evolution_strategy

get_CMASolutionDict(functional=True)
    return a functional or a template "empty" class.
cma.evolution_strategy.inf
Python Library Documentation: float object

class float(object)
 |  float(x=0, /)
 |
 |  Convert a string or number to a floating-point number, if possible.
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(self, /)
 |      Return the ceiling as an Integral.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(self, /)
 |      Return the floor as an Integral.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Formats the float according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(self, ndigits=None, /)
 |      Return the Integral closest to x, rounding half toward even.
 |
 |      When an argument is passed, work like built-in round(x, ndigits).
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(self, /)
 |      Return the Integral closest to x between 0 and x.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is exactly equal to the original float.
 |
 |      The ratio is in lowest terms and has a positive denominator.  Raise
 |      OverflowError on infinities and a ValueError on NaNs.
 |
 |      >>> (10.0).as_integer_ratio()
 |      (10, 1)
 |      >>> (0.0).as_integer_ratio()
 |      (0, 1)
 |      >>> (-.25).as_integer_ratio()
 |      (-1, 4)
 |
 |  conjugate(self, /)
 |      Return self, the complex conjugate of any float.
 |
 |  hex(self, /)
 |      Return a hexadecimal representation of a floating-point number.
 |
 |      >>> (-0.1).hex()
 |      '-0x1.999999999999ap-4'
 |      >>> 3.14159.hex()
 |      '0x1.921f9f01b866ep+1'
 |
 |  is_integer(self, /)
 |      Return True if the float is an integer.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __getformat__(typestr, /)
 |      You probably don't want to use this function.
 |
 |        typestr
 |          Must be 'double' or 'float'.
 |
 |      It exists mainly to be used in Python's test suite.
 |
 |      This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
 |      little-endian' best describes the format of floating-point numbers used by the
 |      C type named by typestr.
 |
 |  fromhex(string, /)
 |      Create a floating-point number from a hexadecimal string.
 |
 |      >>> float.fromhex('0x1.ffffp10')
 |      2047.984375
 |      >>> float.fromhex('-0x1p-1074')
 |      -5e-324
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.no_constraints
Python Library Documentation: function no_constraints in module cma.evolution_strategy

no_constraints(x)
cma.evolution_strategy.range
Python Library Documentation: class range in module builtins

class range(object)
 |  range(stop) -> range object
 |  range(start, stop[, step]) -> range object
 |
 |  Return an object that produces a sequence of integers from start (inclusive)
 |  to stop (exclusive) by step.  range(i, j) produces i, i+1, i+2, ..., j-1.
 |  start defaults to 0, and stop is omitted!  range(4) produces 0, 1, 2, 3.
 |  These are exactly the valid indices for a list of 4 elements.
 |  When step is given, it specifies the increment (or decrement).
 |
 |  Methods defined here:
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(...)
 |      Return a reverse iterator.
 |
 |  count(...)
 |      rangeobject.count(value) -> integer -- return number of occurrences of value
 |
 |  index(...)
 |      rangeobject.index(value) -> integer -- return index of value.
 |      Raise ValueError if the value is not present.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  start
 |
 |  step
 |
 |  stop
cma.evolution_strategy.rglen
Python Library Documentation: function rglen in module cma.utilities.utils

rglen(ar)
    return generator ``range(len(.))`` with shortcut ``rglen(.)``
cma.evolution_strategy.round_integer_variables
Python Library Documentation: bool object

class bool(int)
 |  bool(x) -> bool
 |
 |  Returns True when the argument x is true, False otherwise.
 |  The builtins True and False are the only two instances of the class bool.
 |  The class bool is a subclass of the class int, and cannot be subclassed.
 |
 |  Method resolution order:
 |      bool
 |      int
 |      object
 |
 |  Methods defined here:
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from int:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from int:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from int:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.round_integer_variables_revert_changes
Python Library Documentation: bool object

class bool(int)
 |  bool(x) -> bool
 |
 |  Returns True when the argument x is true, False otherwise.
 |  The builtins True and False are the only two instances of the class bool.
 |  The class bool is a subclass of the class int, and cannot be subclassed.
 |
 |  Method resolution order:
 |      bool
 |      int
 |      object
 |
 |  Methods defined here:
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from int:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from int:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from int:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.tell_augmented_lagrangian_logging
Python Library Documentation: NoneType object

class NoneType(object)
 |  Methods defined here:
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
cma.evolution_strategy.tell_constraints_archives
Python Library Documentation: bool object

class bool(int)
 |  bool(x) -> bool
 |
 |  Returns True when the argument x is true, False otherwise.
 |  The builtins True and False are the only two instances of the class bool.
 |  The class bool is a subclass of the class int, and cannot be subclassed.
 |
 |  Method resolution order:
 |      bool
 |      int
 |      object
 |
 |  Methods defined here:
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from int:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from int:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from int:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.tell_find_feasible_first
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.tell_find_feasible_only
Python Library Documentation: bool object

class bool(int)
 |  bool(x) -> bool
 |
 |  Returns True when the argument x is true, False otherwise.
 |  The builtins True and False are the only two instances of the class bool.
 |  The class bool is a subclass of the class int, and cannot be subclassed.
 |
 |  Method resolution order:
 |      bool
 |      int
 |      object
 |
 |  Methods defined here:
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from int:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from int:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from int:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.tell_initial_infeasibility_foffset
Python Library Documentation: float object

class float(object)
 |  float(x=0, /)
 |
 |  Convert a string or number to a floating-point number, if possible.
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(self, /)
 |      Return the ceiling as an Integral.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(self, /)
 |      Return the floor as an Integral.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Formats the float according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __round__(self, ndigits=None, /)
 |      Return the Integral closest to x, rounding half toward even.
 |
 |      When an argument is passed, work like built-in round(x, ndigits).
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(self, /)
 |      Return the Integral closest to x between 0 and x.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is exactly equal to the original float.
 |
 |      The ratio is in lowest terms and has a positive denominator.  Raise
 |      OverflowError on infinities and a ValueError on NaNs.
 |
 |      >>> (10.0).as_integer_ratio()
 |      (10, 1)
 |      >>> (0.0).as_integer_ratio()
 |      (0, 1)
 |      >>> (-.25).as_integer_ratio()
 |      (-1, 4)
 |
 |  conjugate(self, /)
 |      Return self, the complex conjugate of any float.
 |
 |  hex(self, /)
 |      Return a hexadecimal representation of a floating-point number.
 |
 |      >>> (-0.1).hex()
 |      '-0x1.999999999999ap-4'
 |      >>> 3.14159.hex()
 |      '0x1.921f9f01b866ep+1'
 |
 |  is_integer(self, /)
 |      Return True if the float is an integer.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __getformat__(typestr, /)
 |      You probably don't want to use this function.
 |
 |        typestr
 |          Must be 'double' or 'float'.
 |
 |      It exists mainly to be used in Python's test suite.
 |
 |      This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
 |      little-endian' best describes the format of floating-point numbers used by the
 |      C type named by typestr.
 |
 |  fromhex(string, /)
 |      Create a floating-point number from a hexadecimal string.
 |
 |      >>> float.fromhex('0x1.ffffp10')
 |      2047.984375
 |      >>> float.fromhex('-0x1p-1074')
 |      -5e-324
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.tpa_dampdown_fac
Python Library Documentation: int object

class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating-point
 |  numbers, this truncates towards zero.
 |
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |
 |  Built-in subclasses:
 |      bool
 |
 |  Methods defined here:
 |
 |  __abs__(self, /)
 |      abs(self)
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __and__(self, value, /)
 |      Return self&value.
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __float__(self, /)
 |      float(self)
 |
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |
 |  __format__(self, format_spec, /)
 |      Convert to a string according to format_spec.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getnewargs__(self, /)
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |
 |  __int__(self, /)
 |      int(self)
 |
 |  __invert__(self, /)
 |      ~self
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mod__(self, value, /)
 |      Return self%value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __neg__(self, /)
 |      -self
 |
 |  __or__(self, value, /)
 |      Return self|value.
 |
 |  __pos__(self, /)
 |      +self
 |
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |
 |  __radd__(self, value, /)
 |      Return value+self.
 |
 |  __rand__(self, value, /)
 |      Return value&self.
 |
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |
 |  __rmod__(self, value, /)
 |      Return value%self.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __ror__(self, value, /)
 |      Return value|self.
 |
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |
 |      Rounding with an ndigits argument also returns an integer.
 |
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |
 |  __rsub__(self, value, /)
 |      Return value-self.
 |
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |
 |  __rxor__(self, value, /)
 |      Return value^self.
 |
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |
 |  __sub__(self, value, /)
 |      Return self-value.
 |
 |  __truediv__(self, value, /)
 |      Return self/value.
 |
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |
 |  __xor__(self, value, /)
 |      Return self^value.
 |
 |  as_integer_ratio(self, /)
 |      Return a pair of integers, whose ratio is equal to the original int.
 |
 |      The ratio is in lowest terms and has a positive denominator.
 |
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |
 |  bit_count(self, /)
 |      Number of ones in the binary representation of the absolute value of self.
 |
 |      Also known as the population count.
 |
 |      >>> bin(13)
 |      '0b1101'
 |      >>> (13).bit_count()
 |      3
 |
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |
 |  is_integer(self, /)
 |      Returns True. Exists for duck type compatibility with float.is_integer.
 |
 |  to_bytes(self, /, length=1, byteorder='big', *, signed=False)
 |      Return an array of bytes representing an integer.
 |
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.  Default
 |        is length 1.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  from_bytes(bytes, byteorder='big', *, signed=False)
 |      Return the integer represented by the given array of bytes.
 |
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.  Default is to use 'big'.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  denominator
 |      the denominator of a rational number in lowest terms
 |
 |  imag
 |      the imaginary part of a complex number
 |
 |  numerator
 |      the numerator of a rational number in lowest terms
 |
 |  real
 |      the real part of a complex number
cma.evolution_strategy.use_archives
Error rendering doc: No Python documentation found for 'not anymore in effect'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
cma.fitness_transformations.BoundTransform
Python Library Documentation: class BoundTransform in module cma.boundary_handler

class BoundTransform(BoundaryHandlerBase)
 |  BoundTransform(bounds=None)
 |
 |  Handle boundaries by a smooth, piecewise linear and quadratic
 |  transformation into the feasible domain.
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> from cma.boundary_handler import BoundTransform
 |  >>> from cma import fitness_transformations as ft
 |  >>> veq = cma.utilities.math.Mh.vequals_approximately
 |  >>> b = BoundTransform([0, None])
 |  >>> assert b.bounds == [[0], None]
 |  >>> assert veq(b.repair([-0.1, 0, 1, 1.2]), np.array([0.0125, 0.0125, 1, 1.2])), b.repair([-0.1, 0, 1, 1.2])
 |  >>> assert b.is_in_bounds([0, 0.5, 1])
 |  >>> assert veq(b.transform([-1, 0, 1, 2]), [0.9, 0.0125,  1,  2  ]), b.transform([-1, 0, 1, 2])
 |  >>> bounded_sphere = ft.ComposedFunction([
 |  ...         cma.ff.sphere,
 |  ...         BoundTransform([[], 5 * [-1] + [np.inf]]).transform
 |  ...     ])
 |  >>> o1 = cma.fmin(bounded_sphere, 6 * [-2], 0.5)  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> o2 = cma.fmin(cma.ff.sphere, 6 * [-2], 0.5, options={
 |  ...    'BoundaryHandler': cma.boundary_handler.BoundTransform,
 |  ...    'bounds': [[], 5 * [-1] + [np.inf]] })  # doctest: +ELLIPSIS
 |  (4_w,9)-aCMA-ES (mu_w=2.8,w_1=49%) in dimension 6 (seed=...
 |  >>> assert o1[1] < 5 + 1e-8 and o2[1] < 5 + 1e-8
 |  >>> b = BoundTransform([-np.random.rand(120), np.random.rand(120)])
 |  >>> for i in range(0, 100, 9):
 |  ...     x = (-i-1) * np.random.rand(120) + i * np.random.randn(120)
 |  ...     x_to_b = b.repair(x)
 |  ...     x2 = b.inverse(x_to_b)
 |  ...     x2_to_b = b.repair(x2)
 |  ...     x3 = b.inverse(x2_to_b)
 |  ...     x3_to_b = b.repair(x3)
 |  ...     assert veq(x_to_b, x2_to_b)
 |  ...     assert veq(x2, x3)
 |  ...     assert veq(x2_to_b, x3_to_b)
 |  >>> for _ in range(5):
 |  ...     lb = np.random.randn(4)
 |  ...     ub = lb + 1e-7 + np.random.rand(4)
 |  ...     b = BoundTransform([lb, ub])
 |  ...     for x in [np.random.randn(4) / np.sqrt(np.random.rand(4)) for _ in range(22)]:
 |  ...         assert all(lb <= b.transform(x)), (lb, ub, b.__dict__)
 |  ...         assert all(b.transform(x) <= ub), (lb, ub, b.__dict__)
 |
 |  Details: this class uses ``class BoxConstraintsLinQuadTransformation``
 |
 |  Method resolution order:
 |      BoundTransform
 |      BoundaryHandlerBase
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, bounds=None)
 |      Argument bounds can be `None` or ``bounds[0]`` and ``bounds[1]``
 |      are lower and upper domain boundaries, each is either `None` or
 |      a scalar or a list or array of appropriate size.
 |
 |  inverse(self, x, copy_if_changed=True)
 |      inverse transform of ``x`` from the bounded domain.
 |
 |  repair(self, x, copy_if_changed=True)
 |      transforms ``x`` into the bounded domain.
 |
 |  transform(self, x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from BoundaryHandlerBase:
 |
 |  __call__(self, solutions, *args, **kwargs)
 |      return penalty or list of penalties, by default zero(s).
 |
 |      This interface seems too specifically tailored to the derived
 |      BoundPenalty class, it should maybe change.
 |
 |  amend_bounds_for_integer_variables(self, integer_indices, at=0.5, offset=1e-09)
 |      set bounds away from ``at=0.5`` such that
 |
 |      a repaired solution is always rounded into the feasible domain.
 |
 |  get_bound(self, index)
 |      return lower and upper bound of variable with index `index`
 |
 |  get_bounds(self, which, dimension)
 |      ``get_bounds('lower', 8)`` returns the lower bounds in 8-D
 |
 |  has_bounds(self, which='both')
 |      return `True` if any variable is bounded
 |
 |  idx_out_of_bounds(self, x)
 |      return index list of out-of-bound values in `x`.
 |
 |      ``if bounds.idx_out_of_bounds`` evaluates to `True` if and only if
 |      `x` is out of bounds.
 |
 |  into_bounds(self, x, copy=True)
 |      set out-of-bound values on bounds and return `x`.
 |
 |      Make a copy when `x` is changed and ``copy is True``,
 |      otherwise change in place.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[0.1], 0.2])
 |      >>> assert all(0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> assert all(0.2 >= b.into_bounds(np.random.randn(11)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], np.inf])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.1], [None]])
 |      >>> assert all(-0.1 <= b.into_bounds(np.random.randn(22)))
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[-np.inf, 0.1])
 |      >>> assert all(0.1 >= b.into_bounds(np.random.randn(22)))
 |
 |  is_in_bounds(self, x)
 |      return `True` if `x` is in bounds.
 |
 |      >>> import numpy as np
 |      >>> import cma
 |
 |      >>> b = cma.boundary_handler.BoundaryHandlerBase(bounds=[[-0.5], 0.2])
 |      >>> for n in [2, 4, 9]:
 |      ...     x = np.random.randn(n)
 |      ...     assert (all(-0.5 <= x) and all(0.2 >= x)) is b.is_in_bounds(x)
 |
 |  to_dim_times_two(self, bounds=None)
 |      return boundaries in format ``[[lb0, ub0], [lb1, ub1], ...]``,
 |      as used by ``BoxConstraints...`` class.
 |
 |      Use by default ``bounds = self.bounds``.
 |
 |  update(self, *args, **kwargs)
 |      end-iteration callback of boundary handler (abstract/empty)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from BoundaryHandlerBase:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from BoundaryHandlerBase:
 |
 |  use_cached_values = False
cma.fitness_transformations.ComposedFunction
Python Library Documentation: class ComposedFunction in module cma.fitness_transformations

class ComposedFunction(Function, builtins.list)
 |  ComposedFunction(list_of_functions, list_of_inverses=None)
 |
 |  compose an arbitrary number of functions.
 |
 |  A class instance is a list of functions. Calling the instance executes
 |  the composition of these functions (evaluating from right to left as
 |  in math notation). Functions can be added to or removed from the list
 |  at any time with the obvious effect. To remain consistent (if needed),
 |  the ``list_of_inverses`` attribute must be updated respectively.
 |
 |  >>> import numpy as np
 |  >>> from cma.fitness_transformations import ComposedFunction
 |  >>> f1, f2, f3, f4 = lambda x: 2*x, lambda x: x**2, lambda x: 3*x, lambda x: x**3
 |  >>> f = ComposedFunction([f1, f2, f3, f4])
 |  >>> assert isinstance(f, list) and isinstance(f, ComposedFunction)
 |  >>> assert f[0] == f1  # how I love Python indexing
 |  >>> assert all(f(x) == f1(f2(f3(f4(x)))) for x in np.random.rand(10))
 |  >>> assert f4 == f.pop()
 |  >>> assert len(f) == 3
 |  >>> f.insert(1, f4)
 |  >>> f.append(f4)
 |  >>> assert all(f(x) == f1(f4(f2(f3(f4(x))))) for x in range(5))
 |
 |  A more specific example:
 |
 |  >>> from cma.fitness_transformations import ComposedFunction
 |  >>> from cma.boundary_handler import BoundTransform
 |  >>> from cma import ff
 |  >>> f = ComposedFunction([ff.elli,
 |  ...                       BoundTransform([[0], [1]]).transform])
 |  >>> assert max(f([2, 3]), f([1, 1])) <= ff.elli([1, 1])
 |
 |  Details:
 |
 |  - This class can serve as basis for a more transparent
 |    alternative to a ``scaling_of_variables`` CMA option or for any
 |    necessary transformation of the fitness/objective function
 |    (genotype-phenotype transformation).
 |
 |  - The parallelizing call with a list of solutions of the `Function`
 |    class is not inherited. The inheritence from `Function` is rather
 |    declarative than funtional and could be omitted.
 |
 |  Method resolution order:
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  __init__(self, list_of_functions, list_of_inverses=None)
 |      Caveat: to remain consistent, the ``list_of_inverses`` must be
 |      updated explicitly, if the list of function was updated after
 |      initialization.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.ConstRandnShift
Python Library Documentation: class ConstRandnShift in module cma.transformations

class ConstRandnShift(builtins.object)
 |  ConstRandnShift(stddev=3, seed=1)
 |
 |  ``ConstRandnShift()(x)`` adds a fixed realization of
 |  ``stddev * randn(len(x))`` to the vector ``x``.
 |
 |  By default, the realized shift is the same for each instance of
 |  `ConstRandnShift`, see ``seed`` argument. This class is used in
 |  class `Shifted` as default transformation.
 |
 |  :See also: class `Shifted`
 |
 |  Methods defined here:
 |
 |  __call__(self, x)
 |      return "shifted" ``x - shift``
 |
 |  __init__(self, stddev=3, seed=1)
 |      with ``seed=None`` each instance realizes a different shift
 |
 |  get(self, dimension)
 |      return shift applied to ``zeros(dimension)``
 |
 |      >>> import numpy as np, cma
 |      >>> s = cma.transformations.ConstRandnShift()
 |      >>> assert all(s(-s.get(3)) == np.zeros(3))
 |      >>> assert all(s.get(3) == s(np.zeros(3)))
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.EvalParallel2
Python Library Documentation: class EvalParallel2 in module cma.optimization_tools

class EvalParallel2(builtins.object)
 |  EvalParallel2(fitness_function=None, number_of_processes=None)
 |
 |  A class and context manager for parallel evaluations.
 |
 |  This class is based on the ``Pool`` class of the `multiprocessing` module.
 |
 |  The interface in v2 changed, such that the fitness function can be
 |  given once in the constructor. Hence the number of processes has
 |  become the second (optional) argument of `__init__` and the function
 |  has become the second and optional argument of `__call__`.
 |
 |  To be used with the `with` statement (otherwise `terminate` needs to
 |  be called to free resources)::
 |
 |      with EvalParallel2(fitness_function) as eval_all:
 |          fvals = eval_all(solutions)
 |
 |  assigns a callable `EvalParallel2` class instance to ``eval_all``.
 |  The instance can be called with a `list` (or `tuple` or any
 |  sequence) of solutions and returns their fitness values. That is::
 |
 |      eval_all(solutions) == [fitness_function(x) for x in solutions]
 |
 |  `EvalParallel2.__call__` may take three additional optional arguments,
 |  namely `fitness_function` (like this the function may change from call
 |  to call), `args` passed to ``fitness`` and `timeout` passed to the
 |  `multiprocessing.pool.ApplyResult.get` method which raises
 |  `multiprocessing.TimeoutError` in case.
 |
 |  ``eval_all = EvalParallel2(fitness_function, 0)`` bypasses
 |  `multiprocessing`, hence the construct can be used even when
 |  `multiprocessing` fails on this `fitness_function` instantiation.
 |
 |  Examples:
 |
 |  >>> from cma.optimization_tools import EvalParallel2
 |  >>> for n_jobs in [None, -1, 0, 1, 2, 4]:
 |  ...     with EvalParallel2(cma.fitness_functions.elli, n_jobs) as eval_all:
 |  ...         res = eval_all([[1,2], [3,4]])
 |  >>> # class usage, don't forget to call terminate
 |  >>> ep = EvalParallel2(cma.fitness_functions.elli, 4)
 |  >>> [float(v) for v in ep([[1,2], [3,4], [4, 5]])]  # doctest:+ELLIPSIS
 |  [4000000.944...
 |  >>> ep.terminate()
 |  ...
 |  >>> # use with `with` statement (context manager)
 |  >>> es = cma.CMAEvolutionStrategy(3 * [1], 1, dict(verbose=-9))
 |  >>> with EvalParallel2(cma.fitness_functions.elli,
 |  ...                    number_of_processes=12) as eval_all:
 |  ...     while not es.stop():
 |  ...         X = es.ask()
 |  ...         es.tell(X, eval_all(X, args=(1e1,)))  # `eval_all` also accepts
 |  ...                                               # `fitness_function` as
 |  ...                                               # (optional) keyword argument
 |  >>> assert es.result[1] < 1e-13 and es.result[2] < 1500
 |
 |  Parameters: the `EvalParallel2` constructor takes the number of
 |  processes as optional input argument, which is by default
 |  ``multiprocessing.cpu_count()``. If ``number_of_processes <= 0``, no
 |  `multiprocessing` is invoked and the fitness is computed directly in a
 |  regular loop.
 |
 |  Limitations: the `multiprocessing` module, on which this class is based
 |  upon, may not work with certain class instance methods or Cython
 |  instances, or class instances that contain modules as it uses `pickle`.
 |
 |  Details: in some cases the execution may be considerably slowed down,
 |  as for example in previous tests done with test suites from coco/bbob.
 |
 |  Comparing setting ``number_of_processes = 0`` with
 |  ``number_of_processes = 1`` evaluates the overhead introduced by
 |  ``multiprocessing.Pool.apply_async``.
 |
 |  Methods defined here:
 |
 |  __call__(self, solutions, fitness_function=None, args=(), timeout=None)
 |      evaluate a list/sequence of solution-"vectors", return a list
 |      of corresponding f-values.
 |
 |      `args` must be a tuple and is passed to `fitness_function` like
 |      ``fitness_function(solutions[0], *args)``. For example, a single
 |      argument, say `a1`, should be passed like ``args=(a1, )``.
 |
 |      Raises `multiprocessing.TimeoutError` if `timeout` is given and
 |      exceeded.
 |
 |  __del__(self)
 |      though generally not recommended `__del__` should be OK here
 |
 |  __enter__(self)
 |
 |  __exit__(self, exc_type, exc_value, traceback)
 |
 |  __init__(self, fitness_function=None, number_of_processes=None)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  terminate(self)
 |      free allocated processing pool
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.Expensify
Python Library Documentation: class Expensify in module cma.fitness_transformations

class Expensify(Function)
 |  Expensify(callable_, time=1)
 |
 |  Add waiting time to each evaluation, to simulate "expensive"
 |  behavior
 |
 |  Method resolution order:
 |      Expensify
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, *args, **kwargs)
 |      Call self as a function.
 |
 |  __init__(self, callable_, time=1)
 |      add time in seconds
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.FBoundTransform
Python Library Documentation: class FBoundTransform in module cma.fitness_transformations

class FBoundTransform(ComposedFunction)
 |  FBoundTransform(fitness_function, bounds)
 |
 |  shortcut for ``ComposedFunction([f, BoundTransform(bounds).transform])``,
 |  see also below.
 |
 |  Maps the argument into bounded or half-bounded (feasible) domain
 |  before evaluating ``f``.
 |
 |  Example with lower bound at 0, which becomes the image of -0.05 in
 |  `BoundTransform.transform`:
 |
 |  >>> import cma, numpy as np
 |  >>> f = cma.fitness_transformations.FBoundTransform(cma.ff.elli,
 |  ...                                                 [[0], None])
 |  >>> assert all(f[1](np.random.randn(200)) >= 0)
 |  >>> assert all(f[1]([-0.05, -0.05]) == 0)
 |  >>> assert f([-0.05, -0.05]) == 0
 |
 |  A slightly more verbose version to implement the lower bound at zero
 |  in the very same way:
 |
 |      >>> import cma
 |      >>> felli_in_bound = cma.s.ft.ComposedFunction(
 |      ...    [cma.ff.elli, cma.BoundTransform([[0], None]).transform])
 |
 |  Method resolution order:
 |      FBoundTransform
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, fitness_function, bounds)
 |      `bounds[0]` are lower bounds, `bounds[1]` are upper bounds
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.FixVariables
Python Library Documentation: class FixVariables in module cma.fitness_transformations

class FixVariables(ComposedFunction)
 |  FixVariables(f, index_value_pairs)
 |
 |  Insert variables with given values, thereby reducing the
 |  dimensionality of the resulting composed function.
 |
 |  The constructor takes ``index_value_pairs``, a `dict` or `list` of
 |  pairs, as input and returns a function with smaller preimage space
 |  than input function ``f``.
 |
 |  Fixing variable 3 and 5 works like
 |
 |      >>> from cma.fitness_transformations import FixVariables
 |      >>> index_value_pairs = [[2, 0.2], [4, 0.4]]
 |      >>> fun = FixVariables(cma.ff.elli, index_value_pairs)
 |      >>> fun[1](4 * [1]) == [ 1.,  1.,  0.2,  1.,  0.4, 1.]
 |      True
 |
 |  Or starting from a given current solution in the larger space from
 |  which we pick the fixed values:
 |
 |      >>> from cma.fitness_transformations import FixVariables
 |      >>> current_solution = [0.1 * i for i in range(5)]
 |      >>> fixed_indices = [2, 4]
 |      >>> index_value_pairs = [[i, current_solution[i]]  # fix these
 |      ...                                     for i in fixed_indices]
 |      >>> fun = FixVariables(cma.ff.elli, index_value_pairs)
 |      >>> fun[1](4 * [1]) == [ 1.,  1.,  0.2,  1.,  0.4, 1.]
 |      True
 |      >>> assert (current_solution ==  # list with same values
 |      ...            fun.transform(fun.insert_variables(current_solution)))
 |      >>> assert (current_solution ==  # list with same values
 |      ...            fun.insert_variables(fun.transform(current_solution)))
 |
 |  Details: this might replace the ``fixed_variables`` option in
 |  `CMAOptions` in future, but hasn't been thoroughly tested yet.
 |
 |  Supersedes `ExpandSolution`.
 |
 |  Method resolution order:
 |      FixVariables
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, f, index_value_pairs)
 |      return `f` with reduced dimensionality.
 |
 |      ``index_value_pairs``:
 |          variables
 |
 |  insert_variables(self, x)
 |      return `x` with inserted fixed values
 |
 |  transform(self, x)
 |      transform `x` such that it could be used as argument to `self`.
 |
 |      Return a list or array, usually dismissing some elements of
 |      `x`. ``fun.transform`` is the inverse of
 |      ``fun.insert_variables == fun[1]``, that is
 |      ``np.all(x == fun.transform(fun.insert_variables(x))) is True``.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.Function
Python Library Documentation: class Function in module cma.fitness_transformations

class Function(builtins.object)
 |  Function(fitness_function=None)
 |
 |  a declarative base class, indicating that a derived class instance
 |  "is" a (fitness/objective) function.
 |
 |  A `callable` passed to `__init__` is called as the fitness
 |  `Function`, otherwise the `_eval` method is called, if defined in the
 |  derived class, when the `Function` instance is called. If the input
 |  argument is a matrix or a list of vectors, the method is called for
 |  each vector individually like
 |  ``_eval(numpy.asarray(vector)) for vector in matrix``.
 |
 |  >>> import cma
 |  >>> from cma.fitness_transformations import  Function
 |  >>> f = Function(cma.ff.rosen)
 |  >>> assert f.evaluations == 0
 |  >>> assert f([2, 3]) == cma.ff.rosen([2, 3])
 |  >>> assert f.evaluations == 1
 |  >>> assert f([[1], [2]]) == [cma.ff.rosen([1]), cma.ff.rosen([2])]
 |  >>> assert f.evaluations == 3
 |  >>> class Fsphere(Function):
 |  ...     def _eval(self, x):
 |  ...         return sum(x**2)
 |  >>> fsphere = Fsphere()
 |  >>> assert fsphere.evaluations == 0
 |  >>> assert fsphere([2, 3]) == 4 + 9 and fsphere([[2], [3]]) == [4, 9]
 |  >>> assert fsphere.evaluations == 3
 |  >>> Fsphere.__init__ = lambda self: None  # overwrites Function.__init__
 |  >>> assert Fsphere()([2]) == 4  # which is perfectly fine to do
 |
 |  Details:
 |
 |  - When called, a class instance calls either the function passed to
 |    `__init__` or, if none was given, tries to call any of the
 |    `function_names_to_evaluate_first_found`, first come first serve.
 |    By default, ``function_names_to_evaluate_first_found == ["_eval"]``.
 |
 |  - This class cannot move to module `fitness_functions`, because the
 |    latter uses `fitness_transformations.rotate`.
 |
 |  Methods defined here:
 |
 |  __call__(self, *args, **kwargs)
 |      Call self as a function.
 |
 |  __init__(self, fitness_function=None)
 |      allows to define the fitness_function to be called, doesn't
 |      need to be ever called
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.GlueArguments
Python Library Documentation: class GlueArguments in module cma.fitness_transformations

class GlueArguments(Function)
 |  GlueArguments(fitness_function, *args, **kwargs)
 |
 |  deprecated, use `functools.partial` or
 |  `cma.fitness_transformations.partial` instead, which has the same
 |  functionality and interface.
 |
 |  from a `callable` return a `callable` with arguments attached.
 |
 |
 |  An ellipsoid function with condition number ``1e4`` is created by
 |  ``felli1e4 = cma.s.ft.GlueArguments(cma.ff.elli, cond=1e4)``.
 |
 |  >>> import cma
 |  >>> f = cma.fitness_transformations.GlueArguments(cma.ff.elli,
 |  ...                                               cond=1e1)
 |  >>> assert f([1, 2]) == 1**2 + 1e1 * 2**2
 |
 |  Method resolution order:
 |      GlueArguments
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args, **kwargs)
 |      call function with at least one additional argument and
 |      attached args and kwargs.
 |
 |  __init__(self, fitness_function, *args, **kwargs)
 |      define function, ``args``, and ``kwargs``.
 |
 |      ``args`` are appended to arguments passed in the call, ``kwargs``
 |      are updated with keyword arguments passed in the call.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.IntegerMixedFunction
Python Library Documentation: class IntegerMixedFunction in module cma.fitness_transformations

class IntegerMixedFunction(ComposedFunction)
 |  IntegerMixedFunction(function, integer_variable_indices, operator=<ufunc 'floor'>, copy_arg=True)
 |
 |  DEPRECATED compose fitness function with some integer variables using `np.floor` by default.
 |
 |  >>> import cma
 |  >>> f = cma.s.ft.IntegerMixedFunction(cma.ff.elli, [0, 3, 6])
 |  >>> assert f([0.2, 2]) == f([0.4, 2]) != f([1.2, 2])
 |
 |  It is advisable to set minstd of integer variables to
 |  ``1 / (2 * len(integer_variable_indices) + 1)``, in which case in
 |  an independent model at least 33% (1 integer variable) -> 39% (many
 |  integer variables) of the solutions should have an integer mutation
 |  on average. Option ``integer_variables`` of `cma.CMAOptions`
 |  implements this simple measure.
 |
 |  Method resolution order:
 |      IntegerMixedFunction
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, function, integer_variable_indices, operator=<ufunc 'floor'>, copy_arg=True)
 |      apply operator(x[i]) for i in integer_variable_indices before to call function(x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.IntegerMixedFunction2
Python Library Documentation: class IntegerMixedFunction2 in module cma.fitness_transformations

class IntegerMixedFunction2(ComposedFunction)
 |  IntegerMixedFunction2(function, integer_variable_indices, operator=<function round at 0x000002897F0B28F0>, copy=True)
 |
 |  compose fitness function with some integer variables using `np.round` by default.
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> f = cma.s.ft.IntegerMixedFunction2(cma.ff.elli, [0, 3, 5])
 |  >>> assert f([-0.2, 2]) == f([0.4, 2]) != f([0.8, 2])
 |  >>> f = cma.s.ft.IntegerMixedFunction2(cma.ff.elli, [0])
 |  >>> assert f([-0.2, 2]) == f(np.array([0.4, 2])) != f(np.array([0.8, 2]))
 |
 |  Related: Option ``'integer_variables'`` of `cma.CMAOptions` sets
 |  ``'minstd'`` of integer variables, see
 |  `cma.options_parameters.integer_std_lower_bound` and rounds the better
 |  solutions, see `cma.integer_centering`.
 |
 |  Method resolution order:
 |      IntegerMixedFunction2
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, function, integer_variable_indices, operator=<function round at 0x000002897F0B28F0>, copy=True)
 |      apply operator(x[i]) for i in integer_variable_indices before to call function(x).
 |
 |      If `copy`, return a copy iff a value is changed.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.NoisyFitness
Python Library Documentation: class NoisyFitness in module cma.fitness_transformations

class NoisyFitness(Function)
 |  NoisyFitness(fitness_function, rel_noise=<function NoisyFitness.<lambda> at 0x000002890B486AC0>, abs_noise=<function NoisyFitness.<lambda> at 0x000002890B486B60>)
 |
 |  apply noise via ``f += rel_noise(dim) * f + abs_noise(dim)``
 |
 |  Method resolution order:
 |      NoisyFitness
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args)
 |      Call self as a function.
 |
 |  __init__(self, fitness_function, rel_noise=<function NoisyFitness.<lambda> at 0x000002890B486AC0>, abs_noise=<function NoisyFitness.<lambda> at 0x000002890B486B60>)
 |      attach relative and absolution noise to ``fitness_function``.
 |
 |      Relative noise is by default computed using the length of the
 |      input argument to ``fitness_function``. Both noise functions take
 |      ``dimension`` as input.
 |
 |      >>> import cma
 |      >>> from cma.fitness_transformations import NoisyFitness
 |      >>> fn = NoisyFitness(cma.ff.elli)
 |      >>> assert fn([1, 2]) != cma.ff.elli([1, 2])
 |      >>> assert fn.evaluations == 1
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.Rotated
Python Library Documentation: class Rotated in module cma.fitness_transformations

class Rotated(ComposedFunction)
 |  Rotated(f, rotate=None, seed=None)
 |
 |  return a rotated version of a function for testing purpose.
 |
 |  This class is a convenience shortcut for the litte more verbose
 |  composition of a function with a rotation:
 |
 |  >>> import cma
 |  >>> from cma import fitness_transformations as ft
 |  >>> f1 = ft.Rotated(cma.ff.elli)
 |  >>> f2 = ft.ComposedFunction([cma.ff.elli, ft.Rotation()])
 |  >>> assert f1([2]) == f2([2])  # same rotation only in 1-D
 |  >>> assert f1([1, 2]) != f2([1, 2])
 |
 |  Method resolution order:
 |      Rotated
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, f, rotate=None, seed=None)
 |      optional argument ``rotate(x)`` must return a (stable) rotation
 |      of ``x``.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.Rotation
Python Library Documentation: class Rotation in module cma.transformations

class Rotation(builtins.object)
 |  Rotation(seed=None)
 |
 |  implement an orthogonal linear transformation for each dimension.
 |
 |  By default each `Rotation` instance provides a different "random"
 |  but fixed rotation. This class is used to implement non-separable
 |  test functions, most conveniently via `Rotated`.
 |
 |  Example:
 |
 |  >>> import cma, numpy as np
 |  >>> R = cma.transformations.Rotation()
 |  >>> R2 = cma.transformations.Rotation() # another rotation
 |  >>> x = np.array((1,2,3))
 |  >>> np.round(R(R(x), inverse=1), 9).tolist()
 |  [1.0, 2.0, 3.0]
 |
 |  :See also: `Rotated`
 |
 |  Methods defined here:
 |
 |  __call__(self, x, inverse=False, **kwargs)
 |      Rotates the input array `x` with a fixed rotation matrix
 |      (``self.dicMatrices[len(x)]``)
 |
 |  __init__(self, seed=None)
 |      same ``seed`` means same rotation, by default a random but
 |      fixed once and for all rotation, different for each instance
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.ScaleCoordinates
Python Library Documentation: class ScaleCoordinates in module cma.fitness_transformations

class ScaleCoordinates(ComposedFunction)
 |  ScaleCoordinates(fitness_function, multipliers=None, zero=None, upper=None, lower=None, from_lower_upper=(0, 1))
 |
 |  compose a (fitness) function with a preceding scaling and offset.
 |
 |  Scaling interface
 |  -----------------
 |  After ``fun2 = cma.ScaleCoordinates(fun, multipliers, zero)``, we have
 |  ``fun2(x) == fun(multipliers * (x - zero))``, where the vector size of
 |  `multipliers` and `zero` is adapated to the size of `x`, in case by
 |  recycling their last entry. This awkwardly asks to pass the `zero`
 |  argument of the preimage space where it has little meaning. Hence more
 |  conveniently,
 |  ``fun2 = cma.ScaleCoordinates(fun, multipliers, lower=lower)`` gets
 |  ``fun2(x) == fun(multipliers * x + lower)``.
 |
 |  Domain interface (lower and upper variable values)
 |  --------------------------------------------------
 |  Let ``u`` and ``l`` be vectors (or a scalar) of (approximate) lower and
 |  upper variable values, respectively. After
 |  ``fun2 = cma.ScaleCoordinates(fun, upper=u, lower=l)`` we have
 |  ``fun2(x) == fun(l + (u - l) * x)``. Now, passing 0 as ``x[i]`` to
 |  ``fun2`` evaluates ``fun`` at ``l[i]`` while passing 1 evaluates
 |  ``fun`` at ``u[i]``.
 |
 |  To match the size of ``x``, the sizes of ``u`` and ``l`` are shortened
 |  or their last entry is recycled if necessary.
 |
 |  The default value for `lower` is zero in which case `upper` just
 |  becomes a scaling multiplier.
 |
 |  Bounding the search domain of ``fun2`` to ``[0, 1]`` now bounds ``fun``
 |  to the domain ``[l, u]``. The ``'bounds'`` option of `CMAOptions`
 |  allows to set these bounds.
 |
 |  More general, the affine transformation is defined such that
 |  ``x[i]==from_lower_upper[0]`` evaluates ``fun`` at ``l[i]`` and
 |  ``x[i]==from_lower_upper[1]`` evaluates ``fun`` at ``u[i]`` where
 |  ``from_lower_upper == [0, 1]`` by default.
 |
 |  Examples and Doctest
 |  --------------------
 |
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> fun = cma.ScaleCoordinates(cma.ff.sphere, upper=[30, 1])
 |  >>> bool(fun([1, 1]) == 30**2 + 1**2)
 |  True
 |  >>> fun.transform([1, 1]).tolist(), fun.transform([0.2, 0.2]).tolist()
 |  ([30.0, 1.0], [6.0, 0.2])
 |  >>> fun.inverse(fun.transform([0.1, 0.3])).tolist()
 |  [0.1, 0.3]
 |  >>> fun = cma.ScaleCoordinates(cma.ff.sphere, upper=[31, 3], lower=[1, 2])
 |  >>> bool(-1e-9 < fun([1, -1]) - (31**2 + 1**2) < 1e-9)
 |  True
 |  >>> f = cma.ScaleCoordinates(cma.ff.sphere, [100, 1])
 |  >>> assert f[0] == cma.ff.sphere  # first element of f-composition
 |  >>> assert f(range(1, 6)) == 100**2 + sum([x**2 for x in range(2, 6)])
 |  >>> assert f([2.1]) == 210**2 == f(2.1)
 |  >>> assert f(20 * [1]) == 100**2 + 19
 |  >>> assert np.all(f.inverse(f.scale_and_offset([1, 2, 3, 4])) ==
 |  ...               np.asarray([1, 2, 3, 4]))
 |  >>> f = cma.ScaleCoordinates(f, [-2, 7], [2, 3, 4]) # last is recycled
 |  >>> bool(f([5, 6]) == sum(x**2 for x in [100 * -2 * (5 - 2), 7 * (6 - 3)]))
 |  True
 |
 |  See also these [Practical Hints](https://cma-es.github.io/cmaes_sourcecode_page.html#practical)
 |  for encoding variables.
 |
 |  Method resolution order:
 |      ScaleCoordinates
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, fitness_function, multipliers=None, zero=None, upper=None, lower=None, from_lower_upper=(0, 1))
 |      :param fitness_function: a `callable` object
 |      :param multipliers: coordinate-wise multipliers.
 |      :param zero: defines a new zero in preimage space, that is,
 |          calling the `ScaleCoordinates` instance returns
 |          ``fitness_function(multipliers * (x - zero))``.
 |      :param upper: variable value to which from_lower_upper[1] maps.
 |      :param lower: variable value to which from_lower_upper[0] maps.
 |
 |      Only either `multipliers` or 'upper` can be passed. If `zero` is
 |      passed then `upper` and `lower` are ignored. The arguments
 |      ``multipliers``, ``zero``, ``upper`` and ``lower`` can be vectors
 |      or scalars, superfluous trailing elements are ignored and the last
 |      element is recycled if needed to fit the length of the later given
 |      input.
 |
 |      `from_lower_upper` is `(0, 1)` by default and defines the preimage
 |      values which are mapped to `lower` and `upper`, respectively
 |      (unless `multipliers` or `zero` are given). These two preimage
 |      values are always the same for all coordinates.
 |
 |      Details
 |      -------
 |      The `upper` and `lower` and `from_lower_upper` parameters are used
 |      to assign `multipliers` and `zero` such that the transformation is
 |      then always computed from the latter two only.
 |
 |  inverse(self, x)
 |      inverse of coordinate-wise affine transformation
 |      ``y / multipliers + zero``
 |
 |  scale_and_offset(self, x)
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.Shifted
Python Library Documentation: class Shifted in module cma.fitness_transformations

class Shifted(ComposedFunction)
 |  Shifted(f, shift=None)
 |
 |  compose a function with a shift in x-space.
 |
 |  >>> import cma
 |  >>> f = cma.s.ft.Shifted(cma.ff.elli)
 |
 |  Details: this class solely provides as default second argument to
 |  `ComposedFunction`, namely a random shift in search space.
 |  ``shift=lambda x: x`` would provide "no shift", ``None``
 |  expands to ``cma.transformations.ConstRandnShift()``.
 |
 |  Method resolution order:
 |      Shifted
 |      ComposedFunction
 |      Function
 |      builtins.list
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, f, shift=None)
 |      ``shift(x)`` must return a (stable) shift of x
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from ComposedFunction:
 |
 |  __call__(self, x, *args, **kwargs)
 |      Call self as a function.
 |
 |  inverse(self, x, *args, **kwargs)
 |      evaluate the composition of inverses on ``x``.
 |
 |      Return `None`, if no list was provided.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from ComposedFunction:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.list:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, index, /)
 |      Return self[index].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __iadd__(self, value, /)
 |      Implement self+=value.
 |
 |  __imul__(self, value, /)
 |      Implement self*=value.
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(self, /)
 |      Return a reverse iterator over the list.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |
 |  __sizeof__(self, /)
 |      Return the size of the list in memory, in bytes.
 |
 |  append(self, object, /)
 |      Append object to the end of the list.
 |
 |  clear(self, /)
 |      Remove all items from list.
 |
 |  copy(self, /)
 |      Return a shallow copy of the list.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  extend(self, iterable, /)
 |      Extend list by appending elements from the iterable.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  insert(self, index, object, /)
 |      Insert object before index.
 |
 |  pop(self, index=-1, /)
 |      Remove and return item at index (default last).
 |
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(self, value, /)
 |      Remove first occurrence of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  reverse(self, /)
 |      Reverse *IN PLACE*.
 |
 |  sort(self, /, *, key=None, reverse=False)
 |      Sort the list in ascending order and return None.
 |
 |      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
 |      order of two equal elements is maintained).
 |
 |      If a key function is given, apply it once to each list item and sort them,
 |      ascending or descending, according to their function values.
 |
 |      The reverse flag can be set to sort in descending order.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.list:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.list:
 |
 |  __new__(*args, **kwargs) class method of builtins.list
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from builtins.list:
 |
 |  __hash__ = None
cma.fitness_transformations.SomeNaNFitness
Python Library Documentation: class SomeNaNFitness in module cma.fitness_transformations

class SomeNaNFitness(Function)
 |  SomeNaNFitness(fitness_function, probability_of_nan=0.1)
 |
 |  transform ``fitness_function`` to return sometimes ``NaN``
 |
 |  Method resolution order:
 |      SomeNaNFitness
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __call__(self, x, *args)
 |      Call self as a function.
 |
 |  __init__(self, fitness_function, probability_of_nan=0.1)
 |      allows to define the fitness_function to be called, doesn't
 |      need to be ever called
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.StackFunction
Python Library Documentation: class StackFunction in module cma.fitness_transformations

class StackFunction(Function)
 |  StackFunction(f1, f2, n1)
 |
 |  a function that returns ``f1(x[:n1]) + f2(x[n1:])``.
 |
 |  >>> import functools
 |  >>> import numpy as np
 |  >>> import cma
 |  >>> def elli48(x):
 |  ...     return 1e-4 * functools.partial(cma.ff.elli, cond=1e8)(x)
 |  >>> fcigtab = cma.fitness_transformations.StackFunction(
 |  ...     elli48, cma.ff.sphere, 2)
 |  >>> x = [1, 2, 3, 4]
 |  >>> assert np.isclose(fcigtab(x), cma.ff.cigtab(np.asarray(x)))
 |
 |  Method resolution order:
 |      StackFunction
 |      Function
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, f1, f2, n1)
 |      allows to define the fitness_function to be called, doesn't
 |      need to be ever called
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from Function:
 |
 |  __call__(self, *args, **kwargs)
 |      Call self as a function.
 |
 |  initialize(self, fitness_function)
 |      initialization of `Function`
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from Function:
 |
 |  function_names_to_evaluate_first_found
 |      attributes which are searched for to be called if no function
 |      was given to `__init__`.
 |
 |      The first present match is used.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Function:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
cma.fitness_transformations.partial
Python Library Documentation: class partial in module functools

class partial(builtins.object)
 |  partial(func, *args, **keywords) - new function with partial application
 |  of the given arguments and keywords.
 |
 |  Methods defined here:
 |
 |  __call__(self, /, *args, **kwargs)
 |      Call self as a function.
 |
 |  __delattr__(self, name, /)
 |      Implement delattr(self, name).
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setattr__(self, name, value, /)
 |      Implement setattr(self, name, value).
 |
 |  __setstate__(...)
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __class_getitem__(...)
 |      See PEP 585
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |
 |  __vectorcalloffset__
 |
 |  args
 |      tuple of arguments to future partial calls
 |
 |  func
 |      function object to use in future partial calls
 |
 |  keywords
 |      dictionary of keyword arguments to future partial calls
cma.fitness_transformations.range
Python Library Documentation: class range in module builtins

class range(object)
 |  range(stop) -> range object
 |  range(start, stop[, step]) -> range object
 |
 |  Return an object that produces a sequence of integers from start (inclusive)
 |  to stop (exclusive) by step.  range(i, j) produces i, i+1, i+2, ..., j-1.
 |  start defaults to 0, and stop is omitted!  range(4) produces 0, 1, 2, 3.
 |  These are exactly the valid indices for a list of 4 elements.
 |  When step is given, it specifies the increment (or decrement).
 |
 |  Methods defined here:
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __reversed__(...)
 |      Return a reverse iterator.
 |
 |  count(...)
 |      rangeobject.count(value) -> integer -- return number of occurrences of value
 |
 |  index(...)
 |      rangeobject.index(value) -> integer -- return index of value.
 |      Raise ValueError if the value is not present.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  start
 |
 |  step
 |
 |  stop
cma.fitness_transformations.rotate
Python Library Documentation: Rotation in module cma.transformations object

class Rotation(builtins.object)
 |  Rotation(seed=None)
 |
 |  implement an orthogonal linear transformation for each dimension.
 |
 |  By default each `Rotation` instance provides a different "random"
 |  but fixed rotation. This class is used to implement non-separable
 |  test functions, most conveniently via `Rotated`.
 |
 |  Example:
 |
 |  >>> import cma, numpy as np
 |  >>> R = cma.transformations.Rotation()
 |  >>> R2 = cma.transformations.Rotation() # another rotation
 |  >>> x = np.array((1,2,3))
 |  >>> np.round(R(R(x), inverse=1), 9).tolist()
 |  [1.0, 2.0, 3.0]
 |
 |  :See also: `Rotated`
 |
 |  Methods defined here:
 |
 |  __call__(self, x, inverse=False, **kwargs)
 |      Rotates the input array `x` with a fixed rotation matrix
 |      (``self.dicMatrices[len(x)]``)
 |
 |  __init__(self, seed=None)
 |      same ``seed`` means same rotation, by default a random but
 |      fixed once and for all rotation, different for each instance
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object