求解器中的线性优化二元约束公式

Linear optimization binary constraints formulation in Solver

我正在研究这个投资问题陈述并且在制定约束方程时遇到困难。

"设 x1、x2、x3 和 x4 表示 经纪人选择投资或不投资投资选项 1、2、3、4 的二元变量。假设经纪人有以下约束:

*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 to do boolean minimization: Computation -> 我们对 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

这应该是一个相当紧凑/强大的公式!

我建议用 Truth Table 仔细检查它。