带有有界变量的 C# LP/Lagrange
摘要:我将如何解决这个问题?
您好,
我正在研究一个混合式最大化问题,其中我的变量将受到最小值和最大值的限制。我的问题的一个代表性示例可能是:
maximize: (2x-3y+4z)/(x^2+y^2+z^2+3x+4y+5z+10)
subj. to: x+y+z=1
1 < x < 2
-2 < y < 3
5 < z < 8
where numerical coefficients and the minima/maxima are given.
我的最终项目涉及一个与上述问题类似的更复杂的问题。问题的结构不会改变——只有系数和输入会改变。因此,对于上面的示例,我将寻找一组函数,这些函数可能允许 C# 程序快速确定 x
,然后 y
,然后 z喜欢:
x = f(given inputs)
y = f(given inputs,x)
z = f(given inputs,x,y)
很想听听您对此的想法!
谢谢!
Summary: How would I go about solving this problem?
Hi there,
I'm working on a mixture-style maximization problem where my variables are going to be bounded by minima and maxima. A representative example of my problem might be:
maximize: (2x-3y+4z)/(x^2+y^2+z^2+3x+4y+5z+10)
subj. to: x+y+z=1
1 < x < 2
-2 < y < 3
5 < z < 8
where numerical coefficients and the minima/maxima are given.
My final project is involving a more complicated problem similar to the one above. The structure of the problems won't change- only the coefficients and inputs will change. So with the example above, I would be looking for a set of functions that might allow a C# program to quickly determine x
, then y
, then z
like:
x = f(given inputs)
y = f(given inputs,x)
z = f(given inputs,x,y)
Would love to hear your thoughts on this one!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
针对您的问题类型(非线性最小化)的标准优化方法是 Levenberg-Marquardt 算法:
但不幸的是它不直接支持您添加的线性约束。人们尝试了许多不同的方法来向 Levenberg-Marquardt 添加线性约束,并取得了不同程度的成功。
在这种情况下我可以推荐的另一种算法是 Simplex 算法:
与 Levenberg-Marquardt 一样,它也适用于非线性方程,但处理类似于不连续性的线性约束。这对于您上面的情况可能很有效。
无论哪种情况,这都不是一个编程问题,而是一个算法选择问题。文献中充斥着算法,您只需稍加搜索就可以找到上述任一算法的 C# 实现。
您还可以组合算法。例如,您可以使用带约束的 Simplex 进行初步搜索,并使用不带约束的 Levenberg-Marquardt 进行细化。
The standard optimization approach for your type of problem, non-linear minimization, is the Levenberg-Marquardt algorithm:
but unfortunately it does not directly support the linear constraints you have added. Many different approaches have been tried to add linear constraints to Levenberg-Marquardt with varying success.
Another algorithm I can recommend in this situation is the Simplex algorithm:
Like the Levenberg-Marquardt, it also works with non-linear equations but handles linear constraints which act like discontinuities. This could work well for your case above.
In either case, this is not so much a programming problem as an algorithm selection problem. The literature is rife with algorithms and you can find C# implementations of either of the above with a little searching.
You can also combine algorithms. For example, you can do a preliminary search with Simplex with the constraints and the refine it with Levenberg-Marquardt without the constraints.
如果您的问题是想要高效地解决线性规划问题,您可以使用 Cassowary.net 或 < a href="http://www.cs.cityu.edu.hk/~hwchun/nsolver/" rel="nofollow noreferrer">Nsolver。
如果您的问题是有效实现线性规划算法,您可能需要阅读组合优化:算法和复杂性,涵盖了短文本中提供的 Simplex 算法的大部分细节 线性规划图解指南,还包括有关椭圆体算法的信息,该算法对于更复杂的约束系统可能更有效。
您的问题本质上没有任何特定于 C# 的内容,但用它来标记它意味着您正在寻找 C# 中的解决方案;因此,查看上述两个工具包的源代码可能会对您有所帮助。
If your problem is that you want to solve linear programming problems efficiently, you can use Cassowary.net or NSolver.
If your problem is implementing a linear programming algorithm efficiently, you may want to read Combinatorial Optimization: Algorithms and Complexity which covers the Simplex algorithm in most of the detail provided in the short text An Illustrated Guide to Linear Programming but also includes information on the Ellipsoid algorithm, which can be more efficient for more complex constraint systems.
There's nothing inherently C#-specific about your question, but tagging it with that implies you're looking for a solution in C#; accordingly, reviewing the source code to the two toolkits above may serve you well.