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
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET

공개 메소드들

메소드 설명
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[]