56
Process Optimization

Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

Embed Size (px)

Citation preview

Page 1: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

Process Optimization

Page 2: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

2

Tier I: Mathematical Methods of Optimization

Daniel Grooms

Section 1:

Introduction

Page 3: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

3

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 hereFor a more detailed discussion, see the references listed at the end of the module

Page 4: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

4

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

Page 5: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

5

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

Page 6: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

6

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

Page 7: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

7

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)

Page 8: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

8

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

Page 9: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

9

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:

Page 10: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

10

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

Page 11: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

11

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?

Page 12: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

12

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

Page 13: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

13

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

Page 14: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

14

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

Page 15: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

15

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

Page 16: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

16

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

Page 17: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

17

Modeling Example 1

So, we have the following problem:

Maximize 1000x1 + 1500x2

Subject to: 4x1 + 2x2 ≤ 80

2x1 + 5x2 ≤ 60

4x1 + 4x2 ≤ 75

x1, x2 ≥ 0

When solved, this has an optimal answer of x1 = 11.25 tons/wk & x2 = 7.5 tons/wk

Constraint 1

Constraint 2

Constraint 3

Page 18: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

18

Graph of Example 1

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

x2

x1

Constraint 1

Constraint 2

Constraint 3

Optimum Point Profit Vector

Page 19: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

19

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

Page 20: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

20

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.

Page 21: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

21

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.

Page 22: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

22

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.

Page 23: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

23

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, C2, & C4.

Page 24: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

24

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.

Page 25: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

25

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 ≥ 62Since it can receive ethanol from plants P1, P2, & P3.

Page 26: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

26

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 ≥ 91The ≥ sign is used because it’s alright if the

customers receive extra ethanol, but they must receive at least their minimum requirements.

Page 27: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

27

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

Page 28: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

28

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

Page 29: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

29

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

Page 30: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

30

Modeling Example 2

x11 + x21 + x31 ≥ 62 x22 + x32 ≥ 83x13 + x33 ≥ 39x14 + 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

Page 31: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

31

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

Page 32: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

32

• Maximizing a function is equivalent to minimizing the negative of the function:

Maximizing & Minimizing

)(min)(max xfxf

x* x*

f(x) f(x)

x x

Page 33: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

33

Local & Global Extremum

• 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

f(x)

x

Page 34: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

34

• 1st Derivative: Rate of change of the function. Also, tangent line.

• 2nd Derivative: Rate of change of the 1st derivative

Calculus Review

In this region, the 2nd derivative is positive because the slope of the 1st derivative is increasing

In this region, the 2nd derivative is negative because the slope of the 1st derivative is decreasing

f(x)

x

1st Derivatives

Page 35: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

35

Calculus Review con’t

• 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

f(x)

x

Page 36: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

36

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:

where x is the thickness of the insulation in centimeters.

101

x

Q kJ/h

Page 37: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

37

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.

Page 38: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

38

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:

Heat CostInsulation CostAnnual

Cost

Insulation thickness

Page 39: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

39

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:

kJyrday

dayh

hkJ

xCostHeat

50.0$36524101

yrx$800,43

380,4

Page 40: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

40

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:

yrxx

CostTotal$800,43

380,4

Page 41: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

41

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.

Page 42: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

42

Unconstrained Optimization Example

Find the derivative of the total cost:

Solve for the derivative equal to zero:

x

xdx

dCost

dx

dTotal 800,43

380,4

10380,4

2

x

0380,4

12

x

380,42 x

Page 43: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

43

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.

Page 44: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

44

Unconstrained Optimization Example

Check the 2nd derivative:

At x= 66.18,

Since the 2nd derivative is positive, this point is a minimum.

3322

2 760,8380,4)2(0

380,41

xxxdx

dCost

dx

dTotal

04.13218.66

760,832

2

TotalCostdx

d

Page 45: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

45

Unconstrained Optimization Example Results

So, the best trade-off between cost for heat loss and cost of insulation is if we install

about 66 cm of insulation.

x* = 66 cm

Total

CostInsulation Thickness

Page 46: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

46

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

Page 47: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

47

Equality Constraints

• Now, the feasible region is the section of the equality constraint line that is inside the area formed by the inequality constraints

x2

x1

Inequality Constraints

Equality Constraint

Page 48: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

48

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

x1

Page 49: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

49

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:

where

• Graphically, a convex combination of two points is a line connecting the two points

21 )1( xx 10

x1x2

=1 =0

Page 50: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

50

• A set is convex if, for any two points in the set, the whole length of the connecting line is also in the set

• Try these:

Graphical Visualization

The whole line is in the set, so the set is convex

This is not in the set, so the set is non-convex

ConvexConvexNon-convex Non-convex

Page 51: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

51

Convex Functions

• f(x) is a convex function if:

f(x1+(1-).x2) ≤ f(x1) + (1-).f(x2)

where 0 ≤ ≤ 1

x1 x2

f(x1)

f(x2)

f(x1)+(1-)f(x2)

f(x1+(1-)x2)

Page 52: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

52

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.

Page 53: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

53

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

Page 54: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

54

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

Page 55: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

55

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

We found the global

minimum!

Oops! – Maybe not

Page 56: Process Optimization. 2 Tier I: Mathematical Methods of Optimization Daniel Grooms Section 1: Introduction

56

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