Name

optim_ga — A flexible genetic algorithm

Calling Sequence

[pop_opt,fobj_pop_opt,pop_init,fobj_pop_init] = optim_ga(ga_f,pop_size,nb_generation,p_mut,p_cross,Log,param)

Parameters

ga_f

the function to be optimized. The prototype if y = f(x) or y = list(f,p1,p2,...).

pop_size

the size of the population of individuals (default value: 100).

nb_generation

the number of generations (equivalent to the number of iterations in classical optimization) to be computed (default value: 10).

p_mut

the mutation probability (default value: 0.1).

p_cross

the crossover probability (default value: 0.7).

Log

if %T, we will display to information message during the run of the genetic algorithm.

param

a list of parameters.

  • 'codage_func': the function which will perform the coding and decoding of individuals (default function: codage_identity).

  • 'init_func': the function which will perform the initialization of the population (default function: init_ga_default).

  • 'crossover_func': the function which will perform the crossover between two individuals (default function: crossover_ga_default).

  • 'mutation_func': the function which will perform the mutation of one individual (default function: mutation_ga_default).

  • 'selection_func': the function whcih will perform the selection of individuals at the end of a generation (default function: selection_ga_elitist).

  • 'nb_couples': the number of couples which will be selected so as to perform the crossover and mutation (default value: 100).

  • 'pressure': the value the efficiency of the worst individual (default value: 0.05).

pop_opt

the population of optimal individuals.

fobj_pop_opt

the set of objective function values associated to pop_opt (optional).

pop_init

the initial population of individuals (optional).

fobj_pop_init

the set of objective function values associated to pop_init (optional).

Description

  • This function implements the classical genetic algorithm.

Examples

 
deff('y=f(x)','y = sum(x.^2)');

PopSize     = 100;
Proba_cross = 0.7;
Proba_mut   = 0.1;
NbGen       = 10;
NbCouples   = 110;
Log         = %T;
nb_disp     = 10; // Nb point to display from the optimal population
pressure    = 0.05;

ga_params = init_param();
// Parameters to adapt to the shape of the optimization problem
ga_params = add_param(ga_params,'minbound',[-2; -2]);
ga_params = add_param(ga_params,'maxbound',[2; 2]);
ga_params = add_param(ga_params,'dimension',2);
ga_params = add_param(ga_params,'beta',0);
ga_params = add_param(ga_params,'delta',0.1);
// Parameters to fine tune the Genetic algorithm. All these parameters are optional for continuous optimization
// If you need to adapt the GA to a special problem, you 
ga_params = add_param(ga_params,'init_func',init_ga_default);
ga_params = add_param(ga_params,'crossover_func',crossover_ga_default);
ga_params = add_param(ga_params,'mutation_func',mutation_ga_default);
ga_params = add_param(ga_params,'codage_func',codage_ga_identity);
ga_params = add_param(ga_params,'selection_func',selection_ga_elitist);
//ga_params = add_param(ga_params,'selection_func',selection_ga_random);
ga_params = add_param(ga_params,'nb_couples',NbCouples);
ga_params = add_param(ga_params,'pressure',pressure);

Min = get_param(ga_params,'minbound');
Max = get_param(ga_params,'maxbound');
x0  = (Max - Min) .* rand(size(Min,1),size(Min,2)) + Min;

[pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
 
  

See Also

optim_moga , optim_nsga , optim_nsga2

References

Michalewicz, Zbigniew Genetic Algorithms + Data Structures = Evolution Programs

Authors

Yann COLLETTE

ycollet@freesurf.fr