Package park :: Package optim :: Module diffev :: Class DiffEvolver

Class DiffEvolver

source code


Minimize a function using differential evolution.

Constructors
------------
DiffEvolver(func, pop0, args=(), crossover_rate=0.5, scale=None,
    strategy=('rand', 2, 'bin'), eps=1e-6)
  func -- function to minimize
  pop0 -- sequence of initial vectors
  args -- additional arguments to apply to func
  crossover_rate -- crossover probability [0..1] usually 0.5 or so
  scale -- scaling factor to apply to differences [0..1] usually > 0.5
    if None, then calculated from pop0 using a heuristic
  strategy -- tuple specifying the differencing/crossover strategy
    The first element is one of 'rand', 'best', 'rand-to-best' to specify
    how to obtain an initial trial vector.
    The second element is either 1 or 2 (or only 1 for 'rand-to-best') to
    specify the number of difference vectors to add to the initial trial.
    The third element is (currently) 'bin' to specify binomial crossover.
  eps -- if the maximum and minimum function values of a given generation are
    with eps of each other, convergence has been achieved.
  prng -- a RandomState instance. By default, this is the global
    numpy.random instance.

DiffEvolver.frombounds(func, lbound, ubound, npop, crossover_rate=0.5,
    scale=None, strategy=('rand', 2, 'bin'), eps=1e-6)
  Randomly initialize the population within given rectangular bounds.
  lbound -- lower bound vector
  ubound -- upper bound vector
  npop -- size of population

Public Methods
--------------
solve(newgens=100)
  Run the minimizer for newgens more generations. Return the best parameter
  vector from the whole run.

Public Members
--------------
best_value -- lowest function value in the history
best_vector -- minimizing vector
best_val_history -- list of best_value's for each generation
best_vec_history -- list of best_vector's for each generation
population -- current population
pop_values -- respective function values for each of the current population
generations -- number of generations already computed
func, args, crossover_rate, scale, strategy, eps -- from constructor

Instance Methods
 
__init__(self, func, pop0, args=(), crossover_rate=0.5, scale=None, strategy=('rand', 2, 'bin'), eps=1e-06, prng=<module 'numpy.random' from '/Library/Frameworks/Python.framew...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
clear(self) source code
 
calculate_scale(self) source code
 
bin_crossover(self, oldgene, newgene) source code
 
select_samples(self, candidate, nsamples) source code
 
diff1(self, candidate) source code
 
diff2(self, candidate) source code
 
choose_best(self, candidate) source code
 
choose_rand(self, candidate) source code
 
choose_rand_to_best(self, candidate) source code
 
get_trial(self, candidate) source code
 
converged(self) source code
 
solve(self, newgens=100)
Run for newgens more generations.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods
 
frombounds(cls, func, lbound, ubound, npop, crossover_rate=0.5, scale=None, strategy=('rand', 2, 'bin'), eps=1e-06, prng=<module 'numpy.random' from '/Library/Frameworks/Python.framew...) source code
Properties

Inherited from object: __class__

Method Details

__init__(self, func, pop0, args=(), crossover_rate=0.5, scale=None, strategy=('rand', 2, 'bin'), eps=1e-06, prng=<module 'numpy.random' from '/Library/Frameworks/Python.framew...)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

solve(self, newgens=100)

source code 

Run for newgens more generations.

Return best parameter vector from the entire run.