ICallbackNLOptimization.GetConstraintPartialDeriv

Syntax

GetConstraintPartialDeriv(IndxCnstr: Integer; IndxVrb: Integer): Variant;

Parameters

IndxCnstr. Constraint index.

IndxVrb. Variable index.

Description

The GetConstraintPartialDeriv method calculates and returns value of the partial derivative for j-th variable from i-th constraint to optimization method.

Comments

To get criterion function value, use the ICallbackNLOptimization.GetObjFunValue method.

Example for the CallBackNLO Class

The example describes the custom class used to calculate values of variables, criterion function and non-linear constraints. The use of this class for handling events is given in the example for ISmNonLinearOptimization.Callback.

To execute the example, add a link to the Stat system assembly.

Public Class CallBackNLO : Object, ICallbackNLOptimization
            U: array[10Of double;
            res: double;
    Public  CallCount: integer;
    Public  log: boolean;
            options: array[16Of Double;
    Public  MAXCOUNT: integer;
            i: integer;

    Public Constructor Create;
    Begin
    End Constructor Create;

    Public Sub SetArgValues(indx: Integer; Value: Double);
    Begin
        U[indx] := Value;
    End Sub SetArgValues;

    Public Function GetObjFunValue: Variant;
    Begin
        res := U[0]*U[3]*(U[0]+U[1]+U[2])+U[2];
        CallCount := CallCount + 1;
        If MAXCOUNT < CAllCount Then
            Options[0] := 1;
        End If;
        Return res;
    End Function GetObjFunValue;

    Public Function GetObjFunPartialDeriv(indx: Integer) : Variant;
    Begin
        Return 1;
    End Function GetObjFunPartialDeriv;

    Public Function GetConstraintValue(indx: Integer) : Variant;
    Begin
        Select Case indx
            Case 0: res := U[0]*U[0] + U[1]*U[1] + U[2]*U[2] + U[3]*U[3];
            Case 1: res := U[0]*U[1]*U[2]*U[3];
        End Select;
        Return res;
    End Function GetConstraintValue;

    Public Function GetConstraintPartialDeriv(indxCnstr: Integer; indxVrb: Integer) : Variant;
    Begin
        res:=Double.Nan;
        Return res;
    End Function GetConstraintPartialDeriv;

    Public Sub set_Options(Val: Array Of Double);
    Begin
        val := Options;
    End Sub set_Options;

    Public Function get_Options: Array Of Double;
    Begin
        Return Options;
    End Function get_Options;
End Class CallBackNLO;

Example for the CallBackBCO Class

The example describes the custom class used to calculate values of variables, criterion function and non-linear constraints. The use of this class for handling events is given in the example for ISmBoxConstrainedOptimization.Callback.

To execute the example, add a link to the Stat system assembly.

Public Class CallBackBCO : Object, ICallbackNLOptimization
            U: Array[3Of Double;
            res: Double;
    Public  CallCount: Integer;
    Public  log: Boolean;
            options: Array[16Of Double;
    Public  MAXCOUNT: Integer;
            i: Integer;

    Public Sub SetArgValues(indx: Integer; Value: Double);
    Begin
        U[indx] := Value;
    End Sub SetArgValues;

    Public Function GetObjFunValue: Variant;
    Begin
        res := U[0]-4*U[1]+2*U[2];
        CallCount := CallCount + 1;
        If MAXCOUNT < CAllCount Then
            options[0] := 1;
        End If;
        Return res;
    End Function GetObjFunValue;

    Public Function GetObjFunPartialDeriv(indx: Integer) : Variant;
    Begin
        Return 0;
    End Function GetObjFunPartialDeriv;

    Public Function GetConstraintValue(indx: Integer) : Variant;
    Begin
        Return 0;
    End Function GetConstraintValue;

    Public Function GetConstraintPartialDeriv(indxCnstr: Integer; indxVrb: Integer) : Variant;
    Begin
        Return 0;
    End Function GetConstraintPartialDeriv;

    Public Sub set_Options(Val: Array Of Double);
    Begin
        val := Options;
    End Sub set_Options;

    Public Function get_Options: Array Of Double;
    Begin
        Return Options;
    End Function get_Options;
End Class CallBackBCO;

See also:

ICallbackNLOptimization