Lecture #4 Komnum - Optimization
Lecture #4 Komnum - Optimization
LECTURE #4 - OPTIMIZATION
Dr. Aries Subiantoro
Research Center for Advanced Vehicle (RCAVe)
Sources
• Chapra chapter 7
• Papalambros & Wilde (2000): Principles of optimal design
3
Chapter Objectives
DTE
ko m n u m
4
Introduction
The difference between roots and optima
5
Optimization Problem Formulation
6
Example: Airtank Design
7
Example: Airtank Design
8
Design Optimization
9
Design Optimization
10
Mathematical Problem Formulation
11
Formulation Examples
12
Example: Airtank Design 1-D
13
Unconstrained Problem
14
Existence
15
Taylor Series Expansion
16
16 3/1/2022 Add a footer
Optimality
17
17 3/1/2022 Add a footer
Example 1
18
18 3/1/2022 Add a footer
Example 2
19
One Variable Minimization
20
One Variable Minimization
21
One Variable Minimization: Sectioning
22
One Variable Minimization: Golden Section
23
Example: Golden Section
Iterasi #1 Iterasi #2
Iterasi #3 Iterasi #8
24
One Variable Minimization: Quadratic Interpolation
1 𝛼 −𝛼 𝑓 𝛼 + 𝛼 −𝛼 𝑓 𝛼 + 𝛼 − 𝛼 𝑓(𝛼 )
𝛼 =
2 𝛼 −𝛼 𝑓 𝛼 + 𝛼 −𝛼 𝑓 𝛼 + 𝛼 − 𝛼 𝑓(𝛼 )
25
Example: Quadratic Interpolation
Iterasi #1 Iterasi #2
Iterasi #3 Iterasi #8
26
Multi Dimensional Optimization
27
Steepest Descent Direction
28
Gradient Algorithm
29
Example
min f (x) ( x1 3) 2 ( x2 2) 2
x
h1(x1,x2): 2x1 + x2 =8
h2(x1,x2): (x1-1)2 + (x2-4)2 = 4
g1(x1,x2): x1 + x2 ≤ 7
g2(x1,x2): x1 – 0.25x22 ≤ 0
inecon1.m
function retval =inecon1(x1, x2)
retval = x1 + x2;
30
Example
inecon2.m
function retval = inecon2(x1,x2)
retval = x1 - 0.25*x2.^2;
eqcon1.m
function retval = eqcon1(x1, x2)
eqcon2.m
function retval = eqcon2(x1, x2)
31
Example
% Minimize f(x1,x2) = (x1-3)**2 + (x2-2)**2
%
% h1(x1,x2) = 2x1 + x2 = 8
% h2(x1,x2) = (x1-1)^2 + (x2-4)^2 = 4
% g1(x1,x2) : x1 + x2 <= 7
% g2(x1,x2) : x1 - 0.25x2^2 <= 0.0
%
% 0 <= x1 <= 10 ; 0 <= x2 <= 10
[C1,h1] = contour(x1,x2,ineq1,[7,7],'r-');
clabel(C1,h1);
set(h1,'LineWidth',2)
% ineq1 is plotted [at the contour value of 8]
hold on % allows multiple plots
k1 = gtext('g1');
set(k1,'FontName','Times','FontWeight','bold','FontSize',14,'Color','red')
% will place the string 'g1' on the lot where mouse is clicked
[C2,h2] = contour(x1,x2,ineq2,[0,0],'r--');
clabel(C2,h2);
set(h2,'LineWidth',2)
k2 = gtext('g2');
set(k2,'FontName','Times','FontWeight','bold','FontSize',14,'Color','red')
[C3,h3] = contour(x1,x2,eq1,[8,8],'b-');
clabel(C3,h3);
set(h3,'LineWidth',2)
k3 = gtext('h1');
set(k3,'FontName','Times','FontWeight','bold','FontSize',14,'Color','blue')
33
Example
% will place the string 'g1' on the lot where mouse is clicked
[C4,h4] = contour(x1,x2,eq2,[4,4],'b--');
clabel(C4,h4);
set(h4,'LineWidth',2)
k4 = gtext('h2');
set(k4,'FontName','Times','FontWeight','bold','FontSize',14,'Color','blue')
[C,h] = contour(x1,x2,f1,'g');
clabel(C,h);
set(h,'LineWidth',1)
set(gca,'xtick',[0 2 4 6 8 10])
set(gca,'ytick',[0 2.5 5.0 7.5 10])
35
Additional Examples (Filled Labelled Contour)
x1=-1:0.01:1; % the semi-colon at the end prevents the echo
x2=-1:0.01:1; % these are also the side constraints
% x1 and x2 are vectors filled with numbers starting
% at 0 and ending at 10.0 with values at intervals of 0.1
37
Additional Examples (2D Contour with Gradient Vectors)
figure
y1 = -1:0.1:1.0;
y2 = -1:0.1:1;
[Y1,Y2] = meshgrid(y1,y2);
f2 = obj_ex2(Y1,Y2);
[C2,h2] = contour(y1,y2,f2,[0 0.5 0.75 1.0 1.5 1.75 2.0 2.5 2.5 3.0]);
clabel(C2,h2)
[GX, GY] = gradient(f2,0.2);
hold on
quiver(Y1,Y2,GX,GY);
hold off
set(gca,'xtick',[-1 -0.5 0.0 0.5 1.0])
set(gca,'ytick',[-1 -0.5 0.0 0.5 1.0])
xlabel(' x_1 values','FontName','times','FontSize',12); % label for x-axes
ylabel(' x_2 values','FontName','times','FontSize',12);
title({'2D Contour','with Gradient Vectors'}, ...
'FontName','times','FontSize',10)
38
Additional Examples (2D Contour with Gradient Vectors)
x2
x1
39
Additional Examples (Coarse Mesh Plot)
mesh(y1,y2,f2)
set(gca,'xtick',[-1 -0.5 0.0 0.5 1.0])
set(gca,'ytick',[-1 -0.5 0.0 0.5 1.0])
colorbar
xlabel(' x_1 values','FontName','times','FontSize',12); % label for x-axes
ylabel(' x_2 values','FontName','times','FontSize',12);
title({'Coarse Mesh Plot','colormap - cool'}, ...
'FontName','times','FontSize',10)
grid
40
Additional Examples (Coarse Mesh Plot)
41
Additional Examples (Coarse Surface Plot)
42
Additional Examples (Coarse Surface Plot)
x2
x1
43
Unconstrained Optimum – 2D Examples
44
Case Study: 2D Equilibrium Potential Energy
45
Homework
DTE
ko m n u m
46
ThankYou
Aries Subiantoro
021-7270078
aries.subiantoro@ui.ac.id
RCAVe
DTE
ko m n u m
47
Tugas
48
Tugas
49