【问题标题】:Linear optimization binary constraints formulation in SolverSolver 中的线性优化二元约束公式
【发布时间】:2023-03-06 01:19:01
【问题描述】:
我正在研究这个投资问题陈述,并且在制定约束方程时遇到了困难。
"让 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*
如何结合以上约束?
【问题讨论】:
标签:
optimization
mathematical-optimization
linear-programming
solver
mixed-integer-programming
【解决方案1】:
我会让你做最后的检查,但基本上这应该是这样的:
"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 做布尔最小化: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 仔细检查。