modea.Algorithms module

Collection of some standard algorithms and the fully customizable CMA-ES as used in ‘Evolving the Structure of Evolution Strategies’, all based on the same baseAlgorithm() function.

class modea.Algorithms.CMAESOptimizer(n, fitnessFunction, budget, mu=None, lambda_=None, elitist=False)

Bases: modea.Algorithms.EvolutionaryOptimizer

Implementation of a default (mu +/, lambda)-CMA-ES Requires the length of the vector to be optimized, a fitness function to use, and the budget

Parameters:
  • n – Dimensionality of the problem to be solved
  • fitnessFunction – Function to determine the fitness of an individual
  • budget – Number of function evaluations allowed for this algorithm
  • mu – Number of individuals that form the parents of each generation
  • lambda – Number of individuals in the offspring of each generation
  • elitist – Boolean switch on using a (mu, l) strategy rather than (mu + l). Default: False
class modea.Algorithms.CustomizedES(n, fitnessFunction, budget, mu=None, lambda_=None, opts=None, values=None)

Bases: modea.Algorithms.EvolutionaryOptimizer

This function accepts a dictionary of options ‘opts’ which selects from a large range of different functions and combinations of those. Instrumental in Evolving Evolution Strategies

Parameters:
  • n – Dimensionality of the problem to be solved
  • fitnessFunction – Function to determine the fitness of an individual
  • budget – Number of function evaluations allowed for this algorithm
  • mu – Number of individuals that form the parents of each generation
  • lambda – Number of individuals in the offspring of each generation
  • opts – Dictionary containing the options (elitist, active, threshold, etc) to be used
  • values – Dictionary containing initial values for initializing (some of) the parameters
addDefaults(opts)
bool_default_opts = ['active', 'elitist', 'mirrored', 'orthogonal', 'sequential', 'threshold', 'tpa']
calculateDependencies(opts, lambda_, mu)
string_default_opts = ['base-sampler', 'ipop', 'selection', 'weights_option']
class modea.Algorithms.EvolutionaryOptimizer(population, fitnessFunction, budget, functions, parameters, parallel=False)

Bases: object

Skeleton function for all ES algorithms Requires a population, fitness function handle, evaluation budget and the algorithm-specific functions

The algorithm-specific functions should (roughly) behave as follows: * recombine The current population (mu individuals) is passed to this function, and should return a new population (lambda individuals), generated by some form of recombination

  • mutate An individual is passed to this function and should be mutated ‘in-line’, no return is expected
  • select The original parents, new offspring and used budget are passed to this function, and should return a new population (mu individuals) after (mu+lambda) or (mu,lambda) selection
  • mutateParameters Mutates and/or updates all parameters where required
Parameters:
  • population – Initial set of individuals that form the starting population of the algorithm
  • fitnessFunction – Function to determine the fitness of an individual
  • budget – Number of function evaluations allowed for this algorithm
  • functions – Dictionary with functions ‘recombine’, ‘mutate’, ‘select’ and ‘mutateParameters’
  • parameters – Parameters object for storing relevant settings
  • parallel – Set to True to enable parallel evaluation. Note: this disables sequential evaluation
Returns:

The statistics generated by running the algorithm

determineRegime()
evalPopulation()
evalPopulationSequentially()
initializePopulation()
instantiateParameters(params)
recordStatistics()
runLocalRestartOptimizer(target=None, threshold=None)

Run the baseAlgorithm with the given specifications using a local-restart strategy.

runOneGeneration()
runOptimizer(target=None, threshold=1e-08)
tpaUpdate()
class modea.Algorithms.GAOptimizer(n, fitnessFunction, budget, mu, lambda_, population, parameters=None)

Bases: modea.Algorithms.EvolutionaryOptimizer

Defines a Genetic Algorithm (GA) that evolves an Evolution Strategy (ES) for a given fitness function

Parameters:
  • n – Dimensionality of the search-space for the GA
  • fitnessFunction – Fitness function the GA should use to evaluate candidate solutions
  • budget – The budget for the GA
  • mu – Population size of the GA
  • lambda – Offpsring size of the GA
  • population – Initial population of candidates to be used by the MIES
  • parameters – Parameters object to be used by the GA
class modea.Algorithms.MIESOptimizer(n, mu, lambda_, population, fitnessFunction, budget, parameters=None)

Bases: modea.Algorithms.EvolutionaryOptimizer

Defines a Mixed-Integer Evolution Strategy (MIES) that evolves an Evolution Strategy (ES) for a given fitness function

Parameters:
  • n – Dimensionality of the search-space for the MIES
  • fitnessFunction – Fitness function the MIES should use to evaluate candidate solutions
  • budget – The budget for the MIES
  • mu – Population size of the MIES
  • lambda – Offpsring size of the MIES
  • population – Initial population of candidates to be used by the MIES
  • parameters – Parameters object to be used by the MIES
class modea.Algorithms.OnePlusOneOptimizer(n, fitnessFunction, budget)

Bases: modea.Algorithms.EvolutionaryOptimizer

Implementation of the default (1+1)-ES Requires the length of the vector to be optimized, the handle of a fitness function to use and the budget

Parameters:
  • n – Dimensionality of the problem to be solved
  • fitnessFunction – Function to determine the fitness of an individual
  • budget – Number of function evaluations allowed for this algorithm