以最小误差求解非线性方程组

发布于 2024-12-13 18:23:37 字数 382 浏览 3 评论 0原文

我有一些非线性优化问题(最好在 python 中解决):

给定 2D 平面中的 3 个圆(中心 x1..3,y1..3,半径 d1..3)。

(x-x1)^2 + (y-y1)^2 - r1^2 = 0
(x-x2)^2 + (y-y2)^2 - r2^2 = 0
(x-x3)^2 + (y-y3)^2 - r3^2 = 0

在这种情况下,需要公共点 (x/y),并且可以通过 fsolve (scipy.optimize) 来计算。 但是,如果半径 r1..3 的不确定性分别为 u1..3,如何解决这个问题呢?即,圆的真实半径位于区间 ru ... r+u 内。

如何找到包含半径不确定性的最佳点 (x/y)?

I have some nonlinear optimization problem (preferably solved in python):

Given are 3 circles (centers x1..3,y1..3, radii d1..3) in a 2D plane.

(x-x1)^2 + (y-y1)^2 - r1^2 = 0
(x-x2)^2 + (y-y2)^2 - r2^2 = 0
(x-x3)^2 + (y-y3)^2 - r3^2 = 0

The common point (x/y) is desired and can be computed by fsolve (scipy.optimize) in this case. But how does one solve the problem if the radii r1..3 are with an uncertainness of u1..3, respectively? I.e. the true radius of a circle is in the interval r-u ... r+u.

How can I find the optimal point (x/y) which incorportes the uncertainty of the radii?

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

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

发布评论

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

