Overload List
| # | Signature | Description |
|---|---|---|
| 1 | Int32 MinBrent(Double ax, Double bx, TRealFunction Func, TMtxFloatPrecision FloatPrecision, Double[] Consts, Object[] ObjConst, ref Double MinX) | Minimizes single variable function by using default settings and no log. |
| 2 | Int32 MinBrent(Double ax, Double bx, TRealFunction Func, TMtxFloatPrecision FloatPrecision, Double[] Consts, Object[] ObjConst, ref Double MinX, Int32 MaxIter, Double Accuracy, TStrings Verbose) | Minimizes single variable function. |
Overload 1: Int32 MinBrent(Double ax, Double bx, TRealFunction Func, TMtxFloatPrecision FloatPrecision, Double[] Consts, Object[] ObjConst, ref Double MinX)
Minimizes single variable function by using default settings and no log.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | ax | Double | scalar |
| 2 | bx | Double | scalar |
| 3 | Func | TRealFunction | |
| 4 | FloatPrecision | TMtxFloatPrecision | |
| 5 | Consts | Double[] | |
| 6 | ObjConst | Object[] | |
| 7 | MinX | Double (ref) | output |
Returns: Int32
Use this version if algorithm step logs are not needed.
Overload 2: Int32 MinBrent(Double ax, Double bx, TRealFunction Func, TMtxFloatPrecision FloatPrecision, Double[] Consts, Object[] ObjConst, ref Double MinX, Int32 MaxIter, Double Accuracy, TStrings Verbose)
Minimizes single variable function.
| # | Name | Description |
|---|---|---|
| 1 | ax | Defines initial lower limit for minimum search. |
| 2 | bx | Defines initial upper limit for minimum search. |
| 3 | Func | Real function of single variable (must be of Dew.Math.TRealFunction type) to be minimized. |
| 4 | Consts | Additional Fun constant parameters (can be/is usually nil). |
| 5 | ObjConst | Additional Fun constant parameters (can be/is usually nil). |
| 6 | MinX | Returns the position of function minimum. |
| 7 | MaxIter | Maximum allowed numer of minimum search iterations. |
| 8 | Accuracy | Desired minimum position tolerance. |
| 9 | Verbose | If assigned, stores Func, evaluated at each iteration step. Optionally, you can also pass Dew.Math.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. |
| 10 | FloatPrecision | Specifies the floating point precision to be used by the routine. |
Returns: Int32 - the number of iterations required to reach the solution(minimum) within given tolerance.
What it computes. Locates a local minimizer x^* of a
real function of one variable on the bracket [a_x,b_x] using Brent's method (golden-section search refined by parabolic interpolation; the modified algol-60 localmin). For the example objective
y(x) = sin(x) + (x+2)^2
Domain. a_x,b_x are finite reals; if b_x < a_x they
are swapped internally, so the order of the bracket does not matter. MaxIter > 0 caps the iterations; Accuracy ≥ 0 is the desired position tolerance.
Defined behaviour. Returns the iteration count and writes the
minimizer to MinX; it converges to a stationary point inside the bracket. MinBrent has no stop-reason output: if Func returns NaN the NaN propagates into MinX (and is reported in Verbose when assigned). The bracket is assumed to contain a minimum; for a monotone objective the result is the corresponding endpoint.
Minimizes the function of one variable. This routine uses slightly modified version of the algol 60 procedure localmin, introduced by Richard Brent.
private double Fun(TVec pars, TVec c, params object[] o)
{
return Math.Sin(Pars[0])+Math387.IntPower(Pars[0]+2,2);
// note that Pars holds only one variable !
}
private void Example()
{
// initial estimates for x1 and x2
double x;
double res = Optimization.MinBrent(-10,10,Fun,TMtxFloatPrecsion.mvDouble,null,null,out x, 500,1e-8,null);
// stop if Iters >500 or Tolerance < 1e-8
// Returns res = -1.8582461797
}