Professional Documents
Culture Documents
Engineering Optimization Notes
Engineering Optimization Notes
Engineering Optimization
Steps:
• Convert the problem statement into a mathematical model (modeling)
• max 𝑓 = min(−𝑓)
Maximize 𝑆 = 2π𝑟𝑙𝑛
– Surface area excluding the bottom must be no more than 900 𝑐𝑚2
Solution:
Maximize 𝑉 = π𝑟 2 h
Subject to: h ≤ 20
5 ≤ 𝑟 ≤ 20
2𝜋𝑟ℎ ≤ 900
Example 3: Modeling
Design a circular tank with minimum cost.
1. V (volume) = 250𝑚3
𝐷
3. Tank has to fit in a shed with the restriction 𝐻 ≤ 10 − 2
Solution:
𝜋D2
Minimize 𝐶 = 400 2𝜋𝑅𝐻 + 2𝜋𝑅 2 = 400(𝜋𝐷𝐻 + )
2
𝐷2 𝐷2
Subject to: 𝜋 𝐻 = 250 → 𝜋 𝐻 − 250 = 0
4 4
𝐷 𝐷
H ≤ 10 − → 𝐻 + − 10 ≤ 0
2 2
Review from Calculus
1-Dimensional (1-D) Problems with no constraints (Minimize /Maximize
𝑓(𝑥) subject to no constraints)
Min/Max occurs at Stationary Points: where the function “stops” increasing or
decreasing (first derivative is equal to zero)
• Necessary Condition:
𝑑𝑓
• Requirement for a stationary point is =0
𝑑𝑥
• Sufficient Condition:
𝑑2 𝑓
• For a minimum, >0
𝑑𝑥 2
𝑑2 𝑓
• For a maximum, <0
𝑑𝑥 2
𝑑2 𝑓
• Otherwise if = 0, the point is called an inflection point
𝑑𝑥 2
1-D Taylor’s Expansion
A 1-D function can be approximated at a point 𝑥 ∗ using Taylor’s
Expansion.
𝑑𝑓 𝑥 ∗ 1 𝑑2𝑓 𝑥∗
𝑓 𝑥 ≈𝑓 𝑥∗ + 𝑥− 𝑥∗ + 𝑥 − 𝑥∗ 2 +𝑅
𝑑𝑥 2 𝑑𝑥 2
𝑑𝑓 𝑥 ∗
𝑓 𝑥 ≈ 𝑓 𝑥∗ + 𝑥 − 𝑥∗
𝑑𝑥
2
= 5 2 + 10 + 10 2 𝑥 − 2
= 20𝑥 − 10
f(x) and its lineaer approximation at X=2
60
50
40
30
20
f
0
0 0.5 1 1.5 2 2.5 3 3.5
-10
-20
x
Example 5: 1-D Taylor’s Expansion
Find the linear approximation of 𝑓 𝑥 = sin 𝑥 at x = 0
Solution:
𝑑𝑓 𝑥 ∗
𝑓 𝑥 ≈ 𝑓 𝑥∗ + 𝑥 − 𝑥∗
𝑑𝑥
sin 𝑥 ≈ sin 0 + cos 0 𝑥 − 0
=𝑥
Example 6: 1-D Taylor’s Expansion
Find the linear and 2nd order approximation of 𝑓 𝑥 = 𝑐𝑜𝑠 𝑥 at x = 0
Solution:
∗
𝑑𝑓 𝑥 ∗
𝑓 𝑥 ≈𝑓 𝑥 + 𝑥 − 𝑥∗
𝑑𝑥
c𝑜𝑠 𝑥 ≈ 𝑐𝑜𝑠 0 + [−𝑠𝑖𝑛 0 𝑥 − 0 ] = 1
∗
𝑑𝑓 𝑥 ∗ ∗
1 𝑑2𝑓 𝑥 ∗
𝑓 𝑥 ≈𝑓 𝑥 + 𝑥−𝑥 + 𝑥 − 𝑥∗ 2
𝑑𝑥 2 𝑑𝑥 2
1 2
1
cos 𝑥 ≈ 1 + [− cos 0 ] 𝑥 − 0 = 1 − 𝑥2
2 2
Example 7: Taylor’s Expansion
𝑓 𝑥 = 2𝑥 3 + 5𝑥 2 + 2𝑥 + 1
Find the 1st and 2nd order approximation of this function around 𝑥 = 2
Solution:
𝑑𝑓(𝑥) 𝑑 2 𝑓(𝑥)
= 6𝑥 2 + 10𝑥 + 2, = 12𝑥 + 10
𝑑𝑥 𝑑𝑥 2
First-order:
𝑑𝑓
𝑓 𝑥 ≈𝑓 2 + 2 𝑥−2
𝑑𝑥
𝑓 𝑥 ≈ 41 + 46(𝑥 − 2)
Second-order:
𝑑𝑓 1 𝑑 2 𝑓(2) 2
𝑓(𝑥) ≈ 𝑓 2 + 2 𝑥−2 + 𝑥−2
𝑑𝑥 2 𝑑𝑥 2
1 2
= 41 + 46 𝑥 − 2 + 12 2 + 10 𝑥 − 2
2
Taylor’s Expansion (cont.)
At stationary point, the linear portion is equal to zero, since
the first derivative is zero.
𝑓 𝑥 = 𝑓(𝑥 ∗ ) at 𝑥 ∗ for linear approximation
Perpendicular to the tangent of the function at that point (if the function is a line,
its gradient at any point is perpendicular to it).
𝜕𝑓
𝜕𝑥1
𝜕𝑓
𝜕𝑥2
𝛻𝑓 𝑥 = : 𝛻 = "𝑑𝑒𝑙"
:
𝜕𝑓
𝜕𝑥𝑛
Example 8: Gradient
Find the gradient of the following function at (3,3).
2 2
𝑓 𝑥 = 𝑥1 − 2 + 𝑥2 − 2
Solution:
• This is the equation of a circle: 𝑅2 = 𝑥1 − 𝑥1𝑐 2
+ 𝑥2 − 𝑥2𝑐 2
• 𝑥1 and 𝑥2 are variables, 𝑥1𝑐 and 𝑥2𝑐 are constants and the coordinates of the center of the circle
(x1c,x2c)
𝑥1 = 3
Let (point 1) → (3,3)
𝑥2 = 3
𝑓 3,3 = 2, so radius of the circle r = 2
2 𝑥1 − 2
𝛻𝑓 =
2(𝑥2 − 2)
2
𝛻𝑓 3,3 =
2
The vector starts at the given point and ends 2 units up and 2 units over from that point.
Example 9: Gradient
Find and plot the gradient of the following function at (1,2).
𝑓 𝑥1 , 𝑥2 = 𝑥12 + 𝑥22 + 3𝑥1 𝑥2
Solution:
𝜕𝑓
= 2𝑥1 + 3𝑥2
𝜕𝑥1
𝜕𝑓
= 2𝑥2 + 3𝑥1
𝜕𝑥2
2𝑥1 + 3𝑥2
𝛻𝑓 =
2𝑥2 + 3𝑥1
8
𝛻𝑓 1,2 =
7
Example 10: Gradient
𝜋
Find and plot the gradient of the following function at ( , 𝜋).
2
𝑓 𝑥1 , 𝑥2 = 𝑠𝑖𝑛𝑥1 + 𝑠𝑖𝑛𝑥2
Solution:
𝜕𝑓
= 𝑐𝑜𝑠𝑥1
𝜕𝑥1
𝜕𝑓
= 𝑐𝑜𝑠𝑥2
𝜕𝑥2
𝑐𝑜𝑠𝑥1
𝛻𝑓 = 𝑐𝑜𝑠𝑥
2
𝜋 0
𝛻𝑓 ,𝜋 =
2 −1
Example 11: Gradient
Find and plot the gradient of the following function at (3,4).
𝑓 𝑥1 , 𝑥2 = 𝑥1 − 2 2 + 𝑥2 − 3 2
Solution:
𝜕𝑓
= 2(𝑥1 − 2)
𝜕𝑥1
𝜕𝑓
= 2(𝑥2 − 3)
𝜕𝑥2
2(𝑥1 − 2)
𝛻𝑓 =
2(𝑥2 − 3)
2
𝛻𝑓 3,4 =
2
Graphical Optimization
Steps:
Plot the constraints and identify the Feasible
Domain (collection of all acceptable solutions)
Plot the contours of the objective functions
Determine the direction of increase or decrease of
the function
Identify the optimal solution by inspection
Example 12: Graphical Optimization
Minimize 𝑓 x1 , x2 = 𝑥1 − 5 2 + 𝑥2 − 5 2
s.t. 𝑥1 , 𝑥2 ≥ 0
𝑥1 + 𝑥2 ≤ 3
The optimal solution occurs at the point (1.5,1.5) with a value
of 2(1.5 – 5)2 = 24.5
Example 13: Graphical Optimization
s.t. 𝑥1 , 𝑥2 ≥ 0
𝑥1 + 𝑥2 ≤ 5
Solution:
Assume 𝑓 = 9
9 = 6𝑥1 + 9𝑥2
𝑖𝑓 𝑥1 = 0 → 𝑥2 = 1
𝑖𝑓 𝑥2 = 0 → 𝑥1 = 1.5
𝑥 ∗ = (0,5)
𝑥 ∗ = (0,5)
Example 14: Graphical Optimization
Using the graphical optimization, determine the solution of the
following problem.
2 2
Minimize 𝑓 𝑥, 𝑦 = 𝑥 − 1 + 𝑦−1
s.t. 𝑥 + 𝑦 ≥ 4
𝑥 + 2𝑦 ≤ 8
𝑥, 𝑦 ≥ 0
Solution:
– 𝑥+𝑦 =4
– 𝑎𝑡 𝑥 = 0 → 𝑦 = 4
– 𝑎𝑡 𝑦 = 0 → 𝑥 = 4
– 𝑥 + 2𝑦 = 8
– 𝑎𝑡 𝑥 = 0 → 𝑦 = 4
– 𝑎𝑡 𝑦 = 0 → 𝑥 = 8
– Plot the contours of 𝑓, starting with 𝑓 = 1 and increase the value of 𝑓 until the
optimal point is found.
𝑥 ∗ = 2,2 𝑓∗ = 1 + 1 = 2
𝑥 ∗ = 2,2 𝑓∗ = 1 + 1 = 2
Example 15: Graphical Optimization
2 2
Maximize 𝑓 𝑥1 , 𝑥2 = 𝑥1 − 2 + 𝑥2 − 3
s.t. 𝑥1 ≤ 10
𝑥2 ≤ 5
𝑥1 + 𝑥2 ≤ 4
𝑥1 , 𝑥2 ≥ 0
Example 16: Graphical Optimization
Maximize 𝑓 = 2x + 3y
s.t. 𝑥≤5
𝑦≤3
𝑥, 𝑦 ≥ 0
Example 17: Graphical Optimization
2 2
Minimize 𝑓 = 𝑥 − 5 + 𝑦−6
s.t. 𝑥+𝑦 ≤4
𝑥, 𝑦 ≥ 0
Example 18: Graphical Optimization
Minimize 𝑓 = 5𝑥 + 2𝑦
s.t. 𝑥+𝑦 ≤4
𝑥, 𝑦 ≥ 0
Example 19: Graphical Optimization
Maximize 𝑓 = 𝑥 + 2𝑦
s.t. 𝑥 + 𝑦 ≤ 10
4≤𝑥≤8
0≤𝑦≤6
Example 20: Graphical Optimization
Minimize 𝑓(𝑥, 𝑦) = 𝑥 + 𝑦
s.t. 𝑥−1 2 + 𝑦−1 2 ≤4
𝑥, 𝑦 ≥ 0
Example 21: Graphical Optimization
2 2
Minimize 𝑓 𝑥, 𝑦 = 𝑥 − 4 + 𝑦−4
s.t. 𝑥 + 𝑦 ≤ 4
𝑥 + 2𝑦 ≤ 6
𝑥, 𝑦 ≥ 0
Taylor’s Expansion for a Multi-
Dimensional Problem
𝑇 1 𝑇
𝑓 𝑥 ≈𝑓 𝑥∗ + 𝛻𝑓 𝑥 ∗ 𝑥− 𝑥∗ + 𝑥− 𝑥 ∗ 𝐻 𝑥 − 𝑥∗ + 𝑅
2
6𝑥 + 2𝑦 2 + 3𝑧
𝛻𝑓 = 4𝑥𝑦 + 18𝑦 2 + 18𝑦𝑧
27𝑧 2 + 3𝑥 + 9𝑦 2
30
∗
𝛻𝑓 𝑥 ≈ 282
192
6 4𝑦 3
𝐻 = 4𝑦 4𝑥 + 36𝑦 + 18𝑧 18𝑦
3 18𝑦 54𝑧
Example 23: Taylor’s Expansion
2 2
𝑓 𝑥 = 𝑥1 − 3 + 𝑥2 − 2
Find 1st order approximation at 𝑓(4,4)
Solution:
𝜕𝑓
𝜕𝑥1 2 𝑥1 − 3
𝛻𝑓 = =
𝜕𝑓 2 𝑥2 − 2
𝜕𝑥2
2 4−3 2
𝛻𝑓 𝑥 ∗ = =
2 4−2 4
𝑥1 4 𝑥 −4
𝑥 − 𝑥∗ = 𝑥 − = 1
2 4 𝑥2 − 4
𝑥1 − 4
𝑓 𝑥 ≈ 𝑓 𝑥 ∗ + 𝛻𝑓 𝑥 ∗ 𝑇
𝑥 − 𝑥 ∗ = 5 + [2 4]
𝑥2 − 4
= 5 + 2 𝑥1 − 4 + 4 𝑥2 − 4 = 5 + 2𝑥1 − 8 + 4𝑥2 − 16
= 2𝑥1 + 4𝑥2 − 19
Example 24: Taylor’s Expansion
𝑓(𝑥, 𝑦) = 5𝑥2𝑦 + 3𝑥3 + 2𝑥𝑦 + 4𝑦2𝑥
Solution:
10𝑥𝑦 + 9𝑥 2 + 2𝑦 + 4𝑦 2 138
𝛻𝑓 = =
5𝑥 2 + 2𝑥 + 8𝑥𝑦 72
𝑥−2
𝑓 𝑥 ≈ 168 + 138 72
𝑦−3
𝑓 𝑥 ≈ 168 + 138 𝑥 − 2 + 72 𝑦 − 3
= 138𝑥 + 72𝑦 − 324
Example 24 (cont.)
Now, find 2nd order approximation at 𝑓(2,3)
Solution:
10𝑦 + 18𝑥 10𝑥 + 8𝑦 + 2 66 46
• 𝐻 = =
10𝑥 + 8𝑦 + 2 8𝑥 46 16
1 66 46 𝑥 − 2
• 𝑄𝑢𝑎𝑑𝑟𝑎𝑡𝑖𝑐 𝑝𝑜𝑟𝑡𝑖𝑜𝑛 = 𝑥−2 𝑦−3
2 46 16 𝑦 − 3
1 66 𝑥 − 2 + 46(𝑦 − 3)
= 𝑥 − 2 , (𝑦 − 3
2 46 𝑥 − 2 + 16(𝑦 − 3)
1 2 2
= 66 𝑥 − 2 + 46 𝑥 − 2 𝑦 − 3 + 46 𝑥 − 2 𝑦 − 3 + 16 𝑦 − 3
2
2 2
= 33 𝑥 − 2 + 46 𝑥 − 2 𝑦 − 3 + 8 𝑦 − 3
• Summing the 1st order approximation, the 2nd order approximation:
2 2
138𝑥 + 72𝑦 − 324 + 33 𝑥 − 2 + 46 𝑥 − 2 𝑦 − 3 + 8 𝑦 − 3
Example 25: Taylor’s Expansion
𝑓 𝑥, 𝑦 = 5𝑥 3 + 2𝑥𝑦 + 9𝑥𝑦 2 + 3𝑦 2
Find the quadratic approximation of this function at (1,1)
Solution:
𝑓 1,1 = 5 + 2 + 9 + 3 = 19
15𝑥 2 + 2𝑦 + 9𝑦 2 26
𝛻𝑓 = → 𝛻𝑓 1,1 =
2𝑥 + 18𝑥𝑦 + 6𝑦 26
30𝑥 2 + 18𝑦 30 20
𝐻 = →
2 + 18𝑦 18𝑥 + 6 20 24
𝑇 1 𝑇
𝑓 𝑥 ≈ 𝑓 𝑥 ∗ + 𝛻𝑓 𝑥 ∗ 𝑥 − 𝑥∗ + 𝑥 − 𝑥∗ 𝐻 𝑥 − 𝑥∗
2
𝑥−1 1 20 𝑥 − 1
𝑓 𝑥, 𝑦 ≈ 19 + 26 26 𝑦 − 1 + [𝑥 − 1 𝑦 − 1] 30
2 20 24 𝑦 − 1
= 19 + 26 𝑥 − 1 + 26 𝑦 − 1
1 2 2
+ 30 𝑥 − 1 + 20 𝑥 − 1 𝑦 − 1 + 20 𝑦 − 1 𝑥 − 1 + 24 𝑦 − 1
2
Example 26: Stationary Points
𝑓 𝑥 = 5𝑥 2 − 20𝑥 + 1
Find the stationary points for the function and determine the
natural of these points (max or min)
Solution:
𝑑𝑓
=0
𝑑𝑥
𝑑𝑓
= 10𝑥 − 20 = 0 → 𝑥 = 2
𝑑𝑥
𝑑2 𝑓
= 10 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 → 𝑚𝑖𝑛
𝑑𝑥 2
Multi-Dimensional Functions
Necessary condition for stationary points is 𝛻𝑓 = 0
Sufficient condition is that [𝐻] matrix is positive definite for a minimum and
negative definite for a maximum
• [H] is positive definite if the determinant of the upper left 1x1 matrix, upper left 2x2
matrix, and so on, plus the matrix itself, is positive (all the leading principal minors
are positive).
• [H] is negative definite if the determinant of the principal minors alternate between
negative and positive, starting with negative (the 1x1 matrix) (odd matrices have
negative determinant, even ones have positive determinant).
𝐻 −λ 𝐼 =0
1 0 0
𝐼 = 𝑡ℎ𝑒 𝑖𝑑𝑒𝑛𝑡𝑖𝑡𝑦 𝑚𝑎𝑡𝑟𝑖𝑥 = 0 1 0
0 0 1
• If all λ’s are positive, 𝐻 is positive definite, if all λ’s are negative, 𝐻 is negative definite,
otherwise, the matrix is indefinite.
Example 27: Hessian Matrix
−5 6 −5 < 0
𝐻 = indeterminate
6 2 −10 − 36 = −46 < 0
λ2 − 11λ + 26 = 0
11 ± (112 − 4(1)(26)
𝜆= = 5.5 ± 2.1
2
𝑑𝑒𝑡 = 2 − λ 3 − λ − 1 = 0
λ2 − 5λ + 5 = 0
5 ± (5)2 − 4(1)(5)
𝜆= = 2.5 ± 1.12
2
Solution:
𝜕𝑓
= 10𝑥 + 2𝑦 = 0
𝜕𝑥
𝜕𝑓
= 2𝑥 + 18𝑦 = 0
𝜕𝑦
𝑥=0
(𝑜𝑛𝑒 𝑠𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑟𝑦 𝑝𝑜𝑖𝑛𝑡)
𝑦=0
Example 31: Stationary Points
Find the stationary points for the function and determine if they are
minimum, maximum, or inflection points?
𝑓 𝑥 = 5𝑥12 + 3𝑥22 − 2𝑥1 𝑥2
Solution:
𝛻𝑓 = 0
𝜕𝑓
= 10𝑥1 − 2𝑥2 = 0
𝜕𝑥
𝜕𝑓
= 6𝑥2 − 2𝑥1 = 0
𝜕𝑦
𝑥1 = 0
𝑥2 = 0
10 −2 10 > 0
𝐻 =
−2 6 60 − 4 = 56 > 0
• The nature of a quadratic form can be found by separating the function into
the product of vectors and a matrix as shown below:
1
𝑎 𝑐 𝑥
2
• 2-D: 𝑥 𝑦 1 𝑦
𝑐 𝑏
2
Quadratic Form (cont.)
1 1
𝑎 𝑑 𝑒
2 2 𝑥 Note: A symmetric matrix must be used,
1 1
• 3-D: 𝑥 𝑦 𝑧 𝑑 𝑏 𝑓 𝑦 which only occurs in these cases
2 2
1 1 𝑧
𝑒 𝑓 𝑐
2 2
A quadratic form is definite if it has only one sign over the entire range
𝑓 𝑥, 𝑦 = 5𝑥 2 + 4𝑥𝑦 + 6𝑦 2
Solution:
10𝑥 + 4𝑦
𝛻𝑓 = =0
4𝑥 + 12𝑦
10 4
𝐻 =
4 12
ℎ1 = 10 > 0
ℎ2 = 10 12 − 4 4 = 104 > 0
1 1.5 ℎ1 = 2 > 0
𝐻 = ℎ2 = 2 − 2.25 = 0.25 < 0
1.5 2
Indefinite
2 −1 ℎ1 = 2 > 0
𝐻 =
−1 5 ℎ2 = 10 − 1 = 9 > 0
Definite.
Solution:
𝑇 3 3 𝑥
𝑥 𝑥 → [𝑥 𝑦]
3 1 𝑦
3 3 ℎ1 = 3 > 0
𝐻 =
3 1 ℎ2 = 3 − 9 = −6 < 0
Indeterminate
Example 36: Quadratic Form
What is the nature of the quadratic form:
𝑓 𝑥, 𝑦, 𝑧 = 6𝑥 2 + 3𝑥𝑦 + 2𝑥𝑧 + 3𝑦 2 + 𝑦𝑧 + 𝑧 2
Solution:
3
6 1
2
𝑇 3 𝑥
1 𝑦
𝑥 (𝑥) → 𝑥 𝑦 𝑧 3
2 2 𝑧
1
1 1
2
3 ℎ1 = 6 > 0
6 1
2 3 3
3 1 ℎ2 = 6 3 − = 15.75 > 0
𝐻 = 3 2 2
2 2
1 1 3
1 1 3 3 1 3
2 ℎ3 = 6 2
−
3
2 2 +1 2
=6 3−4 −2
1 3 3 1
−2 +1
3
− 3 = 16.5 − 1.5 −
1 2 1 2 4
1 1 1 1
2 2
2.25 = 12.75 > 0
Positive Definite
Example 37: Quadratic Functions
What is the nature of the quadratic function:
𝑓 𝑥1 , 𝑥2 = 2𝑥12 + 𝑥1 𝑥2 + 2𝑥22 + 3𝑥32 − 2𝑥1 𝑥3
Solution:
𝑇
2 0.5 −1 𝑥1
𝑥 (𝑥) → 𝑥1 𝑥2 𝑥3 0.5 2 0 𝑥2
−1 0 3 𝑥3
ℎ1 = 2 > 0
2 0.5 −1 ℎ2 = 4 − 0.25 = 3.75 > 0
𝐻 = 0.5 2 0 ℎ3 = 2
2 0
− 0.5
0.5 0
+ −1
0.5 2
−1 0 3 0 3 −1 3 −1 0
= 2 6 − 0 − (0.5) 1.5 − 0 + (−1) 0 + 2 = 12 − 0.75 − 2 = 9.25 > 0
Definite.
Function is positive everywhere.
Example 38: Quadratic Form
Find the stationary point and it’s nature for the given function.
𝑓 𝑥, 𝑦 = 2𝑥𝑦 + 5𝑥 2 + 6𝑦 2
Solution:
• 𝛻𝑓 = 0 𝑎𝑡 𝑠𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑟𝑦 𝑝𝑜𝑖𝑛𝑡
2𝑦 + 10𝑥
𝛻𝑓 = =0
2𝑥 + 12𝑦
2𝑥 + 12𝑦 = 0
2𝑦 + 10𝑥 = 0
𝑥=0
→
𝑦=0
10 2
𝐻 =
2 12
ℎ1 = 10 > 0 ℎ2 = 10 12 − 2 2 = 116 > 0
6𝑥 + 6𝑦
𝛻𝑓 = =0
6𝑥 + 2𝑦
6 6
𝐻 =
6 2
ℎ1 = 6 > 0
ℎ2 = 6 2 − 6 6 = −24 < 0
𝐻 is indeterminate, function has different signs.
Optimization of Constrained Problems
𝜕𝐿
=2 𝑥−4 +𝑣 =0
𝜕𝑥
𝜕𝐿
=2 𝑦−4 +𝑣 =0
𝜕𝑦
𝜕𝐿
=𝑥+𝑦−4=0
𝜕𝑣
𝑥 ∗ = 2, 𝑦 ∗ = 2, 𝑣=4
𝑓∗ = 2 − 4 2
+ 2−4 2
=8
−4 1
• 𝛻𝑓 2,2 = 𝛻ℎ 2,2 =
−4 1
• 𝛻𝑓 𝑥 ∗ = −𝑣𝛻ℎ(𝑥 ∗ )
Example 41: Lagrangian
s.t. 𝑥 + 2𝑦 − 4 = 0
2𝑥 + 𝑦 − 4 = 0
Solution:
From the plot
𝑥 ∗ = 1.33, 𝑦 ∗ = 1.33
𝑓 ∗ = 26.94
• Using Lagrange multiplier.
𝐿 = 𝑓 𝑥, 𝑦 + 𝑣1 ℎ1 𝑥, 𝑦 + 𝑣2 ℎ2 (𝑥, 𝑦)
2 2
𝐿 = 𝑥−5 + 𝑦−5 + 𝑣1 𝑥 + 2𝑦 − 4 + 𝑣2 (2𝑥 + 𝑦 − 4)
𝛻𝐿 = 0
𝜕𝐿
= 2 𝑥 − 5 + 𝑣1 + 2𝑣2 = 0
𝜕𝑥
𝜕𝐿
= 2 𝑦 − 5 + 2𝑣1 + 𝑣2 = 0
𝜕𝑦
𝜕𝐿
= 𝑥 + 2𝑦 − 4 = 0
𝜕𝑣1
𝜕𝐿
= 2𝑥 + 𝑦 − 4 = 0
𝜕𝑣2
2 x−4 +v
• 𝛻𝐿 = 2 y − 4 + v = 0
x+y−2
• 3 equations, 3 unknowns, 𝑥 = 1, 𝑦 = 1, 𝑣 = 6
• 𝑓∗ = 1 − 4 2
+ 1−4 2
= 18
• The optimal point (found graphically) is (1,1)
−6 1
• 𝛻𝑓 1,1 = 𝛻ℎ 1,1 =
−6 1
• 𝛻𝑓 𝑥 ∗ = −𝑣𝛻ℎ(𝑥 ∗ )
Solution 1:
minimize: SA = 2π𝑅𝐻 + 2π𝑅 2 → 𝑓 𝑅 = 𝑅𝐻 + 𝑅 2
s.t. V = π𝑅 2 𝐻 → π𝑅 2 𝐻 − 𝑉 = 0
𝑉
𝐻=
𝜋𝑅 2
𝑉
𝑓 𝑅 = + 𝑅2
π𝑅
𝑑𝑓 𝑉
= − 2 + 2𝑅 = 0
𝑑𝑅 π𝑅
1
𝑉 3
𝑅∗ =
2π
1 3
𝑉 𝑉 3 22
𝐻∗ = 2
= 1
π𝑅
π3
𝑑2 𝑓 2𝑉 2𝑉
=2+ 3 =2+ =6>0
𝑑𝑅 2 π𝑅 𝑉
π 2π
𝑅 ∗ , 𝐻 ∗ 𝑖𝑠 𝑎 𝑚𝑖𝑛𝑖𝑚𝑢𝑚
Solution 2 (Lagrangian):
minimize: 𝑓 𝑅, 𝐻 = 𝑅𝐻 + 𝑅2
s.t. ℎ 𝑅, 𝐻 = π𝑅2 𝐻 − 𝑉 = 0
ϕ(𝑅, 𝐻, 𝑣) = 𝑓(𝑅, 𝐻) + 𝑣ℎ(𝑅, 𝐻)
𝜕ϕ
=0 𝜕𝑓 𝜕ℎ
𝜕𝑅 +𝑣 =0
𝜕ϕ 𝜕𝑅 𝜕𝑅
𝛻ϕ = 0 → = 0 → 𝜕𝑓 𝜕ℎ
𝜕𝐻 +𝑣 =0
𝜕ϕ 𝜕𝐻 𝜕𝐻
=0 ℎ(𝑅, 𝐻) = 0
𝜕𝑣
𝜕ϕ
= 𝐻 + 2𝑅 + 𝑣 2π𝑅𝐻 = 0
𝜕𝑅
𝜕ϕ
= 𝑅 + 𝑣(π𝑅2 ) = 0
𝜕𝐻
𝜕ϕ
= π𝑅2 𝐻 − 𝑉 = 0
𝜕𝑣
Three equations, three unknowns.
What is the Lagrange Multiplier?
Minimize 𝑓(𝑥, 𝑦) s.t. ℎ 𝑥, 𝑦 = 0
𝑑𝑦 𝑑ϕ
𝑦 = ϕ 𝑥 → =
𝑑𝑥 𝑑𝑥
𝑑ℎ 𝜕ℎ 𝜕ℎ 𝑑ϕ 𝑑ϕ 𝜕ℎ 𝜕ℎ
= + ∙ =0 → =− /
𝑑𝑥 𝜕𝑥 𝜕𝑦 𝑑𝑥 𝑑𝑥 𝜕𝑥 𝜕𝑦
𝑑𝑓 𝜕𝑓 𝜕𝑓 𝑑𝑦 𝜕𝑓 𝜕𝑓 𝑑ϕ
= + ∙ = + ∙
𝑑𝑥 𝜕𝑥 𝜕𝑦 𝑑𝑥 𝜕𝑥 𝜕𝑦 𝑑𝑥
𝜕𝑓 𝜕𝑓 𝜕ℎ 𝜕ℎ 𝜕𝑓 𝜕ℎ 𝜕𝑓 𝜕ℎ
• = + − / = + − /
𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
𝜕𝑓 𝜕ℎ
• → 𝑣=− /
𝜕𝑦 𝜕𝑦
Inequality Constraints
Standard Format for All Cases:
minimize 𝑓(𝑥)
s.t. 𝑔𝑗 (𝑥) ≤ 0
Add a slack variable 𝒔𝟐 to each 𝑔(𝑥) ≤ 0 to convert it to an equality
constraint, use 𝑢 as the new Lagrange multiplier
• 𝑔 𝑥 + 𝑠2 = 0
• 𝑠 = 0 𝑎𝑛𝑑/𝑜𝑟 𝑢 = 0
s.t. 𝑥 + 𝑦 − 4 ≤ 0
Solution:
2 2
• ℒ = 𝑥−4 + 𝑦−4 + 𝑢(𝑥 + 𝑦 − 4 + 𝑠 2 )
𝜕ℒ
=0
𝜕𝑥
𝜕ℒ 2 𝑥−4 +𝑢=0
=0 2 𝑦−4 +𝑢 =0
𝜕𝑦
• 𝛻ℒ = 0 → →
𝜕ℒ
=0 𝑥 + 𝑦 − 4 + 𝑠2 = 0
𝜕𝑢
𝜕ℒ
2𝑢𝑠 = 0
=0
𝜕𝑠
Example 44 (cont.)
• Case 1: 𝑢 = 0
𝑥=𝑦=4
4 + 4 − 4 + 𝑠2 = 0
𝑠 2 = −4 not acceptable
• Case 2: 𝑠 = 0
𝑥∗ = 𝑦∗ = 2
𝑢=4>0 (𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑏𝑙𝑒)
Active Constraints
Active Constraint: an inequality constraint that becomes an
equality at the optimum point
S must be equal to 0 for a constraint to be active
condition 𝑢𝑗 𝑠𝑗 = 0)
K-K-T (Karush-Khun-Tucker) Conditions
All problems must first be converted to standard format for rules to apply:
Minimize 𝑓(𝑥)
s.t. ℎ𝑖 𝑥 = 0 𝑖 = 1,2, … , 𝑛
𝑔𝑗 𝑥 ≤ 0 𝑗 = 1,2, … , 𝑚
s.t. 𝑥1 + 𝑥2 ≤ 4
Solution:
• Convert: 𝑥1 + 𝑥2 − 4 + 𝑠 2 = 0
• K.K.T. Condition:
𝜕ℒ
• = 8𝑥1 − 5𝑥2 + 𝑢 = 0
𝜕𝑥1
𝜕ℒ
• = 6x2 − 5x1 + u = 0
𝜕𝑥2
𝜕ℒ
• = 𝑥1 + 𝑥2 − 4 + 𝑠 2 = 0
𝜕𝑢
𝜕ℒ
• = 2𝑢𝑠 = 0 (𝑠𝑤𝑖𝑡𝑐ℎ𝑖𝑛𝑔 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛)
𝜕𝑠
• Always start from a switching condition
• Case 1:
• 𝑢=0
8𝑥1 − 5𝑥2 = 0 𝑥1 = 0
• →
6x2 − 5x1 = 0 𝑥2 = 0
• 𝑥1 + 𝑥2 − 4 + 𝑠 2 = 0 → 𝑠 2 = 4
• Acceptable
• Case 2:
• 𝑠=0
• Not acceptable
Example 46: KKT Condition
Minimize 𝑓 𝑥1 , 𝑥2 = 2𝑥1 + 3𝑥2 − 𝑥13 − 2𝑥22
s.t. 𝑥1 + 3𝑥2 ≤ 6
5𝑥1 + 2𝑥2 ≤ 10
Solution:
• Convert: 𝑥1 + 3𝑥2 − 6 ≤ 0
• 5𝑥1 + 2𝑥2 − 10 ≤ 0
• ℒ = 2𝑥1 + 3𝑥2 − x13 − 2x22 + u1 x1 + 3x2 − 6 + 𝑠12 + 𝑢2 (5𝑥1 + 2𝑥2 − 10 + 𝑠22 )
• K.K.T. Condition:
𝜕ℒ
• 𝜕𝑥1
= 2 − 3𝑥12 + 𝑢1 + 5𝑢2 = 0
𝜕ℒ
• 𝜕𝑥2
= 3 − 4x2 + 3u1 + 2u2 = 0
𝜕ℒ
• = 𝑥1 + 3𝑥2 − 6 + 𝑠12 = 0
𝜕𝑢1
𝜕ℒ
• = 5𝑥1 + 2𝑥2 − 10 + 𝑠22 = 0
𝜕𝑢2
𝜕ℒ
• 𝜕𝑠1
= 2𝑢1 𝑠1 = 0
𝜕ℒ
• 𝜕𝑠2
= 2𝑢2 𝑠2 = 0
• Case 1:
• 𝑢1 = 0 , 𝑢2 = 0
2 2
2 − 3𝑥12 = 0 𝑥1 = (𝑛𝑒𝑔𝑙𝑒𝑐𝑡 − )
• → 3 3
3 − 4x2 = 0 3
𝑥2 =
4
• Acceptable
• Other Cases:
• 𝑢1 = 0 , 𝑠2 = 0 𝑢2 = 0 , 𝑠1 = 0 𝑠1 = 0 , 𝑠2 = 0
Homework
Maximize 𝑓 𝑥1 , 𝑥2 = 𝑥 2 + 2𝑦 2 − 𝑥𝑦 − 4
s.t. h=𝑥+𝑦 =4
𝑔 = 𝑥2 − 𝑦 ≥ 5
Solution:
• Convert:
• Minimize 𝑓 𝑥, 𝑦 = −𝑥 2 − 2𝑦 2 + 𝑥𝑦 + 4
• s.t. h=𝑥+𝑦−4=0
• g = −x 2 + 𝑦 + 5 ≤ 0
• ℒ = 𝑓 𝑥, 𝑦 + 𝑣ℎ 𝑥, 𝑦 + 𝑢(𝑔 𝑥, 𝑦 + 𝑠 2 )
• Complete
Global Minimum
K-K-T Conditions only provide the local minimum.
All of the inequality constraints are convex functions (when they are
in standard format)
Solution:
𝜕𝑓
𝜕𝑥 6𝑥
𝛻𝑓 𝑥, 𝑦 = =
𝜕𝑓 16𝑦 3
𝜕𝑦
6>0
6 0 6 48𝑦 = 288𝑦 2 ≥ 0
2
𝐻 =
0 48𝑦 2
s.t. 𝑔1 = 2𝑥 + 3𝑦 − 5 = 0
𝑔2 = 2𝑥 2 + 𝑦 2 − 5 ≤ 0
Solution:
8𝑥 − 2𝑦
𝛻𝑓 𝑥, 𝑦 =
12𝑦 − 2𝑥
8>0
8 −2
8 12 − (−2)(−2) = 92 ≥ 0
𝐻 = pos.-def
−2 12
• Function is convex.
• The function has a global minimum since it is a convex function defined over a convex set.
Sensitivity Analysis
Minimize 𝑓(𝑥)
s.t. ℎ𝑖 𝑥 = 0 𝑖 = 1,2, … 𝑛
s.t. 𝑔𝑗 𝑥 = 0 𝑗 = 1,2, … 𝑚
Then:
𝜕𝑓∗
• = −𝑣𝑖
𝜕𝑏𝑖
𝜕𝑓∗
• = −𝑢𝑗
𝜕𝑒𝑗
𝑛 𝑚
• δ𝑓 ∗ = − 𝑖=1 𝑣𝑖 𝑏𝑖 − 𝑗=1 𝑢𝑗 𝑒𝑗
Examples 50: Sensitivity Analysis
Minimize 𝑓 𝑥, 𝑦 = 𝑥 − 4 2 + 𝑦−4 2
s.t. ℎ =𝑥+𝑦−2=0
𝑔 =𝑥+𝑦−4≤0
s.t. 𝑔1 = 4 − 𝑥 − 𝑦 ≤ 0
𝑔2 = 𝑥 + 2𝑦 − 8 ≤ 0
𝑥, 𝑦 ≥ 0