TDOA 计算,scipy 尽量减少过冲

TDOA calculation, scipy minimize overshoot sometime

我正在尝试使用 TDOA 在坐标系中查找声源位置。

我们的成本函数如下所示:

    def costfunction(point, meas_list, dims=2):
        #### Cost function to be fed into the scipy.optimize.minimize function
        #### For a candidate point, calculates the time differences, compares it
        #### to data
        error = 0
        for m in meas_list:
            actualdiff = m.delta
            calcdiff = (
                m.soundpointB.dist(point, dims=dims)
                - m.soundpointA.dist(point, dims=dims)
                )
            
            error += (actualdiff - calcdiff) ** 2
    
        return(error)
soundpointB.dist #---> is to calculate the distance between sensors

我们的传感器位置是

b = [-2, 2,0]
c = [2,-2,0]
d = [2,2,0]
e = [0,0,2]

我们在 x,y 的 -50 到 50 和 z 的 0 到 -20 范围内模拟随机源 模拟会产生从源到每个传感器的时间差。

所以我们有了成本函数来计算均方误差 然后我们使用scipy最小化来找出最好的解决方案

    startpoint = np.array([0,0,0])
    dims = 3
    result = minimize(
            fun=costfunction,
                x0=startpoint,
                args=(meas_list, dims),
                method='BFGS',
                  options={
                      'gtol': 1e-06,
                      'return_all':True,
                      'norm':inf},
                jac='2-point')

大部分计算都很好,实际位置与TDOA计算位置的误差为+-10%

但是对于某些位置,例如 [-30.0, 0.5, -6.0],TDOA 计算 return [-325.07,5.49,-64.73]

当我们检查 scipy 最小化的所有结果时。它似乎已经找到了位置,但它超出了范围。

有谁知道如何让它变得更好?或者有什么需要更正的?

BFGS 除了局部最小值外,不提供任何保证。如果您知道您的传感器将始终在 -50 和 50 以及 -2 和 2 之间,那么我建议:

  • 作为第一步,尝试有界局部最小化 - 使用 L-BFGS-B、SLSQP 等...并为您的变量提供这些边界
  • 如果以上还不够满意,拿出大炮试试全局优化算法,比如SHGO、DifferentialEvolution、DualAnnealing。它们都在 SciPy 中可用,可能速度较慢,但​​您会对结果更有信心。