# Global and Local genetic algorithm (GL25)¶

class pypop7.optimizers.ga.gl25.GL25(problem, options)

Global and Local genetic algorithm (GL25).

Note

25 means that 25 percentage of function evaluations (or runtime) are first used for global search while the remaining 75 percentage are then used for local search.

Parameters:
• problem (dict) –

problem arguments with the following common settings (keys):
• ’fitness_function’ - objective function to be minimized (func),

• ’ndim_problem’ - number of dimensionality (int),

• ’upper_boundary’ - upper boundary of search range (array_like),

• ’lower_boundary’ - lower boundary of search range (array_like).

• options (dict) –

optimizer options with the following common settings (keys):
• ’max_function_evaluations’ - maximum of function evaluations (int, default: np.Inf),

• ’max_runtime’ - maximal runtime to be allowed (float, default: np.Inf),

• ’seed_rng’ - seed for random number generation needed to be explicitly set (int);

and with the following particular settings (keys):
• ’alpha’ - global step-size for crossover (float, default: 0.8),

• ’n_female_global’ - number of female at global search stage (int, default: 200),

• ’n_male_global’ - number of male at global search stage (int, default: 400),

• ’n_female_local’ - number of female at local search stage (int, default: 5),

• ’n_male_local’ - number of male at local search stage (int, default: 100),

• ’p_global’ - percentage of global search stage (float, default: 0.25),.

Examples

Use the optimizer to minimize the well-known test function Rosenbrock:

``` 1>>> import numpy
2>>> from pypop7.benchmarks.base_functions import rosenbrock  # function to be minimized
3>>> from pypop7.optimizers.ga.gl25 import GL25
4>>> problem = {'fitness_function': rosenbrock,  # define problem arguments
5...            'ndim_problem': 2,
6...            'lower_boundary': -5*numpy.ones((2,)),
7...            'upper_boundary': 5*numpy.ones((2,))}
8>>> options = {'max_function_evaluations': 5000,  # set optimizer options
9...            'seed_rng': 2022}
10>>> gl25 = GL25(problem, options)  # initialize the optimizer class
11>>> results = gl25.optimize()  # run the optimization process
12>>> # return the number of function evaluations and best-so-far fitness
13>>> print(f"GL25: {results['n_function_evaluations']}, {results['best_so_far_y']}")
14GL25: 5000, 1.0505276479694516e-05
```

For its correctness checking of coding, refer to this code-based repeatability report for more details.

alpha

global step-size for crossover.

Type:

float

n_female_global

number of female at global search stage.

Type:

int

n_female_local

number of female at local search stage.

Type:

int

n_individuals

population size.

Type:

int

n_male_global

number of male at global search stage.

Type:

int

n_male_local

number of male at local search stage.

Type:

int

p_global

percentage of global search stage.

Type:

float

References

García-Martínez, C., Lozano, M., Herrera, F., Molina, D. and Sánchez, A.M., 2008. Global and local real-coded genetic algorithms based on parent-centric crossover operators. European Journal of Operational Research, 185(3), pp.1088-1113. https://www.sciencedirect.com/science/article/abs/pii/S0377221706006308