gaft.engine¶
Genetic Algorithm engine definition
-
class
gaft.engine.
GAEngine
(population, selection, crossover, mutation, fitness=None, analysis=None)¶ Bases:
object
Class for representing a Genetic Algorithm engine. The class is the central object in GAFT framework for running a genetic algorithm optimization. Once the population with individuals, a set of genetic operators and fitness function are setup, the engine object unites these informations and provide means for running a genetic algorthm optimization.
Parameters: - population (
gaft.components.Population
) – The Population to be reproduced in evolution iteration. - selection (
gaft.plugin_interfaces.operators.Selection
) – The Selection to be used for individual seleciton. - crossover (
gaft.plugin_interfaces.operators.Crossover
) – The Crossover to be used for individual crossover. - mutation (
gaft.plugin_interfaces.operators.Mutation
) – The Mutation to be used for individual mutation. - fitness (function) – The fitness calculation function for an individual in population.
- analysis (
OnTheFlyAnalysis
list) – All analysis class for on-the-fly analysis.
-
analysis_register
(analysis_cls)¶ A decorator for analysis regsiter.
Parameters: analysis_cls ( gaft.plugin_interfaces.OnTheFlyAnalysis
) – The analysis to be registered
-
dynamic_linear_scaling
(target='max', ksi0=2, r=0.9)¶ A decorator constructor for fitness dynamic linear scaling.
Parameters: - target (str) – The optimization target, maximization or minimization possible value: ‘min’ or ‘max’
- ksi0 (float) – Initial selective pressure adjustment value, default value is 2
- r (float in range [0.9, 0.999]) – The reduction factor for selective pressure adjustment value, ksi^(k-1)*r is the adjustment value for generation k, default value is 0.9
Note
Dynamic Linear Scaling:
For maximizaiton, \(f' = f(x) - \min f(x) + {\xi}^{k}\), \(k\) is generation number.
-
fitness_register
(fn)¶ A decorator for fitness function register.
Parameters: fn (function) – Fitness function to be registered
-
linear_scaling
(target='max', ksi=0.5)¶ A decorator constructor for fitness function linear scaling.
Parameters: Note
- Linear Scaling:
- \(arg \max f(x)\), then the scaled fitness would be \(f - \min f(x) + {\xi}\)
- \(arg \min f(x)\), then the scaled fitness would be \(\max f(x) - f(x) + {\xi}\)
-
minimize
(fn)¶ A decorator for minimizing the fitness function.
Parameters: fn (function) – Original fitness function
- population (
-
gaft.engine.
do_profile
(filename, sortby='tottime')¶ Constructor for function profiling decorator.