trust(trust)
trust()所属R语言包:trust
Non-Linear Optimization
非线性优化
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function carries out a minimization or maximization of a function using a trust region algorithm. See the references for details.
此功能使用的信赖域算法的最小化或最大化的功能。有关详细信息,请参考相关手册。
用法----------Usage----------
trust(objfun, parinit, rinit, rmax, parscale,
iterlim = 100, fterm = sqrt(.Machine$double.eps),
mterm = sqrt(.Machine$double.eps),
minimize = TRUE, blather = FALSE, ...)
参数----------Arguments----------
参数:objfun
an R function that computes value, gradient, and Hessian of the function to be minimized or maximized and returns them as a list with components value, gradient, and hessian. Its first argument should be a vector of the length of parinit followed by any other arguments specified by the ... argument.
一个R函数计算值,梯度和Hessian的功能,最小化或最大化和返回的组件的列表value,gradient和hessian。它的第一个参数应该是一个矢量的长度parinit其次是...参数指定的任何其他参数。
If the domain of the objective function is not the whole Euclidean space of dimension length(parinit), then objfun should return list(value = Inf) when given a parameter value not in the domain of the objective function and minimize == TRUE. Similarly, it should return list(value = - Inf) when given a parameter value not in the domain and minimize == FALSE. Conversely, when given a parameter value in the domain, it must return a list with components with components value, gradient, and hessian. that are all finite and are the value, gradient, and Hessian of the objective function at the given point.
如果域的目标函数是整个欧氏空间的尺寸length(parinit),那么objfun应该返回list(value = Inf)当给定一个参数值,而不是在域的目标函数和minimize == TRUE。同样,它应该返回list(value = - Inf)时域和minimize == FALSE的参数值。相反,当给定一个参数值域,它必须返回一个列表,组件与组件value,gradient和hessian。都是有限的,并且是在给定的点的目标函数的值,梯度,和Hessian。
Warning: The feature of allowing infinite values to indicate a restricted domain does not allow for true constrained optimization. The algorithm will converge to solutions on the boundary very slowly. (See details below.)
警告:该功能允许无限的限制域值,以指示不允许真正的约束优化。该算法的收敛边界上的速度非常慢的解决方案。 (详见下文)。
参数:parinit
starting parameter values for the optimization. Must be feasible (in the domain).
起始参数的优化值。必须是可行的(在域)。
参数:rinit
starting trust region radius. The trust region radius (see details below) is adjusted as the algorithm proceeds. A bad initial value wastes a few steps while the radius is adjusted, but does not keep the algorithm from working properly.
开始信赖域半径。信赖域半径(详见下文)算法进行调整。一个坏的初始值,浪费了一些步骤,而半径进行调整,但不保持算法的正常工作。
参数:rmax
maximum allowed trust region radius. This may be set very large. If set small, the algorithm traces a steepest descent path (steepest ascent, when minimize = FALSE).
最大允许的信赖域半径。这可以被设置非常大的。如果设置小,算法的痕迹,一个最速下降路径(最速上升,当minimize = FALSE“)。
参数:parscale
an estimate of the size of each parameter at the minimum. The algorithm operates as if optimizing function(x, ...) objfun(x / parscale, ...). May be missing in which case no rescaling is done. See also the details section below.
估计每个参数的大小在最小。如果优化算法操作function(x, ...) objfun(x / parscale, ...)。可能会丢失,在这种情况下,没有进行重新标度的。请参阅下面的详细信息部分。
参数:iterlim
a positive integer specifying the maximum number of iterations to be performed before the program is terminated.
一个正整数,指定该程序之前必须执行的迭代的最大数量被终止。
参数:fterm
a positive scalar giving the tolerance at which the difference in objective function values in a step is considered close enough to zero to terminate the algorithm.
一个正的标量,其中在一个步骤中的目标函数的值的差异在被认为足够接近为零,以终止该算法给的公差。
参数:mterm
a positive scalar giving the tolerance at which the two-term Taylor-series approximation to the difference in objective function values in a step is considered close enough to zero to terminate the algorithm.
的公差在两个术语的泰勒级数近似在一个步骤中的目标函数的值的差异在积极的标量被认为足够接近为零,以终止该算法。
参数:minimize
If TRUE minimize. If FALSE maximize.
如果TRUE最小化。如果FALSE最大化。
参数:blather
If TRUE return extra info.
如果TRUE回报额外的信息。
参数:...
additional arguments to objfun.
附加参数到objfun。
Details
详细信息----------Details----------
See Fletcher (1987, Section 5.1) or Nocedal and Wright (1999, Section 4.2) for detailed expositions.
弗莱彻(1987年,第5.1节)或Nocedal和Wright(1999,第4.2节)的详细论述。
At each iteration, the algorithm minimizes (or maximizes) the two-term Taylor series approximation
在每次迭代中,该算法最小化(或最大化)两任泰勒级数近似
<p align="center">p^T D^2 p <= r^2
<p ALIGN="CENTER"> p^T D^2 p <= r^2
Let f^* be the value returned by objfun at x + p and calculate the ratio of actual to predicted decrease in the objective function
让f^*返回的值objfunx + p和比例计算实际减少的目标函数预测
The trust region algorithm is known to be highly efficient and very safe. It is guaranteed to converge to a point satisfying the first and second order necessary conditions (gradient is zero and Hessian is positive semidefinite) for a local minimum (Fletcher, 1987, Theorem 5.1.1; Nocedal and Wright, 1999, Theorem 4.8) if the level set of the objective function below the starting position is bounded. If the point to which the algorithm converges actually satisfies the second order sufficient condition (Hessian is positive definite and Lipschitz in a neighborhood of this point), then the algorithm converges at second order (Fletcher, 1987, Theorem 5.1.2).
信赖域算法被称为是高效的,非常安全的。这是保证满足第一和第二阶必要条件(梯度是零和Hessian是半正定)的局部最小值(弗莱彻,1987年,定理5.1.1 Nocedal和赖特,1999年,定理4.8)如果收敛到一个点水平低于初始位置的目标函数是有界的。如果该点的算法收敛实际上满足二阶充分条件(Hessian是正定和Lipschitz在这点附近),然后在二阶(弗莱彻,1987年,定理5.1.2)的算法收敛。
The algorithm is not designed for use on functions of thousands of variables or for functions for which derivatives are not available. Use nlm or optim for them. It is designed to do the best possible job at local optimization when derivatives are available. It is much safer and much better behaved than nlm or optim. It is especially useful when function evaluations are expensive, since it makes the best possible use of each function, gradient, and Hessian evaluation.
该算法不适合使用的功能成千上万个变量或衍生工具不提供的功能。使用nlm或optim他们的。衍生工具时,它的设计做最好的工作,在局部优化。它是更安全和更好的的表现比nlm或optim。这是特别有用的功能评估时,是昂贵的,因为它使每个函数,梯度和Hessian评价的最大可能地利用。
The algorithm is not designed for constrained optimization. It does allow for a restricted domain, but does not converge efficiently to solutions on the boundary of the domain. The theorems mentioned above assure rapid convergence to a local optimum (at least a point satisfying the first and second order necessary conditions) if the level set of the objective function below the starting position is bounded and is contained in the interior of the domain of the objective function (that is, all points on the boundary of the domain have higher objective function values than the starting point). The algorithm automatically adjusts the trust region to keep accepted iterates in the interior of the domain. This is one way it is safer than nlm or optim, which do not handle general restricted domains.
该算法没有约束优化设计。它只允许有限制域,但并不收敛有效的域的边界上的解决方案。上面提到的定理保证快速收敛到局部最优的(至少一个点,满足第一和第二阶必要条件),如果下面的起始位置设定的目标函数是有界的水平,并包含域的内部目标函数(即,该域的边界上的所有点有更高的目标函数值比起点)。该算法自动调整信赖域的域在内部保持公认的迭代点。这是一种比nlm或optim,不处理的约束域的安全。
值----------Value----------
A list containing the following components: <table summary="R valueblock"> <tr valign="top"><td>value</td> <td> the value returned by objfun at the final iterate.</td></tr> <tr valign="top"><td>gradient</td> <td> the gradient returned by objfun at the final iterate.</td></tr> <tr valign="top"><td>hessian</td> <td> the Hessian returned by objfun at the final iterate.</td></tr> <tr valign="top"><td>argument</td> <td> the final iterate.</td></tr> <tr valign="top"><td>converged</td> <td> if TRUE the final iterate was deemed optimal by the specified termination criteria.</td></tr> <tr valign="top"><td>iterations</td> <td> number of trust region subproblems done (including those whose solutions are not accepted).</td></tr> <tr valign="top"><td>argpath</td> <td> (if blather == TRUE) the sequence of iterates, not including the final iterate.</td></tr> <tr valign="top"><td>argtry</td> <td> (if blather == TRUE) the sequence of solutions of the trust region subproblem.</td></tr> <tr valign="top"><td>steptype</td> <td> (if blather == TRUE) the sequence of cases that arise in solutions of the trust region subproblem. "Newton" means the Newton step solves the subproblem (lies within the trust region). Other values mean the subproblem solution is constrained. "easy-easy" means the eigenvectors corresponding to the minimal eigenvalue of the rescaled Hessian are not all orthogonal to the gradient. The other cases are rarely seen. "hard-hard" means the Lagrange multiplier for the trust region constraint is minus the minimal eigenvalue of the rescaled Hessian; "hard-easy" means it isn't.</td></tr> <tr valign="top"><td>accept</td> <td> (if blather == TRUE) indicates which of the sequence of solutions of the trust region subproblem were accepted as the next iterate. (When not accepted the trust region radius is reduced, and the previous iterate is kept.)</td></tr> <tr valign="top"><td>r</td> <td> (if blather == TRUE) the sequence of trust region radii.</td></tr> <tr valign="top"><td>rho</td> <td> (if blather == TRUE) the sequence of ratios of actual over predicted decrease in the objective function in the trust region subproblem, where predicted means the predicted decrease in the two-term Taylor series model used in the subproblem.</td></tr> <tr valign="top"><td>valpath</td> <td> (if blather == TRUE) the sequence of objective function values at the iterates.</td></tr> <tr valign="top"><td>valtry</td> <td> (if blather == TRUE) the sequence of objective function values at the solutions of the trust region subproblem.</td></tr> <tr valign="top"><td>preddiff</td> <td> (if blather == TRUE) the sequence of predicted differences using the two-term Taylor-series model between the function values at the current iterate and at the solution of the trust region subproblem.</td></tr> <tr valign="top"><td>stepnorm</td> <td> (if blather == TRUE) the sequence of norms of steps, that is distance between current iterate and proposed new iterate found in the trust region subproblem.</td></tr> </table>
一个列表,其中包含以下组件:<table summary="R valueblock"> <tr valign="top"> <TD> value </ TD> <TD>的返回值的objfun最终的迭代。</ TD> </ TR> <tr valign="top"> <TD>gradient </ TD> <TD>梯度返回objfun在最后的迭代。</ TD> </ TR> <tr valign="top"> <TD>hessian </ TD> <TD>的Hessian返回objfun在最后的迭代。</ TD> </ TR > <tr valign="top"> <TD> argument </ TD> <TD>最终的迭代。</ TD> </ TR> <tr valign="top"> <TD><X > </ TD> <TD>converged最后的迭代指定的终止条件被认为是最佳的。</ TD> </ TR> <tr valign="top"> <TD>TRUE </ TD> <TD>的信赖域子做(包括那些不被接受的解决方案)。</ TD> </ TR> <tr valign="top"> <TD>iterations</ TD> <TD>(如果argpath)的序列,不包括最后的迭代,迭代。</ TD> </ TR> <tr valign="top"> <TD>blather == TRUE</ TD> <TD>(如果argtry)的序列的信赖域子问题的解决方案。</ TD> </ TR> <tr valign="top"> <TD>blather == TRUE</ TD <TD>(如果steptype)的序列中出现的信赖域子问题的解决方案。 blather == TRUE是指,牛顿步解决的子问题(信任域范围内)。其他值意味着约束子问题的解决方案。 "Newton"是指重新调整的黑森州的最小特征值对应的特征向量是正交的梯度。其他情况下是很少见的。 "easy-easy"是指对我的信任区域约束的拉格朗日乘子是负的最小特征值的重新调整的黑森州,“"hard-hard"”意味着它是不。</ TD> </ TR> <TR VALIGN =“顶” > <TD> "hard-easy" </ TD> <TD>(如果accept)被接纳为下一次迭代序列的信赖域子问题的解决方案。 (如果不被接受的信赖域半径的降低,保持和以前的迭代。)</ TD> </ TR> <tr valign="top"> <TD> blather == TRUE </ TD> <TD> (如果r)序列的信赖域半径。</ TD> </ TR> <tr valign="top"> <TD> blather == TRUE</ TD> <TD>(如果rho)序列的实际比值在预测减少在信赖域子问题,其中预测中的目标函数是指在两个学期的泰勒级数模型中的子问题的预测减少。</ TD> </ TR> <tr valign="top"> <TD> blather == TRUE </ TD> <TD>(如果valpath)的目标函数值在迭代点的序列。</ TD> </ TR> < TR VALIGN =“”> <TD>blather == TRUE </ TD> <TD>(如果valtry)序列的目标函数值的信赖域子问题的解决方案。</ TD> < / TR> <tr valign="top"> <TD> blather == TRUE </ TD> <TD>(如果preddiff)的顺序使用两个学期的泰勒级数模型之间的预测差异在当前迭代函数值和信赖域子问题的解决方案。</ TD> </ TR> <tr valign="top"> <TD> blather == TRUE</ TD> <TD>(如果 stepnorm)规范的步骤的顺序,也就是当前迭代,并建议新的迭代发现在信赖域子。</ TD> </ TR> </表之间的距离>
参考文献----------References----------
Fletcher, R. (1987) Practical Methods of Optimization, second edition. John Wiley, Chichester.
Nocedal, J. and Wright, S. J. (1999) Numerical Optimization. Springer-Verlag, New York.
参见----------See Also----------
nlm and optim for competitors that do not require analytical derivatives. deriv to calculate analytical derivatives.
nlm和optim不需要分析的衍生工具的竞争对手。 deriv计算分析衍生工具。
实例----------Examples----------
##### Rosenbrock's function #####[#########的Rosenbrock函数]
objfun <- function(x) {
stopifnot(is.numeric(x))
stopifnot(length(x) == 2)
f <- expression(100 * (x2 - x1^2)^2 + (1 - x1)^2)
g1 <- D(f, "x1")
g2 <- D(f, "x2")
h11 <- D(g1, "x1")
h12 <- D(g1, "x2")
h22 <- D(g2, "x2")
x1 <- x[1]
x2 <- x[2]
f <- eval(f)
g <- c(eval(g1), eval(g2))
B <- rbind(c(eval(h11), eval(h12)), c(eval(h12), eval(h22)))
list(value = f, gradient = g, hessian = B)
}
trust(objfun, c(3, 1), 1, 5)
##### function with restricted domain #####[####功能受限制的领域#####]
d <- 5
mu <- 10 * seq(1, d)
objfun <- function(x) {
normxsq <- sum(x^2)
omnormxsq <- 1 - normxsq
if (normxsq >= 1) return(list(value = Inf))
f <- sum(x * mu) - log(omnormxsq)
g <- mu + 2 * x / omnormxsq
B <- 4 * outer(x, x) / omnormxsq^2 + 2 * diag(d) / omnormxsq
list(value = f, gradient = g, hessian = B)
}
whoop <- trust(objfun, rep(0, d), 1, 100, blather = TRUE)
whoop$converged
whoop$iterations
data.frame(type = whoop$steptype, rho = whoop$rho, change = whoop$preddiff,
accept = whoop$accept, r = whoop$r)
##### solution[####解决方案]
whoop$argument
##### distance of solution from boundary[####从边界距离的解决方案]
1 - sqrt(sum(whoop$argument^2))
##### fail when initial point not feasible[####失败时,初始点并不可行]
## Not run: trust(objfun, rep(0.5, d), 1, 100, blather = TRUE)[#不运行:信任(代表(objfun,0.5,D),1,100,废话= TRUE)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|