最小化受平等和完整性约束的3个变量的总和 [英] Minimizing the sum of 3 variables subject to equality and integrality constraints
问题描述
我正在研究一个编程(使用Python)问题,我必须在3个变量中解决以下类型的线性方程:
I am working on a programming (using Python) problem where I have to solve the following type of linear equation in 3 variables:
x,y,z都是整数.
x, y, z are all integers.
方程式示例:2x + 5y + 8z = 14
条件:Minimize x + y + z
我一直在尝试寻找一种算法,以最佳的方式找到解决方案.如果有人有任何想法,请通过算法或代码源指导我.
I have been trying to search for an algorithm for finding a solution to this, in an optimum way. If anybody has any idea please guide me through algorithm or code-sources.
我很好奇,如果将此问题外推到n个变量,该怎么办?
I am just curious, what can be done if this problem is extrapolated to n variables?
我不想使用hit&试用循环以继续检查值.同样,可能存在方程式无解的情况.
I don't want to use hit & trial loops to keep checking for values. Also, there may be a scenario that equation has no solution.
更新
添加下限条件:
x, y, z >= 0
x, y, z are natural
推荐答案
任何三元组(x,y,z),其中 z =(14-2x-5y)/8 ,满足您的约束.
Any triple (x, y, z), with z = (14 - 2x - 5y) / 8, satisfies your constraint.
请注意, x + y +(14-2x-5y)/8 从下面是不受限制的.当 x 和 y 均减小时,该函数减小,而没有最小值限制.
Note that x + y + (14 - 2x - 5y) / 8 is unbounded from below. This function decreases when each of x and y decrease, with no finite minimum.
这篇关于最小化受平等和完整性约束的3个变量的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!