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

Fitness function for symbolic regression (function approximation) problem

The fitness function calculates fitness value of GP and GEP chromosomes with the aim of solving symbolic regression problem. The fitness function's value is computed as: 100.0 / ( error + 1 ) where error equals to the sum of absolute differences between function values (computed using the function encoded by chromosome) and input values (function to be approximated).

Sample usage:

// constants double[] constants = new double[5] { 1, 2, 3, 5, 7 }; // function to be approximated double[,] data = new double[5, 2] { {1, 1}, {2, 3}, {3, 6}, {4, 10}, {5, 15} }; // create population Population population = new Population( 100, new GPTreeChromosome( new SimpleGeneFunction( 1 + constants.Length ) ), new SymbolicRegressionFitness( data, constants ), 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.

SymbolicRegressionFitness ( double data, double constants ) : System

Initializes a new instance of the SymbolicRegressionFitness class.

The data parameter defines the function to be approximated and represents a two dimensional array of (x, y) points.

The constants parameter is an array of constants, which can be used as additional variables for a genetic expression. The actual amount of variables for genetic expression equals to the amount of constants plus one - the x variable.

Translate ( IChromosome chromosome ) : string

Translates genotype to phenotype .

The method returns string value, which represents approximation expression written in polish postfix notation.

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

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

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

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

Initializes a new instance of the SymbolicRegressionFitness class.

The data parameter defines the function to be approximated and represents a two dimensional array of (x, y) points.

The constants parameter is an array of constants, which can be used as additional variables for a genetic expression. The actual amount of variables for genetic expression equals to the amount of constants plus one - the x variable.

public SymbolicRegressionFitness ( double data, double constants ) : System
data double Function to be approximated.
constants double Array of constants to be used as additional /// paramters for genetic expression.
Результат System

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

Translates genotype to phenotype .
The method returns string value, which represents approximation expression written in polish postfix notation.
public Translate ( IChromosome chromosome ) : string
chromosome IChromosome Chromosome, which genoteype should be /// translated to phenotype.
Результат string