Optimization::Simplex Function

Overload List

#SignatureDescription
1int Simplex(TRealFunction Func, DewArray<double> &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision = TMtxFloatPrecision::mvDouble, int MaxIter = 500, double Tolerance = 1.0E-8, tStrings *Verbose = null);Minimizes the function of several variables by using the Nelder-Mead (Simplex) optimization method.
2int Simplex(TRealFunction Func, double &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, int MaxIter, double Tolerance);Minimizes function of several variables by using Simplex optimization method with no algorithm step log.
3int Simplex(TRealFunction Func, DewArray<double> &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, const DewArray<double> &LB, const DewArray<double> &UB, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, int MaxIter = 500, double Tolerance = 1.0E-8, tStrings *Verbose = null);Minimize function of several variables by using Simplex method with lower and/or upper bounds for parameters.

Overload 1: int Simplex(TRealFunction Func, DewArray<double> &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision = TMtxFloatPrecision::mvDouble, int MaxIter = 500, double Tolerance = 1.0E-8, tStrings *Verbose = null);

Minimizes the function of several variables by using the Nelder-Mead (Simplex) optimization method.

#NameTypeDescription
1FuncTRealFunctionReal function (must be of TRealFunction type) to be minimized.
2ParsDewArray<double> &Stores the initial estimates for parameters (minimum estimate). After the call to routine returns adjusted calculated values (minimum position).
3Constsconst DewArray<double> &Additional Fun constant parameteres (can be/is usually nil).
4ObjConstconst DewArray<tObject *> &Additional Fun constant parameteres (can be/is usually nil).
5FMindouble &Returns function value at minimum.
6StopReasonTOptStopReason &Returns reason why minimum search stopped (see TOptStopReason).
7FloatPrecision = TMtxFloatPrecision::mvDoubleconst TMtxFloatPrecisionSpecifies the floating point precision to be used by the routine.
8MaxIter = 500intMaximum allowed numer of minimum search iterations.
9Tolerance = 1.0E-8doubleDesired Pars - minimum position tolerance.
10Verbose = nulltStrings *If assigned, stores Fun, evaluated at each iteration step. Optionally, you can also pass TOptControl object to the Verbose parameter. This allows the optimization procedure to be interrupted from another thread and optionally also allows logging and iteration count monitoring.

Returns: the number of iterations required to reach the solution(minimum) within given tolerance.

Remarks:

What it computes. Minimizes a real function of several
variables with the gradient-free Nelder-Mead (downhill simplex) method - reflection, expansion, contraction and shrink steps on a simplex of n+1 vertices. No gradient or Hessian is required. The standard test ('Banana'/Rosenbrock) objective is

f(x_0,x_1) = 100 (x_1 - x_0^2)^2 + (1 - x_0)^2

with the global minimum f=0 at (x_0,x_1)=(1,1).

Domain. Pars holds the n starting coordinates (any
finite reals); MaxIter > 0; Tolerance ≥ 0 is the simplex-size convergence threshold.

Defined behaviour. On return Pars holds the best vertex,
FMin its objective value, and StopReason is TOptStopReason::OptResConverged when the simplex shrank below Tolerance, TOptStopReason::OptResMaxIter when the iteration cap was hit, or TOptStopReason::optNANValue if the objective returned NaN. The bounded overload (with LB/UB) maps each parameter through a smooth transform so the returned point always satisfies LB_i <= Pars_i <= UB_i; use +/-inf for a one-sided or absent bound.

Minimizes the function of several variables by using the Nelder-Mead (Simplex) optimization method. The advantage of Simplex method is it does not require gradient or Hessian.

See Also: TRealFunction
Declared in Dew::Math::Units::Optimization · Dew.Math/Units.Optimization.h · Cross-compiler

Overload 2: int Simplex(TRealFunction Func, double &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, int MaxIter, double Tolerance);

Minimizes function of several variables by using Simplex optimization method with no algorithm step log.

#NameTypeDescription
1FuncTRealFunction
2Parsdouble &
3Constsconst DewArray<double> &
4ObjConstconst DewArray<tObject *> &
5FMindouble &
6StopReasonTOptStopReason &
7FloatPrecisionconst TMtxFloatPrecision
8MaxIterint
9Tolerancedouble
Declared in Dew::Math::Units::Optimization · Dew.Math/Units.Optimization.h · Cross-compiler

Overload 3: int Simplex(TRealFunction Func, DewArray<double> &Pars, const DewArray<double> &Consts, const DewArray<tObject *> &ObjConst, const DewArray<double> &LB, const DewArray<double> &UB, double &FMin, TOptStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, int MaxIter = 500, double Tolerance = 1.0E-8, tStrings *Verbose = null);

Minimize function of several variables by using Simplex method with lower and/or upper bounds for parameters.

#NameTypeDescription
1FuncTRealFunction
2ParsDewArray<double> &
3Constsconst DewArray<double> &
4ObjConstconst DewArray<tObject *> &
5LBconst DewArray<double> &
6UBconst DewArray<double> &
7FMindouble &
8StopReasonTOptStopReason &
9FloatPrecisionconst TMtxFloatPrecision
10MaxIter = 500int
11Tolerance = 1.0E-8double
12Verbose = nulltStrings *
Remarks:

This version supports lower and upper bound(s) for function parameters Pars. Lower and upper bounds are defined in LB and UP arrays respectively. Depending on lower and/or upper bound for parameter, there are several possibilities for LB and UB:

  • Lower and upper bound: For each parameter both LB and UB should be set to specific value.
  • Upper bound only: In this case, LB is set to -INF, UB to specific value.
  • Lower bound only: In this case, LB should be set to specific value, UB to +INF.
  • No bounds: In this case, use non-bounded Simplex version or set LB and UB to -INF and +INF respecively.
Declared in Dew::Math::Units::Optimization · Dew.Math/Units.Optimization.h · Cross-compiler