Skip to content

Implementation of the evolutionary algorithm ES (μ+λ) for finding the minimum/maximum of a function

Notifications You must be signed in to change notification settings

mik00laj/Evolutionary-algorithm-ES-mu-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Evolutionary-algorithm-ES-μ+λ

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.

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)

image

However, you can define your own function in the code file.

Algorithm Parameters

  • 𝜇 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).

    Evolutionary Strategy

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.

Example Results

WolframAlpha Results:

image

image

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:

  1. Minimum of f(x,y) ≈ -2.43687 for (x,y) ≈ (-0.84307, 0.707107)
  2. 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:

  1. Maximum of f(x,y) ≈ 1.19715 for (x,y) ≈ (0.59307, 0.707107)
  2. Maximum of f(x,y) ≈ 2.43687 for (x,y) ≈ (-0.84307, -0.707107)

Find Minimum using Evolutionary-algorithm-ES-μ+λ

image image image image

Find Maximum using Evolutionary-algorithm-ES-μ+λ

image image image image

About

Implementation of the evolutionary algorithm ES (μ+λ) for finding the minimum/maximum of a function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages