Professional Documents
Culture Documents
Autumn 2016-17
(kishalay@iith.ac.in)
https://sites.google.com/site/kishalaymitra/
Overview
Topics
Evaluation
No.
Type
Marks
Final
Weightage
Tentative
Time
1.
Mid Test
30
30
Sept
Starting
2.
End Test
30
30
Course
End
3.
20
20
Aug-Sept
3.
Attendance (85%),
Class performance
20
20
Almost
each
class
Total = 100
Motivating Example
I want to minimize the cost of manufacturing a cylindrical
vessel with fixed volume V find me a suitable diameter and
height
Objective Function Min f cos t c s DL c t / 2 D 2
L,D
s.t.
Constraints
V / 4 D L
2
Decision Variables D 0, L 0
Min f cos t 4c s V / D c t / 2 D 2
D
df
4c s V / D 2 c t D 0
dD
1/ 3
4c s V
4V
, L
D
c t
1/ 3
ct
cs
2/3
L ct
D cs
What is Optimization?
What is Optimization
Why Optimization
largest production, the greatest profit, the minimum cost, the least
energy usage, and
Levels of Optimization
Management
Plant
Process
......
Plant
....................
Process
Process
......
Process
Essential Features
Optimization problems
Multiple constraints
(equality)
Multiple constraints
(inequality)
Decision variables
& their bounds
Equality (nE)
Inequality (nI)
Independent Decision Variables
(nDV)
Optimization is a case of
nDV > (nE + nI)
nDV = (nE + nI) unique solution
nDV < (nE + nI) over-determined
system
Linear Regression
Linear Regression: to fit the best straight
line through the given points
y m a 0 a 1x
2
E y i y m y i a 0 a 1x i
i 0
i 0
E
2 y i a 0 a 1x i 0
a 0
i 0
n+1
n
E
2 x i y i a 0 a 1x i 0
a 1
i 0
x0
y0
x1
y1
xn
yn
a 0 n 1 a 1 x i y i
a 0 x i a 1
x y x
2
10
n 1 yi x i x i yi
a1
2
2
n 1 x x i
a 0 n 1 a 1 x i y i
a 0 x i a 1
n 1
x i
1
1
.
X
.
.
x y x
2
x a
x a
i
2
i
x0
x1
.
.
.
x n
yi
yx
1
i i
0
y0
y1
.
Y
.
.
y
n
1
a0
a 1 x i y i
n 1
Aa X X a X Y b
T
a 0
a
a1
11
n+1
y a 0 a 1x1 a 2 x 2 ... a N x N
Aa X X a X Y b
T
1 x1, 0
1 x
1,1
X
.
.
1 x1,n
12
x1
x2
x1,0
x1,1
..
xN
x2,0
xN,0
y0
x2,1
xN,1
y1
x1,n
. x N,0
. x N ,1
.
.
. x N ,n
x2,n
y0
y1
.
Y
.
.
y
n
xN,n
yn
a0
a 1
a .
.
a N
= + + 1 120 550
1
1
1
X
1
1
1
1
130 600
108 520
110 420
84 400
90 300
80 230
55 120
64 190
50 100
Aa X X a X Y b
T
13
Ea 1 , a 2 , a 3 , a 4 , a 5 , a 6 , a 7 , a 8 , a 9 y i y calc x i
i 0
(, > )
y calc x i
a3
a6
a 1 exp(a 2 x i ) a 4 sin(a 5 x i )
a9
a 7 log10 (a 8 x i )
15
Optimization Example 1
16
Optimization Example 1
1
2
3
4
17
Optimization Example 1
18
Optimization Example 1
19
Optimization Example 1
20
Optimization Example 1
21
Optimization Example 2
22
Optimization Example 2
23
Optimization Example 2
24
Optimization Example 2
25
Optimization Example 2
26
Optimization Example 3
27
Optimization Example 3
28
Optimization Example 3
29
Optimization Example 4
30
Optimization Example 4
31
Optimization Example 4
32
Optimization Example 4
33
Optimization Example 5
34
Optimization Example 5
35
Optimization Example 5
36
Optimization Example 5
37
Optimization Example 5
38
Optimization Example 5
39
Classification
Existence of Constraints
Constrained Optimization
Unconstrained Optimization
40
Classification
Quadratic
Linear
Geometric
41
Classification
Stochastic
42
Classification
43
Graphical Solution
44
Graphical
45
Graphical
Local Optimum due to
objective function
46
Numerical Solution
How can we solve this numerically?
Obvious answer: with an
optimization solver
What about MS Excel? What
- excel is an Optimization
solver!
OK - Lets try!
Get is set first
Open Excel File Options
Add-Ins Solver addins Go
Find a SOLVER icon in DATA
menu
Ready to use optimization module
47
MATLAB Routines
48
MATLAB Routines
49
MATLAB Routines
50
52
54
a ( t ) exp k1 k 2 t
da
k1 k 2 a ( t ), a (0) 1
dt
db
k1a ( t ), b(0) 0
dt
a ( 0) a ( t ) b ( t ) c ( t )
k1
1 exp k1 k 2 t
b( t )
k1 k 2
k2
1 exp k1 k 2 t
c( t )
k1 k 2
56
time, ti
(ti)
(ti)
(ti)
0.1
0.913
0.0478
0.0382
0.2
0.835
0.0915
0.0732
0.3
0.763
0.1314
0.1051
0.4
0.697
0.1679
0.1343
0.5
0.637
0.2013
0.1610
0.6
0.582
0.2318
0.1854
0.7
0.532
0.2596
0.2077
0.8
0.486
0.2851
0.2281
0.9
0.444
0.3084
0.2467
10
1.0
0.406
0.3296
0.2637
57
a ( t ) exp k1 k 2 t
b( t )
k1
1 exp k1 k 2 t
k1 k 2
k2
1 exp k1 k 2 t
c( t )
k1 k 2
2
2
2
Min f x a t i a t i bt i bt i c t i ct i
k1 , k 2
i 1
N
58
k1
A
B
da
k1a ( t ), a (0) 1
dt
db
k1a ( t ) k 2 b( t ), b(0) 0
dt
dc
k 2 b( t ), c(0) 0
dt
k2
C
Solve using ODE 45
& then perform parameter
estimation using fminunc
61
time, ti
(ti)
(ti)
(ti)
0.0000
1.0000
0.0000
0.0000
0.1000
0.7047
0.2759
0.0194
0.2000
0.4966
0.4367
0.0668
0.3000
0.3499
0.5204
0.1296
0.4000
0.2466
0.5535
0.1999
0.5000
0.1738
0.5541
0.2722
0.6000
0.1225
0.5345
0.3431
0.7000
0.0863
0.5031
0.4106
0.8000
0.0608
0.4656
0.4736
10
0.9000
0.0429
0.4256
0.5316
11
1.0000
0.0302
0.3855
0.5843
62
63
Min x
2
1
x 2 11 x1 x 2 7
2
x1, x 2
s.t.
x12 x 22 25
5 x1 , x 2 5
Solve using fmincon function of
MATLAB and show the effect of
initial guesses.
Plot the function in the backdrop and show
the movement of points over several iterations
on the contour.
66
Min x
2
1
x 2 11 x1 x 2 7
2
x1, x 2
s.t.
x12 x 22 25
5 x1 , x 2 5
Solve using ga function of
MATLAB and see what happens.
Use your binary & real coded GA to see the
effect.
Plot the function in the backdrop and show
the movement of points over several
generations on the contour.
67
Genetic Algorithms
Logic
Initialization: Started with a number of
solutions (Population) instead of a single
solution
Fitness: Computation of function
values for each of them
F(x)
Selection: Select better solutions from
the population (Parents)
Crossover, Mutation: Creating new
solutions from parent solutions (Children)
Continue this process till some
termination criteria it met (say maximum
number of iterations)
Local Basin
Global Basin
X
GA Example
Max sin( x )
String DV
01
10
00
11
001
100
001
010
String
01
10
10
11
001
100
100
010
9
20
1
26
f(x)
0.912
2.027
0.101
2.685
0.791
0.898
0.101
0.485
favg 0.569
String DV
x
01
10
10
11
000
101
010
100
8
21
18
28
01
10
10
11
001
100
100
010
f(x)
0.811
2.128
1.824
2.838
favg
01001
x
1
2
0
1
0 x
0.725
0.849
0.968
0.299
0.710
01001 24 0 23 1 22 0 21 0 20 1
Max sin(x )
0x
x max x min
DecodeValue
2L 1
3.14 0
x 0 5
9 0.912
2 1
x x min
Requirements
Program should be modular (different
functions for initialization, fitness
evaluation, selection, crossover, mutation)
Plot evolution of population with time
Outputs (finalvariable.txt)
Values of variables (binary form & real
value) and objective functions of the last
generation
Outputs (allvariable.txt)
Values of variables (binary form & real
value) and objective functions of all
generations