Bases: builtins.object
ClassicDE(fitness, n_dim, n_pop=30, limits=(1.0, 1.0), batch=False, seed=None)
Implements the classic differential evolution algorithm (DE/rand/1/bin). Holds the vector population, fitness evaluations, and the parameters.
Parameters: 


Returns a generator that can be used for writing custom stopping conditions.
Parameters:  n_it (int) – Number of iterations to perform before yielding the current solution 

Returns:  Returns a generator that yields the current best solution and its fitness value 
Return type:  generator 
Iterates through every vector in the population
Returns:  Returns a (vector, fitness) iterator 

Return type:  iterator 
Returns the index of a random vector from the k vectors with the highest fitness. If k is equal to one, then the best vector index is returned deterministically.
The sorted indexes are cached to optimize the common case where this function can be called multiple times with the same fitness array.
Parameters:  k (int) – Size of the group with the best fitness values 

Returns:  int – Index of the choosen vector 
Return type:  int 
cr: ‘double’ Crossover rate, in the [0., 1.] range
Evaluates a population, storing their fitness for later use.
Parameters: 


f: ‘double’ Differential weight, in the [0., 2.] range
Generates a new trial population by using the current vectors.
Resets the solver internal state for a new computation.
Can be called to reuse an existing solver instance.
Parameters:  new_pop (int or None) – New number of vectors in the population. If None, will use the current number of vectors. 

Runs the optimization algorithm for a number of iterations.
Parameters:  n_it (int) – Number of iterations to be performed 

Returns:  Returns a tuple with the best solution and its fitness evaluation 
Return type:  (double[n_dim], float) 
Merges the best trial vectors to the main population.
Performs one iteration of the optimization algorithm.
Bases: pyfde.classicde.ClassicDE
Implementation of the adaptative DE algorithm proposed by Zhang, J. et al, JADE: Adaptive Differential Evolution with Optional External Archive.
See pyfde.ClassicDE constructor for the constructor parameters.
Returns a generator that can be used for writing custom stopping conditions.
Parameters:  n_it (int) – Number of iterations to perform before yielding the current solution 

Returns:  Returns a generator that yields the current best solution and its fitness value 
Return type:  generator 
Iterates through every vector in the population
Returns:  Returns a (vector, fitness) iterator 

Return type:  iterator 
Returns the index of a random vector from the k vectors with the highest fitness. If k is equal to one, then the best vector index is returned deterministically.
The sorted indexes are cached to optimize the common case where this function can be called multiple times with the same fitness array.
Parameters:  k (int) – Size of the group with the best fitness values 

Returns:  int – Index of the choosen vector 
Return type:  int 
c: ‘double’
Parameter between 0 and 1 that controls the rate of the adaptation of the CR and F parameters.
cr: ‘double’ Crossover rate, in the [0., 1.] range
Evaluates a population, storing their fitness for later use.
Parameters: 


f: ‘double’ Differential weight, in the [0., 2.] range
Generates a new trial population by using the current vectors.
This method differs from the base implementation in two points:
The original JADE algorithm can also be implemented with an archive, that can enhance the performance of the algorithm in high dimentional cases. This implementations does not includes this archive.
p: ‘double’
Parameter between 0 and 1 that determined the top p of the population were the best vector will be selected to guide the optimization procedure.
Resets the solver internal state for a new computation. Can be called to reuse an existing solver instance.
Parameters:  new_pop (int or None) – New number of vectors in the population. If None, will use the current number of vectors. 

Runs the optimization algorithm for a number of iterations.
Parameters:  n_it (int) – Number of iterations to be performed 

Returns:  Returns a tuple with the best solution and its fitness evaluation 
Return type:  (double[n_dim], float) 
Merges the best trial vectors to the main population.
Performs one iteration of the optimization algorithm.
Implements some common benchmark functions.
Rastrigin function.
Parameters:  p (double[n_dim]) – Array with the coefficients 

Returns:  Function value at p 
Return type:  float 
Schewefel function
Parameters:  p (double[n_dim]) – Array with the coefficients 

Returns:  Function value at p 
Return type:  float 
Batch version of the Schewefel function.
Parameters: 

