Modelowanie zjawiska mikrosegregacji stopu

Download Report

Transcript Modelowanie zjawiska mikrosegregacji stopu

Optimization of thermal processes
Lecture 8
Maciej Marek
Czestochowa University of Technology
Institute of Thermal Machinery
Optimization of thermal processes
2007/2008
Overview of the lecture
• Indirect search (descent) methods
• Steepest descent (Cauchy) method
−
−
−
−
The concept of the method
Elementary example
Practical example: optimal design of three-stage compressor
Possible problems with steepest descent method
• Conjugate directions methods
− Davidon-Fletcher-Powell method
Optimization of thermal processes
2007/2008
General types of iterative methods
• Direct search methods (discussed on the previous lecture)
− only the value of the objective function is required (Gauss-Seidel and
Powell’s method are good examples)
• Indirect (descent) methods
− methods of this type require not only the value of the objective
function but also values of its derivatives
− thus, we need
f ( X )
f (X)
and
Gradient of the function
f
f
f
f (X) 
x1 
x2  ... 
xn
x1
x2
xn
f ( x)
?
xi
Unit vector of i axis
? descent
1D case
minimum
x0
Optimization of thermal processes
x
2007/2008
Indirect search (descent methods)
2D case. The gradient is:
f ( x1 , x2 )
 f 
 x 
f   1 
 f 
 x 
 2
The gradient points in
the direction of
steepest ascent.
x2
peak
So:
Si  f
is the steepest descent
direction.
Descent
directions
Optimization of thermal processes
minimum
x1
2007/2008
Indirect search (descent methods)
x2
Gradient is always perpendicular to the
isocontours of the objective function.
C1  C2  ...  C5
f  C5
gradient
The step length may be constant
(this is the idea of simple gradient
method) or may be found with
some one- dimensional
optimization technique.
f
f  C4
f
descent direction
f  C3
f  C2
f  C1
optimum
S1
X5 X 4
X3
S2
X1
All descent methods make use
of the gradient vector. But
in some of them gradient is
only one of the components
needed to find the search
direction
X2
x1
Optimization of thermal processes
2007/2008
Calculation of the gradient vector
• To find the gradient we need to calculate the partial derivatives
of the objective function. But this may lead to certain problems:
− when the function if differentiable, but the calculation of the
components of the gradient is either impractical or impossible
− although the partial derivatives can be calculated, it requires a lot
of computational time
− when the gradient is not defined at all points
• In the first (or the second) case we can use e.g. finite difference
formula:
f
xi
Xm
f ( X m  xi ui )  f ( X m )

,
xi
ui
i  1, 2,..., n
Vector whose i-th component has a value 1 and all
other componets are zero (unit vector of the i-th axis)
xi
Optimization of thermal processes
Small scalar quantity (choose carefully!)
2007/2008
Calculation of the gradient vector
• The scalar quantity (grid step) xi cannot be:
− too large – the truncation error of finite difference formula may be large
− too small – numerical round-off error may be unacceptable
• We can use the central finite difference scheme:
f
xi
Xm
f ( Xm  xi ui )  f ( Xm  xi ui )

,
2xi
i  1, 2,..., n
which is more accurate, but requires an additional function evaluation.
• In the third case (when gradient is not defined), we usually have to
resort to direct search methods.
Optimization of thermal processes
2007/2008
Steepest descent (Cauchy) method
1.
Start with arbitrary initial point X1. Set the iteration numer as i=1.
2.
Find the search direction Si as
Steepest descent direction
Si  fi  f (Xi )
3.
Determine the optimal step length in the direction and set
Optimal step length
Xi 1  Xi  i*Si  Xi  i*fi
4.
Test the new point Xi1 for optimality. If X is optimum, stop the
i1
process. Otherwise, go to step 5.
5.
Set the new iteration number i=i+1 and go to step 2.
Optimization of thermal processes
2007/2008
Steepest descent method
(example)
Minimize
f ( x1, x2 )  x1  x2  2x12  2x1x2  x22
starting from the point
Iteration 1
0
X1    .
0
 f 
 x   1  4 x  2 x 
1
2
f   1   
 f   1  2 x1  2 x2 
 x 
 2
1
f1  f ( X1 )   
 1
So, the first search direction is:
Optimization of thermal processes
gradient
gradient at the starting point
1
S1  f1   
1
2007/2008
Steepest descent method
(example)
Now, we must optimize
    
 0
 1 
