当已经选择了一些变量时如何求解方程组?
我正在使用 scipy.optimize 来最小化成本函数。
Python 将 M 个变量传递到成本函数中,并根据这些变量计算其他 N 个变量。现在,我有一个 M+N 联立方程组,必须满足该方程组才能使解有效。
我想象做这样的事情:
def cost(someTuple):
# This function calculates the cost
return k1 * someTuple[0] + k2 * someTuple[1] + ... kN * someTuple[N-1]
def cost_wrapper(x):
# ************ The following line is what I don't know how to do *************
big_tuple = solveSystemOfEquations(x, f(x))
return cost(big_tuple)
if __name__=="__main__":
from scipy.optimize import minimize
minimize(cost_wrapper, *otherParams)
solveSystemOfEquations() 的重要之处在于它返回的变量比给它的变量多。如果给定的变量与任何可能的解决方案相距甚远,solveSystemOfEquations()
必须返回一个带有梯度的大数,这将引导优化器找到有意义的解决方案。
我们还假设该系统是近似可解的。请注意,无法保证解的 MMSE 误差有界。
是否有任何算法允许您选择一些(不是全部)变量,并求解其他变量?或者说这根本就不是一件事吗?
I'm using scipy.optimize
to minimize a cost function.
Python passes M variables into the cost function, and N other variables are calculated based on those. Now, I have a system of M+N simultaneous equations which must be satisfied for a solution to be valid.
I imagine doing something like this:
def cost(someTuple):
# This function calculates the cost
return k1 * someTuple[0] + k2 * someTuple[1] + ... kN * someTuple[N-1]
def cost_wrapper(x):
# ************ The following line is what I don't know how to do *************
big_tuple = solveSystemOfEquations(x, f(x))
return cost(big_tuple)
if __name__=="__main__":
from scipy.optimize import minimize
minimize(cost_wrapper, *otherParams)
What is important about solveSystemOfEquations()
is that it returns more variables than are given to it. If the variables given to it are far removed from any possible solution, solveSystemOfEquations()
has to return a large number with a gradient that will lead the optimizer towards a meaningful solution.
Let's also assume that the system is approximately solvable. Note that boundedness of MMSE error of a solution cannot be guaranteed.
Is there any algorithm which allows you to choose some (not all) variables, and solve for the others? Or is that not a thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论