我想用二进制变量来最大化毛利率(总利润/总收入),比如产品是否会被混合,即变量将是1还是0(二进制),试图用Gekko混合整数非线性规划来求解
下面是3个产品的示例,我们希望保留任意2个产品
3个产品的变量:x1、x2和x3
利润总额=150*x1+120*x2+100*x3
总收入=200*x1+150x2+250*x3
毛利率=总利润/总收入
solution tried个
m = GEKKO()
x1 = m.Var(integer=True, lb=0, ub=1)
x2 = m.Var(integer=True, lb=0, ub=1)
x3 = m.Var(integer=True, lb=0, ub=1)
m.Maximize((150*x1 + 120*x2 + 100*x3)/(200*x1 + 150*x2 + 250*x3))
m.Equation(x1 + x2 + x3 == 2)
m.options.SOLVER = 1
m.solve()
result个
x1: 0
x2: 0
x3: 0
objective function: nan
things tried个
i) tried with adding one more constraint with the denominator > 0, getting same solution
ii) tried with changing lb=0 to any other integer value and it is working (say lb=1, ub=2), not sure if anything particularly needs to be added for using lb=0
ii) tried absolute profit maximization (removing the denominator) and it is working fine
如有任何帮助,我们将不胜感激,并预先表示感谢