OR Part1 - Lecture2 - LinearProgramming
OR Part1 - Lecture2 - LinearProgramming
2024
1 Linear Programming
Examples
Formulations
2 Solving LPs
2D Graphical solution
Simplex Method
LP solver
3 Duality
A Motivated Example
Definition and Construction
Weak and Strong Duality
Complementary Slackness Condition
For example,
if one ate the chicken and the cheeseburger, that would amount to
the percentages of 23, 21, 45, and 28, along with 890 calories.
if one ate two fifths of each of the hamburger, chicken, and
cheeseburger, this satisfies the four requirements with only 456
calories.
Question 1
Find a menu that satisfies the requirements while consuming fewer than
456 calories.
Question 2
Is it possible to consume fewer than 400 calories under these conditions?
Less than 350?
For example,
if one ate the chicken and the cheeseburger, that would amount to
the percentages of 23, 21, 45, and 28, along with 890 calories.
if one ate two fifths of each of the hamburger, chicken, and
cheeseburger, this satisfies the four requirements with only 456
calories.
Question 1
Find a menu that satisfies the requirements while consuming fewer than
456 calories.
Question 2
Is it possible to consume fewer than 400 calories under these conditions?
Less than 350?
For example,
if one ate the chicken and the cheeseburger, that would amount to
the percentages of 23, 21, 45, and 28, along with 890 calories.
if one ate two fifths of each of the hamburger, chicken, and
cheeseburger, this satisfies the four requirements with only 456
calories.
Question 1
Find a menu that satisfies the requirements while consuming fewer than
456 calories.
Question 2
Is it possible to consume fewer than 400 calories under these conditions?
Less than 350?
Problem formulation:
Minimize w = 250y1 + 400y2 + 370y3 + 490y4
subject to 4y1 + 8y2 + 2y3 + 15y4 ≥ 10
4y1 + 15y2 + 6y4 ≥ 10
(1)
10y1 + 15y2 + 15y3 + 30y4 ≥ 15
15y1 + 8y2 + 10y3 + 20y4 ≥ 15
y1 , y2 , y3 , y4 ≥ 0.
Problem formulation
max z = 10
P P9
c x
P9 i=1 j=0 i,j i,j
s.t.
P10 j=0 ci,j xi,j ≤ 1 ∀1 ≤ i ≤ 10
i=1 ci,j xi,j ≤ 1 ∀0 ≤ j ≤ 9
xi,j ∈ {0, 1}.
m plants, n warehouses
si : supply of the ith plant, i = 1, . . . , m
dj : demand of the jth warehouse, j = 1, . . . , n
cij : cost of transportation from the ith plant to the j warehouse.
Goal: Minimize the cost of transportation.
Variables: xij number of units to send i → j.
m X
X n
min cij xij
i=1 j=1
Xm
subject to xij = dj j = 1, . . . , n
i=1
n
X
xij = si i = 1, . . . , m
j=1
xij ≥ 0
max c1 x1 + · · · + cn xn
subject to ai1 x1 + . . . ain xn ≤ bi i = 1, . . . , m,
xj ≥ 0 j = 1, . . . , n.
Hình: Data
Goal: Find a linear classifier. i.e. a vector a and a scalar b such that for
any example of the first class
aT xi ≥ b,
aT xi < b.
Standard form
Standard form
Standard form
1 Linear Programming
Examples
Formulations
2 Solving LPs
2D Graphical solution
Simplex Method
LP solver
3 Duality
A Motivated Example
Definition and Construction
Weak and Strong Duality
Complementary Slackness Condition
max z = x1 + x2
s.t. 3x1 + 5x2 ≤ 90
9x1 + 5x2 ≤ 180
x2 ≤ 15
x1 , x2 ≥ 0.
max z = x1 + x2
s.t. 3x1 + 5x2 +x3 = 90,
⇔ 9x1 + 5x2 +x4 = 180,
x2 +x5 = 15
xj ≥ 0 ∀1 ≤ j ≤ 5 .
We get
x (1) = (20, 0, 30, 0, 15)
with z (1) = 20. This produces the new basis
β(1) = {1, 3, 5},
parameter set
π(1) = {2, 4},
and dictionary below
Dictionary 2
max z = 20 + 49 x2 + 91 x4
s.t. x3 = 30 − 10 1
3 x2 + 3 x4 ,
x1 = 20 − 59 x2 − 91 x4 ,
x5 = 15 − x2
xj ≥ 0 ∀1 ≤ j ≤ 5
Lecture 2: Linear Programming 40 / 65
Simplex Method: Step 3
Find a better vertex of feasible set and formulate a new dictionary
Colab: https://colab.research.google.com
SciPy.linprog https://docs.scipy.org/doc/scipy/reference/
generated/scipy.optimize.linprog.html
1 Linear Programming
Examples
Formulations
2 Solving LPs
2D Graphical solution
Simplex Method
LP solver
3 Duality
A Motivated Example
Definition and Construction
Weak and Strong Duality
Complementary Slackness Condition
Weak Duality
For any feasible solution x of primal problem and for any feasible solution
y of dual problem, we have
c t x ≤ bt y .
Strong Duality
If primal problem has an optimal solution x ∗ , then dual problem has an
optimal solution y ∗ . Furthermore, we have c t x ∗ = b t y ∗
Theorem
Let x ∗ be a feasible solution of primal problem. and y ∗ be a feasible
solution of dual problem. Then x ∗ and y ∗ are optimal solutions if and only
if
(bi − ai1 x1∗ − ai2 x2∗ − · · · − ain xn∗ )yi∗ = 0 ∀i = 1; . . . ; m;
(a1j y1∗ + a2j y2∗ + · · · + amj ym
∗
− cj )xj∗ = 0 ∀j = 1; . . . ; n
Lecture 2: Linear Programming 62 / 65
Example