逻辑或
-
a T x ≤ c o r b T x ≥ d \mathbf{a^Tx} \leq c \quad or \quad \mathbf{b^Tx} \geq d aTx≤corbTx≥d
等价于
a T x ≤ c + M ( 1 − u ) b T x ≥ d − M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \leq c + M(1-u) \\ \mathbf{b^Tx} \geq d -M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≤c+M(1−u)bTx≥d−M(1−v)u+v≤1u,v∈{0,1} -
a T x ≤ c o r b T x ≤ d \mathbf{a^Tx} \leq c \quad or \quad \mathbf{b^Tx} \leq d aTx≤corbTx≤d
等价于
a T x ≤ c + M ( 1 − u ) b T x ≤ d + M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \leq c + M(1-u) \\ \mathbf{b^Tx} \leq d + M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≤c+M(1−u)bTx≤d+M(1−v)u+v≤1u,v∈{0,1} -
a T x ≥ c o r b T x ≥ d \mathbf{a^Tx} \geq c \quad or \quad \mathbf{b^Tx} \geq d aTx≥corbTx≥d
等价于
a T x ≥ c − M ( 1 − u ) b T x ≥ d − M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \geq c - M(1-u) \\ \mathbf{b^Tx} \geq d - M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≥c−M(1−u)bTx≥d−M(1−v)u+v≤1u,v∈{0,1} -
a T x = c o r b T x = d \mathbf{a^Tx} = c \quad or \quad \mathbf{b^Tx} = d aTx=corbTx=d
等价于
a T x ≤ c + M ( 1 − u ) b T x ≤ d + M ( 1 − v ) , b T x ≥ d + M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \leq c + M(1-u)\\ \mathbf{b^Tx} \leq d + M(1-v), \mathbf{b^Tx} \geq d + M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≤c+M(1−u)bTx≤d+M(1−v),bTx≥d+M(1−v)u+v≤1u,v∈{0,1} -
a T x ≤ c o r b T x = d \mathbf{a^Tx} \leq c \quad or \quad \mathbf{b^Tx} = d aTx≤corbTx=d
等价于
a T x ≤ c + M ( 1 − u ) b T x ≤ d + M ( 1 − v ) , b T x ≥ d + M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \leq c + M(1-u)\\ \mathbf{b^Tx} \leq d + M(1-v), \mathbf{b^Tx} \geq d + M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≤c+M(1−u)bTx≤d+M(1−v),bTx≥d+M(1−v)u+v≤1u,v∈{0,1} -
a T x ≥ c o r b T x = d \mathbf{a^Tx} \geq c \quad or \quad \mathbf{b^Tx} = d aTx≥corbTx=d
等价于
a T x ≥ c − M ( 1 − u ) b T x ≤ d + M ( 1 − v ) , b T x ≥ d + M ( 1 − v ) u + v ≤ 1 u , v ∈ { 0 , 1 } \mathbf{a^Tx} \geq c - M(1-u)\\ \mathbf{b^Tx} \leq d + M(1-v), \mathbf{b^Tx} \geq d + M(1-v) \\ u+v \leq 1\\ u,v \in \{0,1\} aTx≥c−M(1−u)bTx≤d+M(1−v),bTx≥d+M(1−v)u+v≤1u,v∈{0,1}
if…elif…else…
情形1
i
f
if
if
A
x
−
b
≤
0
A\mathbf{x} - \mathbf{b} \leq 0
Ax−b≤0
t
h
e
n
then
then
C
1
x
−
b
≤
0
C_1\mathbf{x} - \mathbf{b} \leq 0
C1x−b≤0
e
l
s
e
else
else
C
2
x
−
b
≤
0
C_2\mathbf{x} - \mathbf{b} \leq 0
C2x−b≤0
等价于
A
x
−
b
≤
(
1
−
u
)
M
C
1
x
−
d
1
≤
(
1
−
u
)
M
C
2
x
−
d
2
≤
u
M
u
∈
{
0
,
1
}
\mathbf{Ax} - \mathbf{b} \leq (1-u)M\\ \mathbf{C}_1\mathbf{x} - \mathbf{d}_1 \leq (1-u)M\\ \mathbf{C}_2\mathbf{x} - \mathbf{d}_2 \leq uM\\ u\in\{0,1\}
Ax−b≤(1−u)MC1x−d1≤(1−u)MC2x−d2≤uMu∈{0,1}
情形2
i
f
if
if
x
≥
y
x \geq y
x≥y
t
h
e
n
then
then
z
=
w
1
z = w_1
z=w1
e
l
s
e
else
else
z
=
w
2
z = w_2
z=w2
等价于
x
≥
y
−
M
(
1
−
b
)
x
<
y
+
M
b
w
1
−
M
(
1
−
b
)
≤
z
≤
w
1
+
M
(
1
−
b
)
w
2
−
M
b
≤
z
≤
w
2
+
M
b
b
∈
{
0
,
1
}
x \geq y -M(1-b) \\ x < y + Mb\\ w_1-M(1-b) \leq z \leq w_1+M(1-b) \\ w_2-Mb \leq z \leq w_2+Mb\\b\in\{0,1\}
x≥y−M(1−b)x<y+Mbw1−M(1−b)≤z≤w1+M(1−b)w2−Mb≤z≤w2+Mbb∈{0,1}
情形3
i
f
if
if
x
>
y
x > y
x>y
t
h
e
n
then
then
z
=
w
1
z = w_1
z=w1
e
l
s
e
else
else
z
=
w
2
z = w_2
z=w2
等价于
x
>
y
+
0.0001
−
M
(
1
−
b
)
x
≤
y
+
M
b
w
1
−
M
(
1
−
b
)
≤
z
≤
w
1
+
M
(
1
−
b
)
w
2
−
M
b
≤
z
≤
w
2
+
M
b
b
∈
{
0
,
1
}
x > y+0.0001 -M(1-b) \\ x \leq y + Mb\\ w_1-M(1-b) \leq z \leq w_1+M(1-b) \\ w_2-Mb \leq z \leq w_2+Mb\\b\in\{0,1\}
x>y+0.0001−M(1−b)x≤y+Mbw1−M(1−b)≤z≤w1+M(1−b)w2−Mb≤z≤w2+Mbb∈{0,1}
连续性表述
如果一个需求
j
j
j可以在各个节点
i
i
i切换状态,约束要求最多只能有1次状态切换,可以引入0-1变量表示
y
j
i
y_{ji}
yji状态是否切换变量,
x
j
i
x_{ji}
xji表示需求
j
j
j在节点
i
i
i是否有某种情况,可以建立以下约束:
y
j
i
≥
x
j
i
−
x
j
(
i
−
1
)
,
∀
i
∈
I
,
∀
j
∈
J
∑
i
y
j
i
≤
1
,
∀
j
∈
J
x
j
i
∈
{
0
,
1
}
,
y
j
i
∈
{
0
,
1
}
y_{ji} \geq x_{ji}-x_{j(i-1)} , \quad \forall i \in I, \forall j \in J\\ \sum_{i} y_{ji}\leq1, \quad \forall j \in J\\ x_{ji} \in \{0,1\},\quad y_{ji} \in \{0,1\}
yji≥xji−xj(i−1),∀i∈I,∀j∈Ji∑yji≤1,∀j∈Jxji∈{0,1},yji∈{0,1}
可以借用这个表格来进行解释