我正在尝试建立遵循此逻辑的线性约束
如果x1 = 1或x2 = 1则y1 = 1
但是如果x1 = 0和x2 = 0,则y1 = 0
如果同时x1 = 1和x2 = 1,则y1 = 1
假设:
x1, x2 are binary-variables / integer-variables in [0, 1]
真值表如下:
x1 x2 || y1
----------------
0 0 || 0
0 1 || 1
1 0 || 1
1 1 || 1
这就是:
y1 = x1 OR x2
这是微不足道的线性化(请参见relevant answer on cs.stackexchange.com:]
y1 = binary-var / (could be integer-var too)
y1 <= x1 + x2
y1 >= x1
y1 >= x2