使用梯度下降法求解非线性系统

问题描述

我有以下代码,该代码使用梯度下降来找到y = (x+5)^2的全局最小值:

cur_x = 3                  # the algorithm starts at x=3
rate = 0.01                # learning rate
precision = 0.000001       # this tells us when to stop the algorithm
prevIoUs_step_size = 1 
max_iters = 10000          # maximum number of iterations
iters = 0                  # iteration counter
df = lambda x: 2*(x+5)     # gradient of our function

while prevIoUs_step_size > precision and iters < max_iters:
    prev_x = cur_x                                # store current x value in prev_x
    cur_x = cur_x - rate * df(prev_x)             # grad descent
    prevIoUs_step_size = abs(cur_x - prev_x)      # change in x
    iters = iters+1                               # iteration count
    print("Iteration",iters,"\nX value is",cur_x) # print iterations
    
print("The local minimum occurs at",cur_x)

该过程非常简单,并且是解决此类问题的最直观,最简短的过程(至少,据我所知)。

我现在想将其应用于求解非线性方程组。即,我想用它来解决三维时差问题。也就是说,给定4个观察者的坐标(或通常,n+1个维解的n个观察者的坐标),某些信号的速度v和时间到达每个观察者后,我想重建源(确定其坐标为[x,y,z]

我已经使用近似搜索完成了此操作(请参见此出色的文章:),现在我想尝试通过梯度下降来实现(确实,这是一个有趣的练习)。我知道二维中的问题可以通过以下非线性系统来描述:

sqrt{(x-x_1)^2+(y-y_1)^2}+s(t_2-t_1) = sqrt{(x-x_2)^2 + (y-y_2)^2}

sqrt{(x-x_2)^2+(y-y_2)^2}+s(t_3-t_2) = sqrt{(x-x_3)^2 + (y-y_3)^2}

sqrt{(x-x_3)^2+(y-y_3)^2}+s(t_1-t_3) = sqrt{(x-x_1)^2 + (y-y_1)^2}

我知道可以 完成,但是我不确定如何做到。

如何将其应用于3维或一般的非线性系统?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)