f ( X1  1S1 )  f     1     f   1    f (1 , 1 )  12  21
 1 
 0
  1  
to find the step length. Using the necessary condition:
f
 0  1*  1
1
0 
 1  1
X2  X1   S     1     
0 
1 1
*
1 1
Is it optimum? Let’s calculate the gradient at this point:
1 0
f 2  f (X2 )      
1 0
Optimization of thermal processes
2007/2008
We didn’t reach
the optimum (non-zero
slope)
Steepest descent method
(example)
Iteration 2
1
S 2  f 2   
1
New search direction
f (X2  2S2 )  f (1  2 ,1  2 )  522  22 1
Necessary condition
f
1
 0  2* 
2
5
Optimize for the step length
1 1 1 0.8
X3  X2   S         

 1  5 1  1.2 
*
2 2
Next point
 0.2  0
f3  f (X3 )  
 

0.2 0
We didn’t reach
the optimum (non-zero
slope)
Gradient at the next point
Proceed to the next iteration.
Optimization of thermal processes
2007/2008
Steepest descent method
(example)
Iteration 3
 0.2
S3  f3  

 0.2 
New search direction
f (X3  3S3 )  f (0.8  0.2  3 ,1.2  0.23 )  0.0432  0.083 1.2
Necessary condition
f
 0  3*  1.0
3
Optimize for the step length
0.8
0.2 1.0
X4  X3   S  
 1.0  




 1.2 
 0.2   1.4 
*
3 3
Next point
0.2 0
f 4  f (X4 )  
 

0.2 0
We didn’t reach
the optimum (non-zero
slope)
Gradient at the next point
This process should be continued
until the optimum is found:
 1.0
X*  
1.5 

Optimization of thermal processes
2007/2008
When to stop?
1.
(convergence criteria)
When the change in function value in two consecutive iterations is
small:
f (X)
1
f ( Xi 1 )  f ( Xi )
 1
f ( Xi )
k
2.
iterations
When the partial derivatives (components of the gradient) of f are
small:
f
 2 ,
xi
3.
k 1
i  1, 2,..., n
Near the optimum point the gradient
should not differ much from zero.
When the change in the design vector in two consecutive iterations
is small:
Xi 1  Xi   3
Optimization of thermal processes
2007/2008
Optimum design of three-stage compressor
(steepest descent method)
Objective: find the values of interstage pressure to minimize work input.
The heat exchangers reduce the temperature of the gas to T after compression.
Compressors
Heat exchangers
pi  105 [Pa]
Initial pressure
Work input
p f  106 [Pa]
Interstage pressure
Final pressure
( 1) / 
( 1) / 
( 1) / 


 x2 
 pf 
  x1 
 
W  RT
 

 3

  1  pi 

 x1 
 x2 

Gas constant

cp
cV
Optimization of thermal processes
 1.4
Let’s use steepest descent method.
2007/2008
Optimum design of three-stage compressor
(steepest descent method)
It’s convenient to use the following the objective function:
( 1) / 
( 1) / 
( 1) / 


p






x1
x2
W

f
 
f ( x1 , x2 ) 

 

 3

RT   1  pi 

 x1 
 x2 

The gradient and its components are:
 f 
 x 
f ( X )   1 
 f 
 x 
 2
1
1
 1
1 2
f
  pi    x1     x2    x1  
x1
 1
1
1
1 2
f

  x1    x2     p f   x2  
x2
Let’s choose the starting point (initial guess):
 x11   4 105 
X1   1   
5
x
7

10

 2 
Optimization of thermal processes
2007/2008
Optimum design of three-stage compressor
(steepest descent method)
Using this values we calculate the first search direction:
 f

 x1
1
S1  f  
  f
 x2

Derivative calculated at point X1


 0.079 105 
X1 

5 

0.009

10

 

X1 
The next point we find from the formula:
 4 105 
 0.079 105   4 105  1  0.079 105 
X2  X1  1S1  
 1 

5
5 
5
5 
7

10



0.009

10
7

10

0.009

10



 
1

Now we must find optimum step length 1 along direction S1 to minimize
the expression:
f (4 105  1  0.079 105 ,7 105  1  0.009 105 )
Optimization of thermal processes
2007/2008
Optimum design of three-stage compressor
(steepest descent method)
This means that we are looking for the minimum of the single-variable
function:
 1
 1

  4  0.079 105  1    7  0.009 105   1  
