Optimization

Interface for MMLF black box optimization algorithms

MMLF optimizers must implement the following methods:
  • getActiveIndividual
  • getAllIndividuals
  • tellFitness
  • tellAllFitness
  • getBestIndividuals
class resources.optimization.optimizer.Optimizer(populationSize, evalsPerIndividual)

Interface for MMLF black box optimization algorithms

MMLF optimizers must implement the following methods:
  • getActiveIndividual(): Returns the parameter vector of the currently

    active individual

  • getAllIndividuals(): Returns all individuals of the current population

  • tellFitness(fitnessSample): Gives one fitness sample for the currently

    active individual

  • tellAllFitness(fitness, individuals): Gives fitness samples for all given

    individuals

  • getBestIndividual(): Returns the parameter vector of the best individual

    found so far

static create(optimizerSpec, sampleInstance)

Factory method that creates optimizer based on spec-dictionary.

getActiveIndividual()

Returns the parameter vector of the currently active individual

getAllIndividuals()

Returns all individuals of the current population

getBestIndividual()

Returns the parameter vector of the best individual found so far

static getOptimizerDict()

Returns dict that contains a mapping from optimizer name to optimizer class.

tellAllFitness(individuals, fitness)

Gives fitness samples for all given individuals

Gives fitness samples fitness for all given individuals. It is assumed that individuals is actually the whole population. A call of this method may trigger the creation of the next generation.

tellFitness(fitnessSample, individual=None)

Gives one fitness sample for the individual

Provides the fitness fitnessSample obtained in one evaluation of the given individual. In individual==None, then the fitnessSample is attributed to the currently active individual.

CMA-ES

The CMA-ES black-box optimization algorithm

Module that contains the covariance matrix adaptation - evolution strategy (CMA-ES) black-box optimization algorithm.

See also: Nikolaus Hansen and Andreas Ostermeier, “Completely derandomized self-adaptation in evolution strategies”, Evolutionary Computation 9 (2001): 159–195.

class resources.optimization.cmaes_optimizer.CMAESOptimizer(sampleInstance=None, evalsPerIndividual=1, initialMean=None, sigma=1.0, **kwargs)

The CMA-ES black-box optimization algorithm

Optimizer that uses CMA-ES for black-box optimization

Optional parameters:
  • sampleInstance: A method which returns a valid parameter vector. This

    method can always return the same instance. However, it is more common to provide a method that returns stochastically sampled different individuals. The returned individuals might for instance be used to generate an initial population.

CONFIG DICT
evalsPerIndividual:
 : The number of fitness values that the optimizer expects for each individual.
numParameters:: The number of parameters (dimensionality of parameter vector). If None, an initial parameter vector must be specified. Otherwise the initial parameters are drawn randomly.
initialMean:: The initial parameter vector.
sigma0:: The initial standard deviation of the search distribution.

Evolution Strategy

A black-box optimization algorithm based on evolution strategies.

class resources.optimization.evolution_strategy.ESOptimizer(sampleInstance, sigma=1.0, populationSize=5, evalsPerIndividual=1, numChildren=10, **kwargs)

A black-box optimization algorithm based on evolution strategies

This black-box optimization algorithm is based on a simple evolution strategies (ES). The mu+lambda ES maintains a set of mu potential parents and generates for each generation a set of lambda children. These children are obtained by mutating randomly sampled parents. This mutation is accomplished by adding normally distributed 0-mean random values to the individuals.

After the children have been evaluated, parents and children are merged in a set and the mu fittest individuals in this set form the new parent set. The mutation standard deviation is adjusted based on Rechenbergs 1/5 rule.

Mandatory parameters:
  • sampleInstance: A method which returns a valid parameter vector. This

    method can always return the same instance. However, it is more common to provide a method that returns stochastically sampled different individuals. The returned individuals might for instance be used to generate an initial population.

CONFIG DICT
sigma:: The initial standard deviation of the the mutation operator. sigma can be either a single value (meaning that each dimension of the parameter vector will be equally strong mutated) or a vector with the same shape as the parameter vector.
populationSize:: The number of parents that survive at the end of a generation (i.e. mu)
evalsPerIndividual:
 : The number of fitness values that the optimizer expects for each individual
numChildren:: The number of children evaluated within a generation (i.e. lambda).