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.
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
|
|
__init__(self,
func,
pop0,
args=(),
crossover_rate=0.5,
scale=None,
strategy=('rand', 2, 'bin'),
eps=1e-006) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frombounds(cls,
func,
lbound,
ubound,
npop,
crossover_rate=0.5,
scale=None,
strategy=('rand', 2, 'bin'),
eps=1e-006) |
source code
|
|
Refine the current trial (e.g. constrain it)
- Parameters:
trial (array) - a trial whose content is to be refined
|
|
Run for newgens more generations.
Return best parameter vector from the entire run.
|