f ( 1 ) 

 
 
5

 1 
1

 4  0.079 10  1 

10




5
7

0.009

10


1 

 1


 3


1  1010  1
Using the necessary condition
f
0
1
we find
1  17
1  17 1010
The next point is:
(4  0.079 17) 105   2.66 105 
X2  

5
5
(7

0.009

17)

10
6.85

10

 

Optimization of thermal processes
2007/2008
Optimum design of three-stage compressor
(steepest descent method)
The value of the objective function at this point is:
 2.66 105 
X2  
5
6.85

10


f (X2 )  2.615
The first iteration has ended. Now we can start the second iteration,
calculating the new search direction:
 f

 x1
2
S 2  f  
  f
 x2



1


S



X2
2


2
  S 2  

X2 
Next point
X3  X2  2S2
New step length
And minimize the expression:
1
2
f (X3 )  f 2.66 105  1   S2  ,6.85 105  1   S2  


and so on...
Solution:
Optimization of thermal processes
x1  2.16 105 , x2  4.64 105 Pa 
2007/2008
Steepest descent method
x2
(possible difficulty)
optimum
Contours of the objective function
X1
Long narrow valey
x1
• If the minimum is in a long narrow valey, steepest descent method may
converge rather slowly
• The problem stems from the fact, that gradient is only local property of the
objective function
• More clever choice of search directions is possible. It is based on the concept of
conjugate directions.
Optimization of thermal processes
2007/2008
Conjugate directions
A set of n vectors (directions)
A-conjugate) if:
STi AS j  0
{Si } is said to be conjugate (more accurately
for all
i  j,
i  1, 2,..., n,
j  1, 2,..., n
Theorem
If a quadratic function
1 T
Q( X)  X AX  BT X  C
2
is minimized sequentially once along each direction of a set of n mutually conjugate
directions, the minimum of the function Q will be found at or before the n-th step
irrespective of the starting point.
Remark: Powell’s method is an example of conjugate directions method.
Optimization of thermal processes
2007/2008
Conjugate directions
(example)
For instance, suppose we have:
x 
X   1
 x2 
Then
1 0 
A

0
1


1
Q( X)   x1
2
0
B 
0
1 0  x1  1 2
2
x2  

(
x

x
2)
 x  2 1
0
1

 2
C 0
Convergence after
two iterations.
X1
x2
and
S1
STi AS j  0  STi S j  0
S2
Orthogonality condition
x1
So, conjugate direction are in this
case simply perpendicular.
Contours of Q
Optimization of thermal processes
2007/2008
Conjugate directions
(quadratic convergence)
• Thus, for quadratic functions conjugate directions method converges
after n steps (at most) where n is the number of design variables
• That is really fast but what about other functions?
• Fortunately, a general nonlinear function can be approximated
reasonably well by a quadratic function near its minimum (see the
Taylor expansion)
• Conjugate directions method is expected to speed up the convergence
for even general nonlinear objective functions
Optimization of thermal processes
2007/2008
Davidon-Fletcher-Powell method
1.
Start with an initial point X1 and a nn positive definite symmetric
matrix [B1] to approximate the inverse of the Hessian matrix of f.
Usually, [B1] is taken as the identity matrix [I]. Set the iteration
numer as i=1.
2.
Compute the gradient of the function,
fi , at point Xi, and set
Si    Bi  fi
3.
Find the optimal step length
i*
in the direction Si and set
Xi 1  Xi  i*Si
4.
Test the new point for optimality. If Xi1 is optimal, terminate the
iterative process. Otherwise, go to step 5.
Optimization of thermal processes
2007/2008
Davidon-Fletcher-Powell method
5.
Update the matrix [B1] as:
[ Bi 1 ]  [ Bi ]  [M i ]  [ Ni ]
where
T
S
S
[M i ]  i* Ti i
Si g i
([ Bi ]gi )([ Bi ]gi )T
[ Ni ]  
gTi [ Bi ]gi
gi  f (Xi 1 )  f (Xi )
6.
Set the new iteration number as i=i+1 and go to step 2.
Optimization of thermal processes
2007/2008
Thank you for your attention
Optimization of thermal processes
2007/2008