[ILNumerics Optimization Toolbox]
Namespace: ILNumerics.Toolboxes
Assembly: ILNumerics.Toolboxes.Optimization (in ILNumerics.Toolboxes.Optimization.dll) Version: 5.5.0.0 (5.5.7503.3146)
public static RetArray<double> fminunconst_newton( OptimizationObjectiveFunction<double> objfunc, InArray<double> x0, OptimizationDerivativeFunction<double> hessianfunc = null, int maxIter = 500, OptimizationDerivativeFunction<double> gradientFunc = null, OutArray<double> iterations = null, OutArray<double> gradientNorm = null, OutArray<int> iterationCount = null, Nullable<double> tol = null, Nullable<double> tolX = null )
Parameters
- objfunc
- Type: ILNumerics.ToolboxesOptimizationObjectiveFunctionDouble
Cost function to be minimized, defined from Rn to R - x0
- Type: ILNumericsInArrayDouble
Initial solution guess, lenght: (Rn). Specifies the starting point for the search. - hessianfunc (Optional)
- Type: ILNumerics.ToolboxesOptimizationDerivativeFunctionDouble
[optional] Custom function for computing the hessian matrix of objfunc. Default: null hessian(OptimizationObjectiveFunctionDouble, InArrayDouble, InArrayDouble)) - maxIter (Optional)
- Type: SystemInt32
[optional] Maximal number of iterations allowed. Default: 500 - gradientFunc (Optional)
- Type: ILNumerics.ToolboxesOptimizationDerivativeFunctionDouble
[optional] Function used to compute the gradient. Default: null (finite differences via jacobian_prec) - iterations (Optional)
- Type: ILNumericsOutArrayDouble
[optional] Output array of intermediate positions at each iteration. Default: null (not provided) - gradientNorm (Optional)
- Type: ILNumericsOutArrayDouble
[optional] Output: Request the gradient norms at each iteration. Default: null (do not compute) - iterationCount (Optional)
- Type: ILNumericsOutArrayInt32
[Output] Number of effective iterations during the computation - tol (Optional)
- Type: SystemNullableDouble
[optional] Exit tolerance on the gradient. Default: DefaultTolerance (1e-8) - tolX (Optional)
- Type: SystemNullableDouble
[optional] Exit the iterations when the solution is not significantly changing anymore. Default: DefaultTolerance (1e-8)
Return Value
Type: RetArrayDoubleA local minimizer of func, length: n
Exception | Condition |
---|---|
ArgumentOutOfRangeException | If objfunc is not defined at x0 or if objfunc was found to be non-scalar |
ArgumentNullException | If one of x0 or objfunc was null on entry |
If x0 is empty, an empty array of the same size will be returned.
This function computes the local minimum of the scalar multivariable non-linear optimization problem by explicitly evaluating the hessian matrix. If no hessian function is provided by the user, the predefined hessian(OptimizationObjectiveFunctionDouble, InArrayDouble, InArrayDouble) function evaluation will be used (finite differences). This leads to very precise results but is rather expensive for demanding problems. In order to control the hessian computation, user can provide a custom hessian function as OptimizationDerivativeFunctionT.
[ILNumerics Optimization Toolbox]
Array<double> x0 = -8 *ILMath.ones(2, 1); // initial guess for the solution Array<double> Mini = Optimization.fminunconst_newton(SampleFunction, x0, hessianfunc: Optimization.hessian); // minimizer of the SampleFuntion in two dimensions; // the hessian argument provided above corresponds to the defaul argument. //Sample function definition public static RetArray<double> SampleFunction(InArray<double> A) { using (Scope.Enter(A)) { return 2 * x[0] * x[0] + x[0] * x[1] + 2 * x[1] * x[1] - 6 * x[0] - 6 * x[1] + 15; } }