CMA-ES

class glompo.optimizers.cmawrapper.CMAOptimizer(_opt_id: Optional[int] = None, _signal_pipe: Optional[multiprocessing.connection.Connection] = None, _results_queue: Optional[multiprocessing.context.BaseContext.Queue] = None, _pause_flag: Optional[multiprocessing.context.BaseContext.Event] = None, workers: int = 1, backend: str = 'threads', is_log_detailed: bool = False, sampler: str = 'full', verbose: bool = True, keep_files: bool = False, force_injects: Optional[bool] = None, injection_frequency: Optional[int] = None, **cmasettings)[source]

Bases: glompo.optimizers.baseoptimizer.BaseOptimizer

Wrapper around a CMA-ES python implementation [c]. Note that this class is also stand-alone, this means it can be used independently of the GloMPO framework. It is also built in such a way that it minimize() can be called multiple times on different functions.

Parameters:
  • _opt_id _signal_pipe _results_queue _pause_flag workers backend is_log_detailed (Inherited,) – See BaseOptimizer.
  • sampler – Allows the use of 'GaussVDSampler' and 'GaussVkDSampler' settings.
  • verbose – If True, print status messages during the optimization, else no output will be printed.
  • keep_files – If True the files produced by CMA are retained otherwise they are not produced.
  • force_injects – If True, injections of parameter vectors into the solver will be exact, guaranteeing that that solution will be in the next iteration’s population. If False, the injection will result in a direction relative nudge towards the vector. Forcing the injecting can limit global exploration but non-forced injections may have little effect.
  • injection_frequency – If None, injections are ignored by the optimizer. If an int is provided then injection are only accepted if at least injection_frequency iterations have passed since the last injection.
  • **cmasettings

    CMA-ES package-specific settings. See cma.s.pprint(cma.CMAOptions()) for a list of available options. Most useful keys are: 'timeout', 'tolstagnation', 'popsize'.

Notes

  1. Although not the default, by adjusting the injection settings above, the optimizer will inject the saved incumbent solution into the solver influencing the points sampled by the following iteration. The incumbent begins at x0 and is updated by the inject method called by the GloMPO manager.
  2. If 'popsize' is not provided during optimizer initialisation, it will be set to the number of workers if this is larger than 1, else it will be set to the default: 4 + int(3 * log(d)).
minimize(function: Callable[Sequence[float], float], x0: Sequence[float], bounds: Sequence[Tuple[float, float]], callbacks: Callable[Optional[Any]] = None, sigma0: float = 0, **kwargs) → glompo.optimizers.baseoptimizer.MinimizeResult[source]

Begin CMA-ES minimization loop.

Parameters:
  • function bounds callbacks (Inherited,) – See BaseOptimizer.minimize()
  • x0 – Initial mean of the multivariate normal distribution from which trials are drawn. Force injected into the solver to guarantee it is evaluated.
  • sigma0 – Initial standard deviation of the multivariate normal distribution from which trials are drawn. One value for all parameters which means that all parameters must be scaled accordingly. Default is zero which will not accepted by the optimizer, thus this argument must be provided.
Returns:

Location, function value and other optimization information about the lowest value found by the optimizer.

Return type:

MinimizeResult

Raises:

ValueError – If sigma0 is not changed from the default value of zero.