Dew MtxVec NET
TMtxOptimization.RealFunction Property
Summary
Defines the function to be minimized.

Class
TMtxOptimization

Declaration
Property RealFunction: TRealFunction read FRealFunction write SetRealFunction;
Description
Defines the function to be minimized. The RealFunction must be of the TRealFunction type. Before you write actual function, set the Parameters, Constants and PConstants array size by using the:

 See Also 
GradProcedure 
GradHessProcedure 
VariableParameters 
ConstantParameters 
SetPointers 

Example 1

Define a function of two variables and one additional constant parameter.

1) Set the VariableParameters, ConstantParameters size and (optionally) initial value:

MtxOptimization.VariableParameters.SetIt(false,[1,1]); MtxOptimization.ConstantParameters.SetIt(false,[2.5]);
MtxOptimization->VariableParameters->SetIt(false,OPENARRAY(TSample,(1,1))); MtxOptimization->ConstantParameters->SetIt(false,OPENARRAY(TSample,(2.5)));

Note that all values are real.

2) Define the actual function:

function TestFunction(Pars:TVec; const Consts: Array of TSample;const ObjConsts: Array of TObject): TSample; begin Result := 2*Pars[0]+Sqrt(Pars[1]-Consts[0]); end;
double __fastcall BTestFunction(TVec * Parameters, const double * Constants, const int Constants_Size, System::TObject* const * ObjConst, const int ObjConst_Size) { double* Pars = Parameters->PValues1D(0); return 2*Pars[0] + Sqrt(Pars[1]-Consts[0]); }

Here Pars = VariableParameters.Values and Consts = ConstantParameters.Values.

3) "Connect" the function with TMtxOptimization component:

MtxOptimization.RealFunction := TestFunction;
MtxOptimization->RealFunction = TestFunction;

NOTE: Internal algorithm does not check if Parameters, Constants, PConstants array size is the same as VariableParameters.Values, ConstantParameters.Values and SetPointers array size.


Copyright 2008 Dew Research
http://www.dewresearch.com