C# Class Accord.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( );
Inheritance: IFitnessFunction
Datei anzeigen Open project: accord-net/framework

Public Methods

Method Description
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.

Method Details

Evaluate() public method

Evaluates chromosome.
The method calculates fitness value of the specified chromosome.
public Evaluate ( IChromosome chromosome ) : double
chromosome IChromosome Chromosome to evaluate.
return double

OptimizationFunction() public abstract method

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.
return double

OptimizationFunction2D() public method

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.
return System

Translate() public method

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
return double[]