评论(2

输什么也不输骨气 2024-12-20 18:23:37

鉴于这里的描述,这实际上并不难:
http://mathworld.wolfram.com/Circle-CircleIntersection.html

提议的算法:

  1. 找到 x - 如链接中所述。
  2. 计算 y。

两者都应该使用任意 2 个圆圈来完成。

  1. 将点 (x,y) 和 (x,-y) 插入 3 个圆中。
  2. 解决方案是所有三个圆相交于:
    x,y
    x,-y
    或者根本没有。

另一个建议...
我再次阅读了你的问题,并意识到你不想找到

但是,如果您在纸上画出所有 9 个圆(3 个相交的圆,加上 r+e 和 re 的 2 个较小和较大的圆,其中 e 是错误),您会注意到以下情况 您的交点位于多边形内。你
可以很容易地计算出这个多边形的顶点。然后你的问题就变成了:
找到多边形中的一个点。
或者你编写一个找到这些顶点的反对函数,然后
你最小化那个区域。

要了解我对圆圈的意思,请运行:

# excuse me for the ugly code ...
import pylab
pylab.axes()

cir = pylab.Circle((1,0), radius=1, alpha =.2, fc='b')
cir1 = pylab.Circle((1,0), radius=0.9, alpha =.2, fc='b')
cir2 = pylab.Circle((1,0), radius=1.1, alpha =.2, fc='b')
cir3 = pylab.Circle((-1,0), radius=1, alpha =.2, fc='b')
cir4 = pylab.Circle((-1,0), radius=0.9, alpha =.2, fc='b')
cir5 = pylab.Circle((-1,0), radius=1.1, alpha =.2, fc='b')
cir6 = pylab.Circle((0,-1), radius=0.9, alpha =.2, fc='b')
cir7 = pylab.Circle((0,-1), radius=1.1, alpha =.2, fc='b')
cir8 = pylab.Circle((0,-1), radius=1, alpha =.2, fc='b')
pylab.gca().add_patch(cir)
pylab.gca().add_patch(cir1)
pylab.gca().add_patch(cir2)
pylab.gca().add_patch(cir3)
pylab.gca().add_patch(cir4)
pylab.gca().add_patch(cir5)
pylab.gca().add_patch(cir6)
pylab.gca().add_patch(cir7)
pylab.gca().add_patch(cir8)

pylab.axis('scaled')
pylab.show()

This is actually not so hard given the decription here:
http://mathworld.wolfram.com/Circle-CircleIntersection.html

A proposed algorithm:

  1. Find x - as described in the link.
  2. Calculate y.

Both should be done using any 2 circles.

  1. Plug the points (x,y) and (x,-y) in the 3 circle.
  2. The solution is either that all three circles intersect at:
    x,y
    x,-y
    or not at all.

Another suggestion ...
I read again your question, and realized you're not looking to find
the point it self...

However, if you draw all 9 circles on a paper (the 3 intersecting, plus 2 smaller and larger for r+e and r-e, where e is error), you notice the following. Your intersection point lies within a polygon. You
can easily calculate the vertices of this polygon. And then your problem becomes either:
find a point in polygon.
Or you write an objection function that finds these vertices, and then
you minimize that area.

To see what I mean about the circles, run:

# excuse me for the ugly code ...
import pylab
pylab.axes()

cir = pylab.Circle((1,0), radius=1, alpha =.2, fc='b')
cir1 = pylab.Circle((1,0), radius=0.9, alpha =.2, fc='b')
cir2 = pylab.Circle((1,0), radius=1.1, alpha =.2, fc='b')
cir3 = pylab.Circle((-1,0), radius=1, alpha =.2, fc='b')
cir4 = pylab.Circle((-1,0), radius=0.9, alpha =.2, fc='b')
cir5 = pylab.Circle((-1,0), radius=1.1, alpha =.2, fc='b')
cir6 = pylab.Circle((0,-1), radius=0.9, alpha =.2, fc='b')
cir7 = pylab.Circle((0,-1), radius=1.1, alpha =.2, fc='b')
cir8 = pylab.Circle((0,-1), radius=1, alpha =.2, fc='b')
pylab.gca().add_patch(cir)
pylab.gca().add_patch(cir1)
pylab.gca().add_patch(cir2)
pylab.gca().add_patch(cir3)
pylab.gca().add_patch(cir4)
pylab.gca().add_patch(cir5)
pylab.gca().add_patch(cir6)
pylab.gca().add_patch(cir7)
pylab.gca().add_patch(cir8)

pylab.axis('scaled')
pylab.show()
养猫人 2024-12-20 18:23:37

我会尝试这种方式。对于给定点 p,我计算从该点到三个圆中每一个的距离。这可以通过取 (1) 点与圆原点之间的距离与 (2) 圆半径之间的差的绝对值来完成。那么你的目标函数是最小化三个距离的总和(p到圆A,p到圆B,p到圆C)。我会尝试算术总和,但可能有一些很好的理由以不同的方式进行聚合(集合平均类型的数学)。然后,您使用非线性包来最小化目标函数(即三个距离的总和)。

现在每个圆都有权重了。因此,您修改目标函数,以根据每个圆的不确定性来折扣距离。同样,您需要一些逻辑来完成此加权...朴素的方法是使用“加权平均值”,即将 1/sigma^2 作为每个距离的权重。所以你的目标函数就变成了

(weighted average distance) 
= ( distA * sigmaA^-2 + distB * sigmaB^-2 + distC * sigmaC^-2 ) 
   / ( sigmaA^-2 + sigmaB^-2 + sigmaC^-2) 

,其中 distX 是点到圆的距离,sigmaA 是圆位置的标准偏差(由于圆的位置和大小的不确定性),^-2 表示平方,然后除以。

使用nonlin包来最小化上面的obj。通过改变点的 x 和 y 来实现函数。

I'd try this way. For a given point, p, I calculate distance from the point to each of three circles. This can be done by taking absolute value of difference between (1)distance between the point and the origin of a circle and (2) radius of the circle. Then your objective function is to minimize the sum of three distances (p to circleA, p to circle B, p to circle C). I'd try arithmetic sum, but there may be some good reason to aggregate differently (ensamble average kind of math). YOu then use the nonlinear package to minimize the objective function (i.e. sum of three distance).

Now you have weight for each circle. So you modify the objective function to discount the distance by uncertainty of each circle. Again, you need some logic how this weigting is accomplished... Naive method is to use "weighted average", which is to take 1/sigma^2 as weight for each distance. so your objective function becomes

(weighted average distance) 
= ( distA * sigmaA^-2 + distB * sigmaB^-2 + distC * sigmaC^-2 ) 
   / ( sigmaA^-2 + sigmaB^-2 + sigmaC^-2) 

where distX is distance from point to circle, sigmaA is standard deviation of location of the circle (due to uncertainty of cicle location and size), ^-2 denotes square and then divide.

Use nonlin package to minimize the above obj. function by changing x and y of the point.

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