WebCab Optimization for COM v2.6

Derivative Interface

This interface should be implemented by all user-defined functions that are unidimensional and have a derivative. Unidimensional functions are functions that have only one variable.

Source Code Examples

With this section we provide source code examples which illustrate explicitly how a uni-dimensional function is implemented. In particular, we provide the source code for the implementation of a polynomial.

Here we provide the definition of the object function:
f(x) = 3x^2 + 4x + 3
which is a linear function.

In order to provide an implementation for this interface you are required to provide an implementation for the following methods:

  1.  GetValueAtVector(double[])
    - Returns the value of the function f, at a given point.
  2.  GetDerivativeAt(double[])
    - Returns the value of the derivative of the function f, at a given point.

Source Code Implemention of the Function on the .NET Platform

             using System;
             using WebCab.Libraries.Math.Optimization.UniDimensional;
            
             public class PolynomialFunction : Derivative {
            
               // Returns the value of the objective function at a given point.
               //
               public double GetValueAt(double evaluationPoint) {
               	return (3*evaluationPoint*evaluationPoint + 2*evaluationPoint +3);
                }
            
                // Returns the value of the derivative of the objective function
                // evaluated at a given point.
                //
                public double GetDerivativeAt(double evaluationPoint) {
                     return (6*evaluationPoint + 4);
                }
            }
             

Source Code Implemention of the Function on the VB Platform

             Imports System
             Imports WebCab.Libraries.Math.Optimization.UniDimensional
            
             Public Class Polynomial Implements Derivative {
            
               ' Returns the value of the objective function at a given point.
               '
               Public Function GetValueAt(evaluationPoint As Double) As Double Implements Derivative.GetValueAt 
               	Return (3*evaluationPoint*evaluationPoint + 2*evaluationPoint +3)
               End Function 'GetValueAt
            
                ' Returns the value of the derivative of the objective function
                ' evaluated at a given point.
                '
                Public Function GetDerivativeAt(evaluationPoint As Double) As Double Implements Derivative.GetDrivativeAt
                     Return (6*evaluationPoint + 4)
                End Function 'GetDerivativeAt
             End Class 'Polynomial
             

Source Code Implemention of the Function on the Delphi Platform

             unit PolynomialFunction_Unit
             interface
             uses WebCab.Libraries.Math.Optimization.UniDimensional;
            
             type
            	 PolynomialFunction = class(Derivative)
               public
                 function GetValueAt(x: System.Double): System.Double;
                 function GetDerivativeAt(x: System.Double): System.Double;
               end;
            
             implementation
            
             (*
              * Returns the value of the objective function at a given point.
              *)
             function PolynomialFunction.GetValueAt(evaluationPoint: System.Double): System.Double;
             begin
             	 Result := 3*evaluationPoint*evaluationPoint + 2*evaluationPoint +3;
             end;
            
             (*
              * Returns the value of the gradient of the objective function
              * evaluated at a given point.
              *)
             function PolynomialFunction.GetDerivativeAt(evaluationPoint: System.Double): System.Double;
             begin
               Result := 6*evaluationPoint + 4;
             end;
             end.
             

For a list of all members of this type, see Derivative Members.

public interface Derivative : UniDimensionalFunction, Function

Requirements

Namespace: WebCab.COM.Math.Optimization.UniDimensional

Assembly: WebCab.COM.Optimization (in WebCab.COM.Optimization.dll)

See Also

Derivative Members | WebCab.COM.Math.Optimization.UniDimensional Namespace | UniDimensionalFunction