|
|
◆ optif0()
| def optif0 |
( |
n |
, |
|
|
x |
, |
|
|
f |
, |
|
|
xpls |
|
|
) |
| |
Minimum of a multivariable nonlinear function (quasi-Newton method) (simple driver)
- Purpose
- optif0 finds the local minimum point (xs1, xs2, ..., xsn) of general nonlinear function f(x1, x2, ..., xn) (a twice continuously differentiable real-valued function).
The first order finite difference is used to compute the gradients, and the secant method (BFGS update) is used to compute the Hessian. The steps are computed by the line search.
optif0 is equivalent to using optif9 with setting default parameters. So that the problem is solved by the quasi-Newton method (BFGS method).
- Returns
- (fpls, info)
fpls (float):
Function value at local minimum xpls.
info (int):
= 0: Successful exit (see sub-code in work[0])
= -1: The argument n had an illegal value (n <= 1)
= -2: The argument x is invalid
= -3: The argument f is invalid
= -4: The argument xpls is invalid
= 1: Last global step failed to locate a point lower than xpls. Either xpls is an approximate local minimum of the function, the function is too nonlinear for this algorithm, or steptl is too large.
= 2: Iteration limit (200) exceeded
= 3: Maximum step size stepmx exceeded five consecutive times. Either the function is unbounded below, becomes asymptotic to a finite value from above in some direction, or stepmx is too small.
- Parameters
-
| [in] | n | The order or dimension of the problem. (n > 1) |
| [in] | x | Numpy ndarray (1-dimensional, float, length n)
Initial approximation of the solution vector. |
| [in] | f | The user supplied function which calculates the function f(x1, x2, ..., xn) defined as follows. _CODE def f(n, x): return function value f(x[0], x[1], ..., x[n-1]) _ENDCODE |
| [out] | xpls | Numpy ndarray (1-dimensional, float, length n)
Local minimum. |
- Reference
- CMLIB
- Example Program
- Find the minimum point of the following function (Rosenbrock function).
f(x1, x2) = 100(x2 - x1^2)^2 + (1 - x1)^2
The initial approximation is (x1, x2) = (-1.2, 1). def f(n, x):
return 100*(x[1] - x[0]**2)**2 + (1 - x[0])**2
def TestOptif0():
n = 2
x = np.array([-1.2, 1.0])
xpls = np.empty(n)
fpls, info = optif0(n, x, f, xpls)
print(xpls)
print(fpls)
print(info)
def optif0(n, x, f, xpls) Minimum of a multivariable nonlinear function (quasi-Newton method) (simple driver)
- Example Results
>>> TestOptif0()
[0.99999056 0.99998111]
8.91804174948292e-11
0
|