This repository contains both a generic framework for implementing evolutionary algorithms (src/EvolutionaryAlgorithm) and an example of a concrete implementation of the Differential Evolution algorithm (src/DifferentialAlgorithm) with extensions supporting optimization of multi-objective minimization problems.
The tests/DifferentialEvolution.Tests/OptimizationProblems contains a small collection of benchmark problems that are used for testing the implementation but also serve as good examples of how the framework is applied on an optimization problem.
An optimization problem is specified in code by implementing a subclass of the abstract OptimizationProblem class. The subclass implements three concrete aspects of an optimization problem:
- Creation of random individuals (CreateRandomIndividual). This is only necessary to override if the range of one or more of the genes differs from the default interval ([0...1]).
- Calculation of fitness values for individuals (CalculateFitnessValues) returning a list containing one fitness value per optimization objective.
- An optional feasibility predicate (IsFeasible). If not overridden, all individuals will be considered feasible - i.e., the search space is only limited by the range of the nummeric types used in the algorithm (double).
The current implementation is based on .NET 6 (formerly known as .NET Core). The SDK is found here: https://dotnet.microsoft.com/download/dotnet/6.0.
After installing the SDK, the code is build using the .NET CLI:
dotnet build
The test optimization problems can be executed by running tests in the project:
dotnet test
Pull requests are very welcome. Some ideas could be:
- Implementing other optimization algorithms based on the generic framework described above.
- Performance optimizations
- Implementing a better scattering measure in the base algorithm class (EvolutionaryAlgorithm)
- Graphical visualization of optimization runs
- + all the things I haven't thought of :-)