第 12 章

线性规划入门:建模、标准形与对偶

用饮食与烘焙两个问题写出线性规划,说明标准形与规范形之间如何互相转换,再从「把约束加权相加」推出对偶规划,并证明弱对偶。

Introduction to Linear Programming: Modelling, Standard Form and Duality

We build linear programs for a diet problem and a bake sale, convert freely between standard and canonical form, then derive the dual by weighting constraints and prove weak duality.

首发于 2025.12.18中 / EN
系统课程optimizationlinear-programmingdualitymodeling
语言
字号
目录
篇内目录

线性规划在做什么

线性规划(LP)就是:在线性约束下,最大化或最小化一个线性函数。它是整个优化的发动机——课程提到,1987 年 CPLEX 问世后成为最赚钱的求解器之一,背后的商业价值说明了它的地位。

本讲做四件事:写两个模型、定义标准形与规范形、说明两者如何互转、推出对偶。

时间轴

时间内容
0:00线性规划的地位与用途
1:54饮食问题:营养需求与两种谷物
10:04烘焙问题:曲奇与蛋白饼
14:55可行解、最优解;在平面上画可行域
19:39标准形与规范形
22:16任意 LP 化归为两种形式的四类变换
28:44为什么需要两种形式:单纯形法用标准形,对偶用规范形
31:17基本可行解与单纯形法的思路
41:18对偶:从约束的加权组合得到上界
57:26规范形的对偶公式
59:53弱对偶定理及其证明
1:02:26强对偶定理(陈述)
1:06:48对偶的对偶是原问题

例一:饮食问题

给小鼠配餐。需要 88 单位淀粉、1515 单位蛋白质、77 单位维生素。谷物 1 每单位提供 (5,4,2)(5,4,2),价格 0.600.60;谷物 2 每单位提供 (7,2,1)(7,2,1),价格 0.350.35。

设 x1,x2x_1,x_2 分别是两种谷物的用量。模型:

min⁡60x1+35x2s.t.5x1+7x2≥8(淀粉)4x1+2x2≥15(蛋白质)2x1+x2≥7(维生素)x1,x2≥0.\begin{aligned} \min\quad & 60x_1+35x_2\\ \text{s.t.}\quad & 5x_1+7x_2\ge 8 &&\text{(淀粉)}\\ & 4x_1+2x_2\ge 15 &&\text{(蛋白质)}\\ & 2x_1+x_2\ge 7 &&\text{(维生素)}\\ & x_1,x_2\ge 0 . \end{aligned}

(价格按美分计。)最后一行的非负约束容易被忘掉,但它不是装饰:没有它,模型可以把 x1=−100x_1=-100 当作「省钱」的解,而负的谷物用量没有物理意义。线性规划软件通常把非负约束单独处理。

建模的固定套路:先选变量,再写目标函数,再写约束,最后交给求解器。本课不教怎么手算求解——实际工作中你也不会手算。

例二:烘焙问题

卖曲奇和蛋白饼。一批曲奇需要 11 个蛋、22 杯糖、1.51.5 杯面粉;一批蛋白饼需要 33 个蛋、11 杯糖、00 杯面粉。现有 99 个蛋、88 杯糖、1515 杯面粉。两批都卖 2020 美元。

设 x1x_1 为曲奇批数,x2x_2 为蛋白饼批数:

max⁡20x1+20x2s.t.x1+3x2≤9(蛋)2x1+x2≤8(糖)1.5x1≤15(面粉)x1,x2≥0.\begin{aligned} \max\quad & 20x_1+20x_2\\ \text{s.t.}\quad & x_1+3x_2\le 9 &&\text{(蛋)}\\ & 2x_1+x_2\le 8 &&\text{(糖)}\\ & 1.5x_1\le 15 &&\text{(面粉)}\\ & x_1,x_2\ge 0 . \end{aligned}

可行域。 两条变量时可以直接画。第一条约束的边界过 (0,3)(0,3) 与 (9,0)(9,0);第二条过 (0,8)(0,8) 与 (4,0)(4,0)。面粉约束 x1≤10x_1\le10 完全多余:满足前两条的点一定满足它。可行域是这两条直线与坐标轴围成的四边形。

可行解是满足全部约束的点(不必最优);最优解是使目标函数最优的可行解。例如 (2,2)(2,2) 可行,目标值 8080;(3,2)(3,2) 也可行,目标值 100100。后面会证明 100100 就是最优值。

