Process Optimization Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction Purpose of this Module • This module gives an introduction to the area of optimization.

Download Report

Transcript Process Optimization Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction Purpose of this Module • This module gives an introduction to the area of optimization.

Process Optimization
Tier I: Mathematical Methods of
Optimization
Daniel Grooms
Section 1:
Introduction
2
Purpose of this Module
• This module gives an introduction to the
area of optimization and shows how
optimization relates to chemical
engineering in general and process
integration in particular
• This is an introduction so there are many
interesting aspects that are not covered
here
For a more detailed discussion, see the
references listed at the end of the module
3
Introduction to Optimization
• What is optimization?
– A mathematical process of obtaining the
minimum (or maximum) value of a function
subject to some given constraints
• Optimization is used every day –
Examples:
– Choosing which route to drive to a destination
– Allocating study time for several classes
– Cooking order of various items in a meal
– How often to change a car’s air filter
4
Optimization Applications
• Examples of optimization in a chemical
plant:
– At what temperature to run a reactor?
– When to regenerate/change reactor catalyst?
– What distillation reflux ratio for desired purity?
– What pipe diameter for a piping network?
• Optimization can be used to determine the
best answer to each of these questions
5
Benefits of Optimization
• Able to systematically determine the best
solution
• Model created for optimization can be
used for other applications
• Insights gained during optimization
process may identify changes that can be
made to improve performance
6
Optimization Requirements
• A clear understanding of what is needed to
be optimized.
– Ex: minimize cost or maximize product
quality?
• A clear understanding of the constraints on
the optimization.
– Ex: safety concerns, customer requirements,
budget limits, etc.
• A way to represent these mathematically
(i.e. a model)
7
Definitions
• Objective function: A representation of
whatever you want to minimize or
maximize – such as: cost, time, yield,
profit, etc.
• Variables: Things that can be changed to
influence the value of the objective
function
• Constraints: Equalities or inequalities that
limit the amount the variables may be
changed
8
More Definitions
• Minimum: A point where the objective
function does not decrease when the
variable(s) are changed some amount.
• Maximum: A point where the objective
function does not increase when the
variable(s) are changed some amount.
Minimum:
Strict minimum:
9
Modeling Example 1
A chemical plant makes urea and
ammonium nitrate. The net profits are
$1000 and $1500/ton produced
respectively. Both chemicals are made in
two steps – reaction and drying. The
number of hours necessary for each
product is given below:
Step/Chemical
Urea
Ammonium Nitrate
Reaction
4
2
Drying
2
5
10
Modeling Example 1
The reaction step is available for a total of
80 hours per week and the drying step is
available for 60 hours per week. There
are 75 tons of raw material available.
Each ton produced of either product
requires 4 tons of raw material.
What is the production rate of each chemical
that will maximize the net profit of the
plant?
11
Modeling Example 1
• Objective Function:
We want to maximize the net profit. Net
Profit = Revenue – Cost. Let x1 = tons of
urea produced per week & x2 = tons of
ammonium nitrate produced per week.
Revenue = 1000x1 + 1500x2. There is no
data given for costs, so assume Cost = 0.
So the objective function is:
Maximize 1000x1 + 1500x2
12
Modeling Example 1
• Constraints:
We are given that the reaction step is
available for 80 hrs/week. So, the
combined reaction times required for each
product cannot exceed this amount.
The table says the each ton of urea
produced requires 4 hours of reaction and
each ton of ammonium nitrate produced
requires 2 hours of reaction. This gives
the constraint:
4x1 + 2x2 ≤ 80
13
Modeling Example 1
We are also given that the drying step is
available for 60 hrs/wk. The table says that
urea requires 2 hrs/ton produced and
ammonium nitrate requires 5 hrs/ton
produced. So, we end up with the
following constraint:
2x1 + 5x2 ≤ 60
14
Modeling Example 1
We are given that the supply of raw material
is 75 tons/week and each ton of urea or
ammonium nitrate produced requires 4
tons of raw material. This gives our final
constraint:
4x1 + 4x2 ≤ 75
15
Modeling Example 1
Finally, to ensure a realistic result, it is
always prudent to include non-negativity
constraints for the variables where
applicable.
Here, we should not have negative
production rates, so we include the two
constraints
x1 ≥ 0 & x2 ≥ 0
16
Modeling Example 1
So, we have the following problem:
Maximize 1000x1 + 1500x2
Subject to:
4x1 + 2x2 ≤ 80 Constraint 1
2x1 + 5x2 ≤ 60 Constraint 2
4x1 + 4x2 ≤ 75 Constraint 3
x1, x2 ≥ 0
When solved, this has an optimal answer of
x1 = 11.25 tons/wk & x2 = 7.5 tons/wk
17
Graph of Example 1
x2
Optimum Point
Constraint 1
Profit Vector
Constraint 2
Constraint 3
x1
The gray area is called the feasible region
and you can see that the optimum point is
at the intersections of constraints 2 & 3.
Since we are maximizing, we went in the
direction of the profit vector
18
Modeling Example 2
A company has three plants that produce
ethanol and four customers they must
deliver ethanol to. The following table
gives the delivery costs per ton of ethanol
from the plants to the customers.
(A dash in the table indicates that a certain plant
cannot deliver to a certain customer.)
Plant/Customer
C1
C2
C3
C4
P1
132
-
97
103
P2
84
91
-
-
P3
106
89
100
98
19
Modeling Example 2
The three plants P1, P2, & P3 produce 135,
56, and 93 tons/year, respectively. The
four customers, C1, C2, C3, & C4 require
62, 83, 39, and 91 tons/year, respectively.
Determine the transportation scheme that
will result in the lowest cost.
20
Modeling Example 2
• Objective Function:
We want to get the lowest cost, so we want
to minimize the cost. The cost will be the
costs given in the table times the amount
transferred from each plant to each
customer. Many of the amounts will be
zero, but we must include them all
because we don’t know which ones we will
use.
21
Modeling Example 2
Let xij be the amount (tons/year) of ethanol
transferred from plant Pi to customer Cj.
So, x21 is the amount of ethanol sent from
plant P2 to customer C1. We will leave out
combinations the table says is impossible
(like x12). So, the objective function is:
Minimize 132 x11 + 97 x13 + 103 x14 + 84 x21 +
91 x22 + 106 x31 + 89 x32 + 100 x33 + 98 x34.
22
Modeling Example 2
• Constraints:
The ethanol plants cannot produce more
ethanol than their capacity limitations. The
ethanol each plant produces is the sum of
the ethanol it sends to the customers. So,
for plant P1, the limit is 135 tons/year and
the constraint is:
x11 + x13 + x14 ≤ 135
Since it can send ethanol to customers C1,
C 2, & C 4.
23
Modeling Example 2
For plants P2 & P3, the limits are 56 and 93
tons/year, so their constraints are:
x21 + x22 ≤ 56
x31 + x32 + x33 + x34 ≤ 93
The ≤ sign is used because the plants may
produce less than or even up to their
limits, but they cannot produce more than
the limit.
24
Modeling Example 2
Also, each of the customers have ethanol
requirements that must be met. For
example, customer C1 must receive at
least 62 tons/year from either plant P1, P2,
P3, or a combination of the three. So, the
customer constraint for C1 is:
x11 + x21 + x31 ≥ 62
Since it can receive ethanol from plants P1,
P2, & P3.
25
Modeling Example 2
The requirements for customers C2, C3, & C4
are 83, 39, & 91 tons/year so their
constraints are:
x22 + x32 ≥ 83
x13 + x33 ≥ 39
x14 + x34 ≥ 91
The ≥ sign is used because it’s alright if the
customers receive extra ethanol, but they
must receive at least their minimum
requirements.
26
Modeling Example 2
• If the customers had to receive exactly
their specified amount of ethanol, we
would use equality constraints
• However, that is not stated for this
problem, so we will leave them as
inequality constraints
27
Modeling Example 2
As in the last example, non-negativity
constraints are needed because we
cannot have a negative amount of ethanol
transferred.
x11, x13, x14, x21, x22, x31, x32, x33, x34 ≥ 0
28
Modeling Example 2
The problem is:
Minimize 132 x11 + 97 x13 + 103 x14 + 84 x21 +
91 x22 + 106 x31 + 89 x32 + 100 x33 +
98 x34
Subject to:
x11
+ x13 + x14 ≤ 135
x21 + x22
≤ 56
x31 + x32 + x33 + x34 ≤ 93
29
Modeling Example 2
x11 + x21 + x31 ≥ 62
x22 + x32 ≥ 83
x13
+ x33 ≥ 39
x14
+ x34 ≥ 91
And: x11, x13, x14, x21, x22, x31, x32, x33, x34 ≥ 0
The optimum result is:
x11
x13
x14
x21
x22
x31
x32
x33
x34
0
39
87
56
0
6
83
0
4
30
Modeling Example 2
• Unlike the previous example, we cannot
find the optimum point graphically because
we have more than 2 variables
• This illustrates the power of mathematical
optimization
31
Maximizing & Minimizing
• Maximizing a function is equivalent to
minimizing the negative of the function:
max f ( x)  min f ( x)
f(x)
f(x)
x*
x
x*
x
32
f(x)
Local & Global Extremum
x
• Example: Trying to minimize an objective
function f(x) which has a single variable, x.
• There are two local minimums
• There is one global minimum
33
Calculus Review
• 1st Derivative: Rate of change of the
function. Also, tangent line.
• 2nd Derivative: Rate of change of the 1st
derivative
1 Derivatives
In this region, the 2nd derivative is
st
f(x)
In this region, the 2nd
derivative is negative
because the slope of the
1st derivative is decreasing
positive because the slope of the
1st derivative is increasing
x
34
Calculus Review con’t
f(x)
x
• We can see that the
slope of the 1st
derivative is zero (flat)
at maximums and
minimums
• Also, the 2nd derivative
is < 0 (negative) at
maximums and is > 0
(positive) at minimums
35
Unconstrained Optimization
Example
Suppose you are deciding how much
insulation to put in your house. Assume
that the heat lost from the house can be
modeled by the equation:
1
Q   10 kJ/h
x
where x is the thickness of the insulation in
centimeters.
36
Unconstrained Optimization
Example
Also, suppose that it costs $0.50 for your
furnace to generate 1kJ of heat and
insulation will cost $1/year for each
centimeter of thickness over the course of
its lifetime. We want to minimize the cost
of lost heat and insulation.
37
Unconstrained Optimization
Example
So, the more insulation we install, the less
heat will be lost, but insulation can only do
so much good and it costs money too, so
we need to find the optimum trade-off.
Here is a graph of the two costs:
Annual
Cost
Insulation Cost
Heat Cost
Insulation thickness
38
Unconstrained Optimization
Example
We don’t have any budget constraints or
insulation supply constraints, so we just
minimize the total cost.
The total annual cost of the heat lost is given
by:
CostHeat

 1
 kJ   h
   365day   $0.50
    10
   24
day 
yr 
kJ
 h 
 x

 4,380
$

 43,800
 x
 yr
39
Unconstrained Optimization
Example
Each centimeter of insulation costs $1/yr, so
the total annual cost of insulation is
1x $/yr. The total cost is simply the sum of
the two costs:
CostTotal
 4,380
$

 43,800 x 
 x
 yr
40
Unconstrained Optimization
Example
We can find the minimum by using the
calculus facts we observed earlier. First,
we find where the first derivative is zero
(flat). Then we make sure the second
derivative is positive, since we are looking
for a minimum.
41
Unconstrained Optimization
Example
Find the derivative of the total cost:
d
d  4,380

CostTotal   
 43,800 x 
dx
dx  x

4,380
  2  0 1
x
Solve for the derivative equal to zero:
4,380
1 2  0
x

x 2  4,380
42
Unconstrained Optimization
Example
The result is: x =  66.18
x is the insulation thickness and we
obviously cannot have negative thickness.
So, our result is x = +66.18 cm
Incidentally, since there is only one positive
solution, we have only one minimum. So
we know it is the global minimum.
43
Unconstrained Optimization
Example
Check the 2nd derivative:
d2
d  4,380
4,380 8,760
CostTotal   1  2   0  (2) 3  3
2
dx
dx 
x 
x
x
At x= 66.18,
d2
8,760
CostTotal  
 132.4  0
