This project implements an evolutionary algorithm (EA) with a (mu + lambda) strategy for optimizing a two-dimensional function. The algorithm can be used for both minimization and maximization of the objective function.
The algorithm can optimize any two-dimensional function 𝑓(𝑥,𝑦). By default, the following function is used:
f(x, y) = (9 * x * y) / exp(x ** 2 + 0.5 * x + y ** 2)
However, you can define your own function in the code file.
-
𝜇 Size of the parent population (default is 128).
-
𝜆 Size of the offspring population (default is 512).
-
𝜎 Standard deviation of the mutation (default is 0.1).
-
ITERATIONS Number of algorithm iterations (default is 200).
Selection: Tournament selection is used, where a certain number of individuals are randomly selected for a tournament, and then the best one is chosen as a parent.
Crossover: Averages-based crossover in the extended variant is applied, which combines features of two parents in proportion determined by a random value 𝑎 from the interval [0,1]
Mutation: Gaussian mutation is utilized, which introduces random changes in individual features by adding Gaussian noise.
Elimination: The best individuals from the offspring population are selected for the next iteration, while the worst ones are removed from the parent population.
WolframAlpha Results:
Based on the analysis of the plots of the function below, it can be observed that the function has two minima and two maxima.
The minima of the function are located in the second and fourth quadrants of the coordinate system. They are as follows:
- Minimum of f(x,y) ≈ -2.43687 for (x,y) ≈ (-0.84307, 0.707107)
- Minimum of f(x,y) ≈ -1.19715 for (x,y) ≈ (0.59307, -0.707107)
The maxima of the function are located in the first and third quadrants of the coordinate system. They are as follows:
- Maximum of f(x,y) ≈ 1.19715 for (x,y) ≈ (0.59307, 0.707107)
- Maximum of f(x,y) ≈ 2.43687 for (x,y) ≈ (-0.84307, -0.707107)
Find Minimum using Evolutionary-algorithm-ES-μ+λ
Find Maximum using Evolutionary-algorithm-ES-μ+λ