Class
TMtxOptimization
| See Also |
|---|
| GradProcedure |
| GradHessProcedure |
| VariableParameters |
| ConstantParameters |
| SetPointers |
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 |