我正在编写这个投资问题声明,在制定约束方程时遇到了困难。
"设x1、x2、x3和x4表示如果经纪人选择在投资选项1、2、3、4中投资或不投资,则为二进制变量。假设broker有以下约束:
*if x3 + x4 ge 1 Then x1 + x2 = 1 and if x3 + x4 = 0 then x1 + x2 ge 0*
如何结合上述约束条件?
我会让你做最后的检查,但基本上这应该像一样工作
"The constraints is if X3 + X4 ge 1 Then x1 + X2 = 1."
这相当于:
(x3 or x4) implies ((x1 and not x2) or (not x1 and x2))
- (x3 or x4) captures the >= 1
- x1 + x2 = 1 is an XOR and captured by ((x1 and not x2) or (not x1 and x2))
- DNF of XOR
让我们让WolframAlpha做布尔最小化:计算->我们对CNF感兴趣
- The CNF produced is ready to be mapped to ILP as it's a conjunction of ORs
- Each OR is a term of it's literals summing up to >= 1:
(1 - x1) + (1 - x2) + (1 - x3) >= 1
(1 - x1) + (1 - x2) + (1 - x4) >= 1
x1 + x2 + (1 - x3) >= 1
x1 + x2 + (1 - x4) >= 1
这应该是一个相当紧凑/强烈的公式!
我建议用真值表仔细检查一下。