2
3
dx
66.18
Since the 2nd derivative is positive, this point
is a minimum.
44
Unconstrained Optimization
Example Results
Total
Cost
x* = 66 cm
Insulation
Thickness
So, the best trade-off between cost for heat
loss and cost of insulation is if we install
about 66 cm of insulation.
45
The Feasible Region
• The feasible region is the set of solutions
that satisfy the constraints of an
optimization problem
• A 2-variable optimization problem with 4
inequality constraints:
x2
x1
Feasible
Region
46
Equality Constraints
x2
Equality
Constraint
Inequality
Constraints
x1
• Now, the feasible region is the section of
the equality constraint line that is inside the
area formed by the inequality constraints
47
More on the Feasible Region
• The optimum point is in the feasible region
• If the feasible region is just a point, there
are no degrees of freedom to optimize.
The constraints are simply a system of
equations.
• If the feasible region does not exist, the
constraints are in conflict:
x2
48
x1
Convex Sets
• A set is convex if a convex combination of any
two points in the set is also in the set
• A convex combination:
– A convex combination of points x1 & x2 is:
x1  (1   ) x2
where
0   1
• Graphically, a convex combination of two points
is a line connecting the two points
=1
x1
x2
=0
49
Graphical Visualization
• A set is convex if, for any two points in the
set, the whole length of the connecting line
is also in the set
The whole line is in
the set, so the set
is convex
This is not in the set, so
the set is non-convex
• Try these:
Non-convex
Convex
Convex
Non-convex
50
Convex Functions
• f(x) is a convex function if:
f(.x1+(1-).x2) ≤ .f(x1) + (1-).f(x2)
where 0 ≤  ≤ 1
f(x1)
f(x1)+(1-)f(x2)
f(x2)
f(x1+(1-)x2)
x1
x2
51
Convex Functions
• In geometric terms, a function is convex if
the chord connecting any two points of the
function is never less than the values of
the function between the two points.
52
Concave Functions
• The definition of a concave function is
exactly opposite that of a convex function
• If f(x) is a convex function, -f(x) is a
concave function
53
Results of Convexity
For the optimization problem
minimize:
f(x)
subject to: gi(x) ≤ 0 i = 1, …, m
where x is a vector of n variables.
• If f(x) is a convex function and the
constraints gi(x) form a convex set, then
there is only one minimum of f(x): the
global minimum
54
Implications
• This is important because it is usually
possible to find a local optimum, but it is
very difficult to determine if a local
optimum is the global optimum.
This is what the optimization process looks
like:
Start
here
Oops! – Maybe not
We found the
global
minimum!
55
Convexity Conclusions
• Having a convex problem (convex
objective function & convex set of
constraints) is the only way to guarantee a
globally optimum solution
• Unfortunately, most real-world problems
are non-convex
• However, convex problems give some
insights and have properties we can
partially use for non-convex problems
56