Optimization3
Optimization3
Course Materials
• Arora, Introduction to Optimum Design, 3e, Elsevier,
(https://www.researchgate.net/publication/273120102_Introductio
n_to_Optimum_design)
• Parkinson, Optimization Methods for Engineering Design, Brigham
Young University
(http://apmonitor.com/me575/index.php/Main/BookChapters)
• Iqbal, Fundamental Engineering Optimization Methods, BookBoon
(https://bookboon.com/en/fundamental-engineering-optimization-
methods-ebook)
The General Optimization Problem
• Let 𝒙 = 𝑥1 , 𝑥2 , … , 𝑥𝑛 denote the vector of design variables; then
the general optimization problem is mathematically defined as:
Objective: min 𝑓 𝒙 , 𝒙 ∈ ℝ𝑛
𝒙
𝑔𝑖 𝒙 ≤ 0, 𝑖 = 1, … , 𝑙;
Subject to ℎ𝑖 𝒙 = 0, 𝑖 = 𝑙 + 1, … , 𝑚;
𝑥𝑗𝐿 ≤ 𝑥𝑗 ≤ 𝑥𝑗𝑈 , 𝑗 = 1, … , 𝑛
𝜕𝑓 1 𝑗
FONC: = 𝑁
𝑖=1 𝑦𝑖 − 𝑝0 + 𝑝1 𝑥𝑖 + ⋯ + 𝑝𝑛 𝑥𝑖𝑛 (−𝑥𝑖 ) = 0
𝜕𝑝𝑗 𝑁
1 1
1 𝑖 𝑥𝑖 𝑝0 𝑦
𝑁 𝑁 𝑖 𝑖
In particular, for 𝑛 = 1, 1 1 2 𝑝1 = 1
𝑁 𝑖 𝑥𝑖 𝑁 𝑖 𝑥𝑖 𝑥𝑦
𝑁 𝑖 𝑖 𝑖
𝜕ℒ
2. =ℎ 𝒙 =0
𝜕𝜆
Note, taken together, these are 𝑛 + 1 equations in 𝑛 + 1 unknowns:
𝑥𝑖 , 𝑖 = 1, … , 𝑛 and 𝜆; hence they can be solved to obtain 𝒙∗ and 𝜆∗
Equality Constrained Problems
• Consider a problem with multiple equality constrains:
min 𝑓 𝒙 , 𝒙 ∈ ℝ𝑛 , subject to: ℎ𝑖 𝒙 = 0, 𝑖 = 1, … , 𝑙
𝒙
• Define a Lagrangian function:
𝑙
ℒ 𝒙, 𝝀 = 𝑓 𝒙 + 𝑖=1 𝜆𝑖 ℎ𝑖 (𝒙)
𝜕ℒ 𝜕𝑓 𝑙 𝜕ℎ𝑖
FONC: = + 𝑖=1 𝑖 𝜕𝑥 𝑥𝑗
𝜆 = 0; 𝑗 = 1, … , 𝑛
𝜕𝑥𝑗 𝜕𝑥𝑗 𝑗
ℎ𝑖 𝒙 = 0, 𝑖 = 1, … , 𝑙
Note:
– A total 𝑛 + 𝑙 equations, need to be solved for 𝑥𝑗 , 𝑗 = 1, … , 𝑛 and
𝜆𝑖 , 𝑖 = 1, … , 𝑙
– The Lagrange multipliers, 𝜆𝑖 for the equality constraint can take on
both positive and negative values
Example: Soda Can Design
• Example: soda can design with one equality constraint:
Objective: min 𝑓 = 12𝜋𝑑2 + 𝜋𝑑ℎ,
𝑑,𝑙
Subject to: 1
4
𝜋𝑑 2 ℎ − 𝑉 = 0
𝜋𝑑 2 𝜋𝑑 2 ℎ
• Define ℒ 𝑑, ℎ, 𝜆 = 2
+ 𝜋𝑑ℎ + 𝜆
4
−𝑉
𝜕ℒ 𝜋𝑑ℎ
• FONC: = 𝜋𝑑 + 𝜋ℎ + 𝜆 =0
𝜕𝑑 2
𝜕ℒ 𝜋𝑑 2
= 𝜋𝑑 + 𝜆 =0
𝜕ℎ 4
𝜕ℒ 𝜋𝑑 2 ℎ
= −𝑉 =0
𝜕𝜆 4
3 4𝑉 4
• FONC are collectively solved to obtain: ℎ∗ = 𝑑∗ = , 𝜆∗ = − ∗
𝜋 𝑑
Example: Soda Can Design
• MATLAB (to rescue)
syms d h V positive
syms lam real
f=pi*d*(d/2+h);
g1=pi*d^2*h/4-V;
L=f+lam*g1;
dL1=diff(L,d);
dL2=diff(L,h);
S1=solve(dL1,dL2,g1, 'Real', true);
V=125;
eval(S1.d) % 5.4193
eval(S1.h) % 5.4193
eval(S1.lam) %-0.73811
Example: Soda Can Design
• Example: soda can design with one equality constraint
Objective: min 𝑓 = 12𝜋𝑑2 + 𝜋𝑑ℎ,
𝑑,𝑙
Subject to: 14 𝜋𝑑2 ℎ − 𝑉 = 0
4𝑉
• Alternatively, use the equality constraint to solve for ℎ =
𝜋𝑑 2
4𝑉
• Define the unconstrained problem: min 𝑓 = 12𝜋𝑑 2 +
𝑑 𝑑
𝜕𝑓 4𝑉
• FONC: = 𝜋𝑑 − =0
𝜕𝑑 𝑑2
3 4𝑉 6𝑉
• FONC are solved to get: 𝑑∗ = ℎ∗ = ; 𝑓∗ =
𝜋 𝑑∗
𝜕2 𝑓(𝑑 ∗ ,ℎ∗ )
• SONC: = 3𝜋 > 0
𝜕𝑑 2
Example: Soda Can Design
• Example: soda can design with two equality constraint:
Objective: min 𝑓 = 12𝜋𝑑 2 + 𝜋𝑑ℎ,
𝑑,𝑙
Subject to: 1
4
𝜋𝑑 2 ℎ − 𝑉 = 0, 2𝑑 − ℎ = 0
𝜋𝑑 2 𝜋𝑑 2 ℎ
• Define ℒ 𝑑, ℎ, 𝜆 = + 𝜋𝑑ℎ + 𝜆1 −𝑉 + 𝜆2 2𝑑 − ℎ
2 4
𝜕ℒ 𝜋𝑑ℎ
• FONC: = 𝜋𝑑 + 𝜋ℎ + 𝜆1 + 2𝜆2 = 0
𝜕𝑑 2
𝜕ℒ 𝜋𝑑 2
= 𝜋𝑑 + 𝜆1 − 𝜆2 = 0
𝜕ℎ 4
𝜕ℒ 𝜋𝑑 2 ℎ
= −𝑉 =0
𝜕𝜆1 4
𝜕ℒ
= 2𝑑 − ℎ = 0
𝜕𝜆2
3 2𝑉
• The last two equations are solved to obtain: ℎ∗ = 2𝑑 ∗ = 2 𝜋
10 𝜋𝑑 ∗
• The first two equations are then solved to obtain: 𝜆1∗ = − 3𝑑∗ , 𝜆∗2 =
6
Inequality Constrained Problems
𝑔𝑖 𝒙 + 𝑠𝑖2 = 0,
𝜆𝑖 𝑠𝑖 = 0, 𝑖 = 1, … , 𝑚
Note,
𝜆𝑖 𝑠𝑖 = 0, 𝑖 = 1, … , 𝑚 define switching conditions, either 𝜆𝑖 = 0 or 𝑠𝑖 = 0.
They require a total of 2𝑚 cases to be explored for feasibility and optimality.
Example: Soda Can Design
• Example: soda can design with one inequality constraint
𝜋𝑑 2 ℎ
min 𝑓 = 𝜋𝑑 2
1
2
+ 𝜋𝑑ℎ, subject to: 𝑉 − ≤0
𝑑,𝑙 4
𝜋𝑑 2 ℎ
• Use slack variable to write: 𝑉 − + 𝑠2 = 0
4
𝜋𝑑 2 𝜋𝑑 2 ℎ
• Define ℒ 𝑑, ℎ, 𝜆 = + 𝜋𝑑ℎ + 𝜆 𝑉 − + 𝑠2
2 4
𝜕ℒ 𝜋𝑑ℎ
• FONC: = 𝜋𝑑 + 𝜋ℎ + 𝜆 =0
𝜕𝑑 2
𝜕ℒ 𝜋𝑑 2
= 𝜋𝑑 + 𝜆 =0
𝜕ℎ 4
𝜕ℒ 𝜋𝑑 2 ℎ
= 𝑉− + 𝑠2 = 0
𝜕𝜆 4
𝜕ℒ
= 2𝜆𝑠 = 0
𝜕𝑠
Then,
3 4𝑉 4
For 𝑠 = 0 we obtain ℎ∗ = 𝑑 ∗ = ; 𝜆∗ = −
𝜋 𝑑∗
No feasible solution for 𝜆 = 0
Optimality Criteria: General Optimization Problem
• Consider the general optimization problem:
min 𝑓 𝒙 , subject to: ℎ𝑖 𝒙 = 0, 𝑖 = 1, … , 𝑙; 𝑔𝑗 𝒙 ≤ 0, 𝑗 = 𝑖, … , 𝑚
𝒙
• Add slack variables and define the Lagrangian function:
𝑙 𝑚
ℒ 𝒙, 𝒖, 𝒗, 𝒔 = 𝑓 𝒙 + 𝑖=1 𝑣𝑖 ℎ𝑖 (𝒙) + 𝑗=1 𝑢𝑗 (𝑔𝑗 (𝒙) + 𝑠𝑗2 )
FONC (KKT):
𝜕ℒ 𝜕𝑓 𝑙 ∗ 𝜕ℎ𝑖 𝑚 ∗ 𝜕𝑔𝑗
Gradient: = + 𝑣
𝑖=1 𝑖 𝜕𝑥 + 𝑢
𝑗=1 𝑗 𝜕𝑥 = 0; 𝑘 = 1, … , 𝑛
𝜕𝑥𝑘 𝜕𝑥𝑘 𝑘 𝑘
Feasibility: 𝑔𝑗 𝒙∗ ≤ 0, 𝑗 = 1, … , 𝑚; ℎ𝑖 𝒙 = 0, 𝑖 = 1, … , 𝑙
Switching: 𝑢𝑗∗ 𝑠𝑗 = 0, 𝑗 = 1, … , 𝑚
Non-negativity: 𝑢𝑗∗ ≥ 0, 𝑗 = 1, … , 𝑚 (𝑣𝑖∗ are not restricted in sign)
Regularity : for those 𝑢𝑗∗ > 0, 𝛻𝑔𝑗 𝒙∗ are linearly independent
Note, we need to solve a total of 2𝑚 cases, each involving 𝑛 + 2𝑚 + 𝑙 variables
Example: Soda Can Design
• Example: soda can design with both equality and inequality constraints
1 2 𝜋𝑑 2 ℎ
min 𝑓 = 𝜋𝑑 + 𝜋𝑑ℎ, subject to: 𝑉 −
2
= 0, 2𝑑 − ℎ ≤ 0
𝑑,𝑙 4
• Use slack variable to write: 2𝑑 − ℎ + 𝑠 2 = 0
𝜋𝑑 2 2 𝜋𝑑 2 ℎ
• Define ℒ 𝑑, ℎ, 𝑢, 𝑣 = + 𝜋𝑑ℎ + 𝑢 2𝑑 − ℎ + 𝑠 +𝑣 𝑉−
2 4
𝜕ℒ 𝜋𝑑ℎ
• FONC (KKT): = 𝜋𝑑 + 𝜋ℎ + 2𝑢 − 𝑣 =0
𝜕𝑑 2
𝜕ℒ 𝜋𝑑 2
= 𝜋𝑑 − 𝑢 − 𝑣 4 =0
𝜕ℎ
𝜕ℒ 2
= 2𝑑 − ℎ + 𝑠 = 0
𝜕𝑢
𝜕ℒ 𝜋𝑑 2 ℎ
𝜕𝑣
=𝑉− 4
=0
𝜕ℒ
= 2𝑢𝑠 = 0
𝜕𝑠
3 2𝑉 𝜋𝑑 ∗ 10 5
• For 𝑠 = 0 we obtain: 𝑑 =∗
, ∗ ∗
ℎ = 2𝑑 ; 𝑢 = ∗
, 𝑣∗ = ∗ ; 𝑓∗ = 𝜋𝑑 ∗ 2
𝜋 6 3𝑑 2
• No feasible solution for 𝑢 = 0
Example: Soda Can Design
• Example: soda can design with equality and inequality constraints
1 2 𝜋𝑑 2 ℎ
min 𝑓 = 2𝜋𝑑 + 𝜋𝑑ℎ, subject to: 𝑉 − = 0, 2𝑑 − ℎ ≤ 0
𝑑,𝑙 4
4𝑉
• Use equality constraint to solve for ℎ = 𝜋𝑑2 (not always easy)
• Redefine the problem
4𝑉 4𝑉
min 𝑓 = 12𝜋𝑑 2 + 𝑑
, subject to: 2𝑑 − 𝜋𝑑2 ≤ 0
𝑑,𝑙
𝜋𝑑 2 4𝑉 4𝑉
• Define ℒ 𝑑, ℎ, 𝑢, 𝑣 = + + 𝑢 2𝑑 − 𝜋𝑑2 + 𝑠 2
2 𝑑
𝜕ℒ 4𝑉 4𝑉
• FONC/KKT = 𝜋𝑑 − + 2𝑢 1 + 𝜋𝑑3 = 0
𝜕𝑑 𝑑2
𝜕ℒ 4𝑉 2
𝜕𝑢
= 2𝑑 − 𝜋𝑑 2 + 𝑠 =0
𝜕ℒ
𝜕𝑠
= 2𝑢𝑠 = 0
3 2𝑉 𝜋𝑑 ∗ 5
• For 𝑠 = 0 we obtain: 𝑑 = ∗
, ∗
ℎ = 2𝑑 ; 𝑢 =∗ ∗
; 𝑓 ∗ = 2 𝜋𝑑 ∗ 2
𝜋 6
• No feasible solution for 𝑢 = 0
Second Order Conditions for Constrained Problems
• Assume that 𝒙∗ satisfies the FONC (KKT) conditions,
• Hessian of the Lagrangian:
𝑙 𝑚
𝛻2ℒ 𝒙 = 𝛻2𝑓 𝒙 + 2
𝑖=1 𝑣𝑖 𝛻 ℎ𝑖 (𝒙) +
2
𝑗=1 𝑢𝑗 𝛻 𝑔𝑗 (𝒙)
∗ ∗
𝛿𝑓 𝒙∗ = − 𝑖 𝑣𝑖 𝑏𝑖 − 𝑗 𝑢𝑗 𝑒𝑗
– The non-zero Lagrange multipliers accompanying active constraints
determine cost function sensitivity to constraint relaxation.
– Inactive constraints have zero Lagrange multipliers, and hence, do
not affect the solution.
Example
• Example: soda can design
𝜋𝑑 2 ℎ
min 𝑓 = 1
2
𝜋𝑑 2 + 𝜋𝑑ℎ, subject to: 𝑉 − = 0, 2𝑑 − ℎ ≤ 0
𝑑,𝑙 4
3 2𝑉 5
• The optimum solution is : 𝑑 ∗ = , ℎ∗ = 2𝑑 ∗ ; 𝑓 ∗ = 𝜋𝑑 ∗ 2 with
𝜋 2
𝜋𝑑 ∗ 10
𝑢∗ = , 𝑣∗ =
6 3𝑑∗
• Define the perturbed problem
𝜋𝑑 2 ℎ
min 𝑓 = 1
2
𝜋𝑑 2 + 𝜋𝑑ℎ, subject to: 𝑉 − = 𝑏, 2𝑑 − ℎ ≤ 𝑒
𝑑,𝑙 4
• Variation in the cost function
∗ ∗ 𝜋𝑑 ∗ 10
𝛿𝑓(𝑏, 𝑒) = −𝑢 𝑒 − 𝑣 𝑏 = − 𝑒 − 𝑏
6 3𝑑 ∗
𝜋𝑑 ∗ 1
For example, let 𝑏 = 𝑒 = 0.1; then 𝛿𝑓 𝑏, 𝑒 = −
60
−
3𝑑 ∗
Example
• Example: min 𝑓 𝑥1 , 𝑥2 = −𝑥1 𝑥2
𝑥1 ,𝑥2
Subject to: 𝑔 𝑥1 , 𝑥2 : 𝑥12 + 𝑥22 − 1 ≤ 0; ℎ 𝑥1 , 𝑥2 : 𝑥12 − 𝑥2 = 0
• A local minimum for the problem exists at: 𝑥1∗ , 𝑥2∗ = ±0.786,0.618 ,
𝑢∗ = 0.527, 𝑣 ∗ = −0.134, 𝑓 ∗ = −0.486.
• Define the perturbed optimization problem:
min 𝑓 𝑥1 , 𝑥2 = −𝑥1 𝑥2
𝑥1 ,𝑥2
Subject to: 𝑔 𝑥1 , 𝑥2 : 𝑥12 + 𝑥22 − 1 ≤ 𝑒; ℎ 𝑥1 , 𝑥2 : 𝑥12 − 𝑥2 = 𝑏
• The variation in the optimal solution is given as:
𝛿𝑓 = 𝑓 ∗ 𝑒, 𝑏 − 𝑓 ∗ 0,0 = −𝑢∗ 𝑒 − 𝑣 ∗ 𝑏.
• Then, for 𝑒 = 0.1, the new optimum is: 𝑓 ∗ = −0.54. Similarly, for
𝑏 = 0.1, the new optimum is: 𝑓 ∗ = −0.35.
The Dual Optimization Problem
• Every optimization problem, termed as primal, has an associated dual
problem defined in terms of dual variables (the Lagrange multipliers).
• Let the primal problem be: min 𝑓 𝒙
𝒙
Subject to: ℎ𝑖 𝒙 = 0, 𝑖 = 1, … , 𝑙; 𝑔𝑗 𝒙 ≤ 0, 𝑗 = 𝑖, … , 𝑚
𝑙 𝑚
Lagrangian: ℒ 𝒙, 𝒖, 𝒗 = 𝑓 𝒙 + 𝑖=1 𝑣𝑖 ℎ𝑖 (𝒙) + 𝑗=1 𝑢𝑗 𝑔𝑗 (𝒙)
• Then, the dual problem is defined as:
max ℒ 𝒙, 𝒖, 𝒗 , Subject to 𝛻ℒ 𝒙, 𝒖, 𝒗 = 0 (optimality constraint)
𝒖≥𝟎,𝒗
• Define a dual function: 𝜑 𝒖, 𝒗 = min ℒ 𝒙, 𝒖, 𝒗 = ℒ 𝒙∗ , 𝒖, 𝒗 ; then,
𝒙∈𝒳
the dual problem is described as: max 𝜑 𝒖, 𝒗
𝒖≥𝟎,𝒗
• For non-optimal 𝒙, 𝒖, 𝒗 , a duality gap exists and is given as:
max ℒ 𝒙∗ , 𝒖, 𝒗 ≤ min ℒ 𝒙, 𝒖∗ , 𝒗∗
𝒖≥𝟎,𝒗 𝒙∈Ω
Example: Quadratic Optimization Problem
1
• Minimize 𝑞 𝒙 = 2 𝒙𝑇 𝑸𝒙 + 𝒄𝑇 𝒙 , Subject to: 𝑨𝒙 ≥ 𝒃
1
• Lagrangian: ℒ 𝒙, 𝝀 = 2 𝒙𝑇 𝑸𝒙 + 𝒄𝑇 𝒙 − 𝝀𝑇 𝑨𝒙 − 𝒃
1
• Dual problem: max ℒ 𝒙, 𝝀 = 2 𝒙𝑇 𝑸𝒙 + 𝒄𝑇 𝒙 − 𝝀𝑇 𝑨𝒙 − 𝒃
𝒙,𝝀≥𝟎
Subject to 𝛻𝑞 𝒙 = 𝑸𝒙 + 𝒄 − 𝑨𝑇 𝝀 = 𝟎
• Using the constraint to solve, 𝒙 𝝀 = 𝑸−1 (𝑨𝑇 𝝀 − 𝒄)
1 1
max 𝜑 𝝀 = 𝝀𝑇 (𝑨𝑸−1 𝑨𝑇 )𝝀 + 𝑨𝑸−1 𝒄 + 𝒃 𝑇 𝝀 − 𝒄𝑇 𝑸−1 𝒄
𝝀≥𝟎 2 2
• Dual optimal solution:
𝝀 = 𝑨𝑸−1 𝑨𝑇 −1 𝑨𝑸−1 𝒄 + 𝒃
𝒙 = 𝑸−1 𝑨𝑇 𝑨𝑸−1 𝑨𝑇 −1 𝑨𝑇 𝑸−1 𝒄 + 𝒃 −𝑸−1 𝒄