Minimize a function func using the L-BFGS-B algorithm.
Arguments:
func – function to minimize. Called as func(x, *args)
x0 – initial guess to minimum
- fprime – gradient of func. If None, then func returns the function
- value and the gradient ( f, g = func(x, *args) ), unless approx_grad is True then func returns only f. Called as fprime(x, *args)
args – arguments to pass to function
- approx_grad – if true, approximate the gradient numerically and func returns
- only function value.
- bounds – a list of (min, max) pairs for each element in x, defining
- the bounds on that parameter. Use None for one of min or max when there is no bound in that direction
- m – the maximum number of variable metric corrections
- used to define the limited memory matrix. (the limited memory BFGS method does not store the full hessian but uses this many terms in an approximation to it).
- factr – The iteration stops when
(f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <= factr*epsmch
where epsmch is the machine precision, which is automatically generated by the code. Typical values for factr: 1e12 for low accuracy; 1e7 for moderate accuracy; 10.0 for extremely high accuracy.
- pgtol – The iteration will stop when
max{|proj g_i | i = 1, ..., n} <= pgtolwhere pg_i is the ith component of the projected gradient.
- epsilon – step size used when approx_grad is true, for numerically
- calculating the gradient
iprint – controls the frequency of output. <0 means no output.
maxfun – maximum number of function evaluations.
Returns: x, f, d = fmin_lbfgs_b(func, x0, ...)
x – position of the minimum f – value of func at the minimum d – dictionary of information from routine
- d[‘warnflag’] is
- 0 if converged, 1 if too many function evaluations, 2 if stopped for another reason, given in d[‘task’]
d[‘grad’] is the gradient at the minimum (should be 0 ish) d[‘funcalls’] is the number of function calls made.