跳到正文

算法·理论

线性规划对偶笔记

zhiyin123约 5 分钟
原文
文章信息与版本

文章信息

发布
2024年12月9日
收录
2026年7月31日
更新
2026年11月15日
篇幅
约 5 分钟

版本

  1. v1当前

线性规划问题

有变量 x1,x2,…,xnx_1,x_2,\dots,x_n 和 mm 个约束条件,你需要最大(或者小)化函数 zz:

max⁡ z=c1x1+c2x2+⋯+cnxn{a1,1x1+a1,2x2+⋯+a1,nxn≤b1a2,1x1+a2,2x2+⋯+a2,nxn≤b2⋯am,1x1+am,2x2+⋯+am,nxn≤bmx1,x2,⋯ ,xn≥0\begin{gathered} \max \ z = c_1 x_1 + c_2 x_2 + \cdots + c_n x _n \\ \left\{ \begin{gathered} a_{1,1} x_1 + a_{1,2} x_2 + \cdots + a_{1,n} x_n \leq b_1\\ a_{2,1} x_1 + a_{2,2} x_2 + \cdots + a_{2,n} x_n \leq b_2\\ \cdots \\ a_{m,1} x_1 + a_{m,2} x_2 + \cdots + a_{m,n} x_n \leq b_m\\ \end{gathered} \right. \\ x_1,x_2,\cdots,x_n \geq 0 \end{gathered}

其中 ∀i,j\forall i,j,xi,ci,ai,j,bj∈Rx_i,c_i,a_{i,j},b_j\in \mathbb{R}。

不妨设 x=[x1x2⋮xn],c=[c1c2⋮cn],b=[b1b2⋮bm],A=[a1,1a1,2⋯a1,na1,1a1,2⋯a1,n⋮am,1am,2⋯am,n]\displaystyle x = \left[\begin{matrix}x_1\\ x_2\\ \vdots\\ x_n\end{matrix}\right],c = \left[\begin{matrix}c_1\\ c_2\\ \vdots\\ c_n\end{matrix}\right],b = \left[\begin{matrix}b_1\\ b_2\\ \vdots\\ b_m\end{matrix}\right],A = \left[\begin{matrix}a_{1,1} & a_{1,2} & \cdots & a_{1,n}\\ a_{1,1} & a_{1,2} & \cdots & a_{1,n}\\ & & \vdots & \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n}\end{matrix}\right], 则可把线性规划写成:

max⁡ z=cTxAx≤bx≥0\begin{gathered} \max \ z = c ^ T x \\ A x \leq b \\ x \geq 0 \end{gathered}

对偶

问题

max⁡ z=cTxAx≤bx≥0\begin{gathered} \max \ z = c ^ T x \\ A x \leq b \\ x \geq 0 \end{gathered}

的对偶是:(yy 是变量)

min⁡ f=bTyATy≥cy≥0\begin{gathered} \min \ f = b ^ T y \\ A ^ T y \geq c \\ y \geq 0 \end{gathered}

有性质 z≤fz \leq f,并且可以取等。

对偶的运筹学意义

原问题

公司要制作 nn 种物品,第 ii 种物品制造 xix_i 个;其中,第 ii 种物品的售价为 cic_i;你需要最大化总售价 zz(假设所有制造的物品都会被卖出);不过,共有 mm 种原料,第 jj 种原料公司有 bjb_j 个,制作第 ii 个物品要使用 ai,ja_{i,j} 个原料 jj。

对偶问题

你要购买公司的 mm 种原料,第 jj 种原料单价为 yjy_j;其中,第 jj 种原料公司有 bjb_j 个,你要都买下来;你需要最小化总费用 ff;不过,对于第 ii 个物品,你使用购买的原料制造它时,成本必须不小于公司的售价,否则公司就会不同意交易。

对偶性的代数证明

我们要证的是 z≤fz \leq f,并且不等式可以取等。

不妨把问题写成如下形式,原问题:

max⁡ z=∑i=1ncixi∀j, ∑i=1nai,jxi≤bj∀i, xi≥0\begin{gathered} \max \ z = \sum_{i = 1} ^ n c_i x_i \\ \forall j,\ \sum_{i = 1} ^ n a_{i, j} x_i \leq b_j \\ \forall i,\ x_i \geq 0 \end{gathered}

对偶问题:

min⁡ f=∑j=1mcjyj∀i, ∑j=1mai,jyj≥ci∀j, yj≥0\begin{gathered} \min \ f = \sum_{j = 1} ^ m c_j y_j \\ \forall i,\ \sum_{j = 1} ^ m a_{i, j} y_j \geq c_i \\ \forall j,\ y_j \geq 0 \end{gathered}

对于 ∀j, ∑i=1nai,jxi≤bj\displaystyle \forall j,\ \sum_{i = 1} ^ n a_{i, j} x_i \leq b_j,我们可以先将等号两边同时乘 yjy_j,得到 ∀j, ∑i=1nai,jxiyj≤bjyj\displaystyle \forall j,\ \sum_{i = 1} ^ n a_{i, j} x_i y_j \leq b_j y_j,然后累加,得到 ∑i=1n∑j=1mai,jxiyj≤∑j=1mbjyj\displaystyle \sum_{i = 1} ^ n \sum_{j = 1} ^ m a_{i, j} x_i y_j \leq \sum_{j = 1} ^ m b_j y_j。

同理,也可以通过 ∀i, ∑j=1mai,jyj≥ci\displaystyle \forall i,\ \sum_{j = 1} ^ m a_{i, j} y_j \geq c_i 得到 ∑i=1n∑j=1mai,jxiyj≥∑i=1ncixi\displaystyle \sum_{i = 1} ^ n \sum_{j = 1} ^ m a_{i, j} x_i y_j \geq \sum_{i = 1} ^ n c_i x_i。

这样,就可以得到 ∑i=1ncixi≤∑j=1mbjyj\displaystyle \sum_{i = 1} ^ n c_i x_i \leq \sum_{j = 1} ^ m b_j y_j,即 z≤fz \leq f。

那么是否一定能取等呢?我不会证捏

原文