Base class for two dimenstional function optimization.

Namespace:  AForge.Genetic
Assembly:  AForge.Genetic (in AForge.Genetic.dll) Version: 2.2.4.0 (2.2.4.0)

Syntax

C#
public abstract class OptimizationFunction2D : IFitnessFunction

Remarks

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(Double, Double), which represents the function to optimize.

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

The class works only with binary chromosomes (BinaryChromosome).

Sample usage:

CopyC#
// 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 Hierarchy

System..::.Object
  AForge.Genetic..::.OptimizationFunction2D

See Also