property RealFunction: TRealFunction;
Defines the function to be minimized.
Returns: TRealFunction
Remarks:
Defines the function to be minimized. The TMtxOptimization.RealFunction must be of the TRealFunction type. Before you write actual function, set the Parameters, Constants and PConstants array size by using the:
- TMtxOptimization.VariableParameters vector Length, Size or SetIt method,
- TMtxOptimization.ConstantParameters vector Length, Size or SetIt method,
- TMtxOptimization.SetObjects method
Examples
MtxOptimization->VariableParameters->SetIt(false,OPENARRAY(double,(1,1)));
MtxOptimization->ConstantParameters->SetIt(false,OPENARRAY(double,(2.5)));
double __fastcall BTestFunction(TVec* const Parameters, TVec* const Constants, System::TObject* const * ObjConst, const int ObjConst_Size)
{
double* Pars = Parameters->PValues1D(0);
return 2*Pars[0] + Sqrt(Pars[1]-Consts[0]);
}
MtxOptimization->RealFunction = TestFunction;
function TestFunction(const Pars: TVec; const Consts: TVec;const ObjConsts: Array of TObject): double;
begin
TestFunction := 2*Pars[0]+Sqrt(Pars[1]-Consts[0]);
end;