CH3133 - Modelling, Simulation and Optimisation for Chemical Engineering
LECTURE 12 – WEEK 12
NUMERICAL TOOLS FOR
OPTIMIZATIONS
Ho Chi Minh City University of technology
Lecturer: Aqsha, Khoa Ta Dang
Ho Chi Minh City University of technology
Institut Teknologi Bandung
2024
Image Souurce: Licdn.com
LAST WEEK MATERIAL
Optimizations
Convex Optimization
Convex Optimization Problem
One-dimensional convex function: Significance of
Convexity
▪ A strictly convex or concave function provides a
single optimum
▪ A non-convex function may have multiple local
optimum
▪ No method can guarantee a global optimum for a
general non-convex function
Image:
Convex Optimization
Convexity of a one-dimensional function:
Given the function f = x2, determine its’ convexity
f ‘(x) > 0 → a strictly convex function
f ‘(x) ≥ 0 → a convex function (not strict)
Image:
CONVEXITY & CONCAVITY
For the following functions, determine if f(x) is convex, concave,
strictly convex, strictly concave, all, or none these classes (indefinite)
in the range of -4 ≤ x ≤ +4
i. f(x) = 3x2
ii. f(x) = 2x
iii. f(x) = -5x2
iv. f(x) = 2x2 - x3
Image:
CONVEXITY & CONCAVITY
Solution
1. f "(x) = 6, always positive, hence f(x) is both strictly convex and
convex.
2. f "(x) = 0 for all values of x, hence f(x) is convex and concave. Note
straight lines are both convex and concave simultaneously.
3. f "(x) = - 10, always negative, hence f(x) is both strictly concave and
concave.
4. f "(x) = 6 - 3x; may be positive or negative depending on the value of
x, hence f(x) is not convex or concave over the entire range of x.
Image:
CONVEXITY & CONCAVITY
Classify the function 𝑓 𝑥 = 2𝑥12 − 3𝑥1 𝑥2 + 2𝑥22 using the categories in
Table below, or state that it does not belong in any of the categories.
Image:
CONVEXITY & CONCAVITY
The eigenvalues of H are 7 and 1, hence H(x) is positive-definite.
Consequently, f(x) is strictly convex (as well as convex)
Image:
1D Unconstrained Optimisation
Image:
1D Unconstrained Optimisation
Image:
Convex Optimisation
Unconstrained Non-Linear Optimisation
We need more convenient methods for searching optimal
solutions for a set of non-linear equations:
Image:
Convex Optimisation
Newton Method
▪ The necessary condition for f(x) to have an optimum is that f ’(x) = 0
▪ Applying Newtons method to solve f ’(x) = 0
Image:
NEWTON’S METHOD
Minimise the following function using the Newton method:
f(x) = x2 - x
• Assume initial search point (xk).
• Calculate f ‘(xk)
• Calculate f ‘‘(xk)
• Calculate (xk+1)
• Iterate until converge
Image:
NEWTON’S METHOD
Minimise the following function using the Newton method:
f(x) = x2 – x
f'(x) = 2x - 1
f"(x) = 2.
Note f"(x) is always positive-definite.
Let say we pick a bracket on the minimum, say x = -10 to x = 10. Assume
x0 = 10 is the starting point for the minimization.
x1= 10 – [19/2] = 1.5
x2= 1.5 – [2/2] = 0.5
x3= 0.5 – [0/2] = 0.5 (converged)
Note: if our initial guess is 3, then we only need 1 guess to obtain the solution
NEWTON’S METHOD
Image:
NEWTON’S METHOD
How to solve this in Matlab?
We can use subroutine fminsearch
>> fun = @(x)x^2-x;
x0 = [10];
x = fminsearch(fun,x0)
x=
0.5000
Image:
NEWTON’S METHOD
How to solve this in
Wolfram?
We can use subroutine
minimize
Image:
NEWTON’S METHOD
Example:
Minimise a nonquadratic function f(x) = x4 - x + 1
Solution:
For Newton's method, f' = 4x3 - 1 and f " = 12x2, and the sequence of
steps is
Image:
NEWTON’S METHOD
Image:
NEWTON’S METHOD
How to solve this in Matlab?
We can use subroutine fminsearch
>> fun = @(x)x^4-x-1;
x0 = [10];
x = fminsearch(fun,x0)
x=
0.6299
Image:
THIS WEEK MATERIAL
Tools for Optimization
PROBLEM-SOLVING
Image:
NUMERICAL METHOD
Image:
NUMERICAL METHOD
Image:
NUMERICAL METHOD
Image:
ROOT FINDING METHODs
BISECTION METHOD
The bisection method, which is alternatively called binary chopping,
interval halving, or Bolzano’s method, is one type of incremental
search method in which the interval is always divided in half.
In general, if f(x) is real and continuous in
the interval from xl to xu and f(xl) and f(xu)
have opposite signs, that is,
f(xl) f(xu) < 0
then there is at least one real root between
xl and xu.
Image:
BISECTION METHOD
Image:
BISECTION METHOD
Problem Statement
Use the graphical approach to determine the drag coefficient c needed
for a parachutist of mass m = 68.1 kg to have a velocity of 40 m/s after
free- falling for time t = 10 s. Note: The acceleration due to gravity is
9.81 m/s2.
Solution
This problem can be solved by determining the root of the eqn above
Image:
BISECTION METHOD
The initial estimate of the root xr lies at the midpoint of the interval
This estimate represents a true percent relative error of et = 5.3% (note
that the true value of the root is 14.8011). Next we compute the product
of the function value at the lower bound and at the midpoint:
create a new interval by redefining the lower bound as 14 and
determining a revised root estimate as
Image:
BISECTION METHOD
The process can be repeated to obtain refined estimates.
We stop the process if the condition is satisfied (% relative error)
xrnew is the root for the present iteration and xrold is the root from the
previous iteration.
Image:
BISECTION METHOD
Thus, after six iterations ɛa finally falls below ɛs = 0.5%, and the
computation can be terminated.
Image:
THE SECANT METHOD
Graphical depiction of the Secant
method. This technique is similar to
the Newton-Raphson technique in
the sense that an estimate of the
root is predicted by extrapolating a
tangent of the function to the
x axis.
However, the secant method uses a
difference rather than a derivative to
estimate the slope (Newton-Raphson).
Image:
THE SECANT METHOD
(Newton-Raphson Method) (Secant Method)
Image:
THE SECANT METHOD
Notice that the approach requires two initial estimates of x. However,
because f(x) is not required to change signs between the estimates, it is
not classified as a bracketing method.
Image:
THE SECANT METHOD
Problem Statement:
Use the secant method to estimate the root of
f(x) = e-x – x
Start with initial estimates of x-1 = 0 and x0 = 1.0.
Solution
Recall that the true root is 0.56714329
Image:
THE SECANT METHOD
First iteration:
Second iteration:
Image:
THE SECANT METHOD
Third iteration:
Image:
DO IT YOURSELF
Determine the highest real root of
f(x) = e-x – x
Use Newton-Raphson Method & compare it with Secant Method.
Image:
DO IT YOURSELF
Starting with an initial guess of x0 = 0, this iterative equation can be
applied to compute
Image:
DO IT YOURSELF
Determine the highest real root of
f(x) = x3 - 6x2 + 11x - 6.1
Use Newton-Raphson Method & Secant Method.
Image:
DO IT YOURSELF
Determine the highest real root of
f(x) = x3 - 6x2 + 11x - 6.1
Image:
THE OTHER METHODS
THE FALSE-POSITION METHOD
SIMPLE FIXED-POINT ITERATION
THE NEWTON-RAPHSON METHOD
Image:
LINEAR PROGRAMMING
Linear programming (LP) is an optimization approach that deals with
meeting a desired objective such as maximizing profit or minimizing
cost in the presence of constraints such as limited resources.
For a maximization problem, the objective function is generally
expressed as
The constraints can be represented generally as
Image:
Example – Cost Optimization
The effect of insulation thickness
on total cost (x* = optimum
thickness). Insulation can be
purchased in 0.5-in. increments.
(The total cost function is shown
as a smooth curve for
convenience, although the sum
of the two costs would not
actually be smooth.)
Image:
LINEAR PROGRAMMING
Problem Statement
The following problem is developed from the area of chemical or petroleum engineering. However, it
is relevant to all areas of engineering that deal with producing products with limited resources.
Suppose that a gas-processing plant receives a fixed amount of raw gas
each week. The raw gas is processed into two grades of heating gas, regular
and premium quality. These grades of gas are in high demand (that is, they
are guaranteed to sell) and yield different profits to the company. However,
their production involves both time and on-site storage constraints. For
example, only one of the grades can be produced at a time, and the facility is
open for only 80 hr/week. Further, there is limited on-site storage for each of
the products. All these factors are listed below (note that a metric ton, or
tonne, is equal to 1000 kg):
Image:
LINEAR PROGRAMMING
Develop a linear programming formulation to maximize the profits for
this operation.
Image:
LINEAR PROGRAMMING
Develop a linear programming formulation to maximize the profits for
this operation!
Solution
The engineer operating this plant must decide how much of each gas
to produce to maximize profits. If the amounts of regular and premium
produced weekly are designated as x1 and x2, respectively, the total
weekly profit can be calculated as:
Image:
LINEAR PROGRAMMING
The constraints can be developed in a similar fashion. For example,
the total raw gas used can be computed as
This total cannot exceed the available supply of 77 m 3/week and
working hour 80 hr/week, so the constraint can be represented as
Image:
LINEAR PROGRAMMING
First, the constraints can be plotted on the
solution space. For example, the first
constraint can be reformulated as a line by
replacing the inequality by an equal sign and
solving for x2
Next, the objective function can be added to
the plot. To do this, a value of Z must
be chosen. For example, for Z = 0, the
objective function becomes
Image:
LINEAR PROGRAMMING
Now, since we are interested in maximizing
Z, we can increase it to say, 600, and the
objective function is
Increasing the value of the objective function
moves the line away from the origin.
Because the line still falls within the solution
space, our result is still feasible. Z can keep
increasing until a further increase will take
the objective beyond the feasible region.
Image:
LINEAR PROGRAMMING
The maximum value of Z corresponds to approximately 1400. At this
point, x1 and x2 are equal to approximately 4.9 and 3.9, respectively.
Thus, the graphical solu- tion tells us that if we produce these
quantities of regular and premium, we will reap a maximum profit of
about 1400.
Image:
SOLVING ODEs
Image:
SOLVING ODEs
Plots of (a) y versus x and (b) dy/dx versus
x for the function
If we differentiate Eq. above
we obtain an ODE:
Image:
SLOPE METHOD
An ODE
New value = old value
+ slope ╳ step size
Image:
EULER METHOD
An ODE
This formula is referred to as
Euler’s (or the Euler-Cauchy or the
point-slope) method. A new value
of y is predicted using the slope
(equal to the first derivative at the
original value of x) to extrapolate
linearly over the step size h
Image:
EULER METHOD
Use Euler’s method to numerically integrate
from x = 0 to x = 4 with a step size of 0.5.
The initial condition at x = 0 is y = 1
Recall that the exact solution is given by Eq. below
Image:
EULER METHOD
Image:
EULER METHOD
The approximate values were computed using Euler’s method with a step size of 0.5. The local error
refers to the error incurred over a single step.
Image:
EULER METHOD
Image:
EULER METHOD
Image:
RUNGE-KUTTA METHOD
Image:
RUNGE-KUTTA METHOD
Image:
RUNGE-KUTTA METHOD
Use the classical fourth-order RK method to integrate
using a step size of h = 0.5 and an initial condition of y = 1 at x = 0.
Image:
PLEASE CONTACT ME!
AQSHA
Assistant (Research) Professor
Dept. of Bioenergy Engineering & Chemurgy
Dept. of Chemical Engineering
Institut Teknologi Bandung, Indonesia
Waste to Energy Conversion | Biofuel & Bio-based Product Development |
CCS/BECCS | Biomimicry Catalyst | Thermochemical Conversion
Program Studi Teknik Kimia, Teknik Pangan, Teknik Bioenergi dan Kemurgi, Institut Teknologi Bandung 65