两种标准形式

标准形(standard form):

max⁡  cTxs.t.Ax=b,    x≥0.\max\; c^Tx \quad\text{s.t.}\quad Ax=b,\;\; x\ge0 .

规范形(canonical form):

max⁡  cTxs.t.Ax≤b,    x≥0.\max\; c^Tx \quad\text{s.t.}\quad Ax\le b,\;\; x\ge0 .

定理。 任何线性规划都可以化成标准形或规范形。

四类变换:

1. 最小化改最大化。 min⁡3x1+5x2\min 3x_1+5x_2 等价于 max⁡−3x1−5x2\max -3x_1-5x_2,最优解相同,最优值取相反数。

2. 自由变量拆成两个非负变量。 若 xix_i 可正可负,令

xi=xi+−xi−,xi+,xi−≥0.x_i=x_i^+-x_i^-,\qquad x_i^+,x_i^-\ge0 .

任意实数都能写成两个非负数之差(例如 −3=0−3-3=0-3),于是所有变量都非负。

3. 不等式加松弛/剩余变量变等式。

x1+3x2≤9  ⟺  x1+3x2+s=9,s≥0,x_1+3x_2\le9 \;\Longleftrightarrow\; x_1+3x_2+s=9,\quad s\ge0 ,

其中 ss 叫松弛变量。

x1+3x2≥9  ⟺  x1+3x2−s=9,s≥0,x_1+3x_2\ge9 \;\Longleftrightarrow\; x_1+3x_2-s=9,\quad s\ge0 ,

其中 ss 叫剩余变量。

4. 等式拆成两个不等式,≥\ge 用取负号变 ≤\le。

x1+3x2=9  ⟺  x1+3x2≤9 且 x1+3x2≥9,x_1+3x_2=9 \;\Longleftrightarrow\; x_1+3x_2\le9 \ \text{且}\ x_1+3x_2\ge9 ,

而 x1+3x2≥9x_1+3x_2\ge9 再写成 −x1−3x2≤−9-x_1-3x_2\le-9,就落进规范形。

两个形式的分工:单纯形法用标准形,因为要解线性方程组找基本可行解;对偶理论用规范形,因为约束全是 ≤\le,加权相加时不等号方向一致。

基本可行解与单纯形法

定理。 有最优解的线性规划,一定存在基本可行解是最优解。

几何上,基本可行解就是可行域的顶点。回忆烘焙问题的可行域是个四边形,四个顶点中必有一个使 20x1+20x220x_1+20x_2 最大。

为什么叫「基本」?把 LP 写成标准形,每个松弛变量对应一列。选一组线性无关的列构成基,令其余变量为 00,解出基变量,就得到一个基本解;若它非负,就是基本可行解。

单纯形法:从一个基本可行解出发,沿可行域的棱走到相邻顶点,每步都让目标函数变大,直到没有更好的邻点。Dantzig 提出后实践效果极好,但很长一段时间里,对任何选边策略都能构造出需要指数步的例子。直到 Spielman 与 Teng 提出平滑分析,才在理论上说明了「几乎总是很快」。

对偶:从约束组合得到上界

回到烘焙问题。可行解给出下界:(3,2)(3,2) 可行,目标值 100100,所以最优值至少 100100。

上界从哪来? 把约束加权相加。取权重 y1=4y_1=4、y2=8y_2=8:

4(x1+3x2)+8(2x1+x2)=20x1+20x2.4(x_1+3x_2)+8(2x_1+x_2)=20x_1+20x_2 .

左边两个括号分别不超过 99 与 88,而系数非负,所以

20x1+20x2≤4⋅9+8⋅8=36+64=100.20x_1+20x_2\le4\cdot9+8\cdot8=36+64=100 .

上下界相等,最优值确定为 100100。这组权重就是对偶最优解,它同时是一个「最优性证书」。

一般地,对规范形

max⁡  cTxs.t.Ax≤b,  x≥0,\max\; c^Tx\quad\text{s.t.}\quad Ax\le b,\;x\ge0,

取 y≥0y\ge0 作权重,把第 ii 行乘以 yiy_i 再相加。要让左边能够覆盖目标函数的系数,需要

ATy≥c.A^Ty\ge c .

在这些条件下,

cTx≤(ATy)Tx=yTAx≤yTb,c^Tx\le (A^Ty)^Tx=y^TAx\le y^Tb,

