Академический Документы
Профессиональный Документы
Культура Документы
1
Optimization Methods
1.1 Introduction
K.H. Yu 2
Optimization Methods
1.1 Introduction
K.H. Yu 3
Optimization Methods
1.1 Introduction
Solution
In mathematical terms,
𝑢 𝑥, 𝑦 = 𝑥𝑦 (1.1)
The constraint is given as
2𝑥 + 2𝑦 = 40 (1.2)
Express (1.2) in terms of 𝑦,
𝑦 = 20 − 𝑥 (1.3)
Substitute (1.3) into (1.1),
𝑢 𝑥 = 𝑥(20 − 𝑥) (1.4)
K.H. Yu 4
Optimization Methods
1.1 Introduction
𝑢 = 𝑥𝑦
K.H. Yu 5
Optimization Methods
1.2 1D Unconstrained Optimization
1.2.1 Newton’s Method
To find the root of a function, use the function 𝑢(𝑥) and its
first derivative 𝑢′(𝑥)
𝑢(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − (1.5)
𝑢′(𝑥𝑖 )
𝑢′(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − (1.6)
𝑢′′(𝑥𝑖 )
K.H. Yu 6
Optimization Methods
Example 1.1
K.H. Yu 7
Optimization Methods
Example 1.1
Solution
Find the first derivative and the second derivative of the
function
𝑢 𝑥 = 20𝑥 − 𝑥 2 (1.7)
𝑢′ 𝑥 = 20 − 2𝑥 (1.8)
𝑢′′ 𝑥 = −2 (1.9)
K.H. Yu 8
Optimization Methods
Example 1.1
Solution
a) To find the local maximum point,
First iteration
Assume the starting point at 𝑥0 = 5
𝑢′ 5 = 20 − 2 5 = 10
𝑢′′ 5 = −2
𝑢′(𝑥0 )
Based on (1.6), 𝑥1 = 𝑥0 −
𝑢′′(𝑥0 )
10
𝑥1 = 5 − = 10
−2
K.H. Yu 9
Optimization Methods
Example 1.1
Solution
Second iteration
At 𝑥1 = 10
𝑢′ 10 = 20 − 2 10 = 0
𝑢′′ 10 = −2
𝑢′(𝑥1 )
Based on (1.6), 𝑥2 = 𝑥1 −
𝑢′′(𝑥1 )
0
𝑥2 = 10 − = 10
−2
K.H. Yu 10
Optimization Methods
Example 1.1
Solution
b) To find the root,
First iteration
Assume the starting point at 𝑥0 = 5
2
𝑢 5 = 20 5 − 5 = 75
𝑢′ 5 = 20 − 2 5 = 10
K.H. Yu 11
Optimization Methods
Example 1.1
Solution
Second iteration
At 𝑥1 = −2.5
𝑢 −2.5 = 20 −2.5 − −2.5 2 = −56.25
𝑢′ 5 = 20 − 2 −2.5 = 25
𝑢(𝑥1 )
Based on (1.5), 𝑥2 = 𝑥1 −
𝑢′(𝑥1 )
−56.25
𝑥2 = −2.5 − = −0.25
25
K.H. Yu 12
Optimization Methods
Example 1.1
Solution
Third iteration
At 𝑥2 = −0.25
2
𝑢 −0.25 = 20 −0.25 − −0.25 = −5.0625
𝑢′ −0.25 = 20 − 2 −0.25 = 20.5
𝑢(𝑥2 )
Based on (1.5), 𝑥3 = 𝑥2 −
𝑢′(𝑥2 )
−5.0625
𝑥3 = −0.25 − = −0.003
20.5
K.H. Yu 13
Optimization Methods
1.3 Linear Programming
1.3.1 Overview
Purpose
K.H. Yu 14
Optimization Methods
1.3 Linear Programming
1.3.2 General Mathematical Form
Objective
𝑧 = 𝑎1 𝑥1 + 𝑎2 𝑥2 + ⋯ + 𝑎𝑛 𝑥𝑛 = 𝐚 ∙ 𝐱
function
𝑎𝑖1 𝑥1 + 𝑎𝑖2 𝑥2 + ⋯ + 𝑎𝑖𝑛 𝑥𝑛 ≤ 𝑏𝑖
Set of 𝑎𝑗1 𝑥1 + 𝑎𝑗2 𝑥2 + ⋯ + 𝑎𝑗𝑛 𝑥𝑛 ≥ 𝑏𝑗
constraints
𝑎𝑘1 𝑥1 + 𝑎𝑘2 𝑥2 + ⋯ + 𝑎𝑘𝑛 𝑥𝑛 = 𝑏𝑘
Constraints of
individual 𝑏𝑖 , 𝑏𝑗 , 𝑏𝑘 ≥ 0
parameters
K.H. Yu 15
Optimization Methods
1.3 Linear Programming
1.3.3 Graphical Method
K.H. Yu 16
Optimization Methods
Example 1.2
𝑥1 ≤ 4
𝑥2 ≤ 3
Constraints of
𝑥1 , 𝑥2 ≥ 0 individual
parameters
K.H. Yu 17
Optimization Methods
Example 1.2
MATLAB command can be used to generate the contour
clear all
close all
x1=[0:0.1:6];
x2=[0:0.1:6];
for i=1:length(x1)
for j=1:length(x2)
z(i,j)=95*x1(i)+150*x2(j);
end
end
figure(1)
contour(z,[150 300 450 600 750 900 1050 1200
1350],'ShowText','on','LineColor','b')
xlabel('$x_{1}$', 'Interpreter', 'Latex','FontSize', 16)
ylabel('$x_{2}$', 'Interpreter', 'Latex','FontSize', 16)
K.H. Yu 18
Optimization Methods
Example 1.2
K.H. Yu 19
Optimization Methods
Example 1.2
hold on
plot(x1,x2_c1,'r')
hold on
plot(x1,x2_c2,'r')
hold on
plot(4*ones(10,1),linspace(0,6,10),'r')
hold on
plot(linspace(0,6,10),3*ones(10,1),'r')
xlim([0,6])
ylim([0,6])
K.H. Yu 20
Optimization Methods
Example 1.2
K.H. Yu 21
Optimization Methods
Example 1.2
Based on the
graph, the
Maximum point maximum
𝑥2,𝑚𝑎𝑥 value of z is
approximately
500.
𝑥1,𝑚𝑎𝑥
K.H. Yu 22
Optimization Methods
Example 1.2
K.H. Yu 23
Optimization Methods
Example 1.2
Maximum point
K.H. Yu 24
Optimization Methods
1.3 Linear Programming
1.3.4 Simplex Method
K.H. Yu 25
Optimization Methods
Example 1.3
𝑥1 , 𝑥2 ≥ 0
K.H. Yu 26
Optimization Methods
Example 1.3
Solution
With four constraint equations involving ≤, 4 slack variables
(i.e., 𝑆1 , 𝑆2 , 𝑆3 and 𝑆4 ). Now we have 6 unknowns.
K.H. Yu 27
Optimization Methods
Example 1.3
Solution
STEP ONE: Create a tableau
K.H. Yu 28
Optimization Methods
Example 1.3
Solution
STEP TWO: Make the column with the largest negative coefficient in
the z row as the entering variable.
K.H. Yu 29
Optimization Methods
Example 1.3
Solution
STEP THREE: Make the smallest positive intercept as the leaving
variable.
Leaving variable
Intercept
Pivot 30/10
row 72/12
3/1
Pivot
column Remark: Intercept is the ratio of the
RHS over the entering variable column
K.H. Yu 30
Optimization Methods
Example 1.3
Solution
STEP FOUR: Using the pivot, perform Gaussian
elimination on the other rows.
From (1.10) 5𝑥1 + 10𝑥2 + 𝑆1 = 30
Rearranging,
1 1
𝑥2 = 3 − 𝑆1 − 𝑥1 (1.15)
10 2
Substituting (1.15) into (1.11),
1 1
20𝑥1 + 12 3 − 𝑆1 − 𝑥1 + 𝑆2 = 72
10 2
12
14𝑥1 − 𝑆1 + 𝑆2 = 36 (1.16)
10
K.H. Yu 31
Optimization Methods
Example 1.3
Solution
Substituting (1.15) into (1.13),
1 1
3 − 𝑆1 − 𝑥1 + 𝑆4 = 3
10 2
1 1
− 𝑆1 − 𝑥1 + 𝑆4 = 0 (1.17)
10 2
Substituting (1.15) into (1.14),
1 1
𝑧 − 95𝑥1 − 150 3 − 𝑆1 − 𝑥1 + 0𝑆1 + 0𝑆2 + 0𝑆3 + 0𝑆4 = 0
10 2
K.H. Yu 32
Optimization Methods
Example 1.3
Solution
Using (1.16) – (1.18), the tableau becomes
Leaving variable
K.H. Yu 33
Optimization Methods
Example 1.3
Solution
Repeat the Gaussian elimination
12
From (1.16) 14𝑥1 − 𝑆1 + 𝑆2 = 36
10
Rearranging,
36 12 1
𝑥1 = + 𝑆1 − 𝑆2 (1.19)
14 140 14
Substituting (1.19) into (1.15),
1 1 36 12 1
𝑥2 = 3 − 𝑆1 − + 𝑆1 − 𝑆2
10 2 14 140 14
20 1 24
𝑥2 + 𝑆1 − 𝑆2 = (1.20)
140 28 14
K.H. Yu 34
Optimization Methods
Example 1.3
Solution
Substituting (1.19) into (1.12),
36 12 1
+ 𝑆1 − 𝑆2 + 𝑆3 = 4
14 140 14
12 1 20
𝑆1 − 𝑆2 + 𝑆3 = (1.21)
140 14 14
K.H. Yu 35
Optimization Methods
Example 1.3
Solution
Substituting (1.19) into (1.18),
36 12 1
𝑧 − 20 + 𝑆1 − 𝑆2 + 15𝑆1 = 450
14 140 14
93 20 7020
𝑧 + 𝑆1 + 𝑆2 = (1.23)
7 14 14
K.H. Yu 36
Optimization Methods
Example 1.3
Maximum value of z
K.H. Yu 37
Optimization Methods
Example 1.3
Alternatively, MATLAB command as stated
below can be executed to yield similar result.
clear all
close all
z=[-95 -150];
A=[5 10; 20 12;1 0;0 1;-1 0;0 -1];
b=[30; 72; 4; 3; 0; 0];
var=linprog(z, A, b);
profit=-z*var
K.H. Yu 38
Optimization Methods
Example 1.4
K.H. Yu 39
Optimization Methods
Example 1.4
Solution
Objective function 𝑧 𝑎, 𝑏 = 10𝑎 + 20𝑏
K.H. Yu 40
Optimization Methods
Example 1.4
Solution
Rearranging,
𝑧 − 10𝑎 − 20𝑏 = 0
50𝑎 + 80𝑏 ≤ 100,000
10𝑎 + 30𝑏 ≤ 28,800
−𝑎 ≤ 0
−𝑏 ≤ 0
K.H. Yu 41
Optimization Methods
Exercise 1
MATLAB command as stated below can be
used to yield the result.
clear all
close all
z=[-10 -20];
A=[50 80; 10 30;-1 0;0 -1];
b=[100000; 28800; 0; 0];
var=linprog(z, A, b);
profit=-z*var
ANSWER: RM22,514
K.H. Yu 42
Optimization Methods
Exercise 1
A local car manufacturer company produces three models
of cars (Model A, Model B and Model C). The net profit for
Model A is RM8,000, Model B is RM5,000 and Model C is
RM4,000. The fuel consumptions are 16 km per liter, 19
km per liter and 20 km per liter for Model A, B and C,
respectively. Government is imposing that energy
efficiency vehicles concept that requires the average car
produced to be at least having 18 km per liter. In a day,
only 5 cars of Model A can be manufactured. Determine
the optimal solution to maximize the profit in a day.
Solve the following problem with graphical method,
simplex method and compare with the MATLAB solution.
ANSWER: RM90,000
K.H. Yu 43