naginterfaces.library.opt.one_var_func¶
- naginterfaces.library.opt.one_var_func(funct, e1, e2, a, b, maxcal, data=None)[source]¶
one_var_func
searches for a minimum, in a given finite interval, of a continuous function of a single variable, using function values only. The method (based on quadratic interpolation) is intended for functions which have a continuous first derivative (although it will usually work if the derivative has occasional discontinuities).For full information please refer to the NAG Library document for e04ab
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/e04/e04abf.html
- Parameters
- functcallable fc = funct(xc, data=None)
You must supply this function to calculate the value of the function at any point in .
It should be tested separately before being used in conjunction with
one_var_func
.- Parameters
- xcfloat
The point at which the value of is required.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- fcfloat
Must be set to the value of the function at the current point .
- e1float
The relative accuracy to which the position of a minimum is required. (Note that, since is a relative tolerance, the scaling of is automatically taken into account.)
should be no smaller than , and preferably not much less than , where is the machine precision.
- e2float
The absolute accuracy to which the position of a minimum is required. should be no smaller than .
- afloat
The lower bound of the interval containing a minimum.
- bfloat
The upper bound of the interval containing a minimum.
- maxcalint
The maximum number of calls of to be allowed.
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- e1float
If you set to (or to any value less than ), will be reset to the default value before starting the minimization process.
- e2float
If you set to (or to any value less than ), will be reset to the default value .
- afloat
An improved lower bound on the position of the minimum.
- bfloat
An improved upper bound on the position of the minimum.
- maxcalint
The total number of times that was actually called.
- xfloat
The estimated position of the minimum.
- ffloat
The function value at the final point given in .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, , and .
Constraint: .
- Warns
- NagAlgorithmicWarning
- (errno )
The maximum number of function calls, , have been performed. This may have happened simply because was set too small for the particular problem, or may be due to a mistake in the user-supplied function . If no mistake can be found in , restart
one_var_func
(preferably with the values of and given on exit from the previous call toone_var_func
).
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
one_var_func
is applicable to problems of the form:It normally computes a sequence of values which tend in the limit to a minimum of subject to the given bounds. It also progressively reduces the interval in which the minimum is known to lie. It uses the safeguarded quadratic-interpolation method described in Gill and Murray (1973).
You must supply a to evaluate . The arguments and together specify the accuracy
to which the position of the minimum is required. Note that is never called at any point which is closer than to a previous point.
If the original interval contains more than one minimum,
one_var_func
will normally find one of the minima.
- References
Gill, P E and Murray, W, 1973, Safeguarded steplength algorithms for optimization using descent methods, NPL Report NAC 37, National Physical Laboratory