C# Класс AForge.Genetic.OptimizationFunction2D

Base class for two dimenstional function optimization.

The class is aimed to be used for two dimensional function optimization problems. It implements all methods of IFitnessFunction interface and requires overriding only one method - OptimizationFunction, which represents the function to optimize.

The optimization function should be greater than 0 on the specified optimization range.

The class works only with binary chromosomes (BinaryChromosome).

Sample usage:

// define optimization function public class UserFunction : OptimizationFunction2D { public UserFunction( ) : base( new Range( -4, 4 ), new Range( -4, 4 ) ) { } public override double OptimizationFunction( double x, double y ) { return ( Math.Cos( y ) * x * y ) / ( 2 - Math.Sin( x ) ); } } ... // create genetic population Population population = new Population( 40, new BinaryChromosome( 32 ), new UserFunction( ), new EliteSelection( ) ); // run one epoch of the population population.RunEpoch( );
Наследование: IFitnessFunction
Показать файл Открыть проект

Открытые методы

Метод Описание
Evaluate ( IChromosome chromosome ) : double

Evaluates chromosome.

The method calculates fitness value of the specified chromosome.

OptimizationFunction ( double x, double y ) : double

Function to optimize.

The method should be overloaded by inherited class to specify the optimization function.

OptimizationFunction2D ( Range rangeX, Range rangeY ) : System

Initializes a new instance of the OptimizationFunction2D class.

Translate ( IChromosome chromosome ) : double[]

Translates genotype to phenotype

The method returns array of two double values, which represent function's input point (X and Y) encoded by the specified chromosome.

Описание методов

Evaluate() публичный Метод

Evaluates chromosome.
The method calculates fitness value of the specified chromosome.
public Evaluate ( IChromosome chromosome ) : double
chromosome IChromosome Chromosome to evaluate.
Результат double

OptimizationFunction() публичный абстрактный Метод

Function to optimize.
The method should be overloaded by inherited class to specify the optimization function.
public abstract OptimizationFunction ( double x, double y ) : double
x double Function X input value.
y double Function Y input value.
Результат double

OptimizationFunction2D() публичный Метод

Initializes a new instance of the OptimizationFunction2D class.
public OptimizationFunction2D ( Range rangeX, Range rangeY ) : System
rangeX AForge.Range Specifies X variable's range.
rangeY AForge.Range Specifies Y variable's range.
Результат System

Translate() публичный Метод

Translates genotype to phenotype
The method returns array of two double values, which represent function's input point (X and Y) encoded by the specified chromosome.
public Translate ( IChromosome chromosome ) : double[]
chromosome IChromosome Chromosome, which genoteype should be /// translated to phenotype
Результат double[]