You are here: Symbol Reference > MtxVecTools Namespace > Classes > TMtxOptimization Class > public > TMtxOptimization.SetObjects Method
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtxOptimization.SetObjects Method

Define any additional Object constant parameters in the RealFunction.

Pascal
procedure SetObjects(Const ObjConst: Array of TObject);

Use SetObjects method to define any additional Object constant parameters in the RealFunction. By default, the PConsts has 0 elements.

The SetObject method provides an easy way to use all TVec and TMtx methods to construct function to be minimized:

Uses Math387, MtxVecTools; function MyFunction(const Pars: TVec; const consts: TVec; const OConsts: Array of TObject): double; var tmpVec: TVec; begin tmpVec: = OConsts[0] as TVec; MyFunction := Pars[0]*tmpVec.Sum -tmpVec.SumOfSquares*Pars[1]; end; begin // ... MtxOptimization.VariableParameters.SetIt(false,[-1,0]); MtxOptimization1.SetObjects([XVec]); // ... end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "MtxVecTools.hpp" // define the real function to be minimized double __fastcall VecFun(TVec* const Parameters, TVec* const Constants, System::TObject* const * ObjConst, const int ObjConst_Size) { double* pars = Parameters->PValues1D(0); TVec *tmpVec = dynamic_cast<TVec*>(ObjConst[0]); return (pars[0] * tmpVec->Sum() - pars[1] * tmpVec->SumOfSquares()); } void __fastcall Example(TMtxOptimization* opt1); { // ... opt1->RealFunction = VecFun; opt1->VariableParameters->SetIt(false,OPENARRAY(double,(-1,0))); sVector xVec; TObject* o[1]; o[0] = xVec; opt1->SetObjects(o,0); }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!