Matlab 求解器中的相对和绝对公差定义

发布于 2024-12-28 13:57:21 字数 672 浏览 1 评论 0 原文

我试图理解以下RelTol和AbsTol参数的Matlab定义:

RelTol — This tolerance is a measure of the error relative to the size of each
solution component. Roughly, it controls the number of correct digits in all 
solution components, except those smaller than thresholds AbsTol(i).The default,
1e-3, corresponds to 0.1% accuracy.

AbsTol — AbsTol(i) is a threshold below which the value of the ith solution 
component is unimportant. The absolute error tolerances determine the accuracy 
when the solution approaches zero.

我不明白为什么AbsTol在解接近零时确定精度(事实上,如果我的问题的解是半径为7000公里的圆形轨道,则这不满足它)以及为什么 RelTol 控制所有解分量中正确数字的数量(除了那些小于阈值 AbsTol(i) 的分量)。确定每个容差的实际表达式是什么?我想要获得更简单且易于理解的定义。

I am trying to understand the following Matlab definitions for RelTol and AbsTol parameters:

RelTol — This tolerance is a measure of the error relative to the size of each
solution component. Roughly, it controls the number of correct digits in all 
solution components, except those smaller than thresholds AbsTol(i).The default,
1e-3, corresponds to 0.1% accuracy.

AbsTol — AbsTol(i) is a threshold below which the value of the ith solution 
component is unimportant. The absolute error tolerances determine the accuracy 
when the solution approaches zero.

I do not understand why AbsTol determines the accuracy when the solution approaches zero (indeed, if the solution of my problem is a circular orbit of 7000 km radius this does not meet it) and why RelTol controls the number of correct digits in all solution components, except those smaller than thresholds AbsTol(i). What are the actual expressions for determining each tolerance? I would like to get simpler and understandable definitions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2025-01-04 13:57:21

当您执行优化时,您需要决定何时停止。检查您的解决方案是否足够好的一种方法是检查该解决方案是否仍在发生显着变化。有两种方法可以衡量解决方案的变化程度:相对变化(即变化百分比)或绝对变化。

检查相对变化非常有意义,因为当解在 1 左右时,5 的变化意味着与解在 100000 左右时非常不同。因此,优化例程在每次迭代时都会检查 i 是否abs(1-x(i)/x(i-1)),即自上次迭代以来新解发生了多少变化。请注意,如果您同时优化多个参数,则 x 可以是解决方案数组(因此该解决方案具有“多个组件”)。当然,您希望在停止进一步优化之前所有“解决方案组件”都满足条件。

然而,当解接近零时,相对容差就会出现问题,因为 x/0 未定义。因此,查看值的绝对变化并在 abs(x(i)-x(i-1)) 时退出优化是有意义的。如果您选择的 absTol 足够小,则只有 relTol 对大型解决方案有意义,而 absTol 仅在解决方案不成立时才变得相关0 左右。

由于当满足两个标准中的任何一个时求解器就会停止,因此您与(局部)最佳解决方案的接近程度由 absTolrelTol 决定。例如,如果 relTol 为 10%,那么您与最佳解决方案的距离永远不会比 10% 更接近,除非您的解决方案大约为零,在这种情况下,absTol 标准(例如,0.0001)在 relTol 标准之前得到满足。

When you perform an optimization, you need to decide when to stop. One way to check for whether your solution is good enough is to check whether the solution is still changing significantly. There are two ways to measure how much a solution changes: relative change (i.e. % change), or absolute change.

It makes a lot of sense to check for relative change, since a change of 5 means something very different when the solution is around 1 than when it is around 100000. Thus, the optimization routine checks, at every iteration i whether abs(1-x(i)/x(i-1))<relTol, i.e. by what fraction the new solution has changed since the last iteration. Note that x can be an array of solutions if you're optimizing multiple parameters at the same time (the solution thus has "multiple components"). Of course, you want the condition to be fulfilled for all "solution components" before you stop optimizing further.

The relative tolerance, however, becomes problematic when the solution is around zero, since x/0 is undefined. Thus, it makes sense to also look at the absolute change in value, and quit optimizing when abs(x(i)-x(i-1))<absTol. If you choose absTol small enough, it will only be relTol that counts for large solutions, while absTol only becomes relevant if the solution comes to lie around 0.

Since the solver stops when either of the two criterion is fulfilled, how close you get to a (locally) optimal solution is determined by absTol or relTol. For example, if relTol is 10%, you will never get much closer than 10% to the optimal solution, unless your solution is around zero, in which case the absTol criterion (of, say, 0.0001) is satisfied before the relTol criterion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文