于是 yTby^Tb 是一个上界。要让上界尽可能紧,就求

min⁡  bTys.t.ATy≥c,  y≥0.\min\; b^Ty\quad\text{s.t.}\quad A^Ty\ge c,\;y\ge0 .

这就是对偶规划。原问题与对偶的对应关系:

原问题(规范形)对偶问题
最大化 cTxc^Tx最小化 bTyb^Ty
约束矩阵 AA转置 ATA^T
约束右端 bb变成目标函数系数
目标系数 cc变成约束右端
x≥0x\ge0y≥0y\ge0

为什么 y≥0y\ge0?因为如果某个 yi<0y_i<0,乘上 ≤\le 约束会翻转不等号,相加就没有意义了。

弱对偶与强对偶

弱对偶定理。 若 xx 是原问题可行解、yy 是对偶可行解,则

cTx≤bTy.c^Tx\le b^Ty .

证明。 由对偶可行性 ATy≥cA^Ty\ge c,两边左乘 xT≥0x^T\ge0:

cTx≤(ATy)Tx=yTAx.c^Tx\le (A^Ty)^Tx=y^TAx .

由原问题可行性 Ax≤bAx\le b 及 y≥0y\ge0,左乘 yTy^T:

yTAx≤yTb.y^TAx\le y^Tb .

串联起来即得。整个证明只用了「非负权重乘不等号不翻向」这一件事。

强对偶定理(陈述,下一讲证明)。 若原问题的最优值 z∗z^* 有限,则对偶最优值 w∗w^* 也有限,且 z∗=w∗z^*=w^*。

对偶的对偶是原问题。 把对偶 min⁡bTy\min b^Ty、ATy≥cA^Ty\ge c、y≥0y\ge0 先化成规范形(取负号变最大化、变 ≤\le),再取对偶,得到 min⁡−cTx\min-c^Tx、−Ax≥−b-Ax\ge-b、x≥0x\ge0;再取负号就回到原问题。名字「对偶」由此而来。

本节结论

  • 线性规划 = 线性目标 + 线性约束 + 非负约束;建模顺序是变量、目标、约束。
  • 标准形是 Ax=b, x≥0Ax=b,\ x\ge0;规范形是 Ax≤b, x≥0Ax\le b,\ x\ge0;两者可以互相转换。
  • 转换四招:取负、拆自由变量、加松弛/剩余变量、等式拆成两个不等式。
  • 基本可行解是可行域的顶点,单纯形法沿棱走到最优顶点。
  • 对偶 = 用非负权重把约束相加,得到最优值的上界;权重就是灵敏度。
  • 弱对偶:任何原可行值不超过任何对偶可行值。

理解检验

1. 写出饮食问题的完整模型,并说明为什么非负约束不能省。

参考答案:

min⁡ 60x1+35x2s.t.5x1+7x2≥8,  4x1+2x2≥15,  2x1+x2≥7,  x1,x2≥0.\min\ 60x_1+35x_2\quad\text{s.t.}\quad 5x_1+7x_2\ge8,\;4x_1+2x_2\ge15,\;2x_1+x_2\ge7,\;x_1,x_2\ge0 .

省掉 x1,x2≥0x_1,x_2\ge0 后,模型允许负的用量,而负用量可以减少「成本」、又能无限制地满足 ≥\ge 约束(取足够负的值也不行——实际上会让营养约束更难过,但目标会趋向 −∞-\infty,问题变成无界或荒谬)。更本质的理由是:用量在物理上不能为负,非负性属于问题本身,而不是求解技巧。

2. 把下面的问题化成规范形:min⁡3x1+5x2\min 3x_1+5x_2,约束 x1+x2≥4x_1+x_2\ge4,x1−2x2≤6x_1-2x_2\le6,x1≥0x_1\ge0,x2x_2 自由。

参考答案:先令 x2=x2+−x2−x_2=x_2^+-x_2^-,x2±≥0x_2^\pm\ge0;再把最小化取负变最大化;最后把 ≥\ge 约束两边取负:

max⁡ −3x1−5x2++5x2−s.t.−x1−x2++x2−≤−4,    x1−2x2++2x2−≤6,    x1,x2+,x2−≥0.\max\ -3x_1-5x_2^++5x_2^- \quad\text{s.t.}\quad -x_1-x_2^++x_2^-\le-4,\;\; x_1-2x_2^++2x_2^-\le6,\;\; x_1,x_2^+,x_2^-\ge0 .

3. 用松弛变量把 x1+3x2≤9x_1+3x_2\le9 写成等式;如果是 ≥9\ge9,又该怎么写?

参考答案:≤\le 引入松弛变量 s≥0s\ge0,写成 x1+3x2+s=9x_1+3x_2+s=9;≥\ge 引入剩余变量 s≥0s\ge0,写成 x1+3x2−s=9x_1+3x_2-s=9。两者都保持「原不等式与等式解集相同」。

4. 对烘焙问题,给出一个可行解、一个上界证书,并说明最优值。

参考答案:可行解 x=(3,2)x=(3,2):3+6=93+6=9,6+2=86+2=8,满足全部约束,目标值 100100。上界证书取对偶可行解 y=(4,8)y=(4,8):4(x1+3x2)+8(2x1+x2)=20x1+20x2≤4⋅9+8⋅8=1004(x_1+3x_2)+8(2x_1+x_2)=20x_1+20x_2\le4\cdot9+8\cdot8=100;对偶约束为 y1+2y2=4+16=20≥20y_1+2y_2=4+16=20\ge20、3y1+y2=12+8=20≥203y_1+y_2=12+8=20\ge20,非负。上下界相等,故最优值为 100100。

5. 证明弱对偶。

参考答案:由 ATy≥cA^Ty\ge c 与 x≥0x\ge0 得 cTx≤(ATy)Txc^Tx\le (A^Ty)^Tx;由 (ATy)Tx=yTAx(A^Ty)^Tx=y^TAx、Ax≤bAx\le b 与 y≥0y\ge0 得 yTAx≤yTby^TAx\le y^Tb。串联:cTx≤yTAx≤yTbc^Tx\le y^TAx\le y^Tb,即原问题任意可行值不超过对偶任意可行值。

6. 为什么把等式拆成两个不等式,而不是别的方式?

参考答案:等式 aTx=ba^Tx=b 与「aTx≤ba^Tx\le b 且 aTx≥ba^Tx\ge b」完全等价,这是集合层面的等价,不引入新变量。而规范形只允许 ≤\le,所以再把 aTx≥ba^Tx\ge b 写成 −aTx≤−b-a^Tx\le-b。这样写的好处是每条约束的权重符号规则统一,取对偶时不必特殊处理。

与前后课的关系

本讲建立了模型与对偶的框架,但把强对偶留作结论。下一讲给出强对偶的三种证明思路(单纯形表、Farkas 引理、力学类比),并用互补松弛从原问题最优解反推对偶最优解,最后用它证明二分图的 König 定理。再往后,对偶会直接变成零和博弈的极小极大定理与最大流最小割定理。

What linear programming does

A linear program (LP) is: maximise or minimise a linear function subject to linear constraints. It is the engine behind a great deal of optimisation — the lecture notes that when CPLEX appeared in 1987 it became the dominant solver, and the commercial sums involved show how much it matters.

This lecture does four things: writes two models, defines standard and canonical form, shows how to convert between them, and derives the dual.

Timeline

TimeTopic
0:00Why linear programming matters
1:54The diet problem: nutritional requirements and two grains
10:04The bake sale: cookies and meringues
14:55Feasible and optimal solutions; drawing the feasible region
19:39Standard form and canonical form
22:16Four transformations that put any LP into either form
28:44Why two forms: simplex needs standard form, duality needs canonical form
31:17Basic feasible solutions and the idea of the simplex method
41:18Duality: upper bounds from weighted combinations of constraints
57:26The dual formula for canonical form
59:53Weak duality and its proof
1:02:26Strong duality (statement)
1:06:48The dual of the dual is the primal

Example 1: the diet problem

Feed some mice. They need 88 units of starch, 1515 of protein and 77 of vitamins. Grain 1 supplies (5,4,2)(5,4,2) per unit at 0.600.60; grain 2 supplies (7,2,1)(7,2,1) at 0.350.35.

Let x1,x2x_1,x_2 be the amounts of the two grains:

min⁡60x1+35x2s.t.5x1+7x2≥8(starch)4x1+2x2≥15(protein)2x1+x2≥7(vitamins)x1,x2≥0.\begin{aligned} \min\quad & 60x_1+35x_2\\ \text{s.t.}\quad & 5x_1+7x_2\ge 8 &&\text{(starch)}\\ & 4x_1+2x_2\ge 15 &&\text{(protein)}\\ & 2x_1+x_2\ge 7 &&\text{(vitamins)}\\ & x_1,x_2\ge 0 . \end{aligned}

(Prices in cents.) The final line, the non-negativity constraints, is easy to forget and is not decoration: without it the model can regard a negative amount of grain as a saving, while negative grain has no physical meaning. Solvers usually treat non-negativity separately from the other constraints.

The modelling recipe is fixed: choose variables, write the objective, write the constraints, hand it to a solver. This course does not teach hand-solving — in practice you would not either.

Example 2: the bake sale

You sell cookies and meringues. A batch of cookies needs 11 egg, 22 cups of sugar and 1.51.5 cups of flour; a batch of meringues needs 33 eggs, 11 cup of sugar and no flour. You have 99 eggs, 88 cups of sugar and 1515 cups of flour. Each batch sells for \20$.

Let x1x_1 be batches of cookies and x2x_2 batches of meringues:

max⁡20x1+20x2s.t.x1+3x2≤9(eggs)2x1+x2≤8(sugar)1.5x1≤15(flour)x1,x2≥0.\begin{aligned} \max\quad & 20x_1+20x_2\\ \text{s.t.}\quad & x_1+3x_2\le 9 &&\text{(eggs)}\\ & 2x_1+x_2\le 8 &&\text{(sugar)}\\ & 1.5x_1\le 15 &&\text{(flour)}\\ & x_1,x_2\ge 0 . \end{aligned}

The feasible region. With two variables it can be drawn. The first constraint's boundary passes through (0,3)(0,3) and (9,0)(9,0); the second through (0,8)(0,8) and (4,0)(4,0). The flour constraint x1≤10x_1\le10 is redundant: every point satisfying the first two satisfies it. The feasible region is the quadrilateral cut out by the two lines and the axes.

A feasible solution satisfies all constraints (not necessarily optimally); an optimal solution optimises the objective among feasible points. For instance (2,2)(2,2) is feasible with value 8080, and (3,2)(3,2) is feasible with value 100100. We will see that 100100 is optimal.

Two standard forms

Standard form:

max⁡  cTxs.t.Ax=b,    x≥0.\max\; c^Tx \quad\text{s.t.}\quad Ax=b,\;\; x\ge0 .

Canonical form:

max⁡  cTxs.t.Ax≤b,    x≥0.\max\; c^Tx \quad\text{s.t.}\quad Ax\le b,\;\; x\ge0 .

Theorem. Any linear program can be put into standard or canonical form.

Four transformations:

1. Minimisation to maximisation. min⁡3x1+5x2\min 3x_1+5x_2 is equivalent to max⁡−3x1−5x2\max -3x_1-5x_2: same optimiser, objective negated.

2. Split a free variable. If xix_i may have either sign, set

xi=xi+−xi−,xi+,xi−≥0.x_i=x_i^+-x_i^-,\qquad x_i^+,x_i^-\ge0 .

Every real number is a difference of two non-negative numbers (for example −3=0−3-3=0-3), so all variables become non-negative.

3. Inequalities to equations with slack or surplus variables.

x1+3x2≤9  ⟺  x1+3x2+s=9,s≥0,x_1+3x_2\le9 \;\Longleftrightarrow\; x_1+3x_2+s=9,\quad s\ge0 ,

where ss is a slack variable, and

x1+3x2≥9  ⟺  x1+3x2−s=9,s≥0,x_1+3x_2\ge9 \;\Longleftrightarrow\; x_1+3x_2-s=9,\quad s\ge0 ,

where ss is a surplus variable.

4. Equations become two inequalities; ≥\ge becomes ≤\le after negation.

x1+3x2=9  ⟺  x1+3x2≤9 and x1+3x2≥9,x_1+3x_2=9 \;\Longleftrightarrow\; x_1+3x_2\le9 \ \text{and}\ x_1+3x_2\ge9 ,

and x1+3x2≥9x_1+3x_2\ge9 is rewritten as −x1−3x2≤−9-x_1-3x_2\le-9, which is canonical.

The division of labour: the simplex method uses standard form, since it solves linear systems to find basic feasible solutions; duality uses canonical form, since all constraints point the same way and can be added with non-negative weights.

Basic feasible solutions and the simplex method

Theorem. If a linear program has an optimal solution, then some basic feasible solution is optimal.

Geometrically, basic feasible solutions are the vertices of the feasible region. The bake-sale region is a quadrilateral, and one of its four vertices maximises 20x1+20x220x_1+20x_2.

Why "basic"? In standard form each slack variable contributes a column. Pick a linearly independent set of columns — a basis — set the remaining variables to zero, and solve for the basic variables. The result is a basic solution; if it is non-negative it is a basic feasible solution.

The simplex method starts at a basic feasible solution and walks along an edge of the feasible region to a neighbouring vertex, each step improving the objective, until no neighbour is better. Dantzig's method worked extremely well in practice, yet for a long time every pivot rule admitted examples requiring exponentially many steps. Spielman and Teng's smoothed analysis finally explained why it is fast almost always.

Duality: upper bounds from combining constraints

Back to the bake sale. A feasible solution gives a lower bound: (3,2)(3,2) is feasible with value 100100, so the optimum is at least 100100.

Where does an upper bound come from? Weight and add the constraints. Take y1=4y_1=4, y2=8y_2=8:

4(x1+3x2)+8(2x1+x2)=20x1+20x2.4(x_1+3x_2)+8(2x_1+x_2)=20x_1+20x_2 .

The two brackets are at most 99 and 88, and the weights are non-negative, so

20x1+20x2≤4⋅9+8⋅8=36+64=100.20x_1+20x_2\le4\cdot9+8\cdot8=36+64=100 .

The bounds meet, so the optimum is exactly 100100. Those weights form a dual optimal solution and act as a certificate of optimality.

In general, for canonical form

max⁡  cTxs.t.Ax≤b,  x≥0,\max\; c^Tx\quad\text{s.t.}\quad Ax\le b,\;x\ge0,

take weights y≥0y\ge0, multiply row ii by yiy_i and add. To cover the objective coefficients on the left we need

ATy≥c.A^Ty\ge c .

Under that condition,

cTx≤(ATy)Tx=yTAx≤yTb,c^Tx\le (A^Ty)^Tx=y^TAx\le y^Tb,

so yTby^Tb is an upper bound. The tightest such bound solves

min⁡  bTys.t.ATy≥c,  y≥0,\min\; b^Ty\quad\text{s.t.}\quad A^Ty\ge c,\;y\ge0 ,

the dual program. The correspondence:

Primal (canonical)Dual
Maximise cTxc^TxMinimise bTyb^Ty
Matrix AATranspose ATA^T
Right-hand side bbBecomes objective coefficients
Objective coefficients ccBecome right-hand side
x≥0x\ge0y≥0y\ge0

Why y≥0y\ge0? If some yi<0y_i<0, multiplying a ≤\le constraint flips its inequality, and adding the results would prove nothing.

Weak and strong duality

Weak duality. If xx is primal feasible and yy is dual feasible, then

cTx≤bTy.c^Tx\le b^Ty .

Proof. From dual feasibility ATy≥cA^Ty\ge c, left-multiply by xT≥0x^T\ge0:

cTx≤(ATy)Tx=yTAx.c^Tx\le (A^Ty)^Tx=y^TAx .

From primal feasibility Ax≤bAx\le b and y≥0y\ge0, left-multiply by yTy^T:

yTAx≤yTb.y^TAx\le y^Tb .

Chaining the two gives the claim. The whole proof rests on one fact: a non-negative weight times an inequality does not flip it.

Strong duality (stated; proved next lecture). If the primal optimum z∗z^* is finite, so is the dual optimum w∗w^*, and z∗=w∗z^*=w^*.

The dual of the dual is the primal. Put the dual min⁡bTy\min b^Ty, ATy≥cA^Ty\ge c, y≥0y\ge0 into canonical form (negate to get a maximisation with ≤\le), take the dual to get min⁡−cTx\min -c^Tx, −Ax≥−b-Ax\ge-b, x≥0x\ge0, then negate again to recover the primal. This is where the name comes from.

What this lecture establishes

  • An LP is a linear objective, linear constraints and non-negativity; model by choosing variables, objective, constraints.
  • Standard form is Ax=b, x≥0Ax=b,\ x\ge0; canonical form is Ax≤b, x≥0Ax\le b,\ x\ge0; either converts to the other.
  • Four conversions: negate, split free variables, add slack/surplus, split equations into two inequalities.
  • Basic feasible solutions are vertices; simplex walks along edges to the best vertex.
  • The dual weights the constraints to bound the optimum; the weights are the certificate.
  • Weak duality: no primal feasible value exceeds any dual feasible value.

Comprehension check

1. Write the full diet model and explain why non-negativity cannot be dropped.

Reference answer:

min⁡ 60x1+35x2s.t.5x1+7x2≥8,  4x1+2x2≥15,  2x1+x2≥7,  x1,x2≥0.\min\ 60x_1+35x_2\quad\text{s.t.}\quad 5x_1+7x_2\ge8,\;4x_1+2x_2\ge15,\;2x_1+x_2\ge7,\;x_1,x_2\ge0 .

Without x1,x2≥0x_1,x_2\ge0 the model allows negative amounts of grain, which are physically meaningless; the feasible set no longer describes the problem. Non-negativity is part of the problem, not a solution technique.

2. Convert to canonical form: min⁡3x1+5x2\min 3x_1+5x_2 subject to x1+x2≥4x_1+x_2\ge4, x1−2x2≤6x_1-2x_2\le6, x1≥0x_1\ge0, x2x_2 free.

Reference answer: Set x2=x2+−x2−x_2=x_2^+-x_2^- with x2±≥0x_2^\pm\ge0; negate the objective to maximise; negate the ≥\ge constraint:

max⁡ −3x1−5x2++5x2−s.t.−x1−x2++x2−≤−4,    x1−2x2++2x2−≤6,    x1,x2+,x2−≥0.\max\ -3x_1-5x_2^++5x_2^- \quad\text{s.t.}\quad -x_1-x_2^++x_2^-\le-4,\;\; x_1-2x_2^++2x_2^-\le6,\;\; x_1,x_2^+,x_2^-\ge0 .

3. Turn x1+3x2≤9x_1+3x_2\le9 into an equation; what if it were ≥9\ge9?

Reference answer: For ≤\le, add a slack s≥0s\ge0: x1+3x2+s=9x_1+3x_2+s=9. For ≥\ge, subtract a surplus s≥0s\ge0: x1+3x2−s=9x_1+3x_2-s=9. Both preserve the solution set of the original inequality.

4. For the bake sale, give a feasible solution, an upper-bound certificate, and the optimum.

Reference answer: x=(3,2)x=(3,2) is feasible: 3+6=93+6=9 and 6+2=86+2=8, objective 100100. The certificate is the dual feasible y=(4,8)y=(4,8): 4(x1+3x2)+8(2x1+x2)=20x1+20x2≤4⋅9+8⋅8=1004(x_1+3x_2)+8(2x_1+x_2)=20x_1+20x_2\le4\cdot9+8\cdot8=100, with y1+2y2=20≥20y_1+2y_2=20\ge20, 3y1+y2=20≥203y_1+y_2=20\ge20 and y≥0y\ge0. The bounds agree, so the optimum is 100100.

5. Prove weak duality.

Reference answer: From ATy≥cA^Ty\ge c and x≥0x\ge0 we get cTx≤(ATy)Txc^Tx\le(A^Ty)^Tx. Using (ATy)Tx=yTAx(A^Ty)^Tx=y^TAx, Ax≤bAx\le b and y≥0y\ge0 gives yTAx≤yTby^TAx\le y^Tb. Hence cTx≤yTAx≤yTbc^Tx\le y^TAx\le y^Tb: every primal feasible value is at most every dual feasible value.

6. Why split an equation into two inequalities rather than something else?

Reference answer: aTx=ba^Tx=b is exactly equivalent, as a set of solutions, to "aTx≤ba^Tx\le b and aTx≥ba^Tx\ge b", and this introduces no new variables. Since canonical form allows only ≤\le, the second is rewritten as −aTx≤−b-a^Tx\le-b. The advantage is that every constraint now has the same orientation, so the sign rules for dual weights are uniform.

Relation to neighbouring lectures

The lecture sets up modelling and duality but leaves strong duality as a statement. The next lecture gives three proof routes (simplex tableau, Farkas' lemma, a mechanical analogy), uses complementary slackness to recover a dual optimum from a primal one, and closes with König's theorem for bipartite graphs. Further on, duality becomes the minimax theorem for zero-sum games and the max-flow min-cut theorem.

来源