简体   繁体   English

在 MILP/MIP 中建模 if-then-else-逻辑

[英]Modelling if-then-else-logic in MILP/MIP

I would like to model the following for a mixed-integer linear programming problem : Let y be a binary and x1 and x2 be continuous variables, whereas k1 is an invariant parameter.我想为混合整数线性规划问题建模以下内容:令 y 为二进制,x1 和 x2 为连续变量,而 k1 为不变参数。

if y == 1 then:  
    x2 = k1*x1   
else (y == 0):  
    x2 = 0

First idea that comes to mind is to do something like:想到的第一个想法是做类似的事情:

x2 >= k1*x1 - M*(1-y)  
x2 <= k1*x1 - M*(1-y)

But here M would have to be k1*x1 and is therefore not an invariant parameter anymore.但这里 M 必须是 k1*x1,因此不再是不变参数。 Does anyone have a better idea.有没有人有更好的主意。 Thank you!谢谢!

Per your problem: y: binary_variable x1: continous_variable x2: continous_variable根据你的问题: y: binary_variable x1: continous_variable x2: continous_variable

Please see equations below:请参见下面的等式:

x2 <= u*y
x2 <= k1*x1
x2 >= k1*x1 − u*(1 − y)
x2 >= 0

u is the upper bound on k1*x1
0 <= k1*x1 <= u

you don't require a big M over here.你在这里不需要大M。

when y == 1 => x2 == k1*x1当 y == 1 => x2 == k1*x1
when y == 0 => x2 == 0当 y == 0 => x2 == 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM