Practical Chemical Process Optimization Book
Practical Chemical Process Optimization Book
Practical Chemical Process Optimization Book
Ioannis K. Kookos
Practical
Chemical Process
Optimization
With MATLAB® and GAMS®
Springer Optimization and Its Applications
Volume 197
Series Editors
Panos M. Pardalos , University of Florida
My T. Thai , University of Florida
Honorary Editor
Ding-Zhu Du, University of Texas at Dallas
Advisory Editors
Roman V. Belavkin, Middlesex University
John R. Birge, University of Chicago
Sergiy Butenko, Texas A&M University
Vipin Kumar, University of Minnesota
Anna Nagurney, University of Massachusetts Amherst
Jun Pei, Hefei University of Technology
Oleg Prokopyev, University of Pittsburgh
Steffen Rebennack, Karlsruhe Institute of Technology
Mauricio Resende, Amazon (United States)
Tamás Terlaky, Lehigh University
Van Vu, Yale University
Michael N. Vrahatis, University of Patras
Guoliang Xue, Arizona State University
Yinyu Ye, Stanford University
Aims and Scope
Optimization has continued to expand in all directions at an astonishing rate.
New algorithmic and theoretical techniques are continually developing and the
diffusion into other disciplines is proceeding at a rapid pace, with a spot light
on machine learning, artificial intelligence, and quantum computing. Our
knowledge of all aspects of the field has grown even more profound. At the
same time, one of the most striking trends in optimization is the constantly
increasing emphasis on the interdisciplinary nature of the field. Optimization
has been a basic tool in areas not limited to applied mathematics, engineering,
medicine, economics, computer science, operations research, and other
sciences.
Volumes from this series are indexed by Web of Science, zbMATH, Mathematical
Reviews, and SCOPUS.
Ioannis K. Kookos
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature
Switzerland AG 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher,
whether the whole or part of the material is concerned, specifically the rights of translation,
reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any
other physical way, and transmission or information storage and retrieval, electronic adaptation,
computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt
from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in
this book are believed to be true and accurate at the date of publication. Neither the publisher nor
the authors or the editors give a warranty, expressed or implied, with respect to the material
contained herein or for any errors or omissions that may have been made. The publisher remains
neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
To my beloved children
Kostas and Georgia
for the happiness you have offered
to me by simply watching you grow!
Preface
introduces the modeling of decisions and logical conditions which gives rise to
mixed-integer programming problems and introduces the Branch and Bound
algorithm for solving complex problems. In Chap. 6, the GAMS® software is
introduced through some interesting recreational applications. Chapter 7
includes several classical and interesting case studies from chemical and
bio-chemical engineering.
The book is based heavily on the use of MATLAB® (www.mathworks.com)
for solving the case studies presented in Chaps. 1, 2, 3, 4, and 5 and MATLAB
Optimization ToolboxTM is introduced from the very first chapter of the book.
Appendix A offers a gentle and short introduction to MATLAB. Although
MATLAB’s built-in optimization routines have been developed over the
years, they are not as efficient as most of the specialized solvers available
from other sources. To solve the more demanding case studies in Chaps. 6 and
7, use is made of GAMS software (www.gams.com).
ix
x Contents
Consider the situation where you have been asked to design a vertical, cylin-
drical storage tank with torispherical heads (see Fig. 1.1). The only information
that you have been provided with is the operating pressure of the tank (from
which you can deduce the thickness of the shell) and the volume of the tank.
The question is how to proceed and present a practical solution to this
seemingly simple problem. The first thing to realize is that the problem at
hand has two degrees of freedom which are the tank diameter d and the tank
height h. The meaning is that once you specify the diameter and the height of
the tank, then the design is practically finished. Any combination of d and h that
satisfy the volume constraint:
πd2
h=V ð1:1Þ
4
h
d
where ρM is the density of the metal used to construct the tank. For each head
we similarly have that:
πd2
whead = area × thickness × density = a × K × t × ρM ð1:4Þ
4
1.1 An Introductory Example 3
where a is the ratio between the area of the torispherical dished (ASME) end
sections of the tank and the cross-sectional area of the cylindrical part of the
tank (a circle with diameter d, in which case a ≈ 1.124). K is the ratio between
the thickness of the end sections and the cylindrical part of the tank (which, for
dished heads, is approximately equal to 1.77). We therefore observe that
aK ≈ 2. The overall mass of the tank is therefore:
2
πd
w = πdhtρM þ 2αK tρM
4
or:
w = π dh þ d2 tρM ð1:5Þ
C0 n
f ðxÞ : R3 ° R, f ðxÞ = x ð1:8Þ
wn0 3
4 1 Preliminary Concepts and Definitions
h1 ðxÞ : R3 ° R, h1 ðxÞ = x3 - π x1 x2 þ x21 tρM ð1:9Þ
π 2
h2 ðxÞ : R3 ° R, h2 ðxÞ = V - x x ð1:10Þ
4 1 2
g1 ðxÞ : R3 ° R, g1 ðxÞ = - x1 ð1:11Þ
g2 ðxÞ : R3 ° R, g2 ðxÞ = - x2 ð1:12Þ
these are the equality and inequality constraints of the problem. Then we may
write (1.6) as:
C0 n
min x
x wn0 3
s:t: ð1:13Þ
h1 ðxÞ = x3 - π x1 x2 þ x21 tρM = 0
h2 ðxÞ = 4V - πx21 x2 = 0
g 1 ðx Þ = - x 1 ≤ 0
g 2 ðx Þ = - x 2 ≤ 0
min f ðxÞ
x
s:t: ð1:14Þ
hðxÞ = 0
gðx Þ ≤ 0
where h = [h1 h2]T and g = [g1 g2]T. This is the general form of a nonlinear
programming problem or simply NLP.
When all functions appearing in (1.14) are linear, i.e., a constant times a
variable, then one obtains the following problem:
min c T x
x
s:t: ð1:15Þ
Ax - b = 0
Bx - d ≤ 0
0≤x
1.3 Optimization of Functions of a Single Variable 5
where c, b, and d are constant vectors and A and B are constant matrices.
Formulation (1.15) is known as a linear programming problem (or simply LP)
and is the class of optimization problems for which we do have today very
efficient algorithms to attack. The requirement for the vector x to have only
non-negative elements is traditional to the formulation of the LP problems. A
related problem is that of the quadratic programming problem in which the
objective function is quadratic:
1
min c T x þ xT Qx
x 2
s:t: ð1:16Þ
Ax - b = 0
Bx - d ≤ 0
0≤x
In the general case, x 2 Rn and f:Rn → R. In the simplest possible case, x is scalar,
i.e., x 2 R and f:R → R (i.e., f is a real valued function of a single variable).
We will start from the study of problem (1.18), which you most probably have
seen already, and then move backward to finally discuss problem (1.14).
We start our journey with the simplest possible problem in optimization, i.e.,
the minimization of a real valued function of a single variable:
We will make use of the definition of the stationary point and the Taylor’s
approximation of a function around a point. We need to remind ourselves these
6 1 Preliminary Concepts and Definitions
If f(x) has continuous partial derivatives of all orders, then the value of f(x)
around x (at a distance δ from x) is given by the following Taylor series:
df 1 d2 f 2
f ðx þ δ Þ = f ðx Þ þ δ þ 2 δ þ o jδj2 ð1:21Þ
dx x 2 dx x
where the o(|δ|2) is the remainder and denotes that o(ζ) approaches zero faster
than ζ as ζ approaches zero, i.e., |o(ζ)|/ζ → 0 as ζ → 0. Starting from (1.21), we
can define the following linear and quadratic approximations of f(x) which are
more accurate when |δ| → 0:
df
f ðx þ δÞ = f ðxÞ þ δ ð1:22aÞ
dx x
df 1 d2 f 2
f ðx þ δÞ = f ðxÞ þ δ þ δ ð1:22bÞ
dx x 2 dx2 x
(1.22b) that when the first derivative is zero, the local behavior of f(x) can be
determined from its second derivative.
More specifically, the second derivative has to be positive for f(x) to increase
as we move away from x0 and negative for f(x) to decrease as we move away
from x0. The following are sufficient conditions, i.e., conditions that guarantee
that x0 is a local minimizer:
df d2 f
1: If = 0 & > 0,then x0 is a strict local minimum: ð1:23aÞ
dxx0 dx2 x0
df d2 f
2: If = 0 & 2 < 0,then x0 is a strict local maximum: ð1:23bÞ
dxx0 dx x0
df d2 f
3: If = 0 & 2 = 0, then the criterion fails: ð1:23cÞ
dxx0 dx x0
Let’s now return to our introductory example of the storage tank. We may
transform our problem to an unconstrained problem by first using (1.1) to
eliminate h from (1.5):
1 4V
w=π þ d2 tρM ð1:24Þ
d π
where a = C 0 ðπtρM Þn =wn0 and β = 4 V/π are constants. We note that we can
proceed and search for the minimum without any information regarding the
particular value of the constant a appearing in our model. We will therefore
n
search for the optimal value of the function f ðdÞ = f ðadÞ = dβ þ d2 . We will use
MATLAB® to plot the function before getting into the algebra. We will first
evaluate the value of the function for a single value of the tank diameter, and to
simplify the algebra, we select V = π/4 (or β = 1):
f = 1.5157
f = 3.9835
1.5157
3.8196
1.3 Optimization of Functions of a Single Variable 9
We now see that the cost function depends strongly on the value of the
diameter. To investigate the complete variation of the objective function, we
may plot the function for several values of d in the interval [0.1, 3] and observe
the results:
The results are presented in Fig. 1.3. Clearly the objective function has a
minimum in the interval 0.1 < d < 3. To find the minimum analytically, we set
x = d and apply (1.2):
n n - 1 h i
df d 1 1 d 1
= β þ x2 = n β þ x2 β þ x2
dx dx x x dx x
or:
n - 1
df 1 1
= n β þ x2 2x - β 2 = 0 ð1:26Þ
dx x x
>> clear
>> syms d n beta f; % define the symbolic variables d,n,β & f
>> f=(beta/d+d^2)^n; % give function
>> diff(f,d) % calculate first derivative
ans =
To rest our case, we need to determine the second derivative and to show that
it is indeed positive:
n - 1 n - 1
d df 1 d 1 1 d 1
= n β þ x2 2x - β 2 þ n 2x - β 2 β þ x2
dx dx x dx x x dx x
or:
n - 1 n - 2
d2 f 1 1 1 2 1
= n β þ x 2
2 þ 2β þ n ð n - 1 Þ 2x - β β þ x 2
dx2 x x3 x2 x
and, as the second term in the right hand side is zero, we finally obtain:
n - 1
d2 f 1 1
= n β þ x 2
2 þ 2β ð1:28Þ
dx2 x x3
1.4 Convex Functions 11
We have so far discussed the existence and the calculation of the local minima
of functions of a single variable. We need to emphasize the fact that the
conditions for locating a minimum are only valid locally (in a region around a
local minimum) and not global properties. This is depicted in Fig. 1.4 where a
case of two local minima in S, x1 and x2, is shown. x2, as can be seen by
inspection, is also the global minimum in S. There is, however, a case in
which a local minimum can be proven to be the global minimum, i.e.,
f(x0) < f(x) for every x in S. This can be guaranteed if f(x) is a convex function.
By comparing (1.32) with (1.22), it is easy to derive the local criterion for
convexity:
d2 f
≥0 ð1:33Þ
dx2 x0
If (1.33) holds for all x in S (as it does for f(x) = x2), then the function is convex
everywhere, and any local minima is also the global minimum.
Examples of convex functions are the following:
• eax, for any a > 0
• e f(x), if f(x) is convex
• xn, for n < 0 or n > 1, for positive x
• ax + b, for any a and b
1.5 Applications 13
1.5 Applications
A B
E ðr Þ = - þ ð1:34Þ
rn rm
14 1 Preliminary Concepts and Definitions
where A and n are constants associated with the attractive forces developed,
while B and m are constants associated with the repulsive forces. It is reminded
that the force developed between the atoms is calculated with principles of
classical mechanics and is the negative of the derivative of the potential energy:
dE ðr Þ
F ðr Þ = - ð1:35Þ
dr
clear
A=14.45;
B=12.13;
e=0.003121; % eV
sigma=0.274; % nm
r=linspace(0,3*sigma,1001);
E=-2*e*(A*(sigma./r).^6-B*(sigma./r).^12);
plot(r/sigma,E/(2*e),'LineWidth',1)
axis([0.9 3 -5 1])
grid on
xlabel('Intermolecular separation (r/\sigma)')
ylabel('potential (E/2\epsilon)')
1.5 Applications 15
The results are presented in Fig. 1.7, from which we immediately observe
the existence of a minimum in potential energy. To derive the analytic expres-
sions, we calculate the first and second derivative:
dE ðr Þ
d σ n d σ m
= - 2ε A -B
dr dr r dr r
h m - 1 i d σ
σ n-1
= - 2ε nA r - mB σr
dr r
or:
dE ðr Þ h n m i
σ σ 1
= 2ε nA - mB ð1:37Þ
dr r r r
and:
16 1 Preliminary Concepts and Definitions
n h n m i o
d 2 E ðr Þ d dE ðr Þ d σ σ 1
2
= = 2ε nA - mB
dr dr dr dr r r r
h n m i h n m i
1 d σ σ σ σ d 1
= 2ε nA - mB þ nA - mB
r dr r r r r dr r
nh n m i h n m io
σ σ σ σ d 1
= 2ε n2 A - m2 B þ nA - mB
r r r r dr r
or:
d 2 E ðr Þ h m n i
σ σ 1
2
= 2ε ðm þ 1ÞmB - ðn þ 1ÞnA ð1:38Þ
dr r r r2
We then calculate the separation distance by finding r that makes the first
derivative equal to zero:
dE ðr Þ h n m i n m
σ σ 1 σ σ
= 2ε nA - mB = 0 ) nA = mB
dr r r r r r
or:
1=ðn - mÞ
r nA
= = 1:0902 ð1:39Þ
σ mB
n m
Using the fact that nA σr = mB σr , the second derivative at the optimum
separation becomes:
d 2 E ðr Þ
εA σ nþ2
= 2nð m - nÞ >0 ð1:40Þ
dr 2 σ2 r
Things would have been simpler if we had used MATLAB to perform the
algebra:
>> simplify(diff(E,r,1))
(continued)
1.5 Applications 17
>> simplify(diff(E,r,2))
We will now use Fig. 1.6 to calculate the density of the crystal. From Fig. 1.6
and simple geometric arguments, we have that:
pffiffiffi pffiffiffi
2a2 = 4r 20 ) a = r 0 2 = 1:0902 2σ ð1:41Þ
The mass of an Ne atom is the molecular mass divided by the Avogadro number
(NA). From careful examination of Fig. 1.6, we conclude that there are four
atoms in one cell. As the density is the mass per volume, we have that:
4mwNe
ρNe =
N A a3
4 20:18 mol
g
= pffiffiffi 3 - 7 3
6:02214076 × 1023 mol 1:0902 2 0:274 nm
1 3 10 cm
nm
g
= 1:778
cm3
P w
T w
P P
N T T
P
C-101 T
E-101
C-102
where N is the molar flow rate of the gas, R is the ideal gas constant, e (<1) is
the fractional efficiency with respect to a reversible adiabatic compression, and
cP (cv) is the constant pressure (volume) heat capacity. As the temperature in
the suction of both compressors is the same, we have:
a a
W 1 P 1 Pf
w = NRT 0 = -1 þ -1
a P0 a P
e
or:
a a
1 P Pf
w= þ -2 ð1:43Þ
a P0 P
We may note that the ratio of the delivery to suction pressure (known as
compression ratio) for the two compressors is:
pffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffi
P P0 P f Pf Pf P
= = = pffiffiffiffiffiffiffiffiffi
ffi= f ð1:46Þ
P0 P0 P0 P0 P f P
i.e., at the optimum point, the compression ratios of the two compressors are
equal. To make sure that the solution given by (1.45) corresponds to a mini-
mum, we calculate the second derivative to validate that it is indeed positive
everywhere:
rffiffiffiffiffi
d2 w 2a Pf
= >0 ð1:47Þ
dP2 P f P0 P0
1.5 Applications 19
F F F
C C C
FC 0 - FC - V 1 kC = 0 ð1:48Þ
and in reactor 2:
FC - FC f - V 2 kC f = 0 ð1:49Þ
The total volume is the sum of the volumes of the two reactors:
20 1 Preliminary Concepts and Definitions
F C0 - C F C - Cf F C0 C
V ðC Þ = V 1 þ V 2 = þ = þ -2 ð1:52Þ
k C k Cf k C Cf
If we set the first derivative equal to zero and solve for the concentration, we
obtain:
pffiffiffiffiffiffiffiffiffiffi
C= C0Cf ð1:54Þ
>> clear
>> syms C F k C0 Cf V positive;
>> V=(F/k)*(C0/C+C/Cf-2);
>> diff(V,C)
ans = -(F*(C0/C^2 - 1/Cf))/k
>> solve(diff(V,C)==0,C)
ans = C0^(1/2)*Cf^(1/2)
>> diff(V,C,2)
ans = (2*C0*F)/(C^3*k)
As the second derivative is positive for all C in [C0, Cf], the solution deter-
mined by (1.54) corresponds to a global minimum.
We substitute the solution given by (1.54) to Eqs. (1.50) and (1.51) to
determine the volumes:
rffiffiffiffiffi
F C0
V1 = V2 = -1 ð1:56Þ
k Cf
It follows that at the optimal solution, the two volumes are equal.
1.5 Applications 21
S: substrate
X: cells P: product
D=F/V V
Feed
F F
S S
X
P
Product
Biomass : - FX þ Vr X = 0 ð1:57Þ
Substrate : FS 0 - FS - Vr S = 0 ð1:58Þ
Product : - FP þ Vr P = 0 ð1:59Þ
The production rate of the biomass is usually expressed through the defini-
tion of the specific production rate, denoted by μ:
rX = μX ð1:60Þ
22 1 Preliminary Concepts and Definitions
In many cases, as it is, for example, the case of bioethanol production, there
is an inhibition effect caused by the product. The specific production rate is
described by a classical Monod equation with an additional term to account for
the inhibition:
rX S
μ= = μ max e - P=P max ð1:61Þ
X Ks þ S
μmax is the maximum specific production rate, Ks the saturation constant, and
Pmax a constant related to the inhibition by the product.
The rate of product formation can be considered, for growth-associated
product formation, analogous to the rate of biomass production, i.e.:
- FX þ VμX = 0
or:
F
D= =μ ð1:63Þ
V
where D is called the dilution rate. From (1.63), it follows that for a continuous
bioreactor, the dilution rate is equal to the specific biomass production rate.
Using this result, (1.58) becomes:
μX
F ðS 0 - S Þ - V =0
Y X=S
or:
X
S = S0 - ð1:64Þ
Y X=S
where we have used the yield coefficient YX/S which can be defined as the ratio
of rX to rS. If we now substitute (1.62) and (1.63) into (1.59), we also obtain:
- FP þ VaμX = 0
or:
1.5 Applications 23
P = aX ð1:65Þ
S0 - X
Y X=S
D = μ max e - aX=P max ð1:66Þ
K S þ S0 - X
Y X=S
We have achieved to eliminate all variables and express the dilution rate as a
function of the biomass concentration.
The productivity of bioreactors is defined as the mass of the product
produced per unit reactor volume and per unit time. In the case of a continuous
bioreactor, the mass of the product produced is the flow rate of the product
stream F times the concentration of the product. If we then divide by the
reactor volume, we obtain the productivity Π:
F P
Π= =D P ð1:67Þ
V
S0 - X
Y X=S
Π = μ max e - aX=P max aX ð1:68Þ
K S þ S0 - X
Y X=S
S
ΠðS Þ = ξ e - aY X=S S=P max ðS0 - S Þ ð1:69Þ
Ks þ S
where:
aY X=S S 0
ξ = μ max e P max aY X=S ð1:70Þ
or:
Setting the derivative equal to zero is equivalent to the expression inside the
brackets to be equal to zero, from which we obtain (the algebra is again lengthy
but involves only basic operations):
αS 3 þ βS 2 þ γS þ δ = 0 ð1:72Þ
where:
aY X=S aY X=S
α= , β=1 þ ðK s - S 0 Þ,
P max P max
aY X=S
γ = Ks 2 - S Þ , δ = - K s S0
P max 0
1 g g g g
μ max = 0:41 , K s = 0:4 , a = 2:44 , Y X=S = 0:1 , S0 = 100 ,
h L g g L
g
P max = 35
L
Let’s perform the calculations in MATLAB and generate the plot of productivity
as a function of the substrate concentration.
(continued)
1.5 Applications 25
>> hold on
>> plot(D,X,'k-','Linewidth',1.5)
>> plot(D,S,'k--','Linewidth',1.5)
>> axis([0 0.45 0 30])
>> figure(2)
>> plot(S,D.*P,'k-','Linewidth',1.5)
>> grid on
>> alpha=a*Yxs/Pmax; % Eq. (1.72)
>> beta=1+alpha*(Ks-S0);
>> gamma=Ks*(2-alpha*S0);
>> delta=-Ks*S0;
>> roots([alpha beta gamma delta])
ans = -37.8671
-15.6546
9.6791
The results are presented in Figs. 1.11 and 1.12. The substrate concentration
at the optimum is approximately 9.68 g/L. To determine the dilution rate, we
can substitute into Eqs. (1.64), (1.65), and (1.66):
Fig. 1.11 Biomass, substrate, and product concentration as a function of dilution rate
26 1 Preliminary Concepts and Definitions
>> Sopt=max(ans)
Sopt = 9.6791
>> Xopt=Yxs*(S0-Sopt)
Xopt = 9.0321
>> Popt=a*Xopt
Popt = 22.0383
>> Dopt=miumax*Sopt*exp(-Popt/Pmax)/(Ks+Sopt)
Dopt = 0.2098
S 2 þ 2K s S - K s S 0 = 0 ð1:720 Þ
Analytic solution can be obtained in this case (note that S is non-negative), and
the optimum substrate concentration is given by:
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
S = Ks 1 þ S0 =K s - 1 ð1:73Þ
1.5 Applications 27
– –
o
O2– E
– –
o
I=jA
Fig. 1.14 Comparison of experimental results (o) with model predictions for a solid oxide
fuel cell. (Experimental results from Huang et al., 2010)
where E0 is the voltage at zero current (E0 = 0.85 V), RΩ is the (area specific)
Ohmic resistance (RΩ = 0.145 Ωcm2), R is the ideal gas constant
(R = 8.3144 VC/(mol K)), Τ is the absolute temperature (873 K for the data
shown in Fig. 1.14), and F is the Faraday’s constant (96,485 C/mol). jL is the
limiting current density (3.85 V).
We consider the case where our goal is to extract the maximum power. The
power density P (w/cm2) is the product of the voltage and the current density:
RT j
PðjÞ = E ðjÞ j = E 0 j - RΩ j þ
2
ln 1 - j ð1:75Þ
2F jL
We note that:
dð - PÞ dE
= -E-j ð1:76Þ
dj dj
and:
1.5 Applications 29
dE d RT j RT 1
= E - RΩ j þ ln 1 - = - RΩ - ð1:77Þ
dj dj 0 2F jL 2F ðjL - jÞ
d 2 ð - PÞ 1 jL
= 2RΩ þ f þf >0 ð1:79Þ
dj 2 ð j L - j Þ ðj L - j Þ2
It follows that as j < jL, the second derivative is always positive. Before closing
this section, in Fig. 1.15, the variation of the power density as a function of the
current density is presented, from which we note that there is indeed a clear
maximum (which, however, we cannot determine analytically).
Let’s summarize what we have learned from trying to solve some representa-
tive examples of single variable optimization. The optimization problem is
transformed to a problem of solving a possibly nonlinear equation that is
obtained when applying optimality conditions (1.23). We begin with the objec-
tive function f(x) which we seek to minimize, and we end up with searching for
the values of x that are roots of its first derivative. However, as we have seen,
solving a nonlinear equation is far from easy, even when the equation involves
a single variable only. We therefore have to rely on numerical techniques for
solving the resulting nonlinear equation. We will therefore complete this
chapter by reviewing the basics about the most well-known methodology for
solving nonlinear equations which is the Newton’s method.
In what follows, we will be using the symbol F to denote the first derivative
of f and the symbol H for the second derivative of f (or the first derivative of
F), i.e.:
df ðxÞ
F ðx Þ = ð1:80Þ
dx
d2 f ðxÞ dF ðxÞ
H ðx Þ = = ð1:81Þ
dx2 dx
F ðx Þ = 0 ð1:82Þ
We then equate the linear approximation to zero and use the definition of H(x)
to obtain:
1
δx = - F ðxÞ ð1:85Þ
H ðx Þ
x1 = x0 þ δx1 ð1:86Þ
1
δxkþ1 = - F xk ð1:87Þ
H ðx Þ
k
and:
f xk+δxk
f xk F xk x–xk
fx
f xk
f xk+ δxk
Fig. 1.16 Naïve backtracking algorithm (note that taking a full Newton step results in an
increased value of f(x), while one backtracking step results in a decreased value)
n
1
xkþ1 = xk þ δxkþ1 , n is smallest n : f xkþ1 < f xk is satisfied ð1:91Þ
2
In other words, we start with n = 0 and check whether f has been decreased
(see Fig. 1.16). If this turns out not to be the case, we set n = n + 1 and
backtrack from our previous trial position. This is repeated until we discover
the first point (smaller n) that results in a lower value for f relative to f(xk).
We can allow ourselves to backtrack a finite number of times; otherwise, as
n increases xk+1 → xk, and the algorithm must terminate. When we are stack in
our rudimentary algorithm, there is a way out: to try a different starting point
x0. The algorithms that handle the size of the step taken at each iteration in an
efficient (robust and still fast) implementation of the Newton’s method are
rather sophisticated. We will return to this point when studying unconstrained
optimization in many directions where the issue of backtracking is vital to the
Newton’s method. It is important to note that single-variable optimization is
performed (without relying in most cases on derivative information) by using
local interpolation with quadratic or cubic polynomials or the bisection
algorithm.
Before closing this paragraph, it is important to note that there are two other
options for setting the size of the Newton step. The first is the simplest and uses
a constant factor (usually smaller than 1) that multiplies the full Newton step.
This is very simple and can be efficient in some cases but needs a trial-and-
error approach to find what is the appropriate factor in each case study. The
other extreme is to handle the scale factor as the optimization variable and try
to locate the exact optimal value. This is called exact line search and can be
1.6 The Numerical Solution of Single Variable Optimization Problems: Newton’s. . . 33
>>clear
>>f0=inline('-x*(0.85-0.145*x+0.0376*log(1-x/3.85))')
>>f1=inline('-0.85+2*0.145*x-0.0376*log(1-x/3.85)+0.0376*x/
(3.85-x)')
>>f2=inline('2*0.145+0.0376/(3.85-x)+0.0376*3.85/(3.85-x)
^2')
f0 = Inline function:
f0(x) = -x*(0.85-0.145*x+0.0376*log(1-x/3.85))
f1 = Inline function:
f1(x) = -0.85+2*0.145*x-0.0376*log(1-x/3.85)+0.0376*x/
(3.85-x)
f2 = Inline function:
f2(x) = 2*0.145+0.0376/(3.85-x)+0.0376*3.85/(3.85-x)^2
>> x=3.6;
>> f=feval(f0,x) ; % response f = -0.8107
>> F=feval(f1,x) ; % response F = 0.8383
>> H=feval(f2,x) ; % response H = 2.7566
>> NewtonStep=-F/H; % response NewtonStep = -0.3041
>> x=x+NewtonStep ; % response x = 3.2959
>> f=feval(f0,x) ; % response f = -0.9862
The tangent at x = 3.6 is shown in Fig. 1.17 and is given by the following
equation (k = 0):
F xk þ δxkþ1 = F xk þ H xk δxkþ1 = 0:8383 þ 2:7566 δxkþ1 ð1:92Þ
Equating this to zero and solving for δx1 gives δx1 = -0.3041, and finally the
new estimate of the solution is x1 = x0 + δx1 = 3.6–0.3041 = 3.2959 (point at
which the tangent at x0 becomes zero in Fig. 1.17). As the objective becomes
34 1 Preliminary Concepts and Definitions
Fig. 1.17 Steps of the Newton methodology when applied to the fuel cell case study
smaller (more negative), the Newton step is accepted. We determine the new
tangent at this new point:
Table 1.1 Results of applying Newton method to the fuel cell case study
k f(xk–1) F(xk–1) H(xk–1) δxk xk
0 3.6000
1 -0.8107 +0.8383 +2.7566 -0.3041 +3.2959
2 -0.9862 +0.4024 +0.8294 -0.4851 +2.8108
3 -1.1052 +0.1161 +0.4602 -0.2522 +2.5586
4 -1.1205 +0.0076 +0.4059 -0.0186 +2.5400
5 -1.1206 2.6826 10-5 +0.4031 -6.6558 10-5 +2.5399
6 -1.1206 3.337510-10
Table 1.2 Implementation of the Newton algorithm (to be used only for training)
36 1 Preliminary Concepts and Definitions
based on a combination of the Golden section method and the cubic interpo-
lation method), and therefore only the function is required, which is a signif-
icant advantage. Its general syntax is as follows:
>> options=optimset('display','iter');
>> f0=inline('-x*(0.85-0.145*x+0.0376*log(1-x/3.85))');
>> xopt=fminbnd(f0,0.1,3.6,options)
The procedure takes nine iterations to locate the optimum which agrees
with the one found using the Newton’s method.
Learning Summary
The most general class of optimization with continuous variables is the NLP
problem:
min f ðxÞ
x
s:t:
hðx Þ = 0
gðx Þ ≤ 0
Learning Summary 37
min c T x
x
s:t:
Ax - b = 0
Bx - d ≤ 0
0≤x
min f ðxÞ
x
min f ðxÞ
x2R
The definition of the local minimum: let D be the domain of f. f has a strict
local minimum value at a point x0 if f(x) > f(x0) for all x lying in an open interval
around x0. The conditions that need to be satisfied at an extremum are
(sufficient conditions):
df d2 f
1: If = 0& > 0, then x0 is a strict local minimum:
dxx0 dx2 x0
df d2 f
2: If = 0& 2 < 0, then x0 is a strict local maximum:
dx x0 dx x0
df d2 f
3: If = 0& = 0, then the criterion fails:
dxx0 dx2 x0
38 1 Preliminary Concepts and Definitions
Problems
r1 = - k1 C R
r2 = - k2 C P
C P ðt Þ k 1 - k1 t
= e - e - k2 t
C R,0 k2 - k1
1.2 The potential energy is many ion pairs (such as Na+-Cl-) can be described
by the following potential or bonding energy (in eV per pair)
α β
E ðr Þ = - þ
r rν
q_ = Ao U o ðT i - T 1 Þ
To
qloss ri
ro
h , T∞
k
hi , Ti
(a) Explain why increasing the outside radius (i.e., the thickness of the
insulation) may result in an increase in the heat transfer losses.
(b) Calculate the critical thickness of the insulation by determining the
conditions at which losses are maximized (prove that it is actually a
maximum).
1.4 We continue with Problem 1.3. Consider now the case where instead of a
cylindrical pipe you have a spherical storage tank. What are the condi-
tions of the critical thickness of insulation? It is reminded that the heat
losses in this case are given by:
q_ = Ao U o ðT i - T 1 Þ
1 r - ri 1 1
≈ o þ
Ao U o 4πkr o r i 4πr 2o ho
(a) Explain why increasing the outside radius (i.e., the thickness of the
insulation) may result in an increase in the heat transfer losses.
(b) Calculate the critical thickness of the insulation by determining the
conditions at which losses are maximized (prove that it is actually a
maximum).
1.5 We return to Problem 1.3. Define the Biot number as Bi = hri/k and the
dimensional heat loss as:
q_
Q=
2πLk ðT i - T 1 Þ
Show that
1
Q=
ln ro
ri þ ri
ro Bi1
Use MATLAB to produce Fig. P1.5. What conclusion can be drown from
Fig. P1.5?
Problems 41
Fig. P1.5 Dimensionless heat loss as a function of dimensionless insulation thickness and Bi
number
1.6 A storage tank with conical basis and a flat top (see Fig. P1.6) has a radius
r equal to the height h of the conical basis. The cylindrical part has a
height H. If the volume of the tank needs to be equal to V = 9π, find the
dimensions of the tank that minimize the outer surface of the tank. It is
reminded that the volume Vc and the lateral surface Sc of a cone are
given by:
π 2 pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
Vc = r h, Sc = πr r 2 þ h2
3
1.7 Snell’s law is a formula used to describe the relationship between the
angles of incidence and refraction, when referring to light passing
through a boundary between two different isotropic media, such as
water and air. The refraction index, n, of a transparent medium is defined
as the ratio of speed of light in vacuum to the speed of light in that
medium u. If the speed of light in air is u1 (refraction index n1 = c/u1)
and in water is u2, prove that:
n1 sin θ1 = n2 sin θ2
Problems 43
where the angles θ1 and θ2 are defined in Fig. P1.7. Use the idea that light
will follow the path that minimizes the time needed to travel from the eye
to the fish!
1.8 A wind turbine (WT) is shown in Fig. P1.8 which has a sweep area AWT. A
WT extracts energy by “slowing down” the wind (transforming the kinetic
energy of the wind to a kinetic energy of the blades). A 100% efficient WT
would need to stop completely the wind—but then the rotor would have
to be a solid disk, and it would not turn. A wind turbine with just one
rotor blade will not work either, as most of the wind passing through the
area swept by the WT blade would miss the blade completely. Let’s
assume that the upstream and downstream velocities of the wind are u0
and u1 and that the velocity of the wind at the turbine is the mean
between these two: u = (u0 + u1)/2. Perform the following step to
prove the Betz limit on the energy that can be extracted from the wind
(Betz’s law):
(a) Calculate the maximum energy that can be extracted from the wind if
the wind “slows down” from u0 to u1 (change in the kinetic energy
ΔΕK).
(b) Calculate the mass flow rate of the wind through the sweep area of
the WT using the velocity of the wind at the turbine.
(c) Substitute the mass flow rate into the equation for the change in the
kinetic energy, and prove that the maximum change in the kinetic
energy is realized when u1 = u0/3.
(d) Substitute this result to show that the maximum fraction of the
kinetic energy of the incoming wind that can be recovered is equal
to 16/27 (or 59.26%).
1.9 The reaction A $ B is taking place in two identical CSTRs in series that
operate in the same temperature. The reaction rate is given by:
44 1 Preliminary Concepts and Definitions
CB
r = k CA -
KE
ω2n
G ð sÞ =
s2 þ 2ζωn s þ ω2n
where ωn is the natural frequency and ζ is the damping ratio. When ζ < 1,
it follows that the unit step response is:
" #
ζ
yðt Þ = 1 - en- ζωn t cos ðωd t Þ þ pffiffiffiffiffiffiffiffiffiffiffiffiffi sin ðωd t Þ
1 - ζ2
where:
qffiffiffiffiffiffiffiffiffiffiffiffiffi
ω d = ωn 1 - ζ2
Fig. P1.9 Unit step response of a prototype second-order system with ζ = 0.2
46 1 Preliminary Concepts and Definitions
dxðt Þ
þ axðt Þ = buðt Þ, xð0Þ = x0 = 1
dt
with a, b > 0 and the feedback control law u(t) = -kx(t). Our aim is to
find the value of k so that the following criterion is minimized:
Z 1
J ðk Þ = x2 ðt Þ þ ru2 ðt Þ dt, r ≥ 0
0
Prove that the minimum is achieved at the root of the following quadratic
equation that guarantees stability:
α
rk2 þ 2 rk - 1 = 0
b
y = ax
r i = axi - yi , i = 1,2,⋯,n
X T Xa = X T Y
ty
PB = V ðC 0 - C Þ
t batch þ t downtime
where tbatch is the time needed to achieve the final concentration C in the
batch reactor, which is given by:
1 C
t batch = ln 0
k C
r = kf C A - kb C B
ZX
V dX 1 kf
= = ln
F k f - ðkf þ kb ÞX kf þ kb kf - ðkf þ kb ÞX
0
h i
1 xD 1 - xD
rr min = -α
α-1 z 1-z
h i
ln 1 -xDxD 1 -xBxB
N min =
ln α
(b) The only optimization variable λ, which is the ratio between the
actual reflux ratio (rr) to the minimum reflux (rrmin), is selected,
and the actual reflux ratio and the actual number of theoretical
trays NT are estimated:
N T - NT, min
3 rr - rr min 0:5668
= 1-
NT þ 1 4 rr þ 1
NT - 1
H = 1:2 TS
Eo
2
uV = pffiffiffiffiffi
ρV
uV ρV Anet = mw ð1 þ rÞDC
πD2C
0:88 = Anet
4
(e) The heat load of the reboiler QB and condenser QD are calculated
followed by the calculation of the heat transfer area of the reboiler
and the condenser (AB, AD), by assuming that the product of the heat
transfer coefficient and the logarithmic mean temperature difference
are approximately equal to 100 kW/m2:
QB = ð1 þ rrÞD ΔhB
100AB = QB
QD = ð1 þ rrÞD ΔhD
100AD = QD
0 1
1B C
C EQ = @20,000 H 0:81 D1:05 þ 700 H 0:97 D1:45 þ 8000A0:65 þ 8000A0:65 B A
3 |fflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflffl}
C C
|fflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflffl}
C C
|fflfflfflfflfflffl{zfflfflfflfflfflffl}
D
|fflfflfflfflfflffl{zfflfflfflfflfflffl}
shell trays condenser reboiler
(g) The cost of the utilities (practically the heating steam) is estimated
using the operating time ty and the unitary utility cost clps:
QB
C UT ≈ t c
Δhlps y lps
TAC = C EQ þ C UT
50 1 Preliminary Concepts and Definitions
Table P1.16 Implementation of the FUG method for designing binary distillation columns
for constant relative volatility systems
Problems 51
The similarity is striking, and as we will see shortly, this similarity will help us
derive the optimality conditions and solution methodologies.
A key concept in developing the optimization theory for problem (2.1) was
the first and second derivative and the (linear and quadratic) Taylor approx-
imation of a function of a single variable. The immediate question to answer is:
What is the generalization of these concepts to a function of several variables?
Let’s consider a function of two variables f:R2 → R, i.e. f(x1,x2). What is the
definition of the first derivative? As we have two variables, we need to consider
two first derivatives, one with respect to x1 and one with respect to x2. This
operation follows directly from the operation that we apply when we calculate
the derivative of a function of a single variable. The only difference is that when
we calculate the derivative with respect to x1, we treat x2 as constant, i.e., we
perform the operation:
d ∂f
f ðx1 , x2 Þjx2 = constant = ð2:3Þ
dx1 ∂x1
∂x2
The next, and most important, step is to present the generalization of the
Taylor approximation. Let’s remind ourselves the form of the quadratic
approximation around x0 for the case of a function of a single variable:
df 1 d2 f
f ðxÞ = f ðx0 Þ þ ð x - x Þ þ ð x - x Þ ðx - x 0 Þ ð2:7Þ
dxx0 0
2 0
dx2 x0
1
f ðxÞ = f ðx0 Þ þ ∇T f ðx0 Þðx - x0 Þ þ ðx - x0 ÞT Hðx0 Þðx - x0 Þ ð2:8Þ
2
For convex functions, there is a useful property that follows directly from
(1.32):
∇f ðx0 Þ = 0 ð2:11Þ
If we restrict attention to stationary points, then from (2.8), the local behavior
of f(x) is determined from the Hessian matrix:
1
f ð x Þ - f ðx 0 Þ ≈ ðx - x 0 ÞT H ðx 0 Þðx - x 0 Þ ð2:12Þ
2
If f(x0) is a (strict) local minimum, then it follows that f(x) – f(x0) > 0 and
therefore:
If this holds true, then H(x0) is called a positive definite matrix (p.d.). A matrix is
positive definite if and only if all of its eigenvalues are positive. We may,
therefore, calculate the eigenvalues of the Hessian matrix and determine
whether it is a local minimum or not. If f(x0) is a (strict) local maximum, then
the Hessian matrix is negative definite (n.d., i.e., all its eigenvalues are nega-
tive). If the Hessian happens to be positive definite everywhere, then the
results are global as the function is convex and (2.10) holds true. To summa-
rize, the sufficient conditions for a local minimum in the case of a differentiable
function of many variables are:
56 2 Multidimensional Unconstrained Optimization
∇ f ðx 0 Þ = 0 ð2:14Þ
&ðx - x0 ÞT Hðx0 Þðx - x0 Þ > 0 or Hðx0 Þ is p:d: ð2:15Þ
>> clear
>> syms x y;
>> fmesh(x.^3+y.^3+2*x.^2+4*y.^2+6, [-1.5 0.5 -3.5 0.5])
In Fig. 2.2, the contour plots of the same function are given and have also
been generated in MATLAB:
From the surface and the contours, we note that there are four stationary
points. To determine them, we calculate the gradient:
xð3x þ 4Þ
∇f ðx, yÞ = ð2:17Þ
yð3y þ 8Þ
The stationary points are (0,0), (0,-8/3), (-4/3,0), and (-4/3,-8/3). We will
study these points one by one, but we first calculate the Hessian:
6x þ 4 0
Hðx, yÞ = ð2:18Þ
0 6y þ 8
f=
x^3 + 2*x^2 + y^3 + 4*y^2 + 6
>> g=gradient(f)
g=
3*x^2 + 4*x
3*y^2 + 8*y
>> H=hessian(f)
H=
[ 6*x + 4, 0]
[ 0, 6*y + 8]
6x þ 4 0 4 0
Hð0, 0Þ = = ð2:19Þ
0 6y þ 8 ð0, 0Þ 0 8
where I2 is the 2-by-2 unit matrix. However, as the hessian is diagonal, the
solutions follow immediately, and the eigenvalues are λ1 = +4 > 0 and
λ2 = +8 > 0. As both eigenvalues are positive, the hessian is positive definite,
and point (0,0) is a local minimum. The corresponding value of the function is
f(0,0) = 6. Locally, the function can be approximated by:
1 x 1 2
f ðx, yÞ ≈ f ð0, 0Þ þ ½ x y Hð0, 0Þ =6 þ 4x þ 8y2 ð2:21Þ
2 y 2
6x þ 4 0 4 0
Hð0, - 8=3Þ = = ð2:23Þ
0 6y þ 8 ð0, - 8=3Þ 0 -8
As the hessian is again diagonal, the eigenvalues follow immediately and are
λ1 = 4 > 0 and λ2 = -8 < 0. As one eigenvalues is positive and one is negative,
the hessian is indefinite (a square matrix is indefinite if and only if it has at least
one positive eigenvalue and at least one negative eigenvalue), and point (0,-8/
3) is neither a local maximum or a local minimum. When a point is a stationary
point and the hessian matrix is indefinite, then the point is a saddle point (the
general form of the surface and the contour lines around a saddle point are
shown in Figs. 2.3 and 2.4). Locally, the function can be approximated by:
" #
h i x
1 8 8
f ðx, yÞ ≈ f ð0, - 8=3Þ þ x yþ H 0, - 8
2 3 3 yþ
3 ð2:24Þ
2
418 1 8
= þ 4x2 - 8 y þ
27 2 3
Fig. 2.3 Surface around the minimum (0,0) (left) and one saddle point (0, - 8/3) (right) of
the function f(x, y) = x3 + y3 + 2x2 + 4y2 + 6
60 2 Multidimensional Unconstrained Optimization
Fig. 2.4 Contours around the minimum (0,0) (left) and one saddle point (0, - 8/3) (right) of
the function f(x, y) = x3 + y3 + 2x2 + 4y2 + 6
(which is the standard form of the equation of a hyperbola with center (0,–8/
3)). This justifies the form of the contour lines around the point (0,–8/3) shown
in Fig. 2.2 that resemble the case shown in Figs. 2.3 and 2.4. Point (-4/3,0) has
the same characteristics as point (0,–8/3).
C. Point (-4/3,–8/3). The gradient is zero while the hessian is:
6x þ 4 0 -4 0
H ð - 4=3, - 8=3Þ = = ð2:26Þ
0 6y þ 8 ð - 4=3, - 8=3Þ 0 -8
The hessian is again diagonal, and the eigenvalues follow immediately and are
λ1 = -4 < 0 and λ2 = -8 < 0. As both eigenvalues are negative, point (-4/3,–
8/3) is a local maximum. Locally, the function can be approximated by:
3 2
4
h i xþ
1 4 8 4 8 6 3 7
f ðx, yÞ ≈ f ð - 4=3, - 8=3Þ þ xþ yþ H - , - 4 5
2 3 3 3 3 8
yþ
2 2
3
50 1 4 8
= þ -4 x þ -8 y þ
3 2 3 3
ð2:27Þ
∇f x
δx
fx θ
which f(x0) = c. Obviously, the contour line f(x) = c passes through x0 as shown
in Fig. 2.5. Consider now any unit vector δx emanating from x0. Any vector that
satisfies the unit length criterion has its end point on the unit circle with center
at x0. Let us now calculate the linear approximation of f(x) around x0 as shown:
The dot product of two vectors can be calculated as the product of their
magnitudes and the cosine of their angle θ (see Fig. 2.5). We write (2.29) as
follows:
However, δx is a unit vector and therefore (as the norm of any vector is a
scalar):
cosθ is maximum when θ = 0, i.e., when δx is collinear and has the same
direction as the gradient vector, then the change in f(x) is maximized. When
θ = -π, then cosθ is minimum, i.e., when δx is parallel with the gradient and has
direction opposite to the direction of the gradient vector, then the change in
f(x) is minimized. When θ = ±π/2, then the change in f(x) is zero (i.e., we stay
on the same contour at least locally). We therefore conclude that if we are at a
point x0 in Rn, then:
62 2 Multidimensional Unconstrained Optimization
∇T f ð x 0 Þ ð x - x 0 Þ = 0 ð2:32Þ
∇T f ð x 0 Þ ð x - x 0 Þ > 0 ð2:33Þ
∇T f ð x 0 Þ ð x - x 0 Þ < 0 ð2:34Þ
∇f ðx0 Þ = 0 ð2:36Þ
&Hðx0 Þ is positive definite ð2:37Þ
The method to locate any x that satisfies (2.36) will be of iterative nature.
We start by writing the quadratic approximation of f(x) around a point that we
have arrived at iteration k:
1 T
f xk þ δxk = f xk þ ∇T f xk δxk þ δxk H xk δxk ð2:38Þ
2
where δxk = x–xk. We take the derivative with respect to δxk to obtain an
approximation for the gradient:
2.2 Algorithms for Multivariable Unconstrained Optimization 63
∇f xk þ δxk = ∇f xk þ H xk δxk ð2:39Þ
Using (2.36) and (2.39), we obtain the following iterative methodology for
calculating the step at iteration k:
H xk δxk = - ∇f xk ð2:40Þ
As we know from the previous chapter, this is the basic Newton’s method
which has no guarantee to locate the (local) optimal solution. However, before
moving further, we will examine the general performance of the method when
applied to representative functions.
We first examine the following function (see also Fig. 2.6):
2
f ðxÞ = 10 x21 - x2 þ ðx1 - 1Þ2 þ 4 ð2:41aÞ
The initial point chosen is x0 = [-1 3]T. We calculate the gradient and the
hessian at the initial point:
64 2 Multidimensional Unconstrained Optimization
Fig. 2.6 Contour and surf plots generated in MATLAB for f(x,y) given by (2.41)
2.2 Algorithms for Multivariable Unconstrained Optimization 65
" #
0 40 x21 - x2 x1 þ 2x1 - 2 76
∇f x = =
- 20 x21 - x2 40
120x21 - 40x2 þ 2 - 40x1 2 40
H x0 = =
- 40x1 20 40 20
dx = -0.0513
-1.8974
>> x=x+dx
x = -1.0513
1.1026
>> f(x)
ans = 8.2078
Repeating the same process for a second time, we obtain the following:
66 2 Multidimensional Unconstrained Optimization
>> dx=-inv(H(x))*g(x)
dx = 1.9488
-4.0948
>> x=x+dx
x = 0.8975
-2.9922
>> f(x)
ans = 148.2397
We note that in the second iteration, f(x2) = 148.2397 > f(x1) = 8.2078! The
reader is advised to use MATLAB to perform the remaining steps shown in
Fig. 2.7. The unexpected behavior of the Newton’s algorithm should be noted.
Let’s now study an additional example:
qffiffiffiffiffiffiffiffiffiffiffiffiffi qffiffiffiffiffiffiffiffiffiffiffiffiffi
1 þ x21 þ 1 þ x22
f ðx Þ = ð2:42aÞ
2 x1 3
pffiffiffiffiffiffiffiffiffiffiffiffiffi
6 1 þ x21 7
∇f ðxÞ = 64 x2
7
5 ð2:42bÞ
pffiffiffiffiffiffiffiffiffiffiffiffiffi
1 þ x2 2
2 1 3
6 1 þ x2 3=2
0
7
6 1 7
HðxÞ = 6 7 ð2:42cÞ
4 1 5
0 3=2
1 þ x2 2
The surface of the function is shown in Fig. 2.8. Let’s start from x0 = [5 5]T.
We determine the value of the function, the gradient, and the hessian:
pffiffiffiffiffiffi
f x0 = 2 26
0 5 1
∇f x = pffiffiffiffiffiffi
26 1
pffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffiffiffiffiffiffiffiffiffi
Fig. 2.8 Surface plot of f ðxÞ = 1 þ x21 þ 1 þ x22 generated in MATLAB
68 2 Multidimensional Unconstrained Optimization
0 1 1 0
H x = pffiffiffiffiffiffi3
26 0 1
Then:
" # " # " #
x11 x01 δx01 5 1 125
= þ = - 130 =- !
x12 x02 δx02 5 1 125
The method diverges as in the second step, it moves further away from the
origin (which is the unique global minimum). There was nothing to give us a
warning that this could happen. Clearly, we need to devise a strategy to prevent
Newton’s method from accepting rather aggressive steps that could cause
divergence.
We already know from the previous chapter that the “naïve” approach will
fail in many cases and a backtracking scheme is necessary to make the algo-
rithm robust. There is a huge amount of literature on this issue. There are three
basic strategies that can be followed. The first one uses a constant scale factor
(<1) that multiplies the Newton’s step with the aim to make the method less
aggressive. It has the advantage that it is easy to apply and does not increase
the computational load as it does not involve any additional calculations of the
function. It has the disadvantage that as the scale factor is constant, it will work
in some cases but not in others. The other extreme is to use exact calculation of
the optimum in the direction of the Newton’s step. This turns to be very
demanding in terms of additional evaluations of the function. There is an
intermediate strategy which only seeks for an acceptable decrease in the
function at every step of the algorithm. This is arguably the most successful
practical approach as it achieves convergence with reasonable increase in the
computational load. Here we will present a simple, yet efficient, backtracking
algorithm that will suffice for the purposes of this book.
We will not get into the mathematical details, but we will only present the
steps that need to be taken to apply a line search algorithm that is known as
Armijo’s inexact line search. The user needs to select two parameters α 2 (0,1)
and β 2 (0,1) (usually α = 0.2 and β = 1/2 will work fine in most cases). Then
in Step 2 of the Newton’s algorithm, we do not accept immediately the full
Newton’s step, but we determine the minimum n, starting from n = 0, that
satisfies the criterion.
2.2 Algorithms for Multivariable Unconstrained Optimization 69
f xk þ βn δx k < f x k þ αβn ∇f T x k δx k ð2:43Þ
function x=myNewton(f,F,H,x0)
% Newton’s method with Armijo's inexact line search
% f is the obj. function (inline function)
% F is the gradient of the obj. function (inline function)
% H is the hessian of the obj. function (inline function)
% x0 is an initial guess of the solution
a = 0.2; beta=1/2; maxiter=100; tol=1e-6; % modify if
necessary
iter=0;
fprintf('Iter Objective Gradient\n',iter,fun)
while ((norm(grad)>tol)&&(iter<maxiter)) % STEP 3
iter=iter+1;
n=0;
% Backtrack if Eq (2.2.9) is not satisfied
while( f(x+beta^n*NewtonStep) >
f(x)+a*beta^n*grad'*NewtonStep )
n=n+1;
fprintf('Backtracking with n=%4u \n',n)
end
x=x+beta^n*NewtonStep; % STEP 2
fun=f(x); grad=F(x); hess=H(x); NewtonStep= hess \ (-grad);
fprintf('%4u %14.8f %14.8f \n',iter,fun,norm(grad))
end
70 2 Multidimensional Unconstrained Optimization
>> clear
>> f=@(x)sqrt(1+x(1)^2)+sqrt(1+x(2)^2);
>> F=@(x)[x(1)/sqrt(x(1)^2+1);x(2)/sqrt(x(2)^2+1)];
>> H=@(x)diag([1/(x(1)^2+1)^1.5,1/(x(2)^2+1)^1.5]);
>> x=myNewton(f,F,H,[5;5])
>> runmyNewton
Iter Objective Gradient
Backtracking with n= 1
Backtracking with n= 2
Backtracking with n= 3
Backtracking with n= 4
1 6.56220237 1.34693115
Backtracking with n= 1
Backtracking with n= 2
Backtracking with n= 3
2 2.94421208 1.03783719
Backtracking with n= 1
3 2.00813014 0.12712853
4 2.00000054 0.00103988
5 2.00000000 0.00000000
x=
1.0e-09 *
-0.3976
-0.3976
Observe that in the first iteration, the algorithm enters the backtracking and
performs four backtracking steps, and the new point is:
x1 x0 x0 5 1 4 1 3:125
= þδ = - 130 =-
y1 y0 y0 5 2 1 3:125
and:
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
f x1 , y1 = 2 1 þ ð - 3:125Þ2 = 6:5622 < f x0 , y0 = 10:198
Clearly backtracking has been successful in solving the problem with the
aggressive nature of Newton’s method (at least for this peculiar example).
2.3 Application Examples 71
>> syms P0 P1 P2 PF a;
>> simplify(gradient((P1/P0)^a+(P2/P1)^a+(PF/P2)^a-3,[P1 P2]))
ans =
(a*((P1/P0)^a - (P2/P1)^a))/P1
(a*((P2/P1)^a - (PF/P2)^a))/P2
P w1
T w2
P1 P
N T w3
P2 P
C-101
T
P
E-101
C-102
T
E-102
C-103
P1 P2 P
λ= = = f ð2:46Þ
P 0 P 1 P2
We note again that all compressors have the same compression ratio λ. To
determine the exact value of the intermediate pressures, we make the follow-
ing calculation:
Pn = λPn - 1 = λ2 Pn - 2 = . . . = λn P0 ð2:47Þ
or:
rffiffiffiffiffi
n Pn
λ= ð2:48Þ
P0
where n is the number of compression stages used. For the case of three
compression stages that increase the pressure from 1 to 10 bar, for instance,
we obtain:
rffiffiffiffiffiffi
3 10
λ= = 2:15443469
1
clear
a=0.3;
P0=1;
Pf=10;
x=myNewton(f,F,H,[2;4])
2.3 Application Examples 73
>> runmyNewton
Iter Objective Gradient
1 0.77718894 0.00276651
2 0.77685083 0.00112495
3 0.77678870 0.00045021
4 0.77677826 0.00017999
5 0.77677656 0.00007198
6 0.77677629 0.00002879
7 0.77677624 0.00001152
8 0.77677624 0.00000461
9 0.77677624 0.00000184
10 0.77677624 0.00000074
x = 2.1544
4.6415
>> eig(H(x))
ans = 0.0451
0.0142
xopt=fminunc(fun,x0,options)
inds a local minimum of a function of several variables. Starts at x0 and
attempts to ind a local minimizer xopt of the function fun. fun (an inline
function or an m-ile) returns the value of the objective function. It may also
return the gradient in which case one must use [f,g]=fun(x) and:
options=optimoptions('fminunc','SpecifyObjectiveGradient',true); use
also ‘Diplay’,Iter to display intermediate results.
function f=ThreeStageCompression(P)
P0 = 1; % initial pressure in bar
Pf = 10; % final pressure in bar
a =0.3; % parameter of the model
f= (P(1)/P0)^a + (P(2)/P(1))^a + (Pf/P(2))^a - 3;
end
>> clear
>> options=optimoptions('fminunc','Display','iter');
>> x=fminunc(@ThreeStageCompression,[2;4],options)
First-order
Iteration Func-count f(x) Step-size optimality
0 3 0.778671 0.00639
1 9 0.778294 10 0.0054
2 12 0.776876 1 0.00289
3 15 0.776777 1 0.00021
4 18 0.776776 1 1.01e-05
5 21 0.776776 1 1.4e-06
6 24 0.776776 1 1.28e-08
x = 2.1544
4.6416
Two points that we will not be discussing in detail in this book (a lot of
information can be found in the literature) are the numerical approximation of
the first and second derivatives. The hessian matrix is usually calculated based
on quasi-Newton methods that can guarantee that the hessian is positive
definite (the BFGS method is one of the most popular members of this class).
It is interesting to note that even when the hessian is available, using a quasi-
Newton method is the preferred method to use. For approximating the gradi-
ent finite differences can be used. The forward finite differences are the
preferred method as they only require one additional function evaluation:
df f ðx þ δxÞ - f ðxÞ
≈ , δx = max f1, jxjg eps1=2 ð2:49Þ
dx δx
where eps is the accuracy of the computer (type >> eps in MATLAB to get the
accuracy of your computer system). Central finite differences are more accu-
rate but require two function evaluations:
2.3 Application Examples 75
df f ðx þ δxÞ - f ðx - δxÞ
≈ , δx = max f1, jxjg eps1=3 ð2:50Þ
dx 2δx
>> clear
>> format long
>> x=5;
>> exp(x)
ans = 1.484131591025766e+02
>> dx=max(1,abs(x))*sqrt(eps);
>> (exp(x+dx)-exp(x))/dx
ans = 1.484131645202637e+02
>> dx=max(1,abs(x))*eps^(1/3);
>> (exp(x+dx)-exp(x-dx))/(2*dx)
ans = 1.484131591241918e+02
V V V
F
C C C C
F C0 - C1
C1 - C2 C2 - Cf
V ðC 1 , C 2 Þ = þ þ
k C1
C2 Cf
ð2:51Þ
F C0 C1 C2
= þ þ -3
k C1 C2 Cf
C02 13
þ -
F 6 C1 C2 7
2
∇V = 6 7 ð2:52Þ
k4 C 15
- 12 þ
C2 Cf
2
C 1 3
2 03 - 2
F 6 C1 C2 7
H= 6 7 ð2:53Þ
k4 1 C1 5
- 2 2 3
C2 C2
>> syms C0 C1 C2 Cf F k;
>> gradient((F/k)*(C0/C1+C1/C2+C2/Cf-3),[C1 C2])
-(F*(C1/C2^2 - 1/Cf))/k
[ -F/(C2^2*k), (2*C1*F)/(C2^3*k)]
C 21 = C 0 C 2 ð2:54Þ
C 22 = C 1 C f ð2:55Þ
or:
2.3 Application Examples 77
1=3
C0 C1 C
= = 0 ð2:56Þ
C1 C2 Cf
1=3
C1 C2 C
= = 0 ð2:57Þ
C2 Cf Cf
As in the case of the two CSTR in series, the volumes are equal.
Consider now the following numerical example: F = 1 m3/h, k = 1 1/h,
C0 = 1 kmol/m3, and Cf = 0.125 kmol/m3. It then follows from (2.56) and
(2.57) that C1 = 0.5 kmol/m3 and C2 = 0.25 kmol/m3. The eigenvalues of the
hessian are both positive, and the point determined is a local minimum.
The graphical representation of the optimal solution is shown in Fig. 2.11. It
is reminded that the material balance of a single CSTR can be written as:
F
V= ½C in - C out ð2:59Þ
r ðC out Þ
where Cin is the concentration in the feed, Cout is the product concentration, and
r is the rate of reaction. It then follows that if we plot F/r as a function of C, then
the volume of each reactor is the area of the rectangle with height F/r(Cout) and
width Cin – Cout.
From Fig. 2.11, it follows that if one CSTR is used, the necessary volume is
V = 8(1 – 0.125) = 7 m3. The three reactors have a total volume of:
F F F
V = ðC 0 - C 1 Þ þ ðC 1 - C 2 Þ þ C2 - Cf
kC 1 kC 2 kC f
1 1
= ð1 - 0:5Þ þ ð0:5 - 0:25Þ
1 0:5 1 0:25
1
þ ð0:25 - 0:125Þ = 1 þ 1 þ 1 = 3 m3
1 0:125
This is a significant decrease in the total volume (57% decrease) at the expense
of having a more complex system to operate (three CSTR instead of one).
78 2 Multidimensional Unconstrained Optimization
Fig. 2.11 Graphical representation of the optimal solution of the three CSTR in series with
first-order reaction case study
The contour lines of the total reactor volume are shown in Fig. 2.12. Please
note that not all points shown have a physical meaning. We use our implemen-
tation of Newton’s method to find the minimum numerically:
>> clear
>> C0=1;
>> Cf=0.125;
>> f=@(C) (C0-C(1))/C(1) + (C(1)-C(2))/C(2) + (C(2)-Cf)/Cf;
>> F=@(C) [ -C0/C(1)^2+1/C(2); -C(1)/C(2)^2+1/Cf];
>> H=@(C) [2*C0/C(1)^3, -1/C(2)^2; -1/C(2)^2, 2*C(1)/C(2)^3];
>> Copt=myNewton(f,F,H,[0.6;0.3])
Iter Objective Gradient
1 3.00984448 0.53867447
2 3.00012125 0.05270747
3 3.00000003 0.00084742
4 3.00000000 0.00000021
Copt = 0.5000
0.2500
>> eig(H(Copt))
ans = 11.1556
68.8444
2.3 Application Examples 79
Fig. 2.12 Contour lines for the three CSTR case study with first-order reaction (for a point to
have physical meaning, C1 must be greater than C2)
However, as the reader can verify, the algorithm diverges easily if we change
the initial point (try (0.8,0.3), for instance). This is also true even for the
MATLAB command fminunc, which seems not to be useful for this relatively
simple example. The mathematical formulation is, unfortunately, incomplete as
the constraints 0.125 < C2 < C1 < 1 need to be incorporated into the formu-
lation to make the algorithm robust and practically useful. This must wait for
the discussion in the next chapter.
dC R ðt Þ
= - r 1 ðt Þ, C R ðt Þ = C 0 ð2:60aÞ
dt
dC P ðt Þ
= þ r 1 ðt Þ - r 2 ðt Þ, C P ðt Þ = 0 ð2:60bÞ
dt
where r1 is the reaction rate of the reaction R → P and r2 the reaction rate of
the reaction P → W. In this case, we assume that the first reaction is second
order with respect to the concentration of the reactant and the second reaction
is first order with respect to the concentration of the product:
E1
r 1 ðt Þ = k 0,1 exp - C 2 ðt Þ ð2:61aÞ
Rg T ðt Þ R
E2
r 2 ðt Þ = k0,2 exp - C ðt Þ ð2:61bÞ
Rg T ðt Þ P
where k0,1 and k0,2 are the reaction rate constants, E1 and E2 the activation
energies, and Rg the ideal gas constant. Temperature T(t) is an unknown
function of time, and we need to optimize its variation over time to maximize
the production of the product:
min - C P ðt f Þ ð2:62Þ
T ðt Þ
It is important to note at this point that the variable over which we solve the
problem is defined over an infinite number of points as we need to determine
the values of the temperature T(t), for every 2[0, tf], where tf is the final time.
To alleviate this difficulty, we may define temperature to be a specific function
of time such as a polynomial or an exponential function:
2.3 Application Examples 81
T ðt Þ = α 0 þ a 1 t þ α 2 t 2 þ ⋯ þ a n t n ð2:63Þ
or:
temperature profile:
T ðt Þ = T 0 þ ðT 1 - T 0 Þt ð2:65Þ
min - C P ð1Þ
T 0 ,T 1
s:t:
dC R 2500
= - 4000 exp - C2
dt T 0 þ ðT 1 - T 0 Þt R
dC P - 2500 - 5000
= þ 4000 exp C 2R - 620,000 exp C
dt T 0 þ ðT 1 - T 0 Þt T 0 þ ðT 1 - T 0 Þt P
t 2 ½0, 1, C R ð0Þ = 1, C P ð0Þ = 0
ð2:66Þ
function Cdot=RayReactor(t,C,T0,T1)
T=T0+(T1-T0)*t;
Cdot(1) = -4000*exp(-2500/T)*C(1)^2;
Cdot(2) = +4000*exp(-2500/T)*C(1)^2 -620000*exp(-5000/T)*C(2);
Cdot=Cdot(:);
To obtain the solution for T0 = 400 K and T1 = 300 K, we use the following
command:
The solution obtained can be seen in Fig. 2.13. The value of the objective
function is:
>> -C(end,2)
ans = -0.5278
Fig. 2.13 Simulation results of the batch reactor with T(t) = 400–100 t
2.3 Application Examples 83
Fig. 2.14 Contour lines for the batch reactor final product concentration
We may repeat the procedure just presented and plot the results to obtain
the contour plot shown in Fig. 2.14. We note that the case study has a clear
minimum which can be determined using the MATLAB command fminunc:
function obj=RayReactorObj(T)
[t,C]=ode113(@RayReactor,[0 1],[1 0],[],T(1),T(2));
obj=-C(end,2);
>> clear
>> x0=[400;300];
>> options=optimoptions('fminunc','Display','Iter');
>> Topt=fminunc(@RayReactorObj,x0,options)
First-order
Iteration Func-count f(x) Step-size optimality
0 3 -0.52778 0.00423
1 15 -0.543452 820 0.00378
2 18 -0.601359 1 0.000423
3 24 -0.606268 7.24839 0.000588
4 27 -0.608215 1 0.000311
5 30 -0.60893 1 2.02e-05
6 33 -0.608949 1 2.36e-05
7 36 -0.608954 1 1.11e-06
8 39 -0.608954 1 5.16e-09
Local minimum found.
ans = 349.7223
320.6829
In this chapter, we have studied methods and examples for the general prob-
lem of unconstrained optimization problem with many variables:
y = φðx, pÞ ð2:68Þ
In the case of the fuel cell, there is only one controlled variable and one
response, and Eq. (2.68) can be simplified:
y = φðx, pÞ ð2:680 Þ
The experiments take place at discrete values of the controlled variable xi,
i = 1,2,. . .,n, and experimental observations are obtained yexp(xi). The discrep-
ancies between the experimentally observed values of the response and the
ones predicted by the model are defined by the residual function r(p):
1 Xn 2 1 Xn 2
min f ðpÞ = =
r i ðxi , pÞ = i=1
ðφðxi , pÞ - yiexp Þ ð2:70Þ
p 2 i 1 2
or:
∂f ðpÞ Xn ∂φðxi , pÞ
= r ðx , pÞ
i=1 i i
ð2:71Þ
∂pk ∂pk
or:
where:
2.4 Parameter Estimation: Nonlinear Least Squares 87
2 3
∂f ðpÞ
6 ∂p 7 2 3
6 1 7 r 1 ð pÞ
6 ∂f ðpÞ 7
6 7 6 r ð pÞ 7
6 7 6 2 7
∇f ðpÞ = 6 ∂p2 7 , r ðpÞ = 6 7 ð2:73Þ
6 7 4 ⋮ 5
6 ⋮ 7
6 7 r n ð pÞ n × 1
4 ∂f ðpÞ 5
∂pm m × 1
or by ignoring the second term in the right-hand side (as the residuals become
small close to the solution):
which requires only the first derivatives of the mathematical model with
respect to the parameters.
We have presented a great deal of theory which we will now try to elucidate
through the fuel cell example. The experimental data available are pairs of
applied current density and measured cell voltage (xi = ji, yi = E( ji)). The
mathematical model is given by Eq. (1.74):
88 2 Multidimensional Unconstrained Optimization
RT x
yi ðxi ; E 0 , RΩ , jL Þ = E 0 - RΩ xi þ ln 1 - i ð2:77Þ
2F jL
Experimental data for a particular solid oxide fuel cell (SOFC) that operates at a
relatively low temperature (873 K) are presented in Table 2.2. We make use of
these data to determine the parameters of the model (2.79). To this end, we
build the following m-file that calculates the residuals:
function [r,f,jexp,Eexp]=SSR_FuelCell(p)
% Sum of Squares of Residuals for the SOFC model
jexp=[.020 .109 .600 1.087 1.588 2.089 2.583 3.083 3.462 3.835]';
Eexp=[.835 .827 .764 .690 .609 .533 .447 .346 .242 0.062]';
r=(p(1)-p(2)*jexp+0.0376*log(1-jexp/p(3))) - Eexp;
Fig. 2.15 Comparison of experimental results (o) and model predictions (-) for the fuel cell
case study
>> clear
>> p=[0.9;0.2;4]
>> opts = optimoptions(@lsqnonlin,'Display','Iter');
>> po=lsqnonlin(@SSR_FuelCell,p,[],[],opts)
>> [r,f,jexp,Eexp]=SSR_FuelCell(po);
>> j=linspace(0,po(3),101);
>> plot(j,po(1)-po(2)*j+0.0376*log(1-j/po(3)),'k-
','LineWidth',1)
>> hold on
>> grid on
>> xlabel('Current density j (A/cm^{2})')
>> ylabel('Voltage E (V)')
>> plot(jexp,Eexp,'ko','LineWidth',1)
90 2 Multidimensional Unconstrained Optimization
Norm of First-order
Iteration Func-count f(x) step optimality
0 4 0.0538428 1.44
1 8 0.0538428 0.650709 1.44
2 12 0.00968978 0.162677 0.376
3 16 0.00116089 0.0459602 0.00237
4 20 0.00116068 8.36595e-05 9.67e-06
Local minimum possible.
po = 0.8517
0.1445
3.8422
Before closing this section, it is interesting to examine the case where the
mathematical model is linear of the following general form:
y = p0 þ p1 x 1 þ p2 x 2 þ . . . pq x q þ ⋯ þ pn x n ð2:81Þ
The discrepancies between the experimentally observed values and the ones
predicted by the model are defined by the vector of residuals r(p) with
elements:
ri ðx i , pÞ = yi ðx i , pÞ - ykexp ð2:83Þ
The linear least squares method (LLS) is based on minimizing the sum of the
squares of the residuals:
1 Xn 2 1 Xn 2
min f ðpÞ = =
r i ðx i , pÞ = ðy ðx , pÞ - yiexp Þ
i=1 i i
p 2 i 1 2
1 ð2:84Þ
= ðAp - y exp ÞT ðAp - y exp Þ
2
1 T T
= p A Ap - pT AT y exp - y exp T Ap þ y exp T y exp
2
or:
1 T T
min f ðpÞ = p A Ap - 2y exp T Ap þ y exp T y exp ð2:85Þ
p 2
∂f ðpÞ 1 ∂ T T
= p A Ap - 2y exp T Ap þ y exp T y exp
∂p 2 ∂p
1 ∂ T T ∂ exp T
= p A Ap - y Ap = AT Ap - AT y exp
2 ∂p ∂p
Learning Summary
minn f ðxÞ
x2R
are:
∇f ðx 0 Þ = 0
ðx - x 0 ÞT H ðx 0 Þðx - x 0 Þ > 0 or H ðx 0 Þ is p:d:
∇T f ðx 0 Þð x - x 0 Þ > 0
∇T f ðx 0 Þðx - x 0 Þ < 0
1 Xn 2 1 Xn 2
min f ðpÞ = =
r i ðx i , pÞ = i=1
ðφðxi , pÞ - yiexp Þ
p 2 i 1 2
The NLLS parameter estimation is the most important (if not the only) appli-
cation of unconstrained optimization.
Problems
LT
ht
A
kF t
2.2 The tank shown in Fig. P2.2 is initially filled with water up to the level of
h = 68 cm. The valve is opened at t = 0, and the level of the liquid in the
tank is measured through a computer system every 10 s. The equation for
the volumetric flow rate of the liquid is the following:
Problems 95
pffiffiffiffiffiffiffiffiffi
Q_ ðt Þ = - k hðt Þ
dC
= - kC n
dt
1 1
- = ðn - 1Þkt
C n - 1 ðt Þ C n0 - 1
b0 þ b1 s þ b2 s2 þ . . . þ bn - 1 sn - 1 - ds
G ð sÞ = e
a0 þ a1 s þ a2 s2 þ . . . þ an sn
β0 þ β1 s þ β2 s2 þ . . . þ βm - 1 sm - 1 - θs
gðsÞ = e , m< <n
α0 þ α1 s þ α2 s2 þ . . . þ αm sm
fωi , ARi , φi g
1
GðsÞ =
s5 þ 5s4 þ 10s3 þ 10s2 þ 5s þ 1
G=tf(1,[1 5 10 10 5 1]);
w=logspace(-2,0.5,10);
[AR,phi]=bode(G,w);
AR_G=squeeze(AR)
phi_G=squeeze(phi)/(180/pi)
Select the first order plus delay time model (p = [k τ θ]Τ), and
determine its parameters:
k
gðsÞ = e - θs
τs þ 1
where:
k
ARg ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ðωτÞ2 þ 1
2.5 Table P2.5 contains data for the saturation pressure Ps of water as a
function of the absolute temperature T. Estimate the parameters of the
following forms of the Antoine equation:
B
ln Ps = A -
T
B
ln Ps = A -
T þC
98 2 Multidimensional Unconstrained Optimization
2Ben , DPH þ H2
Ben þ DPH , TPH þ H2
are reported by Seinfield and Gavalas (AIChE J., 16, p. 644, 1970). The
authors also present a mathematical model consisting of two ordinary
differential equations that involve two unknown parameters. Study the
paper, and use the data to estimate the model parameters. Compare your
results with the results presented in the paper. What are your
conclusions?
2.7 In Fig. P2.7 a closed loop system is shown. A process with first order
dynamics:
dyðt Þ
τp þ y ðt Þ = u ðt Þ þ d ðt Þ
dt
d
e U u y
where:
y is the process output.
ysp is the set point (the desired value of the output).
e is the error (deviation) signal.
U is the controller output.
d is a disturbance to the system.
u is the valve input to the system.
I is the integral of the error.
τp is the time constant of the process (τp = 1 s).
kc is the controller gain.
τI is the integral time of the controller.
The controller output U drives a valve which also exhibits first-order
system dynamics:
duðt Þ
τv þ uðt Þ = U ðt Þ
dt
Hint: build an m-file that solves the differential equations and also
transforms the objective function to a differential equation for a given
pair of kc and τI. Create a contour plot for kc 2 [5,12] and τI 2 [0.5,1,5].
Chapter 3
Constrained Optimization
min f ðxÞ
x
s:t: ð3:2Þ
hðxÞ = 0
gðx Þ ≤ 0
x L ≤ x ≤ xU
and the extra effort and space needed to cover its mathematical details cannot
be justified. We refer the interested reader into classical NLP theory books. As
we have mentioned in Chap. 1, linear programming (LP) problems are indeed
convex problems, and we will present the basic steps in solving LP problems in
the next chapter without explicit reference to the general theory of convex sets
and function (but we will present the basic elements necessary to establish
whether a point is actually the solution to an LP problem or not).
min f ðxÞ
x
s:t: ð3:3Þ
hðxÞ = 0
where ∇x denotes the gradient with respect to the vector x and ∇λ denotes the
gradient with respect to the vector λ. These results follow directly by
noticing that:
Xm ∂f ðxÞ Xm ∂hi ðxÞ
∂
f ðxÞ þ λ i h i ð xÞ = þ λ
i = 1 i ∂x j
ð3:8Þ
∂xj i=1 ∂xj
Xm
∂ ∂ Xm
f ðx Þ þ λ i h i ð x Þ = λi h i ð x Þ = hk ðxÞ ð3:9Þ
∂λk i=1 ∂λk i=1
or
2 3 2 3
∂f ðxÞ ∂h1 ðxÞ ∂h2 ðxÞ ∂hm ðxÞ
6 ∂x 7 6 ∂x ⋯
6 1 7 6 1 ∂x1 ∂x1 7 2 3
7 λ1
6 7 6 7
6 ∂f ðxÞ 7 6 ∂h1 ðxÞ ∂h2 ðxÞ ∂hm ðxÞ 7 6 λ 7
6 7 6 ⋯ 76 2 7
∇x L ðx, λÞ = 6 ∂x2 7 þ 6 ∂x2 ∂x2 ∂x2 7 6 7
6 7 6 7 4⋮ 5
6⋮ 7 6⋮ ⋮ ⋱ ⋮ 7
6 7 6 7
4 ∂f ðxÞ 5 4 ∂h1 ðxÞ ∂h2 ðxÞ ∂hm ðxÞ 5 λm
⋯
∂xn ∂xn ∂xn ∂xn
and finally:
104 3 Constrained Optimization
where the m-by-n Jacobian matrix of the equality constraints is defined by:
2 3
∂h1 ðxÞ ∂h1 ðxÞ ∂h1 ðxÞ
6 ∂x ⋯
6 1 ∂x2 ∂xn 7 7
6 7
6 ∂h2 ðxÞ ∂h2 ðxÞ ∂h2 ðxÞ 7
∂hi ðxÞ 6 ⋯ 7
∇hðxÞ = 6 ∂x1 ∂x2 ∂xn 7 ð3:11Þ
∂xj 6 7
6⋮ ⋮ ⋱ ⋮ 7
6 7
4 ∂hm ðxÞ ∂hm ðxÞ ∂hm ðxÞ 5
⋯
∂x1 ∂x2 ∂xn
Xm
∂ ∂f ðxÞ Xm
2
∂ ∂hi ðxÞ
f ðx Þ þ λ h ðx Þ =
i=1 i i
þ λ
i = 1 i ∂xj
∂xℓ ∂xj ∂xℓ ∂xj
ð3:12Þ
∂ f ðxÞ Xm
2 2
∂ hi ðxÞ
= þ λ
i = 1 i ∂xℓ ∂x j
∂xℓ ∂xj
and to prove that the second derivative of the Lagrangian function is given by:
" # P " #
∇2xx L ∇2xλ L
∇2 f ðxÞ þ mi=1 λ i ∇ 2
h i ð x Þ ∇ T
h ðx Þ
∇ L=2
= ð3:13Þ
∇2λx L ∇2λλ L ∇hðxÞ 0
Consider the following simple numerical example where we seek for the
minimum distance from the origin in the x1, x2 space that satisfies a linear
equality constraint:
min
x
x21 þ x22
s:t: ð3:14Þ
x1 þ x2 = 1
The graphical solution of the problem is shown in Fig. 3.1. The Lagrangian
function is:
x f xA
f xB
h
h
xA h
xB
f xC
xC x
f
x
f
Fig. 3.1 Graphical solution to the equality constrained problem given by Eq. (3.14)
2x1 þ λ = 0 ð3:16Þ
2x2 þ λ = 0 ð3:17Þ
x1 þ x2 - 1 = 0 ð3:18Þ
Equations (3.16, 3.17, and 3.18) consist a system of linear equations with
solution x1 = x2 = 1/2, and λ = -1. The optimal point is shown as point xB
in Fig. 3.1. At this point, the gradients of the objective function and of the
equality constraint are:
2x1 1 1
∇f = = , ∇h = ð3:19Þ
2x2 1 1
Apparently, the gradient of the objective function belongs to the same line as
the gradient of the equality constraint. This only happens at point xB. There is
no other feasible point (a point that satisfies the equality) where the two
gradients belong to the same line. At point xC, for instance, the gradient of
the objective function and the gradient of the equality constraint are:
2x1 2 1
∇f = = , ∇h = ð3:20Þ
2x2 0 1
vectors do not belong to the same line). The same observation can be made for
point xA and any other feasible point apart from xB.
Before moving forward, there is a point to clarify: What is the physical
meaning and the practical usefulness of the Lagrange multipliers? To answer
this question, we consider the following problem with one equality constraint,
but the RHS of the equality is equal to an arbitrary number β:
min f ðxÞ
x
s:t: ð3:21Þ
hðxÞ = β
We use the linear approximation of the objective function close to the solution:
f ðxÞ = f xβ þ ∇T f xβ x - xβ ð3:23Þ
Or, as both f(x) and h(x) are real valued functions and h(x) - h(xβ) = (β + Δβ) -
β = Δβ:
Δf xβ
λβ = - ð3:27Þ
Δβ
We therefore conclude that the Lagrange multiplier is the ratio of the variation
of the objective function at the optimum to the variation of the RHS of the
equality constraint when written in the form (3.21). As the ratio can be both
negative and positive (we have no reason to believe that in the general case, an
3.3 Application Examples 107
min V 1 þ V 2
V 1 ,V 2 ,C
s:t: ð3:28Þ
FC0 - FC - V 1 kC = 0
FC0 - FCf - V 2 kC f = 0
L = ðV 1 þ V 2 Þ þ λ1 ðFC 0 - FC - V 1 kC Þ þ λ2 FC - FC f - V 2 kC f ð3:29Þ
1 - λ1 kC = 0 ð3:30aÞ
108 3 Constrained Optimization
1 - λ2 kC f = 0 ð3:30bÞ
- λ1 ð F þ V 1 k Þ þ λ 2 F = 0 ð3:30cÞ
FC 0 - FC - V 1 kC = 0 ð3:30dÞ
FC - FC f - V 2 kC f = 0 ð3:30eÞ
We substitute (3.30a) and (3.30b) into (3.30c) and solve for V1 to obtain:
F C
V1 = -1 ð3:31Þ
k Cf
F C0
V1 = -1 ð3:32Þ
k C
C2 = C0Cf ð3:33Þ
1
λ1 = pffiffiffiffiffiffiffiffiffiffi ð3:34Þ
k C0Cf
1
λ2 = ð3:35Þ
kC f
From (3.30e) when solved for V2, it follows that the two reactors have equal
volumes. These results agree with the results obtained in Example 1.3 by
variable elimination.
the aim is to determine the current density at which the power density is
maximum:
min - E ðjÞ j
j,E
s:t: ð3:36Þ
RT j
E - E 0 þ RΩ j - ln 1 - =0
2F jL
where E0 is the voltage at zero current (E0 = 0.85 V), RΩ is the (area specific)
Ohmic resistance (RΩ = 0.145 Ωcm2), R is the ideal gas constant (R = 8.3144
VC/(mol K)), Τ is the absolute temperature (873 K for the data shown in
Fig. 1.14), and F is the Faraday’s constant (96,485 C/mol). jL is the limiting
current density (3.85 V). We define the Lagrangian function:
RT j
LðE, j, λÞ = - Ej þ λ E - E 0 þ RΩ j - ln 1 - ð3:37Þ
2F jL
-j þ λ=0 ð3:38aÞ
RT 1
- E þ λRΩ þ λ =0 ð3:38bÞ
2F j - jL
RT j
E - E 0 þ RΩ j - ln 1 - =0 ð3:38cÞ
2F jL
They are described, in their most basic form, from a second-order polynomial
function:
OC = a þ βP þ γP2 ð3:39Þ
Fig. 3.2 Input-output characteristic curves for the two power plants considered
3.3 Application Examples 111
$
OC1 = 1:0 þ 0:025 P1 þ 0:000020 P21 ð3:40Þ
h
$
OC2 = 0:2 þ 0:025 P2 þ 0:000 075 P22 ð3:41Þ
h
where P1 and P2 are the power outputs in kW. The aim is to determine P1 and
P2 to satisfy the power demand constraint:
P1 þ P2 = PD ð3:42Þ
In the general case where n Power plants are available, the final formulation is:
X
n
min αi þ βi Pi þ γ i P2i
Pi
i=1
s:t: ð3:45Þ
X
n
Pi = P D
i=1
112 3 Constrained Optimization
dL
= βi þ 2γ i Pi þ λ ð3:47Þ
dPi
For the case of two power production units, we may observe that Eq. (3.47)
can be written as:
1 β
Pi þ λ= - i ð3:47Þ
2γ i 2γ i
It then follows that for the general case, the solution can be obtained by the
following equation (where we have assumed that PD = 500 kW):
Pn
βi
PD þ 2γ i
i=1
λ = - Pn 1 ð3:51Þ
i = 1 2γ i
500 þ 20:000020
0:025
þ 20:000075
0:025
λ= - = - 0:040789479
20:000020 þ 20:000075
1 1
" ! #
XNC ΔG0f ,i XNC
GðT, ni Þ = n
i=1 i
þ ln ni - ln n
i=1 i
ð3:52Þ
RT
where ni are the mole of chemical species i, ΔG0f ,i is the standard state Gibbs
free energy of formation of chemical species i at the temperature of the
reaction T, and R is the ideal gas constant. Let use aik to denote the number
of atoms of element k in chemical species i. If we use ethane (C2H6) as an
example, then aC2H6,H = 6, and aC2H6,C = 2. If the initial number of atoms of
element k is denoted by a0k , then we can write the following material balance
constraints:
XNC
n
i=1 i
ai,k = a0k , k = 1,2,⋯,NE ð3:53Þ
where NE denotes the number of elements present in the system. We can now
define the following Lagrangian function:
" ! #
XNC ΔG0f ,i XNC
L ðni , λk Þ = n
i=1 i
þ ln ni - ln n
i=1 i
RT ð3:54Þ
XNE XNC
þ λ
k=1 k
n a
i = 1 i i,k
- a0
k
This case study will be the subject of a detailed investigation latter in this
chapter.
min f ðxÞ
x
s:t: ð3:55Þ
gðx Þ ≤ 0
gi ð x Þ = 0
, 8i 2 I ðxÞ ð3:57Þ
μi ≥ 0
The Lagrange multipliers of inactive constraints are all equal to zero (i.e., either
gi(x) = 0 or μi = 0 always holds true). It takes a lot of careful thinking to realize
that the following conditions are indeed equivalent to conditions (3.56) and
(3.57) but require no prior knowledge of the active constraints at the feasible
point x0:
Xp
∇f ðxÞ þ μ ∇gi ðxÞ = 0
i=1 i
ð3:58Þ
μi gi ðxÞ = 0, 8i ð3:59Þ
μi ≥ 0, 8i ð3:60Þ
3 – f belongs
μ μ μ μ t
– f
2
– f
0
0 1 2 3 4 x
min
x ,x
f ðx1 , x2 Þ = ðx1 - 4Þ2 þ ðx2 - 2Þ2
1 2
s:t: ð3:61Þ
g1 ð x 1 , x 2 Þ = x 1 þ x 2 - 4 ≤ 0
g2 ðx1 , x2 Þ = x21 þ x22 - 32 ≤ 0
g3 ð x 1 , x 2 Þ = - x 1 ≤ 0
g4 ðx1 , x2 Þ = - x2 ≤ 0
We consider the case where the information that the optimum lies at the
intersection of inequality constraints g1 and g2 is given (i.e., points A and B in
Fig. 3.3):
3.4 Inequality Constrained Problems 117
We first check whether point A is a KKT point. Point A is a feasible point (PF is
satisfied). We calculate the gradients of the two constraints:
1 x1 2:5858
∇g1 = , ∇g2 = 2 =
1 x2 5:4142
x1 - 4
We determine the gradient of the objective function: ∇f = 2 =
x2 - 2
- 5:4142
and we apply (3.58):
þ1:4142
- 5:4142 1 2:5858 μ1 0 μ1 11:6569
þ = ) =
- 0:5858 1 5:4142 μ2 0 μ2 - 2:4142
As μ2<0, the dual feasibility conditions are not satisfied, and point A is not a
KKT point.
At point B, in Fig. 3.3, we have:
1 x1 5:4142
∇g1 = , ∇g2 = 2 =
1 x2 2:5858
And:
- 2:5858 1 5:4142 μ1 0 μ1 0:3431
þ = ) = >0
- 1:4142 1 2:5858 μ2 0 μ2 0:4142
We therefore conclude that PF, DF, CS, and independence of the gradients of the
active constraints are satisfied and point B is a KKT point.
We will try to elaborate further the KKT conditions given by (3.58) and
(3.60) (the DF conditions) for the optimization problem with inequality con-
straints (3.55). We will consider the nonlinear inequality constraints g1(x) and
g2(x) shown in Fig. 3.4. Their gradients, when multiplied with non-negative
numbers, generate a “convex cone” as shown in the same figure. In Fig. 3.4a, the
case of a KKT point is shown as the negative of the gradient of the objective
118 3 Constrained Optimization
– f belongs
μ μ μ μt
– f
– f
f
x
Fig. 3.4 The negative of the gradient of the objective function must belong to the “convex
cone” generated by the gradients of the active constraints at any KKT point
function belongs to the “convex cone” spanned by ∇g1(x0) and ∇g2(x0). Note
that all directions forming an angle between ±90o with -∇f(x0) for which:
also point toward the infeasible region and are not acceptable directions of
movement (even though they may result in decreasing values of the objective
function). We conclude that when a feasible point x0 has been located for which
3.4 Inequality Constrained Problems 119
The formulation is complete by adding the requirement that all circles are
completely inside the enclosing circle with radius R:
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
x2i þ y2i þ r ≤ R, 8i ð3:64Þ
The complete formulation for the case of predefined number of circles with
non-uniform radius ri is given by:
120 3 Constrained Optimization
r
yj
dij
r
yi
xk
xi xj
yk r
Fig. 3.5 The circle packing problem of uniform circles in a circle centered at the origin
min R
R,xi ,yi
s:t:
rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð3:65Þ
2ffi
2
ri þ rj ≤ xi - xj þ yi - yj , 8i,j; i<j
qffiffiffiffiffiffiffiffiffiffiffiffiffiffi
xi - y2i þ r i ≤ R, 8i
min L
xi ,yi ,L
s:t:
rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð3:66Þ
2ffi
2
ri þ rj ≤ xi - xj þ yi - yj , 8i,j; i<j
)
r i ≤ xi ≤ L - r i
8i
r i ≤ yi ≤ W - r i
X
πr 2i ≤ WL
i
min f ðxÞ
x
s:t: ð3:67Þ
hðxÞ = 0
gðx Þ ≤ 0
where x is a n-th dimensional vector, f:Rn → R, h:Rn → Rm, and g:Rn → R p are
differentiable functions (well-behaved function in the general sense). Let x be a
feasible point, i.e., h(x) = 0 and g(x) ≤ 0, and the gradients of the equality
constraints and the active inequality constrains are linearly independent at x. If
x solves Problem (3.67) locally, then there exist unique scalars λi 2 R, i = 1,
2, . . ., m and non-negative scalars μj, j = 1, 2, . . ., p, such that:
122 3 Constrained Optimization
Xm Xp
∇f ðxÞ þ λ ∇hi ðxÞ þ
i=1 i
μ ∇gj ðxÞ = 0
j=1 j
ð3:68Þ
Conditions (3.68, 3.69, and 3.70) can also be written in a more compact form:
where ∇h(x) is the m-by-n Jacobian matrix of the equality constraints (defined
in Eq (3.11)) and ∇g(x) is the p-by-n Jacobian matrix of the inequality con-
straints. These conditions are referred to as the general necessary KKT condi-
tions for Problem (3.67) and are, as you can realize, of paramount importance
in optimization theory. It is important to note that a KKT point is only a
candidate local solution to problem (3.67). A useful result is also the following:
if point x0 solves Problem (3.67), then is also the solution to the following
linear approximation problem:
The KKT conditions are only necessary in the general case and are also
sufficient when the problem has mild convexity properties. This is almost
never the case in engineering problems and in order to check the sufficient
conditions, we need to rely on the hessian of the Lagrangian function (which
apparently needs to be p.d.):
Xm X
L ðx, λ, μÞ = f ðxÞ þ λ h ðx Þ
i=1 i i
þ μ g ðxÞ,
j2J ðx Þ j j
J ð x Þ = j : gj ð x Þ = 0
ð3:72Þ
i.e.:
Xm X
∇2 L ðx, λ, μÞ = ∇2 f ðxÞ þ λ∇
i=1 i
2
hi ðxÞ þ μ∇
j2J j
2
gi ð x Þ ð3:73Þ
3.5 General Nonlinear Programming Problems 123
must satisfy dT(∇2L)d > 0. Clearly this is not a practical way to check “man-
ually” the properties of a KKT point, but normally this is left to the software to
validate and inform us on the results.
An algorithm that can be used to solve small-scale equality and inequality
constrained optimization problems is based on the following steps:
STEP 0: Set k = 1, and assume that all inequality constraints are inactive at the
optimum point or J kA = ∅, where J kA is the set of the active constraints at
iteration k.
STEP 1: Solve the equality constrained optimization problem to determine the
solution (xk, λk, μk):
X X
∇f ðxÞ þ λi ∇hi ðxÞ þ μj ∇gj ðxÞ = 0
i j2J k
hi ðxÞ = 0,i 2 I
gj ðxÞ = 0,j 2 J kA
STEP 2: If gj(xk) ≤ 0, 8 j and μj ≥ 0,j 2 J kA, then a KKT point has been found, and
the algorithm terminates (apparently μj = 0,j= 2J kA). Otherwise, continue.
STEP 3: Remove the inequality constraint with the most negative Lagrange
multiplier from the set of the active constraints, and add to JA all
violated inequality constraints. Set k = k + 1 and return to STEP 1.
To demonstrate the application of the algorithm, we consider again the
optimal operation of the power plant studied in Example 3.3, but with the
power demand increased to 550 kW (i.e., PD = 550 kW). The mathematical
formulation of the optimal operation of the two power plants including the
constraints on their minimum and maximum capacity is the following:
min 1:0 þ 0:025 P1 þ 0:000020 P21
P1 ,P2
the set of active constraints (J 2A = f3g). We then solve the equality constrained
problem:
min 1:0 þ 0:025 P1 þ 0:000020 P21
P1 ,P2
which has the trivial solution P1 = 400 kW, P2 = 150 kW that satisfies all
inequality constraints. To determine the corresponding Lagrange multiplier μ3,
we solve the following problem:
λ∇h þ μ3 ∇g3 = - ∇f
or:
1 1 0:025 þ 0:000040 P1
λ þ μ3 =-
1 0 0:025 þ 0:000150 P2
Xm
∇x L xk , λ = ∇f xk þ λ ∇hi xk = 0
i=1 i
ð3:76Þ
∇λ L x k , λ = h x k = 0 ð3:77Þ
We have also seen that the hessian matrix is given by (see Eq. (3.13)):
" Pm #
∇2 f ð x Þ þ i = 1 λi ∇ hi ðxÞ
2
∇T hðxÞ
∇2 L = ð3:78Þ
∇hðxÞ 0
Observe that (3.82) corresponds to applying the KKT conditions to the follow-
ing quadratic programming problem:
126 3 Constrained Optimization
1 T
min f xk þ ∇T f xk δxk þ δxk HL xk , λk δxk
δxk 2
s:t: ð3:83Þ
h xk þ ∇h xk δxk = 0
A naïve SQP algorithm can be as follows (see also how Newton’s method was
applied to unconstrained optimization problems):
The algorithm of the SQP method is similar to the general “naïve” Newton’s
algorithm presented in Chap. 2 (Sect. 2.2). The only difference is the problem
solved to determine the improving direction in Step 2. As you may expect, the
algorithm is greatly improved by using a line search algorithm to satisfy several
convergence criteria. In these one-dimensional search techniques, a modified
Lagrangian function is employed, usually called merit function, which takes
into account the need to maintain feasibility and at the same time improve the
objective function. When the algorithm terminates, a KKT point has been
discovered which is a candidate solution to (3.3). When both inequality and
equality constraints are considered, the SQP algorithm is much more compli-
cated, but the basic idea remains the same.
f = Inline function:
f(x) = -x(1)*x(2)
gf = Inline function:
gf(x) = [-x(2); -x(1)]
Hf = Inline function:
Hf(x) = [0 -1;-1 0]
>> h =inline('x(1)-0.85+0.145*x(2)-0.0376*log(1-x(2)/3.85)')
h = Inline function:
h(x) = x(1)-0.85+0.145*x(2)-0.0376*log(1-x(2)/3.85)
Jh = Inline function:
Jh(x) = [1 0.145+0.0376/(3.85-x(2))]
Hh = Inline function:
Hh(x) = [0 0;0 0.0376/(3.85-x(2))^2]
>> x=[0.5;2.5]
x = 0.5000
2.5000
We then evaluate all functions and determine the step toward an improved
solution:
>> fun=feval(f,x)
fun = -1.2500
gfun = -2.5000
-0.5000
(continued)
128 3 Constrained Optimization
Hfun = 0 -1
-1 0
>> ceq=feval(h,x)
ceq = 0.0519
>> Jceq=feval(Jh,x)
>> Hceq=feval(Hh,x)
Hceq = 0 0
0 0.0206
s = -0.0589
0.0402
2.5402
>> x=x+s(1:2)
x = 0.4411
2.5402
>> lamda=s(3)
lamda = 2.5402
>> norm(s(1:2))
ans = 0.0713
xopt=fmincon(fun,x0,A,b,Aeq,beq,LB,UB,nonlcon)
inds a local minimum of a function of several variables under
linear and nonlinear constraints. Starts at x0 and attempts to ind
a local minimizer xopt of the function fun subject to the linear
inequality constraints A x≤b, linear equality constraints Aeq
x=beq , lower bounds LB and upper bounds UB on x and
nonlinear inequality constraints g and equality constraints h:
[g,h]=nonlcon(x).
f=
Inline function:
f(x) =
(1+0.025*x(1)+0.000020*x(1)^2)+(0.2+0.025*x(2)+0.000075*x(2)^2)
P1
We then define the linear equality constraint ½ 1 1 = 550 :
P2
130 3 Constrained Optimization
Table 3.1 A basic implementation of SQP algorithm for equality constrained problems
(1 equality constraint only)
>> x=[0.5;2.5];
>> [xopt,funopt,lagramult]=mySQP(f,gf,Hf,h,Jh,Hh,x)
Iter f(x) ||Step_{x}||
1 -1.25000000 0.07562817
2 -1.12060968 0.00636423
3 -1.12056140 0.00000747
4 -1.12056030 0.00000000
xopt = 0.4412
2.5399
funopt = -1.1206
lagramult = 2.5399
3.7 Application Examples 131
fmincon can now be used to solve the problem (with the unconstrained
optimum as the initial point):
>> options=optimset('Display','Iter');
>> fmincon(f,[434.21;115.79],A,b,Aeq,beq,[],[],[],options)
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 1.972632e+01 3.421e+01 9.729e-08
1 7 1.972632e+01 3.418e+01 3.893e-06 3.668e-02
2 10 1.980822e+01 4.848e+00 4.404e-03 4.149e+01
3 13 1.983755e+01 0.000e+00 5.133e-03 6.867e+00
4 16 1.983919e+01 0.000e+00 3.085e-03 3.539e-01
5 19 1.984873e+01 0.000e+00 1.147e-02 2.018e+00
6 22 1.984267e+01 0.000e+00 4.966e-03 1.271e+00
7 25 1.983755e+01 0.000e+00 5.118e-05 1.101e+00
8 28 1.983750e+01 0.000e+00 2.032e-06 1.069e-02
9 31 1.983750e+01 0.000e+00 2.003e-08 4.377e-04
ans = 400.0000
150.0000
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 1.825973e+01 3.520e+01 4.709e-04
1 6 1.834628e+01 3.313e+01 6.294e-04 1.468e+00
2 9 1.852192e+01 2.903e+01 1.244e-03 4.095e+00
3 12 1.983752e+01 0.000e+00 5.598e-03 2.903e+01
4 15 1.983764e+01 0.000e+00 5.601e-03 2.532e-02
5 18 1.984203e+01 0.000e+00 5.701e-03 9.456e-01
6 21 1.984338e+01 1.137e-13 5.732e-03 2.874e-01
7 24 1.984053e+01 0.000e+00 2.421e-03 6.087e-01
8 27 1.983752e+01 0.000e+00 2.290e-04 6.508e-01
9 30 1.983771e+01 0.000e+00 2.079e-04 4.189e-02
10 33 1.983754e+01 0.000e+00 4.018e-05 3.642e-02
11 36 1.983750e+01 0.000e+00 4.105e-07 8.651e-03
ans = 399.9999
150.0001
Yet another equivalent way to solve the problem (and arguably the more
general) is to use an m-file to define a MATLAB function that calculates the
inequality and equality constraints:
function [g,h]=cnstr(P)
g(1) = -P(1)+150;
g(2) = -P(2)+ 50;
g(3) = P(1)-400;
g(4) = P(2)-200;
h(1) = P(1)+P(2)-550;
>> clear all
(continued)
3.7 Application Examples 133
>>
f=inline('(1+0.025*x(1)+0.000020*x(1)^2)+(0.2+0.025*x(2)
+0.000075 *x(2)^2)');
>> options=optimset('Display','Iter');
>> fmincon(f,[434.21;115.79],[],[],[],[],[],[],@cnstr,
options)
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 1.972632e+01 3.421e+01 9.688e-08
1 7 1.972632e+01 3.418e+01 3.895e-06 3.668e-02
2 10 1.980822e+01 4.848e+00 4.404e-03 4.149e+01
3 13 1.983755e+01 7.349e-08 5.133e-03 6.867e+00
4 16 1.983919e+01 5.157e-09 3.085e-03 3.539e-01
5 19 1.984873e+01 4.397e-08 1.147e-02 2.018e+00
6 22 1.984267e+01 1.336e-08 4.966e-03 1.271e+00
7 25 1.983755e+01 7.895e-09 5.118e-05 1.101e+00
8 28 1.983750e+01 1.137e-12 2.032e-06 1.068e-02
9 31 1.983750e+01 6.821e-13 2.003e-08 4.377e-04
ans = 400.0000
150.0000
>>[xopt,fopt,flag,output,lambda,g,H]=fmincon(f,
[434.21;115.79],[],[],[],[],[],[],@cnstr,options);
>> xopt
xopt = 400.0000
150.0000
>> fopt
fopt = 19.8375
>> flag
flag = 1
(continued)
134 3 Constrained Optimization
>> lambda.eqnonlin
ans = -0.0475
>> lambda.ineqnonlin
ans = 0.0000
0.0000
0.0065
0.0000
>> g
g= 0.0410
0.0475
>> H
H= 0.5000 0.5000
0.5000 0.5001
Note that the values of the Lagrange multipliers agree with the ones derived
analytically in Sect. 3.5.
ρ S, k
t
L
h, T∞
rffiffiffiffiffiffiffiffiffi
h 2
q_ fin = kHt ðT 0 - T 1 Þm tanh ðmLÞ, m = ð3:84Þ
k t
HtLρs = m
136 3 Constrained Optimization
or, when solved for the area of the profile of the fin Ap:
1 m
tL = Ap = const =
H ρs
We can use the equality constraint to eliminate one of the two variables and
practically transform the problem to an unconstrained problem. By eliminating
L, the solution obtained satisfies the following equation (Aziz, A., Appl Mech
Rev, 45(5), 1992, p. 155):
where:
rffiffiffiffiffiffi
2h 1
ξ = Ap ð3:88Þ
k t 3=2
and:
rffiffiffiffiffiffiffiffiffi
3 k
L = 1:0023 A ð3:90Þ
h p
If we treat the problem in its initial form, we need to define the Lagrangian
function:
rffiffiffiffiffiffi !
pffiffi 2h L
L ðt, L, λÞ = - t tan h pffiffi þ λ tL - Ap ð3:91Þ
k t
tL - Ap = 0 ð3:92cÞ
We may use the last equality constraint to eliminate L (and we also use the
definition of ξ to simplify the final expression):
Ap
- tanh ðξÞ þ ξ sech2 ðξÞ þ 2λ pffiffiffi = 0 ð3:93aÞ
2
Ap
2ξ sech2 ðξÞ - 2λ pffiffiffi = 0 ð3:93bÞ
2
The last one can be transformed to (3.87) using the identities sech(ξ) = 1/
cosh(ξ) and 2sinh(ξ)cosh(ξ) = sinh(2ξ). The result is the same irrespective of
the strategy followed, as expected.
To use fmincon, we need to build two m-files, one for the objective
function and one for the nonlinear constraints:
function f=ObjFIN(x)
f = -sqrt(x(1))*tanh(sqrt(2*100/58.3)*x(2)/sqrt(x(1)));
function [g,h]=ConstrFIN(x)
g = [];
h = x(1)*x(2)-(1.25/7832)/1;
>> fmincon(@ObjFIN,[0.01;0.01],[],[],[],[],[0;0],[],
@ConstrFIN)
ans = 0.0035
0.0454
138 3 Constrained Optimization
The solution obtained (t = 0.0035 m and L = 0.0454 m) agrees well with the
analytic solution proposed by Aziz (see Eqs. (3.89) and (3.90)):
s ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2 s ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2 ffi
3 m=ρs h 3 1:25=7832 100
t = 0:9977 = 0:9977 = 0:0035
H k 1 58:3
rffiffiffiffiffiffiffiffiffi sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ffi
3 k 3 1:25=7832 58:3
L = 1:0023 Ap = 1:0023 = 0:0454
h 1 100
After having applied the SQP optimizer available in MATLAB once, we need to
repeat the solution process, but this time, we will follow a more detailed
approach. This approach facilitates better understanding, easier debugging,
and easier generalization or modification of the problem at hand. The m-file
that calculates the objective function is modified to incorporate extensive
comments. It is a good practice to add comments that describe the code as
comments allow others to understand your code and you can refresh your
memory when you return to it later:
function f=ObjFIN(x)
Note that in the proposed structure, we divide the m-file in three parts. The
first part involves only comments that inform the user about the physical
variables that correspond to the elements of the x vector. In the second part,
all constants appearing in the model are defined, and numerical values are
assigned to them. It is important, apart from the numerical values, to indicate
carefully the units used in each constant. In the third part of the m-file, the
objective function is defined.
The same idea is followed for the m-file that calculates the equality and
inequality constraints:
3.7 Application Examples 139
function [g,h]=ConstrFIN(x)
% A. EXPLAIN THE MEANING OF EACH ELEMENT OF x
% x(1) is the thickness of the fin in m
% x(2) is the length of the fin in m
Note that parts A and B are the same as in the m-file that defines the
objective function. The inequality constraints are defined in part C and the
nonlinear equality constraints in part D. We need now to build an m-file with
all the commands necessary to use the two m-files presented above in
fmincon to solve the problem:
clear
% A. EXPLAIN THE MEANING OF EACH ELEMENT OF x
% x(1) is the thickness of the fin in m
% x(2) is the length of the fin in m
x0=[ 0.01;
0.01];
A =[];b =[];
Aeq=[];beq=[];
LB=[0;0]; UB=[1;1];
options=optimoptions
('fmincon','Algorithm','sqp','Display','iter');
(continued)
140 3 Constrained Optimization
[xopt,fopt,flag,outinfo,lambda,grad,hessian]=...
fmincon(@ObjFIN,x0,A,b,Aeq,beq,LB,UB,@ConstrFIN,options)
eig(hessian)
lambda.eqnonlin
xopt_analytic=[0.9977*(Ap^2*ht/k)^(1/3); 1.0023*(Ap*k/ht)^
(1/3)]
>> runOptFIN
Note that the solution obtained agrees well with the analytic solution and
that the hessian has positive eigenvalues. The Lagrange multiplier of the
nonlinear equality constraint is equal to 110.1147.
Example 3.8 Optimal Design of a Liquid Pumping System
In Fig. 3.8, the basic elements of a liquid transfer system are shown. Liquid
with density ρ = 1000 kg/m3 and viscosity μ = 0.001 kg/(m s) is to be pumped
between two storage tanks that are located L = 100 m apart, with flow rate
Q = 100 m3/h. The unit will operate for ty = 8322 h/y, and the cost of
electricity is cel = 0.1 $/kWh. A smooth pipe is to be used with diameter
between 0.03 and 0.30 m with an installed cost that depends on the diameter
of the pipe used:
The equipment cost involves also the cost of the pump used which is given by:
w is the electrical power needed to drive the pump (in kW). To calculate the
electrical power, we take into consideration the friction losses through the
straight pipe:
L 1 2
Δp = f ρu ,Δp in Pa ð3:97Þ
d 2
where u is the velocity of the liquid in the pipe and f is the Moody friction factor
calculated (for smooth pipes) as a function of the Reynolds number by the
equation (Re > 5000):
142 3 Constrained Optimization
0:316 udρ
f= , Re = ð3:98Þ
Re 0:25 μ
Finally, if the pressure drop is known, the power to drive a pump with
efficiency ηe is given by:
Q Δp
w= ð3:99Þ
ηe
The aim is to select the pipe diameter so as to minimize the following approx-
imate total annual cost (TAC) of the piping system:
1
TAC = ðC þ C PUMP Þ þ wt y cel ð3:100Þ
3 PIPE
1
min 1500 d1:5 L þ 750w0:3 þ wt y cel
d,u, Re ,f ,Δp,w 3
s:t: ð3:101Þ
πd 2
u-Q=0
4
udρ
Re - =0
μ
0:316
f- =0
Re 0:25
L 1
Δp - f ρu2 = 0
d 2
Q Δp
w=
ηe
The problem at hand has six optimization variables and five equality con-
straints, and there is only one degree of freedom. The meaning is that if we
assign value to one of the variables, then all remaining variables can be
determined by solving the equations. To see that this is indeed the case for
the problem under investigation, assume that we assign a value to the pipe
diameter d, and then we can determine:
3.7 Application Examples 143
Fig. 3.9 Cost as a function of the pipe diameter for the fluid pumping case study
144 3 Constrained Optimization
d = 0.3 m, then the velocity obtained is 0.393 m/s, and this is clearly the
minimum velocity that can be obtained. As Reynolds number is inversely
proportional to the diameter, the minimum diameter corresponds to the max-
imum Reynolds number, etc.
The following m-file is a possible implementation for the calculation of the
objective function:
function f=pumping_obj(x)
function [g,h]=pumping_cnstr(x)
It is interesting to note the way that we have written the equality constraints
trying always to avoid division by an optimization variable that may cause
numerical problems. Also note that as Eq. (3.99) is a linear equality constraint,
it does not appear in the m-file. The main program is as follows:
clear
% A. EXPLAIN THE MEANING OF EACH ELEMENT OF x
...
% B. ASSIGN VALUES TO ALL MODEL PARAMETERS
...
LB(2)=Q/(pi*UB(1)^2/4);
x0(2)=Q/(pi*x0(1)^2/4);
UB(2)=Q/(pi*LB(1)^2/4);
LB(3)=LB(1)*LB(2)*rho/miu;
x0(3)=x0(1)*x0(2)*rho/miu;
UB(3)=UB(1)*UB(2)*rho/miu;
LB(4)=0.316/UB(3)^(1/4);
x0(4)=0.316/x0(3)^(1/4);
UB(4)=0.316/LB(3)^(1/4);
LB(5)=0;
x0(5)=x0(4)*(L/x0(1))*0.5*rho*x0(2)^2 ;
UB(5)=50000;
LB(6)=LB(5)*Q/hta_e;
x0(6)=x0(5)*Q/hta_e;
UB(6)=UB(5)*Q/hta_e;
options = optimoptions('fmincon','Display','iter');
fmincon(@pumping_obj,x0,A,b,Aeq,beq,LB,UB,@pumping_cnstr,
options);
146 3 Constrained Optimization
ans = 0.12773
2.1678
2.769e+05
0.013776
25342
879.92
X
NC ΔG0f ,i XNC
min Gðni Þ = ni þ ln ni - ln ni
ni ≥ 0
i=1
RT i=1
s:t: ð3:102Þ
X
NC
ni ai,k = a0k , k = 1,2, . . . ,NE
i=1
where ni are the mole of chemical species i at the product stream (there are NC
chemical species present), ΔG0f ,i is the standard state Gibbs free energy of
formation of chemical species i, T is the absolute temperature of the reaction,
and R is the ideal gas constant. aik denote the number of atoms of element k in
chemical species i, and NE are the elements present in the system. The atoms of
element k present in the feed are a0k .
An interesting application of the chemical equilibrium is that of hydrogen
production from hydrocarbons. In a particular example, a stream that contains
4 mol of water per mol of ethane (C2H6) is fed to the fixed bed reactor shown in
Fig. 3.10. The components that are detected (or believed that can be detected)
in the product stream are shown in Fig. 3.10. Our aim is to solve the mathe-
matical Formulation (3.102) to estimate the composition of the product stream
at equilibrium.
To perform the calculation, we need to determine ΔG0f ,i =RT for all compo-
nents. This is a long calculation to be performed by hand, but the details are
explained in most undergraduate books on chemical thermodynamics. The
results of the calculation for T = 1000 K are shown in Table 3.2 together
with all other parameters appearing in Formulation (3.102).
The first step in solving the problem in MATLAB is to define the objective
function which is achieved through the following m-file:
function obj=ChemEquil(n,G0)
obj=n'*(G0+log(n))-sum(n)*log(sum(n));
where G0 denotes ΔG0f ,i =RT (the condensed form at which we have written the
objective functions needs the attention of the reader). We then use the follow-
ing script to solve the problem (as all equality constraints are linear, there is no
need to define an m-file for the nonlinear equality/inequality constraints):
148
Table 3.2 Parameters appearing in Formulation (3.102) for the cracking of ethane
ai,k i = CH4 i = C2H4 i = C2H2 i = CO2 i = CO i = O2 i = H2 i = H2O i = C2H6 a0k
k=C 1 2 2 1 1 0 0 0 2 2
k=H 4 4 2 0 0 0 2 2 6 14
k=O 0 0 0 2 1 2 0 1 0 4
n0i 4 1
ΔG0f ,i 2.4703 14.2933 20.4388 -47.5942 -24.0675 0 0 -23.1795 13.1664
RT
3
Constrained Optimization
3.7 Application Examples 149
clear
% A.EXPLAIN THE MEANING OF EACH ELEMENT OF n
% n(i),i=1,2,..,9 are the mol of component i
% i= 1:CH4 2:C2H4 3:C2H2 4:CO2 5:CO 6:O2 7:H2 8:H20 9:C2H6
% initial guess
n0=[ eps eps eps 2 eps eps 7 eps eps]';
options=optimoptions('fmincon','Algorithm','sqp','Display',
'iter');
[x,f]=fmincon(@(n)
ChemEquil(n,G0),n0,A,b,Aeq,beq,LB,UB,[],options)
>> runChemEq
Iter Func- Fval Feasibility Step Length Norm of First-order
count step optimality
0 10 -9.995585e+01 3.553e-15 1.000e+00 0.000e+00 4.910e+01
1 20 -1.005245e+02 8.882e-15 1.000e+00 6.114e+00 1.825e+01
2 30 -1.014197e+02 4.441e-16 1.000e+00 1.491e+00 1.223e+01
3 50 -1.014219e+02 1.776e-15 2.825e-02 4.140e-02 1.445e+01
...
24 300 -1.042672e+02 1.776e-15 1.000e+00 3.222e-06 2.034e-01
25 310 -1.042672e+02 1.776e-15 1.000e+00 1.618e-06 6.394e-02
x = 0.062545005772458
0.000000093992436
0.000000000000000
0.552064310254511
1.385390078518543
0.000000000000000
5.364427873293356
1.510481300972434
0.000000208734807
f = -1.042671973068029e+02
The total moles in the product stream are 8.8749 mol, and the composition
is 60% H2, 17% water, 15.6% carbon monoxide, 6.2% carbon dioxide, and
0.7% methane. The moles in the product stream are also shown in Fig. 3.11.
Example 3.10 Optimization of a Heat Exchanger Network
In Fig. 3.12, a heat exchanger network is shown. A hot stream with a product
of flow rate and heat capacity of FCp,H = 10 kW/°C, feed temperature of TH,
in = 200 °C, and final temperature TH,out = 50 °C exchanges heat with a cold
stream with a product of flow rate and heat capacity of FCp,C = 30 kW/°C, feed
temperature of TC,in = 100 °C, and final temperature TC,out = 150 °C. High-
pressure steam (hps) with constant temperature Thps = 250 °C and cooling
water (cw) with inlet temperature of Tcw,in = 15 °C and exit temperature Tcw,
out = 25 °C are also available.
Q
A
FC
Q T Q
A A
FC
The intermediate temperatures T1 and T2 (see Fig. 3.12) determine the heat
load Q1 (in kW) of the process-to-process heat exchanger. If these tempera-
tures are different than the desired final temperatures of the hot and cold
streams, then low-pressure steam (heat load Q2) and/or cooling water (heat
load Q3) can be used to achieve the targets.
To develop the process model, we start with the process-to-process heat
exchanger for which we can develop two energy balances, one for the hot
stream:
We also have an equation that expresses the heat load of the heat exchanger as
a function of the available heat transfer area A1, the overall heat transfer
coefficient U1, and the logarithmic mean temperature difference:
ð200 - T 2 Þ - ðT 1 - 100Þ
Q1 = A 1 U 1 ð3:105Þ
ð200 - T 2 Þ
ln
ðT 1 - 100Þ
152 3 Constrained Optimization
For the heat exchanger that heats up the cold stream to its destination tem-
perature, we have:
In a similar way, for the heat exchanger that cools down the hot stream to its
target temperature:
As T1 may become smaller than the incoming temperature of the cold stream,
we also need to introduce an inequality constraint that also introduces the
minimum temperature approach ΔTmin between any two streams observed in
the network:
where ty = 3107 s/y is the operating time, clps = 1010-6 $/kJ is the cost of the
low-pressure steam, and ccw = 1.610-6 $/kJ is the unit cost of the cooling
water. The overall heat transfer coefficients are U1 = U2 = U3 = 1 kW/(m2 °C).
By selecting the minimum temperature approach ΔTmin, we can calculate
the temperature T1: T1 = 100 + ΔTmin and then solve the mathematical
equations in the order that have been presented to calculate all parameters
appearing in the model. By selecting values for ΔTmin 2 [0.1, 10], the model is
solved, the cost is calculated, and the results are shown in Fig. 3.13. The
minimum cost solution corresponds to T1 = 101.826 °C, and the corresponding
cost is 237,866.6 $/y.
3.7 Application Examples 153
Fig. 3.13 The approximate total annual cost as a function of the minimum temperature
approach for the heat exchanger network shown in Fig. 3.12
function f=HeatExcNetConstr(x)
% global to local
variables.........................................
T1 = x(1); % intermediate temperature of the hot stream deg C
T2 = x(2); % intermediate temperature of the cold stream deg C
Q1 = x(3); % heat load in the process-to-process heat exch. kW
Q2 = x(4); % heat load in the process-to-lps heat exch. in kW
Q3 = x(5); % heat load in the process-to-cw heat exch. in kW
A1 = x(6); % area of the process-to-process heat exc. in sq m
A2 = x(7); % area of the process-to-lps heat exc. in sq m
A3 = x(8); % area of the process-to-cw heat exc. in sq m
% cost function in $/y
f=2800*(A1^0.65+A2^0.65+A3^0.65)+30*10*Q2+30*1.6*Q3; f=f/1e5;
It could have been easier to define an inline function to achieve the same
objective, but the definition of a dedicated MATLAB function offers greater
154 3 Constrained Optimization
flexibility to the user and improved transparency (through the use of com-
ments to clarify the meaning of each variable or parameter of the model). We
then develop a MATLAB function for the constraints:
function [g,h]=HeatExcNetConstr(x)
% global to local variables
.....................................
T1 = x(1); % intermediate temperature-hot stream in deg C
T2 = x(2); % intermediate temperature-cold stream in deg C
Q1 = x(3); % heat load process-to-process heat exch. in kW
Q2 = x(4); % heat load process-to-lpd heat exch. in kW
Q3 = x(5); % heat load process-to-cw heat exch. in kW
A1 = x(6); % area of the process-to-process heat exc. in m2
A2 = x(7); % area of the process-to-lps heat exc. in sq m
A3 = x(8); % area of the process-to-cw heat exc. in sq m
% constants
....................................................
THIN=200; % inlet temperature of the hot stream in deg C
THOUT=50; % target temperature of the hot stream in deg C
FCpH=10; % "FCP" of the hot stream in kW/deg C
TCIN=100; % inlet temperature of the cold stream in deg C
TCOUT=150; % target temperature of the cold stream in deg C
FCpC=30; % "FCP" of the cold stream in kW/deg C
TLPS=250; % temperature of the lps in deg C
TCWIN=15; % inlet temperature of the cooling water in deg C
TCWOUT=15; % outlet temperature of the cooling water in deg C
U1=1; % overall heat transfer coef. in kW/(m^2 deg C)
U2=1; % overall heat transfer coef. in kW/(m^2 deg C)
U3=1; % overall heat transfer coef. in kW/(m^2 deg C)
% inequality constraints
........................................
g=[];
% equality constraints
.........................................
h(1) = Q1 - FCpH *(THIN - T1);
h(2) = Q1 - FCpC *(T2 - TCIN);
h(3) = Q1*(log(THIN-T2)-log(T1-TCIN))-...
A1*U1*((THIN-T2)-(T1-TCIN));
clear all
% initial values
..........................................................
T1 = 110; % intermediate temperature stream in deg C
T2 = 130; % intermediate temperature stream in deg C
Q1 = 900; % heat load process-to-process heat exch. in kW
Q2 = 600; % heat load process-to-lpd heat exch. in kW
Q3 = 600; % heat load process-to-cw heat exch. in kW
A1 = 10; % area of the process-to-process heat exc. in sq m
A2 = 10; % area of the process-to-lps heat exc. in sq m
A3 = 10; % area of the process-to-cw heat exc. in sq m
x0=[T1 T2 Q1 Q2 Q3 A1 A2 A3]';
optn=optimset('Display','Iter')
fmincon(@HeatExcNetCost,x0,[],[],[],[],lb,ub,
@HeatExcNetConstr,optn)
>> runHeatExcNet
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 9 2.463214e+00 1.151e+03 7.362e-04
1 18 2.551154e+00 1.387e+00 2.833e-03 1.963e+01
2 27 2.551365e+00 7.627e-07 2.836e-03 2.441e-02
3 36 2.551363e+00 1.925e-08 2.836e-03 1.139e-03
...
20 191 2.373218e+00 1.648e-04 2.190e-05 2.029e-02
21 200 2.373218e+00 1.462e-04 2.310e-07 1.909e-02
Learning Summary
min f ðxÞ
x
s:t:
hðxÞ = 0
gðx Þ ≤ 0
If x is a feasible point, i.e., h(x) = 0 and g(x) ≤ 0, the gradients of the equality
constraints and the active inequality constrains are linearly independent at
x and x solves the NLP problem locally, then there exist unique scalars λi 2 R,
i = 1, 2, . . ., m and non-negative scalars μj, j = 1, 2, . . ., p, such that:
Xm Xp
∇f ðxÞ þ λ ∇hi ðxÞ
i=1 i
þ μ ∇gj ðxÞ = 0
j=1 j
μj gj ðxÞ = 0, 8j = 1,2, . . . ,p
μj ≥ 0, 8j = 1,2, . . . ,p
When both inequality and equality constraints are considered, the SQP algo-
rithm is much more complicated, but the basic idea remains the same.
Problems
3.1 Study the paper by Kravitz, S., Packing Cylinders into Cylindrical Con-
tainers, Mathematics Magazine, 40(2), p. 65–71, 1967. Select 2, 4, 7, 8,
16, 19, and 32 circles of unit radius, and solve Formulation (3.65).
Compare your results with the results reported in the paper, and com-
mend on how the difficulty scales with the number of circles considered.
3.2 Consider now the case of unit circle packing in a square problem. Develop
the formulation based on the formulation used in Problem 3.1. Solve the
problem for N = 3, 4, . . ., 8 circles.
3.3 P. Biswas and D. Kunzru (Int. J. of Hydrogen Energy, 32, pp. 969–980,
2007) study the steam reforming (SR) of ethanol for hydrogen production
over Ni/Ce1-xZrxO2 catalyst prepared by co-precipitation and incipient
wetness impregnation technique. In Table 4 of the paper, the results of
the experimental study are summarized. Use Formulation (3.102) to
investigate whether they achieve equilibrium in their experiments or
not. Prepare a short report.
3.4 A stream of benzene (molecular mass: 78.113 and liquid density 11.2145
kmol/m3) and toluene (molecular mass: 92.14 and liquid density 9.3553
kmol/m3), 60% in benzene, has a molar flow rate of F = 100 kmol/h.
Benzene and toluene form an ideal mixture, and their vapor-liquid equi-
librium (VLE) can be described by the Raoult’s law. The saturation
pressure of benzene (B) and toluene (T) is given by the following Antoine
equations:
158 3 Constrained Optimization
2755:642
Psat = exp 9:22143 -
B T - 53:989
3090:783
Psat = exp 9:38490 -
T T - 53:963
C = 12500 D H0:8
where D is the diameter of the vessel and H its height (both in m). You
need to take the following constraints into consideration:
1. The velocity of the vapor stream inside the vessel uV (in m/s) must
satisfy the following constraint:
rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ρL - ρ V
uV = 0:0305
ρV
where ρV is the density of the vapor and ρL is the density of the liquid
(both in kg/m3).
2. The ratio of the height of the vessel over its diameter must be between
3 and 5, i.e., 3 ≤ H/D ≤ 5.
3. The height of the vessel that is not covered by liquid must be at least
1.67 m, i.e., HV > 1.67 m.
4. The liquid holdup is determined by the requirement that the liquid has
a residence time of 10 min (based on the liquid product stream).
Assume that the vessel has flat ends.
3.5 In Fig. P3.5, a heat exchanger network design problem is shown involving
the determination eight mass flow rates (F1, F2, . . ., F8), four temperatures
(T3, T4, T5, T6), and the areas of the two heat exchangers (A1 and A2). The
aim is to determine these parameters so as to minimize the cost of the two
heat exchangers given by:
C = 5000 A0:6
1 þ A2
0:6
The feed stream has a heat capacity of 1 kJ/(kg °C) and the tempera-
ture approach any two streams that exchange heat cannot be less than
Problems 159
Q
U
F F T F
T
A F
F T
T A F
T
F F T F
Saturated steam
at
Q
U
20 °C. It is reminded that the area of the heat exchangers is related to the
heat load Q (in kW), overall heat transfer coefficient U (in kW/(m2 °C),
and mean logarithmic temperature difference ΔΤlm through the following
equation:
where the index h denotes hot stream, the index c cold stream, the index
in at input state, and out at output state.
3.6 (Left and right inverse of a non-square matrix). Consider matrix A with
m rows and n columns and m > n. In that case, the system of linear
equations Ax = b does not have a unique solution as there are more
equations than unknowns (inconsistent). We can, however, obtain a least
squares solution of the system by solving the following minimum norm
problem:
min eT e
x
s:t:
e = b - Ax
160 3 Constrained Optimization
1 T
min x x
x 2
s:t:
Ax - b = 0
After solving these two problems, study the paper “Linear Constraint
Relations in Biochemical Reaction Systems: I&II” by R.T.J.M. van der
Heijden, et al., Biotechnology and Bioengineering, 43, pp. 3–10 and
11–20, 1994, and prepare a short report.
3.7 Fig P3.7 shows a simple batch process which consists of two reactors in
series, a pump that connects the storage of raw material with the first
reactor, a pump that connects the two reactors, and a pump that connects
the second reactor with the product storage vessel. Between the two
reactors and after the second pump, a heat exchanger is located that is
used to heat the product stream of the first reactor. In the first reactor, the
raw material R is transformed to an intermediate product I, which is then
transformed to the product P in the second reactor. There is a need to
produce My kg/y of the product mix P. If Nb is the number of batches
delivered in 1 year and the time between the delivery of two consecutive
batches is τ, then the amount of product mix delivered at each batch
M must satisfy the following constraints:
M Nb = My
τ N b ≤ t y or τ My ≤ t y M
C = a1 V n11 þ a2 V n22 þ β1 Rm
1 þ β 2 R2 þ β 3 R3
1 m2 m3
Determine the cycle time τ, the two reactor volumes V1 and V2, and the
tree transfer rates R1, R2, and R3 so as to minimize the cost of installed
equipment.
3.8 The flue gas from a power plant is available at 1 bar and 180 °C and has a
volumetric flow rate of Ffg = 10 m3/s (molar density ρ = 0.02655 kmol/
m3). Its composition is approximately 10% CO2, 72% N2, 3% O2, and 15%
H2O and has an approximately constant molar heat capacity Cpfg = 31
kJ/(kmol °C). The flue gas is fed to a carbon capture production unit. At
the first step, the flue gas needs to be cooled down to 60 °C. Three options
are available for the cooling medium (U is the estimated overall heat
transfer coefficient):
(i) Cooling water (TCW, in = 25 °C, TCW, out = 35 °C, cost 0.35 $/GJ,
U = 0.1 kW/(m2 °C))
(ii) Low-temperature refrigerant at -20 °C, cost 8 $/GJ, U = 0.2 kW/(m2
°C)
(iii) Very-low-temperature refrigerant at -50 °C, cost 13 $/GJ, U = 0.3
kW/(m2 °C)
162 3 Constrained Optimization
P Ts T
V Ts
A U
L
L x
x
Τ
Property Equation
Boiling point rise BPR = (1.8 + 6.2x)x
(°C)
Heat capacity of solids cps = 1.84
(kJ/(kg °C))
Overall heat transfer coef. U(x) = exp (8.14 - 0.078 ln (x) + 0.26[ln(x)]2)
(kJ/(h m2 °C))
Specific enthalpy of sat. liquid hw(T ) = 9.14 + 3.8648T + 3.3337 10-3T2 -
water (kJ/kg) 9.8 10-6T3
Specific enthalpy of sat. water Hw(T ) = 2502 + 1.8125 T + 2.585 10-4T2 -
vapor 9.8 10-6T3
(kJ/kg)
Specific enthalpy of solution h(x, T ) = (1 - x)hw(T ) + xcpsT
(kJ/kg)
The condition of the feed is given in Fig. P3.9. Our aim is to increase the
solid content of the liquid product stream to at least 50% solids. Design
the system to minimize the following approximate total annual cost
(TAC):
Problems 163
log 10 C eval = 3:9119 þ 0:8627 log 10 ðA1 Þ - 0:0088 ½ log 10 ðA1 Þ2
where Cevap is the purchasing cost of the evaporator in $, CCF = 1/3 (1/y)
is the capital charge factor, FBM = 2.25 is the bare module factor, A1 is the
heat transfer area of the evaporator in m2, V0 is the steam (saturated
steam at Ts0 = 160 °C) consumption in the first effect in kg/h, ty is the
on-stream time (8322 h/y), and cs = 0.03 $/kg is the unit steam cost.
Other variables of interest are:
T1: temperature in the evaporator in °C
P1: pressure in the evaporator in bar
V1: vapor stream coming out from the evaporator in kg/s
L1: liquid stream coming out from the evaporator in kg/s
w1: mass fraction of solids in the evaporator
The pressure, the temperature, and the boiling point rise in the
evaporator are related through the following equations:
3798:3
ln P1 = 11:622 -
Ts1 þ 227:03
T 1 = Ts1 þ BPRðx1 Þ
Di Xi Si
i (h-1) (mg/L) (mg/L)
1 0.042 1589 221
2 0.056 2010 87
3 0.083 1993 112
4 0.167 1917 120
5 0.333 1731 113
6 0.500 1787 224
7 0.667 676 1569
where D is the dilution rate (D = F/V, F is the volumetric flow rate of the
feed and V the volume of the reactor), X is the biomass concentration,
and S is the substrate concentration (substrate at the feed S0 = 3000
mg/L).
164 3 Constrained Optimization
S L V
X
S
S
μ = μ max
Ks þ S
μ max S DK s
D= or S =
Ks þ S μ max - D
X = Y x=s ðS0 - S Þ
min f ðxÞ
x
s:t: ð4:1Þ
hðxÞ = 0
gðx Þ ≤ 0
xL ≤ x ≤ x U
min cT x
x
s:t: ð4:2Þ
Ax = b
Cx ≤ d
xL ≤ x ≤ xU
usually upgraded to be used as gasoline component), kerosene, and gas oil cuts
are also drawn off the CDU. The residual heavy liquid or residue is the bottoms
product and is fed to a column operating under vacuum (vacuum distillation
unit or VDU) to lower the boiling points and to improve recovery of light
components. These products (vacuum distillates) are mixed with the products
of the CDU or are fed to downstream processes for further processing. The
main products are:
• Liquefied petroleum gas or LPG which is a group of light C2–C4 hydrocarbon
gases.
• Automotive and aviation gasoline that have boiling points up approximately
to 250 °C.
• Kerosene is a light petroleum distillate used for heating and lighting.
• Diesel fuels used in compression ignition engines.
• Fuel oils that are mainly used in space heating and are available in several
grades starting from No. 1 fuel oil (similar to kerosene) to No. 2 fuel oil
(similar to diesel fuel). Heavier grades of No. 3 and 4 can also be available.
• Lubricants
• Asphalt used in the construction industry.
• Petroleum coke used as fuel in several industries.
Almost all refinery products are obtained through some sort of blending of
intermediate products. When computers and modern instrumentation for
online monitoring and control were not available, all blending operations
were batch operations. Nowadays, even small refineries use online computer-
based blending because the equipment is relatively inexpensive and cost
savings are significant as the volumes of the products are extremely high.
168 4 Linear Programming
Apart from lubricants, the major refinery products produced by blending are
gasoline and jet fuels (fuels for internal combustion engines), heating oils, and
diesel fuels. The objective of product blending is to allocate the available
intermediate components in such a way as to satisfy product demands and
quality specifications and at the same time maximize overall profit. To be able
to use linear programming formulations to solve the blending problems posed
in the petroleum refining operations, the following requirements must be
satisfied:
• Additivity, i.e., the value of a magnitude corresponding to a whole object is
equal to the sum of the values of the magnitudes corresponding to its parts
for any division of the object into parts. For example, additivity of volume of
gasoline means that the volume of the gasoline produced is equal to the sum
of the volumes of all intermediates blended.
• Linearity, i.e., the contribution of each specific intermediate varies in direct
proportion to the fraction (volume, mass, or molar) of the component used
in the blend (doubling, e.g., the fraction of a particular intermediate in the
blend doubles its contribution to a particular property of the final product).
Let’s now consider an oversimplified version of crude oil selection. Let us
assume that a particular refinery uses two crude oil suppliers, CrOil1 and
CrOil2, to produce LPG, gasoline (GSL), diesel (DSL), and asphalt (ASP). Let us
also assume that the data shown in Table 4.1 are available to assist engineers to
decide which mix of CrOil1 and Croil2 to select.
Note that the two alternative crude oils have different yields relative to the
four products selected. There is also an important difference in the relative
prices of the potential products and a less significant difference in the cost of
crude oils. To model the problem at hand, we denote the amount of crude oil
CrOil1 by mCrOil1 and the amount of crude oil CrOil2 by mCrOil2 (in kt). The LPG
produced mLPG is given by the following linear equality constraint:
Table 4.1 Data for the oversimplified crude oil mix selection problem
Crude oil yields Yji
(t product/t crude)
Product CrOil1 CrOil2 Relative selling price Maximum (kt)
LPG 0.3 0.2 9 1.2
GSL 0.2 0.3 8 1.2
DSL 0.2 0.2 7 0.9
ASP 0.3 0.3 1 1.8
Relative cost 3.25 1.9
4.2 Examples of LP Formulations from the Chemical Industry 169
If we take into account the restriction in the maximum amount that can be
produced (due to limited storage capacity of market share), we may write:
or:
Equations (4.11), (4.12), (4.13), and (4.14) can also be written in matrix form:
2 3 2 3
1:5 1 6
6 7 mCrOil1 6 7
4 1 1:5 5 ≤4 6 5 ð4:15Þ
mCrOil2
1 1 4:5
We can use Eqs. (4.3, 4.4, 4.5, and 4.6) to eliminate the amounts of the specific
products and express the objective as a function of the two optimization vari-
ables only. The final formulation is as follows:
170 4 Linear Programming
This is a linear programming problem, and in this chapter, we will present the
methods available for its solution (including their MATLAB® implementation).
We will now show that a seemingly unrelated problem has an almost
identical mathematical formulation. We will briefly present the case of the
Portland cement clinker (PCC) production. PCC is produced from two natural
raw materials—calcium carbonate (limestone) and aluminum silicate (clay,
shale, etc.). These two natural raw materials complement each other to give
rise to the compounds or phases present in the clinker in the required quan-
tities. Several corrective materials such as bauxite, laterite, iron ore or blue
dust, sand, or sandstone, etc. are used to compensate the specific chemical
shortfalls in the composition of the raw mix. A clinker comprises four major
compounds or phases: 50–55% tricalcium silicate (C3S) or “alite,” 25–30%
dicalcium silicate (C2S) or “belite,” 9–11% tricalcium aluminate (C3A), and
12–15% tetracalcium aluminoferrite (C4AF) or “brownmillerite.” In terms of
the four major oxides present in the clinker, the phase percentage of the clinker
that was presented corresponds approximately to 62–65% CaO, 19–21% SiO2,
4–6% Al2O3, and 3–5% Fe2O3. Generally, three to five component mixes are
prepared, in which the proportion of limestone varies from about 80 to 95%,
depending on its quality. The requirements of the four major oxides are usually
expressed by the following three ratios:
Alumina ratio or modulus (AR):
mcAl2 O3
AR = ð4:18Þ
mcFe2 O3
mcSiO2
SR = ð4:19Þ
mcAl2 O3 þ mcFe2 O3
mcCaO
LSF = ð4:20Þ
2:8mcSiO2 þ 1:1mcAl2 O3 þ 0:65mcFe2 O3
4.2 Examples of LP Formulations from the Chemical Industry 171
where mCi denotes the mass of oxide i in the clinker. If the mass fraction of the
oxide in the raw material r is Ωi,r, then the mass of the oxide i in the raw
materials mix is:
XNR
mCi = r=1
Ωi,r mr ð4:21Þ
where mr is the mass of the raw material r used in the raw materials mix.
Finally, a basis for the calculations needs to be defined and is usually 1000 kg
or 1 t of clinker:
XNO
i=1
mCi = 1000 ð4:22Þ
where NO denotes the number of oxides present in the mix. Other elements
such as alkalis, metals, and SO3 as well as ash due to fuel burned to supply the
necessary energy are present in the raw material, but we ignore them to
simplify the presentation. We will consider a specific case study to facilitate
clarity. The details are presented in Table 4.2. Four different raw materials are
considered with different composition and cost characteristics. Loss on ignition
or LOI refers to the % of volatile material that ends up to the gaseous stream
and does not become part of the solid product (clinker).
The raw material mix usually is selected to satisfy specific amounts of each
oxide in the mixture and minimize the cost of raw materials used. The per-
centage of the oxides is expressed in an indirect way through the alumina ratio
AR, silica ratio SR, and lime saturation factor LSF by setting upper (denoted by
subscript U) and lower (denoted by subscript L) bounds. If we select the AR, for
example, then ARL ≤ AR ≤ ARU, or:
mcAl2 O3
ARL ≤ ≤ ARU ð4:23Þ
mcFe2 O3
or:
Table 4.2 Raw materials composition and relative cost for the clinker production process
Limestone Clay Bauxite Pyrites
Ωi,r (r = L) (r = C) (r = B) (r = P)
Oxides SiO2 0.10 0.55 0.01 0.05
(i) Al2O3 0.02 0.10 0.40 0.03
Fe2O3 0.01 0.05 0.35 0.85
CaO 0.50 0.13 0.15 0.02
Loss on ignition 0.37 0.15 0.07 0.02
Relative Cost 4 1 40 25
172 4 Linear Programming
Finally:
X
r2fL, C, B, Pg
ðΩAl2 O3 ,r - ARU ΩFe2 O3 ,r Þ mr ≤ 0 ð4:26aÞ
X
r2fL, C, B, Pg
ðARL ΩFe2 O3 ,r - ΩAl2 O3 ,r Þ mr ≤ 0 ð4:26bÞ
Similar linear inequality constraints can be developed for the SR and LSF.
These linear inequalities together with the linear equality (4.22) define the
feasible space of the problem. The objective function (cost minimization) is the
following:
XNR
min
mL ,mC ,mB ,mP
cm
r2fL, C, B, Pg r r
= cL mL þ cC mC þ cB mB þ cP mP ð4:27Þ
In this section, we will present the graphical solution of the crude oil selection
problem in order to get some insight in the nature of the problem. We consider
again the LP formulation for the crude oil selection given by Formulation
(4.17). We will start by finding what the feasible space of the LP problem
is. As we have only two variables, it is relatively easy to discover what the
feasible space is. We draw the inequalities as equalities and then exclude the
half space that does not satisfy the inequality. If we consider the general
inequality constraint a1x1 + a2x2 ≤ b, then we can draw the linear equation
a1x1 + a2x2 = b as it passes through the points (0, b/a2) and (b/a1, 0). This line
separates R2 into two half spaces. We then consider the origin (point (0, 0)),
and if it satisfies the inequality, then the half space that includes the origin
belongs to the feasible space. We repeat for all inequalities to find the feasible
space of the overall problem.
4.3 Graphical Solution of Linear Programming Problems 173
The corresponding equality passes through the points (4, 0) and (0, 6). The
origin satisfies the constraint as 0 < 6, and we obtain Fig. 4.2a where we have
also taken into consideration the non-negativity constraints 0 ≤ mCrOil1 and
0 ≤ mCrOil2. We then add the second linear inequality constraint:
The corresponding line passes through the points (0, 4) and (6, 0). The
combined result is shown in Fig. 4.2b. We then add the final inequality
constraint:
to obtain Fig. 4.3. In Fig. 4.3, in addition to the feasible space, the objective
function is also given. Points that have equal values of the objective function
are shown as dashed straight lines. As the value of the function becomes
smaller, the line of the objective function moves away from the origin. It is
important to note that all lines of equal values of the objective function are
parallel to each other. As (in this book) we express all optimization problems as
minimization problems, the objective function shown is the negative of the
objective function given in Formulation (4.17).
It is important to note that the optimal point is located when the line of the
objective function is moved in the improving direction until it only has a single
point in the feasible region. As we will see shortly, this is a general character-
istic of LP problems as the solution is always located in a “corner” or vertex
point of the feasible region. In this particular example, the optimal point is the
intersection of the following two constraints:
mCrOil1 þ 1:5mCrOil2 = 6
mCrOil1 þ mCrOil2 = 4:5
If we subtract the second from the first, we obtain mCrOil2 = 3 kt and then
mCrOil1 = 1.5 kt. It is also important to note that all “corner” points in the
convex polygon formed in the R2 space shown in Fig. 4.3 correspond to the
simultaneous solution of the two constraints that are active (satisfied as
equalities) at this point. We may therefore construct a quick method to solve
algebraically small problems. We may locate all corner points by examining all
possible combinations of two constraints and then solve the resulting linear
systems, evaluate the solution, and then determine the objective function. This
sounds as an extremely efficient method, but you only need to recall the
174 4 Linear Programming
(a)
4
m
3
0 1 2 3 4 5 6
(b)
4
m
3
0 1 2 3 4 5 6
Fig. 4.2 Step toward sketching the feasible space of the crude oil selection problem
4.3 Graphical Solution of Linear Programming Problems 175
m CrOil2
6
m CrOil1
0
0 1 2 3 4 5 6
f=−4 f=−13.5 f=−16.125
number of alternative ways in which you may select n elements among the
m members of a set to realize that the number of corner points can be
extremely high. This number is given by:
m m!
= ð4:31Þ
n n!ðm - nÞ!
(the binomial formula for counting combinations). If, for example, we have a
problem with 10 variables and 30 inequality constraints (a relatively small
case study), then we need to investigate more than 30 million corner points!
This is clearly not a feasible strategy, and a cleverer approach is needed in
order to be able to attack real-world problems with thousands of variables and
thousands or even millions of constraints. This is simplex method developed by
G. B. Dantzig.
176 4 Linear Programming
The simplex algorithm assumes that the LP problem has been defined
(or transformed) in the standard form:
min
x
f = cT x
s:t: ð4:32Þ
Ax = b
x≥0
min
x1 ,x2 ,...,xn
f = c1 x1 þ c2 x2 þ . . . þ ck xk þ . . . þ cn xn
s:t:
a11 x1 þ a12 x2 þ ... þ a1k xk þ ... þ a1n xn = b1
a21 x1 þ a22 x2 þ ... þ a2k xk þ þ a2n xn = b2
⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
ar1 x1 þ ar2 x2 þ ... þ ark xk þ ... þ arn xn = br
⋮ ⋮ ⋮ ⋮ ⋮ ⋮
am1 x1 þ am2 x2 þ . . . þ amk xk þ . . . þ amn xn = bm
x1 ≥ 0, x2 ≥ 0, . . . , xk ≥ 0, . . . , xn ≥ 0
ð4:33Þ
We will demonstrate the steps of the simplex algorithm through the crude oil
selection problem that we have just solved graphically. We can recall that the
initial formulation as given by Eq. (4.17) is not in the standard form as (a) the
problem is a maximization problem and (b) the constraints are inequality
constraints. Point a is easy to resolve as maximizing f is equivalent to minimiz-
ing -f. To transform the inequality problem into an equality problem, we
introduce one non-negative variable si for each constraint i that can be thought
of as the distance from being an active inequality (these are called slack vari-
ables). By performing these two modifications, we obtain the following
formulation:
4.4 The Simplex Method: Basic Definitions and Steps 177
We define the following column vector to facilitate clarity and generality of our
presentation:
2
3 2 3
x1 mCrOil1
6 7 6 7
6 x2 7 6 mCrOil2 7
6 7 6 7
x=6 7 6
6 x 3 7 = 6 s1 7
7 ð4:35Þ
6 7 6 7
4 x 4 5 4 s2 5
x5 s3
3 2
2 3 2 3
x1 mCrOil1 0
2 3 6 7 6 7 6
6 x2 7 6 mCrOil2 7 6 0 7
7 2 3
xN 6 7 6 7 6 7 0
6 7 6⋯7 6 ⋯ 7 6 ⋯7 6 7
x=4⋯5=6 7=6 7=6 7=4⋯5 ð4:38Þ
6x 7 6 s
6 37 6 1
7 6
7 6 6 7
7
xB 6 7 6 7 6 7 b
4 x 4 5 4 s2 5 4 6 5
x5 s3 4:5
x2 þ x3 = 6
1:5x2 þ x4 = 6 ð4:39Þ
x2 þ x5 = 4:5
As we increase x2, the basic variables x3, x4, and x5 must be decreased to ensure
satisfaction of the equality constraints. We want to increase x2 as far as
possible, and we can decrease all basic variables, but they have to remain
non-negative. At the extreme case, they become zero, and this happens when:
• x3 = 0 ) x2 = 6/1 = 6.
• x4 = 0 ) x2 = 6/1.5 = 4.
• x5 = 0 ) x2 = 4.5/1 = 4.5.
The minimum among these ratios is the most restrictive condition, and the
corresponding basic variable (x4 in our case) will become nonbasic.
We have concluded that x2 will become basic variable and x4 will become
nonbasic. We exchange their positions in (4.36):
We are not finished yet as we have destroyed the structure of our table (needs
to have the structure implied by Eq. (4.37)). To bring the table back into the
standard format, we eliminate x2 from all rows but the second one. This can
be achieved by first dividing row 3 by the coefficient of x2 in that row
(R3 ° R3/1.5):
and then subtract row 3 from rows 2 (R2 ° R2 - R3) and 4 (R4 ° R4 - R3)
(eliminate x2):
We finally eliminate x2 from the first row (R1 ° R1 + 4R3) (note that all
coefficients of the basic variables are zero in the line corresponding to the
objective function in (4.37)):
0:25 8
- x þ x þ 0x3 þ 0x2 þ 0x5 = f þ 16
3 1 3 4
5 2
þ x - x þ x3 = 2
4 1 3 4 ð4:43Þ
2 2
þ x þ x þ x2 = 4
3 1 3 4
1 2
þ x - x þ x5 = 0:5
3 1 3 4
Note that we have restated the problem in the standard form, and the solution
follows immediately by simply setting the nonbasic variables equal to zero:
2 3 2 3 2 3
x1 mCrOil1 0
23 6 7 6 7 6
6 x 4 7 6 s2 7 6 0 7 2 3
7
xN 6 7 6 7 6 7 0
6 7 6 ⋯7 6 ⋯ 7 6 ⋯ 7 6 7
x=4⋯5=6 7 6
6 x 7=6 s
7=6 7
7 6 2 7=4⋯5 ð4:44Þ
6 37 6 1 7 6 7
xB 6 7 6 7 6 7 b
4 x2 5 4 mCrOil2 5 4 4 5
x5 s3 0:5
This new basis corresponds to the point (4, 0) in Fig. 4.3 and is again, as
expected, a vertex solution. The objective function has decreased to f = -16.
The slack variables s1 = 2 and s3 = 0.5 show how far away we are from
“hitting” the first and third constraints. Is this solution optimal? The answer
is “no” as the coefficient of x1 in the first line of Formulation (4.43) is negative.
We have therefore completed a step of the simplex algorithm, but we are not
finished yet!
We have identified x1 as the nonbasic variable to become basic by examining
the condition:
4.4 The Simplex Method: Basic Definitions and Steps 181
p = argminfci g ð4:45Þ
i
bi
q = arg min ð4:46Þ
i:aip > 0 aip
i.e., we calculate all ratios bi/aip and locate the most restrictive (smaller
positive ratio). For our case study:
0:25 8
- x þ x þ 0x3 þ 0x2 þ 0x5 = f þ 16
3 1 3 4
5 2
þ x - x þ x3 = 2
4 1 3 4 ð4:47Þ
2 2
þ x þ x þ x2 = 4
3 1 3 4
1 2
þ x - x þ x5 = 0:5
3 1 3 4
formulation. A LP formulation can also have many solutions when the objective
function happens to be parallel to a constraint that is active at the optimum
point. All points on the constraint also correspond to the same value of the
objective function. If a LP problem has a feasible solution, it will also have a
basic feasible solution and, at least, one optimum point (which is always going
to be a vertex point). Finally, although the standard LP formulation involves
only equality constraints and non-negative variables, any modern LP solver can
handle problems of the general LP form that involves both equality and
inequality constraints and lower and upper bound on x:
min f = cT x
x
s:t: ð4:48Þ
Ax ≤ b
Aeq x = beq
LB ≤ x ≤ UB
[xopt,fopt,flag,output,lambda]
=linprog(c,A,b,Aeq,beq,LB,UB)
attempts to solve the linear programming problem given by:
Set A=[] and B=[] if no inequalities exist. Use empty matrices for
LB and UB if no bounds exist. xopt is the optimal solution and
fopt the optimum value of the objective function. When flag=1
the global solution has been found. Lambda is s structure with the
Lagrange multipliers.
To demonstrate the use of linprog, we consider the crude oil mix selection
problem as it is summarized by Formulation (4.17). As linprog solves
minimization problems, we use the negative of the objective function:
>> clear
>> c=[-2.75;-4];
>> A=[1.5 1; 1 1.5;1 1]; b=[6;6;4.5];
(continued)
4.5 Solving LP Problems in MATLAB® 183
xopt = 1.5000
3.0000
fopt = -16.1250
flag = 1
output =
struct with fields:
iterations: 2
constrviolation: 0
message: 'Optimal solution found.'
algorithm: 'dual-simplex'
firstorderopt: 2.2204e-15
lamda =
struct with fields:
lower: [2×1 double]
upper: [2×1 double]
eqlin: []
ineqlin: [3×1 double]
>> lamda.ineqlin
ans = 0
2.5000
0.2500
The solution obtained in MATLAB agrees with the solution obtained graph-
ically in Fig. 4.3 and the solution obtained by the “manual” application of the
simplex algorithm. Note that the Lagrange multipliers for the second and third
constraints that are active are different than zero. To demonstrate how they
can be calculated, we may apply Eq. (3.6):
Xp
∇f þ μ ∇gi
i=1 i
= ∇ðc1 x1 þ c1 x1 Þ þ μ2 ∇ða21 x1 þ a22 x2 Þ
þ μ3 ∇ða31 x1 þ a32 x2 Þ = 0
or:
c1 a21 a31
þ μ2 þ μ3 =0 ð4:49Þ
c2 a22 a32
184 4 Linear Programming
which has the solution [μ1 μ2]=[2.5 0.25]. As the Lagrange multipliers are
positive, this is a KKT point, and given the fact that the problem is convex, it
follows that it is the global optimal solution.
We now return to the clinker production problem for which we have to
finalize the mathematical formulation. We start by using the data in Table 4.2
to write Eq. (4.27) in the following form:
The mass of the oxides in the clinker is obtained from Eq. (4.21) by substituting
the numbers (mass fractions Ωi,r) given in Table 4.2:
2 3 2 32 3
mcSiO2 0:10 0:55 0:01 0:05 mL
6 mc 7 6 0:02 0:03 7 6 7
6 Al2 O3 7 6 0:10 0:40 7 6 mC 7
6 7=6 76 7
4 mcFe2 O3 5 4 0:01 0:05 0:35 0:85 5 4 mB 5
mcCaO 0:50 0:13 0:15 0:02 mP
or:
2 3
mL
6 7
6 mC 7
6 7
2 36 7 2 3
0:10 0:55 0:01 0:05 -1 0 0 0 6 mB 7 0
6 7
6 76 7 6 7
6 0:02 0:10 0:40 0:03 -1 0 7 6 7 6 7
6 0 0 7 6 mP 7 6 0 7
6 7 6 c 7=6 7
6 0:01 0:05 0:35 0:85 -1 0 7 6 7 6 7
4 0 0 5 6 mSiO2 7 4 0 5
6 c 7
0:50 0:13 0:15 0:02 0 0 0 -1 6 7
6 mAl2 O3 7 0
6 7
6m c 7
4 Fe2 O3 5
mcCaO
ð4:53Þ
4.5 Solving LP Problems in MATLAB® 185
We also need to add constraint (4.22) which expresses the fact that the mass of
the produced clinker (oxides) is 1000 kg:
2 3
mL
6 mC 7
6 7
6 7
6 mB 7
6 7
6 m 7
6 P 7
½0 0 0 0 1 1 1 1 6 c 7 = 1000 ð4:54Þ
6 mSiO2 7
6 7
6 mc 7
6 Al2 O3 7
6 c 7
4 mFe2 O3 5
mcCaO
We then express the upper and lower bound constraints on AR, SR, and LSF
(see Eqs. (4.18), (4.19), and (4.20)):
where the subscript L denotes lower bound and the subscript U upper bound
(see also Eqs. (4.23) and (4.24) on how Eqs. (4.55a) and (4.55b) can be derived,
and the approach is exactly the same for Eqs. (4.56) and (4.57)). The inequality
constraints can also be written in the following matrix form:
2 3
mL
2 36 7 2 3
0 0 0 0 0 -1 ARL 0 6 mC 7 0
6 7
6 76 7 6 7
60 þ1 - ARU 0 7 6 7 6 7
6 0 0 0 0 7 6 mB 7 6 0 7
6 76 7 6 7
60 -1 0 7 6 7 6 7
6 0 0 0 SRL SRL 7 6 mP 7 6 0 7
6 7 6 c 7≤6 7
60 þ1 - SRU - SRU 0 7 6 7 6 7
6 0 0 0 7 6 mSiO2 7 6 0 7
6 76 c 7 6 7
60 -17 6 7 6 7
4 0 0 0 2:8LSFL 1:1LSFL 0:65LSFL 5 6 mAl2 O3 7 4 0 5
6 7
0 0 0 0 - 2:8LSFU - 1:1LSFU - 0:65LSFU þ1 4 6 mc 7 0
Fe2 O3 5
mcCaO
ð4:58Þ
186 4 Linear Programming
We have therefore completed the formulation, and we can solve the problem in
MATLAB (which we organize in a script file due to a large volume of informa-
tion necessary to use linprog for this case study):
c=[4 1 40 25 0 0 0 0];
Omega=[0.10 0.55 0.01 0.05;
0.02 0.10 0.40 0.03;
0.01 0.05 0.35 0.85;
0.50 0.13 0.15 0.02];
Aeq=[Omega -eye(4);
zeros(1,4) ones(1,4)]; % see eq (4.5.5) & (4.5.6)
beq=[zeros(1,4) 1]';
ARL = 1.0; ARU = 2.7;
SRL = 1.5; SRU = 2.5;
LSFL= 0.85; LSFU= 1.02;
A=[ 0 -1 ARL 0;
0 1 -ARU 0;
-1 SRL SRL 0
1 -SRU -SRU 0;
2.8*LSFL 1.1*LSFL 0.65*LSFL -1;
-2.8*LSFU -1.1*LSFU -0.65*LSFU 1];
A=[ zeros(6,4) A]; % see eq (4.5.9)
b=zeros(6,1);
LB=zeros(8,1); UB=[];
[x,f,flag,output,lambda]=linprog(c,A,b,Aeq,beq,LB,[])
>> clinker
Optimal solution found.
x = 1.2551
0.2150
0.0040
0.0287
0.2452
0.0490
0.0490
0.6567
f = 6.1103
flag = 1
mcAl2 O3 49
AR = = = 1 = ARL
mcFe2 O3 49
mcSiO2 245:2
SR = = = 2:5 = SRU
þ mcFe2 O3
mcAl2 O3 98
mcCaO
LSF =
2:8mcSiO2 þ 1:1mcAl2 O3 þ 0:65mcFe2 O3
656:7
= = 0:85 = LSFL
2:8 245:2 þ 1:1 48 þ 0:65 48
>> lambda.ineqlin
S D
. .
. .
. .
cij
Si i j Dj
. .
. .
. .
Sm m n Dn
X
m X
n
min cij xij
xij
i=1 j=1
s:t: ð4:59Þ
X
n
xij = S i , i = 1, 2, . . . , m
j=1
X
m
xij = Di , j = 1, 2, . . . , n
i=1
0 ≤ xij ≤ min S i , Dj , i = 1, 2, . . . , m
j = 1, 2, . . . , n
The first m equality constraints state that the total amount shipped from origin
i must always be equal to the available supply from this origin Si. The
remaining n equality constraints ensure that the demand Dj of each destination
j is satisfied. If we take a problem with three origins and three destinations,
then we may write the equations in the following matrix form (only the
nonzero elements are shown to indicate the special structure of the Aeq
matrix):
4.6 Classical LP Formulations 189
2 3
x11
6 7
2 3 6 x12 7 2 3
1 1 1 6 7 s1
6 7
6 7 6 x13 7 6 s 7
6 1 1 1 76 7 6 27
6 7 6 x21 7 6 7
6 1 1 17 6 7 6s 7
6 7 6 x22 7 = 6 3 7 ð4:60Þ
61 76 7 6d 7
6 1 1 76 7 6 17
6 7 6 x23 7 6 7
4 1 1 1 56 7 4 d2 5
6 x31 7
1 66 7
1 1 7 d3
4 x32 5
x33
function [xopt,fopt,flag]=transportationLP(C,S,D)
% build and solve a transportation model
% C is the m-by-n matrix with the unit costs
% S is the m dimensional column vector with the supplies
% D is the n dimensional column vector with the demands
if (sum(S)-sum(D)) % if not balanced give a warning
fprintf('Supply is not equal to demand'); pause
xopt=[];fopt=[];flag=-inf; return;
end
m=length(S) ; % number of origins
n=length(D) ; % number of destinations
c=reshape(C',m*n,1);
Aeq=[ kron(eye(m),ones(1,n));
kron(ones(1,m),eye(n))];
beq=[S;D]';
[xopt,fopt,flag]=linprog(c,[],[],Aeq,beq,zeros(m*n,1));
The following script can be used to solve the transportation problem shown
in Fig. 4.5:
190 4 Linear Programming
clear
C=[ 35 30 40 32;
37 40 42 25;
40 15 20 28];
S=[120 100 80]';
D=[110 40 75 75]';
[xopt,fopt,flag]=transportationLP(C,S,D)
>> run_tranportationLP_1
Optimization terminated.
fopt = 8.4000e+03
flag = 1
S
. D
.
. .
.
. k .
. .
Sm m n Dn
b
c c
b
b b c
c
c c
c
b b
c
c c
c
b c
c c
b c
c b
b
X
m X
n
min cij xij
xij
i=1 j=1
s:t: ð4:61Þ
X
n X
n
xij - xji = bi , i = 1, 2, . . . , n
j=1 j=1
0 ≤ xij ≤ UBij , i, j = 1, 2, . . . , n
4.6 Classical LP Formulations 193
The equality constraint is a balance constraint and expresses the fact that
objects need to be conserved in nodes (cannot be destroyed or generated
from nothing). The first summation is the total amount leaving node i, while
the second summation is the total amount that is fed to node i. Their difference
must be equal to bi, i.e., the supply or demand at the node. This constraint is
also known as the flow conservation or Kirchhoff equation.
Two well-known cases of the general network model are the models of the
maximum flow and the model of the shortest route. The maximum flow
formulation between nodes 1 and n is the following:
max
x
f
ij
s:t:
8 ð4:62Þ
>
> þf , i=1
Xn Xn <
xij - xji = 0, 1<i<n
>
>
j=1 j=1 :
-f, i=n
0 ≤ xij ≤ UBij , i, j = 1, 2, . . . , n
Observe that there is only one source (node 1) and only one destination (node
n). The formulation seeks to calculate the maximum flow available at node
1 that can be transported through the network to the destination.
The shortest route formulation is the following:
X
n X
n
min distij xij
x
ij
i=1 j=1
s:t:
8 ð4:63Þ
> þ1,
> i=1
X n Xn <
xij - xji = 0, 1<i<n
>
>
j=1 j=1 :
- 1, i=n
0 ≤ xij ≤ 1, i, j = 1, 2, . . . , n
Note that we have replaced the unit cost cij by distij to stress the fact that we are
minimizing the total distance covered. Even though we do not impose any
integrality constraint on xij, the solution is always xij = 1 or xij = 0 (binary). This
is an amazing characteristic of the particular formulation and is due to the fact
that the Aeq matrix is unimodular. In Fig. 4.8, a hypothetical network is shown
with the distances between the nodes indicated. The distances are also given in
the following matrix:
194 4 Linear Programming
+1
−1
Fig. 4.8 Example case study for the shortest route problem
2 3
0 80 70 90 M M M M M M
6 80 0 M M 40 M M 60 90 M 7
6 7
6 7
6 70 M 0 60 50 70 M M M M 7
6 7
6 90 M 60 M7
6 0 M 100 M M M 7
6 7
6 M 40 50 M 0 M 60 M M M7
dist = 6
6 M M 70
7 ð4:64Þ
6 100 M 0 40 M M M7 7
6 7
6M M M M 60 40 0 40 M 50 7
6 7
6 M 60 M 50 7
6 M M M 40 0 M 7
6 7
4 M 90 M M M M M M 0 30 5
M M M M M M 50 50 30 0
function [xopt,fopt,flag]=ShortestRouteLP(dist)
(continued)
4.6 Classical LP Formulations 195
c=reshape(dist',n*n,1)
[xopt,fopt,flag]=. . .
linprog(c,[],[],Aeq,beq,zeros(n*n,1),ones(n*n,1));
return
The solution to the example shown in Fig. 4.8 can be obtained as follows:
clear
M=200;
C=[ M 80 70 90 M M M M M M;
80 M M M 40 M M 60 90 M;
70 M M 60 50 70 M M M M;
90 M 60 M M 100 M M M M;
M 40 50 M M M 60 M M M;
M M 70 100 M M 40 M M M;
M M M M 60 40 M 40 M 50;
M 60 M M M M 40 M M 50;
M 90 M M M M M M M 30;
M M M M M M 50 50 30 M];
[xopt,fopt,flag]=ShortestRouteLP(C)
The solution obtained (too long to be included) involves moving from node
1 to node 2, then to node 8, and finally to node 10 with a minimum distance of
190.
Example 4.3 Cutting Stock (or Trim Loss) Models
Cutting stock problems (or trim loss problems) deal with the problem of
producing objects of prespecified size(s) and shape(s) from given initial objects
so as to minimize the loss (unused material) or some more general and detailed
cost-related objective function. The problem can involve 1D, 2D, or even 3D
objects. As an example, we consider the case of 1D objects shown in Fig. 4.9. We
assume that rods of three different lengths are available: 10 cm, 7 cm, and 4 cm.
We want to produce rods with sizes 5 cm (150 pieces) and 3 cm (100 pieces),
and we want to minimize the loss while satisfying the demand. Each cut we
perform has a (labor and machine setting related) cost associated with it. One
way to formulate the problem is to enumerate all cutting patterns that are
compatible with our requirements. The six different cutting patterns that we
196 4 Linear Programming
3 cm
5 cm 5 cm
i=1, 10 cm rods, 50 available
10 cm 3 cm
3 cm
5 cm
3 cm
2 cm
waste 1 cm
waste
5 cm 3 cm
4 cm
i=3, 4 cm rods, 100 available
i=2, 7 cm rods, 80 available
3 cm
7 cm 3 cm
1 cm
waste
2 cm waste
1 cm waste
Fig. 4.9 Example case study for the cutting stock problem
4.6 Classical LP Formulations 197
can use to produce the requested rods from the ones available are shown in
Fig. 4.9 (numbers in squares denote the number of the specific cutting pattern).
To develop a skeleton formulation of the problem at hand, let’s use the
index i to denote the available rods (i = 1, 2, 3) and Si to denote the supply
available of rod i. We will also be using index j to denote the type of the rod in
demand ( j = 1 for the 5 cm rods and j = 2 for the 3 cm rods) and Dj the demand
of rod type j. We will be using the index k to denote the six different cutting
patterns shown in Fig. 4.9 and Yjk to denote the number of rods of type
j produced from cutting pattern k. In our example:
Y jk 1 2 3 4 5 6
" #
1 2 1 0 1 0 0 ð4:65Þ
2 0 1 3 0 2 1
Finally, the variable xk denotes the number of times cutting pattern k is used in
our solution and the constant matrix A with elements aik = 1 when cutting
pattern k is produced from rod i, and aik = 0 otherwise. In our case:
aik 1 2 3 4 5 6
2 3
1 1 1 1
6 7 ð4:66Þ
2 6 1 1 7
4 5
3 1
The first constraint ensures that we will not be using more rods than the ones
available and the second one that demand is satisfied. A possible objective
function is the cost of rods used to satisfy the demands and the cost of cutting
the rods. We assume a basis of the unit cost which is the cost of the rods of
length 4 cm (assumed c3 = 1 monetary unit). Then, we set arbitrarily the
relative cost of the 7 cm rods to c2 = 1.5 and the relative cost of the 10 cm rods
to c1 = 2. Each cutting operation is assigned a cost of ccut = 0.1 monetary units
relative to the unit cost of the 4 cm rods. The objective function is:
198 4 Linear Programming
or:
X3 X6 X6
f= c
i=1 i
a x
k = 1 ik k
þ ccut κ x
k=1 k k
ð4:69Þ
clear
A=[1 1 1 0 0 0;
0 0 0 1 1 0;
0 0 0 0 0 1];
S=[50; 80; 100];
Aeq=[2 1 0 1 0 0;
0 1 3 0 2 1];
D=[150; 100];
c=[2.1 2.2 2.3 1.6 1.7 1.1];
[xopt,fopt,flag]=linprog(c,A,S,Aeq,D,zeros(6,1))
>> CuttingStock
xopt = 50.0000
0
0
50.0000
30.0000
40.0000
fopt = 280
flag = 1
rods, and 40 4 cm rods are cut into 40 3 cm rods to satisfy the demand for
100 3 cm rods. The overall cost is 280 monetary units relative to the unit cost
of 4 cm rods. Before closing this example, it is important to emphasize that the
variables appearing in the mathematical formulation for the one-dimensional
cutting stock problem are integer variables (as only integer patterns can be
cut). The solution obtained by linear programming may involve non-integer
solution in which case rounding to the nearest integer that satisfies the demand
can be an acceptable solution.
Example 4.4 Employee Scheduling Models
In this application example, we will consider a simplified scheduling prob-
lem that assigns employees to working shifts. We will consider the more basic
form of the problem where time slots have been defined and minimum
requirements for workers have been identified for each time slot. An example
is shown in Table 4.3 where 4-hour time slots are considered. We assume that
workers start their shift at the beginning of a time slot, and they work for two
consecutive time slots (8-hour shifts). It then follows that at each time slot, the
workers available are the ones that started their shift at the beginning of the
current time slot or the previous time slot. In this simplified example, we will
assume that all workers are identical in terms of skills required and unit cost.
To present the mathematical formulation, we define the index i = 1, 2, .., n to
denote the time slots and di to denote the minimum number of employees in
time slot i. We will also be using the variable xi to denote the workers starting
their shift at the beginning of time slot i. The objective function is to minimize
the number of total employees necessary to satisfy the manning requirements
for the n time slots:
Xn
min x
i=1 i
= 1T x ð4:70Þ
x
i
clear
n=6;
c=ones(n,1);
D=-[4; 6; 18; 14; 10; 6];
A=diag(-ones(1,n))+diag(-ones(1,n-1),-1); A(1,n)=-1;
[xopt,fopt,flag]=linprog(c,A,D,[],[],zeros(n,1))
>> employeeScheduling
Optimal solution found.
xopt = 4
2
16
4
6
0
fopt = 32
flag = 1
4.6 Classical LP Formulations 201
Table 4.4 Data for the vaccine production scheduling case study
Month Sep Oct Nov Dec Jan Feb
t t=1 2 3 4 5 6
Demand (unit) 10,000 40,000 30,000 20,000 40,000 10,000
dt
Production 10 9 16 20 10 5
Cost in $/unit pct
Storage cost 1 2 3 4 2 9
in $/unit sct (Feb to Aug)
202 4 Linear Programming
overall production cost. Apart from the varying demand, the company also
faces varying production and storage costs that need to be taken into
consideration.
These costs are also given in Table 4.4. The maximum production capacity is
50,000 vaccines per month. Storage capacity is also limited and cannot also
exceed 100,000 vaccines.
The most important variable to determine is the monthly production pt,
t = 1, 2, ..., n. The next most important variable is the inventory It, i.e., the
amount of the product kept in storage at the end of month t. Based on these two
variables, we can propose the following objective function which accounts for
the production and storage cost:
X6
min t=1
ðpct pt þ sct I t Þ ð4:73Þ
xt ,I t
I t - 1 þ pt = I t þ dt , t = 1,2,⋯,6 ð4:74Þ
It is interesting to note that for t = 1, the equation obtains the following form:
I n þ pt = I t þ d t , t=1 ð4:75Þ
i.e., t - 1 = n, when t = 1 (the vaccines available on September are the ones left
in storage in February, as we assume that no flu vaccine is sold in the
meantime). The following bound constraints also need to be satisfied:
0 ≤ pt ≤ 50,000
, t = 1,2,⋯,6 ð4:76Þ
0 ≤ I t ≤ 100,000
x = ½ p1 p2 . . . p6 I1 I2 . . . I 6 T ð4:77Þ
2 3
1 0 0 ⋯ 0 -1 0 0 ⋯ 1
6 7
60 1 0 ⋱ ⋮ 1 -1 0 ⋯ 07
6 7
6
Aeq = 6 0 0 1 ⋱ 0 0 1 -1 ⋱ 07 ð4:78Þ
7
6 7
4⋮ ⋱ ⋱ ⋱ 0 ⋮ ⋱ ⋱ ⋱ 05
0 ⋯ 0 0 1 0 ⋯ 0 1 -1
clear
n=6; % number of scheduling periods
c=[10 9 16 20 10 5 1 2 3 4 2 9];
D=[10; 40; 30; 20; 40; 10]*1000;
Aeq=[eye(n) diag(-ones(1,n))+diag(ones(1,n-1),-1)];
Aeq(1,2*n)=1;
LB=zeros(2*n,1);
UB=[50*ones(n,1); 100*ones(n,1)]*1000;
[xopt,fopt,flag]=linprog(c,[],[],Aeq,D,LB,UB)
>> VaccineProductionScheduling
xopt = 50000
50000
0
0
40000
10000
40000
50000
20000
0
0
0
fopt = 1600000
flag = 1
production during November and December, and the demand is satisfied from
the inventories. Finally, during January and February, the production matches
the demand, and there is no inventory that is kept in storage at the end of
February. The minimum cost is M$1.6.
Example 4.6 Facility Location Models
In this application example, we will consider a simplified version of the
facility location problem. The general description of the case study is shown in
Fig. 4.11. Existing facilities (shown as circles) are located at positions A (0,250),
B (300,500) and C (400,0) in the two-dimensional space (the units of the
distances can be considered arbitrary, but you might think of them as distances
in m if it helps visualize the problem). Two new facilities (shown as squares)
are to be located in the two-dimensional space. The new facilities will exchange
material with the existing facilities and among themselves with transportation
cost that depends on their rectilinear distances. The rectilinear distance
between two points is simply the sum of the difference in x and
y coordinates between two points, i.e., if point i is (xi, yi) and point j is (xj, yj),
then their rectilinear distance rdij is simply:
rdij = xi - xj þ yi - yj ð4:79Þ
x x
x
4.6 Classical LP Formulations 205
min c12 rd12 þ c1A rd1A þ c1C rd1C þ c2A rd2A þ c2B rd2B ð4:80Þ
x1 ,y1 ,x2 ,y2
The rectilinear distances are defined in Eq. (4.79), but they are nonlinear as
they involve absolute values. There is fortunately an efficient technique to
linearize the absolute value terms. Let’s consider the rd12:
x1 - x2 = X þ -
12 - X 12 , Xþ -
12 ,X 12 ≥ 0 ð4:82aÞ
y1 - y2 = Y þ
12
-
- Y 12 , Yþ -
12 ,Y 12 ≥0 ð4:82bÞ
x1 - x2 = X þ
12 ,
-
X 12 =0 ð4:83aÞ
-
x1 - x2 = - X 12 , Xþ
12 = 0 ð4:83bÞ
and therefore:
jx 1 - x 2 j = X þ -
12 þ X 12 ð4:84Þ
min c Xþ - þ - þ - þ -
12 þ X 12 þ Y 12 þ Y 12 þ c1A X 1A þ X 1A þ Y 1A þ Y 1A
x1 ,y1 ,x2 ,y2 12
þ c1C X þ - þ - þ - þ -
1C þ X 1C þ Y 1C þ Y 1C þ c2A X 2A þ X 2A þ Y 2A þ Y 2A
þ - þ -
þ c2B X 2B þ X 2B þ Y 2B þ Y 2B ð4:85Þ
206 4 Linear Programming
Note that we have achieved the indented “linearization” of the absolute values,
but we have paid a price: the number of the variables has increased
dramatically!
The mathematical formulation involves the following equality constraints:
x1 - x 2 = X þ -
12 - X 12
1-2 ð4:86aÞ
y1 - y2 = Y þ -
12 - Y 12
x1 - xA = X þ -
1A - X 1A
1-A ð4:86bÞ
y1 - yA = Y þ -
1A - Y 1A
x1 - x C = X þ -
1C - X 1C
þ -
1-C ð4:86cÞ
y1 - yC = Y 1C - Y 1C
x2 - xA = X þ -
2A - X 2A
þ -
2-A ð4:86dÞ
y2 - yA = Y 2A - Y 2A
x2 - xB = X þ -
2B - X 2B
þ -
2-B ð4:86eÞ
y2 - yB = Y 2B - Y 2B
x1 ,x2 ,X þ - þ - þ - þ - þ -
12 ,X 12 ,X 1A ,X 1A ,X 2A ,X 2A ,X 2B ,X 2B ,X 1C ,X 1C ≥ 0 ð4:87aÞ
y1 ,y2 ,Y þ - þ - þ - þ - þ -
12 ,Y 12 ,Y 1A ,Y 1A ,Y 2A ,Y 2A ,Y 2B ,Y 2B ,Y 1C ,Y 1C ≥ 0 ð4:87bÞ
1
ln Ps = A þ B ð4:88Þ
T
This is clearly a nonlinear model between the vapor pressure Ps and the
absolute temperature T. However, the two parameters of the model A and B
appear linearly. If we perform experiments in which we vary the temperature
and measure the corresponding saturation pressure, then we may define the
variables Y = lnPs and X = 1/T. In this case, our model becomes linear:
Y = A + BX. Linear least squares can be used to determine the model param-
eters, but other options are available as well.
4.6 Classical LP Formulations 207
Y = p0 þ p1 X 1 þ p2 X 2 þ ⋯ þ pn X n ð4:89Þ
This model can be generalized to involve mixed terms such as X1X2 and still be
linear in the parameters, but we only keep the first-order terms to facilitate
clarity of presentation. If we have k experimental pairs (Xj, Yj) available, then
we can define the corresponding errors or residuals rj:
r j = Y j - p0 þ p1 X 1j þ p2 X 2j þ ⋯ þ pn X nj , j = 1,2,⋯,k ð4:90Þ
Instead of minimizing the sum of the squared residuals, we can minimize the
maximum residual:
min μ
po , p1 , ..., pn,μ
s:t: ð4:91Þ
- μ ≤ Y j - p0 þ p1 X 1j þ p2 X 2j þ . . . þ pn X nj ≤ μ,
j = 1, 2, . . . , k μ ≥ 0
X
k
min μþ
j þ μj
-
po , p1 , ..., pn,μ
j=1
s:t: ð4:92Þ
Y j - p0 þ p1 X 1j þ p2 X 2j þ . . . þ pn X nj ≤ μþ
j - μj- ,
j = 1, 2, . . . , k μþ -
j - μj ≥ 0, j = 1, 2, . . . ,k
min
p0 , p1 , p2 , p3 , p4 , μ
μ
s:t: ) ð4:93Þ
- μ - p0 - p1 X 1j - p2 X 2j - p3 X 3j - p4 X 4j ≤ - Y j
, j = 1, 2, . . . , k
- μ þ p0 þ p1 X 1j þ p2 X 2j þ p3 X 3j þ p4 X 4j ≤ þ Y j
μ≥0
208 4 Linear Programming
clear
data=[ 4 21 26 47 114.0
6 7 60 26 78.5
6 7 33 52 95.9
8 11 20 56 104.3
8 11 47 31 87.6
8 10 12 68 109.4
9 11 12 66 113.3
9 11 22 55 109.2
15 1 52 29 74.3
17 3 6 71 102.7
18 2 22 54 93.1
22 1 44 31 72.5
23 1 34 40 83.8];
X=data(:,1:4); Y=data(:,5);
[k,n]=size(X); n=n+1;
A=[-ones(k,1) -ones(k,1) -X; -ones(k,1) +ones(k,1) +X]
b=[-Y; +Y]
c=zeros(n+1,1); c(1)=1;
LB=-inf*ones(n+1,1); LB(1)=1;
[xopt,fopt,flag]=linprog(c,A,b,[],[],LB,[])
(continued)
4.6 Classical LP Formulations 209
>> StatEstLP
A = -1 -1 -4 -21 -26 -47
-1 -1 -6 -7 -60 -26
-1 -1 -6 -7 -33 -52
-1 -1 -8 -11 -20 -56
-1 -1 -8 -11 -47 -31
-1 -1 -8 -10 -12 -68
-1 -1 -9 -11 -12 -66
-1 -1 -9 -11 -22 -55
-1 -1 -15 -1 -52 -29
-1 -1 -17 -3 -6 -71
-1 -1 -18 -2 -22 -54
-1 -1 -22 -1 -44 -31
-1 -1 -23 -1 -34 -40
-1 1 4 21 26 47
-1 1 6 7 60 26
-1 1 6 7 33 52
-1 1 8 11 20 56
-1 1 8 11 47 31
-1 1 8 10 12 68
-1 1 9 11 12 66
-1 1 9 11 22 55
-1 1 15 1 52 29
-1 1 17 3 6 71
-1 1 18 2 22 54
-1 1 22 1 44 31
-1 1 23 1 34 40
b=
-114.0000
-78.5000
-95.9000
-104.3000
-87.6000
-109.4000
-113.3000
-109.2000
-74.3000
-102.7000
-93.1000
-72.5000
-83.8000
114.0000
78.5000
95.9000
104.3000
87.6000
109.4000
113.3000
109.2000
74.3000
(continued)
210 4 Linear Programming
102.7000
93.1000
72.5000
83.8000
Optimal solution found.
xopt = 2.9967
80.2464
-0.1442
1.3998
-0.3057
0.3379
fopt = 2.9967
flag = 1
The reader must have been convinced about the practical importance of LP
models and the wide range of real-world applications that fall in this category
of constrained optimization problems. Some might have also realized that
MATLAB does not use the simplex algorithm introduced in this chapter, but
it uses an “interior point” algorithm. The simplex algorithm has been optimized
in the last 70 years, and extensive research work has been performed to fine-
tune all its implementation details. It is, in overall, a very successful algorithm,
but there are some classes of problems for which simplex algorithm is partic-
ularly inefficient. This fact resulted in extended research work in the 1970s
which led to the introduction of the interior point methods. The name is due to
the fact that, in contrast to the simplex method in which we are moving across
the boundary of the feasible space (from one vertex or extreme point to the
next), interior point methods approach the solution from the interior of the
feasible space.
To present briefly the basic idea of interior point algorithms, we start from
the LP problem in the standard form:
4.7 Interior Point Methods for Solving LP Problems 211
min f = cT x
x
s:t: ð4:95Þ
Ax = b
-x≤0
AT λ þ μ = c ð4:97aÞ
Ax = b ð4:97bÞ
μ≥0 ð4:97cÞ
μi xi = 0, i = 1,2, . . . ,n ð4:97dÞ
We return now to the standard LP Formulation (4.95) and define the following
logarithmic barrier function B(x, π):
Xn
βℓ ðx, π Þ = cT x - π i=1
ln ðxi Þ ð4:98Þ
with π > 0. As the barrier function ensures that x ≥ 0 will be satisfied, we can
drop the x ≥ 0 constraint, and Problem (4.95) is equivalent to the following
problem:
min βðx, π Þ
x
s:t: ð4:99Þ
Ax = b
23
1
617
6 7
e=6 7 ð4:102Þ
4⋮5
1
Note that x = Xe. We now express the KKT conditions for (4.100):
AT λ þ πΧ - 1 e = c ð4:103aÞ
Ax = b ð4:103bÞ
AT λ þ s = c ð4:104aÞ
Ax = b ð4:104bÞ
XSe = πe ð4:104cÞ
Note again that s = Se. It is important to note the similarities with the KKT
conditions for the standard LP problem (Eq. (4.97)) and to realize that we can
recover them by allowing π → 0. Based on the equivalence of the KKT condi-
tions of the standard LP formulation and Formulation (4.99), we may develop a
methodology for solving (4.99) iteratively with the additional requirement that
we also need to ensure that π → 0 (i.e., decreasing the value of π in every
iteration).
One way to achieve that is to solve at each iteration a quadratic approxima-
tion of the Problem (4.99). To this end, note that the gradient ∇βℓ and the
hessian ∇2βℓ of the logarithmic barrier function are given by:
1
min ∇ T β l p þ pT ∇ 2 β l p
p 2
s:t: ð4:106Þ
Aðx þ pÞ = b
" # " T #
∇2 β ℓ AT -p ∇ βℓ
= ð4:107Þ
A 0 λ 0
Learning Summary
min cT x
x
s:t:
Ax = b
Cx ≤ d
xL ≤ x ≤ xU
min cT x
x
s:t:
Ax = b
0≤x
Problems
4.1 In Table P4.1, a sample of the saturation properties of water in the range
273.16–473.15 K is presented. Use these data to develop an equation that
determines the saturation pressure of water as a function of absolute
temperature.
4.2 Use the data from Problem 4.1 to develop an equation that determines the
enthalpy of evaporation of water as a function of the absolute
temperature.
4.3 Solve graphically the following LP problem, and determine the Lagrange
multipliers:
Problems 215
4.4 Repeat Problem 4.3 using the simplex method. Validate your solution
using MATLAB.
4.5 Your company operates three coal mines A, B, and C which provide
800, 1000, and 1400 t of coal, respectively, per week. Five customers
(1, 2, 3, 4, and 5) have ordered 1000, 800, 600, 600, and 1200 t of coal,
respectively, for next week. Transportation cost are shown in the table
that follows:
cij in $/t 1 2 3 4 5
A 6 24 2 24 21
B 27 15 12 18 18
C 9 2 6 19 3
The penalty for not satisfying the demand for customers 1 and 3 is
8 $/t and for customers 2, 4, and 5 is 6 $/t. Determine the weekly
shipping schedule that minimizes the total cost.
4.6 A power plant (see Fig. P4.6) uses an extraction turbine that receives
mS = 200 t/h of superheated steam at 454 °C and 60 atm.
The electrical power generated is given by the following equation:
Pel
m m
Fig. P4.6 Turbine generator for combined heat and power generation
where mHP is the production rate of high-pressure steam (in t/h) and mLP
is the production rate of low-pressure steam (in t/h). The operating
constraints are the following:
(a) At least 15 t/h of LP steam must be produced.
(b) HL steam production to LP steam production ration must be at least
4:3.
(c) The maximum amount of LP and HP steam that can be produced is
50% of the saturated steam fed to the unit.
The selling price of electricity is 0.1 $/kWh. LP steam can be sold for
20 $/t and HP steam for 25 $/t. Maximize the profit of the operation.
4.7 You are responsible for the production scheduling of five different prod-
ucts (say P1, P2,. . ., P5) which can be produced using three machines (say
M1, M2, and M3). Products P1 and P3 can be sold for 10 $/unit and
products P2, P4, and P5 for 8 $/unit. Labor cost is $8/h for all machines,
while raw material costs are 4$ for products P1 and P3 and $2 for P2, P4,
and P5. All machines are available for 5 days per week (120 h/week or
7200 min/week). The processing times in min for each product and
machine are the following:
4.8 In Fig. P4.8, a network is shown which involves water supplies (water
wells) on the left and major residential areas on the right (water con-
sumers). The amounts given in the water sources (water supplies) or
sinks (water demands) are in m3/d, while the weights on the arcs are the
costs in $/m3. Develop a LP formulation for the minimum cost satisfaction
of the water demand, and solve the problem using MATLAB.
4.9 One of the most well-known problems in optimal control is known as the
students problem which can be described as follows:
ZT
min f ðuðt ÞÞ = uðt Þdt
uðt Þ
0
s:t:
dxðt Þ
= - axðt Þ þ buðt Þ, xð0Þ = 0
dt
x ðT Þ = x f
0 ≤ u ðt Þ ≤ u U
Assume that a = 0.1, b = 0.5, T = 15, xf = 50, and uU = 15; use finite
differences to approximate the solution of the differential equation, and
prove that the discrete problem is a LP problem. Solve the problem in
MATLAB.
Chapter 5
Integer and Mixed Integer Programming
Problems
5.1 Introduction
In all chapters up to this point we have studied problems in which all variables
were continuous. In this chapter, we will study optimization formulations and
problems in which either all or some of the variables obtain integer or binary
(either 0 or 1) values. This is arguably the most important class of optimization
problems in engineering as it encompasses the modeling of decisions. We will
first present a number of example problems in which integer (mostly binary)
variables appear naturally in the mathematical formulation. We will then
present some solution strategies and the solver available in MATLAB®.
1, if investment i is made
yi = , i = 1, 2, 3, 4 ð5:1Þ
0, otherwise
55, if investment i = 1 is made or y1 = 1
55y1 = ð5:2Þ
0, otherwise
Xn
max vy
i=1 i i
yi
s:t: ð5:6Þ
Xn
w y ≤W
i=1 i i
yi = 0 or 1, i = 1,2,⋯,n
where vi is the value of item i, wi is the weight of item i, and W is the maximum
capacity. This is the famous knapsack problem in combinatorial optimization: a
set of items is given, each with a weight wi and a value vi, and we seek to
determine the number of items to include in a collection so as to maximize the
collective value, while the total weight is less than or equal to a given capacity
W. Its name comes from the problem faced by anyone who is constrained by a
fixed-size knapsack and must fill it with the most valuable (non-divisible)
items.
After contacting the financial adviser to let her know that you will be
interested in investing your savings (but you have to wait until you have
finished this chapter so as to determine what is the best combination of the
investment opportunities), she informs you on some additional constraints
that you have to take into consideration:
(a) You must invest in at least two investment opportunities.
(b) As there is a lot of interest in investments 1 and 2, you cannot select both at
the same time.
(c) If you decide to invest in investment plan 1, then you also need to invest in
investment plan 4.
(d) You may increase the amount invested in investment opportunity 3 with-
out limit, and each dollar you invest above the minimum of 20 k$ has a
NPW of 1.58 $.
Clearly, you need to amend the formulation in order to account for these
additional complications.
222 5 Integer and Mixed Integer Programming Problems
y1 þ y2 þ y 3 þ y4 ≥ 2 ð5:7Þ
or:
X4
2- y
i=1 i
≤0 ð5:8Þ
y1 þ y 2 ≤ 1 ð5:9Þ
Note that if you select both investment opportunity 1 and investment oppor-
tunity 2, then y1 = y2 = 1 and y1 + y2 = 2, and the inequality is violated
(infeasible solution). If you select investment opportunity 1 and not investment
opportunity 2, then y1 = 1 and y2 = 0 and y1 + y2 = 1, and the inequality is
satisfied as equality. If you select investment opportunity 2 and not investment
opportunity 1, then y1 = 0 and y2 = 1 and y1 + y2 = 1, and the inequality is
satisfied as equality. If you do not select any of the investment opportunities
1 and 2, then y1 = 0 and y2 = 0 and y1 + y2 = 0, and the inequality is satisfied.
We conclude that constraint (5.9) forbids the simultaneous selection of invest-
ment opportunities 1 and 2 but allows all permissible combinations (only one
of the two or none).
Condition c can be expressed through the following inequality constraint:
y1 ≤ y4 ð5:10Þ
or:
y 1 - y4 ≤ 0 ð5:11Þ
0 ≤ x ≤ 50y3 ð5:12Þ
and constraint (5.4) that guarantees that we do not invest more that 70 k$:
Note that while (5.5) is a linear formulation with binary variables only
(an integer linear programming or ILP problem), Formulation (5.15) is also
linear but involves both continuous and integer variables (a mixed integer
linear programming or MILP problem).
Example 5.2 Set Covering Problem
In Fig. 5.1, a geographical area consisting of ten counties (denoted by a, b,
c,. . ., j) is shown. There are eight available locations (denoted by k = 1, 2, . . ., 8)
at which certain major health service facilities can be located. A service facility
k can serve a county provided that the service facility is located at its border.
Given this restriction, we may note that county a can be served by service
facilities 1 and 2, county b can be served by service facilities 2 and 3, . . . ., and
county j can be served by service facilities 4, 5, 6, 7, and 8.
224 5 Integer and Mixed Integer Programming Problems
g f
h j
a
d
i
c
b
county a : y1 þ y2 ≥ 1 ð5:18Þ
In a similar way:
5.2 Examples of Integer Programming Formulations 225
county b : y2 þ y3 ≥ 1 ð5:19Þ
county c : y3 þ y4 ≥ 1 ð5:20Þ
county d : y4 þ y5 ≥ 1 ð5:21Þ
county e : y5 þ y6 ≥ 1 ð5:22Þ
county f : y6 þ y 7 ≥ 1 ð5:23Þ
county g : y1 þ y7 ≥ 1 ð5:24Þ
county h : y1 þ y2 þ y7 þ y8 ≥ 1 ð5:25Þ
county i : y2 þ y 3 þ y4 þ y8 ≥ 1 ð5:26Þ
county j : y4 þ y5 þ y6 þ y7 þ y8 ≥ 1 ð5:27Þ
yk 2 f0, 1g, 8k ð5:28Þ
Note that as n = 3, each row, column, and the two main diagonals sum up to
M = 3(32 + 1)/2 = 15.
Assume that we are given n and we want to solve the MSP by integer linear
programming. The integers that we can place into the n × n cells are the
integers k = 1, 2,. . ., n2. Let’s use index i = 1, 2,. . ., n to denote the row and
index j = 1, 2,. . ., n to denote the column and also define the binary variables
yijk to denote the placement of integer k into the i–j cell or not:
226 5 Integer and Mixed Integer Programming Problems
Fig. 5.2 Melencolia I is a 1514 engraving by the German Renaissance artist Albrecht Dürer,
and its central subject is an enigmatic and gloomy winged female figure thought to be a
personification of melancholia. The engraving features a 4-by-4 magic square!. (From
Wikipedia/Wikipedia domain/public domain work of art)
5.2 Examples of Integer Programming Formulations 227
1, if integer k is placed in the cell at row i and column j
yijk = ð5:29Þ
0, otherwise
We also define the continuous variable xij to be equal to the value of the integer
that has been placed into the i–j cell. xij can be obtained from yijk by the
following equation:
Xn2
xij = k=1
k yijk , 8i,j ð5:30Þ
To satisfy the restrictions set by the recreational problem, the sum of each row
must be equal to the magic number:
Xn
M= x ,
j = 1 ij
8i ð5:31Þ
Xn
M= x ,
i = 1 ij
8j ð5:32Þ
The problem statement also requires that the two diagonals have the
same sum:
The equations that have been presented so far define what the feasible
space of the problem is using only linear constraints in terms of the binary
and continuous variables. To develop a complete ILP formulation, we need to
228 5 Integer and Mixed Integer Programming Problems
devise an appropriate objective function. The statement of the MSP does not
include any objective function as its aim is to define a feasibility problem. Other
classes of MSP have additional objectives. We can, therefore, define any arbi-
trary objective function such as maximize the difference between the integers
placed in cell 1–1 and cell n–n:
An example from the sudoku given in the previous page is y23124 = 1. We can
now express the sudoku number placement restrictions using these binary
variables. The first one is that each cell contains a single integer:
X9
y
k = 1 mnijk
= 1, 8m,n,i,j ð5:39Þ
X3 X3
m=1
y
i = 1 mnijk
= 1, 8n,j,k ð5:40Þ
Finally, each integer appears only once in each internal 3-by-3 grid:
X3 X3
i=1
y
j = 1 mnijk
= 1, 8m,n,k ð5:42Þ
Example 5.4 ILP Model for Truck Load Determination in Liquid Fuels
Distribution
In Fig. 5.3, a characteristic example of a tank truck, used by oil companies to
distribute liquid fuels such as gasoline and diesel, is shown. These tank trucks
have several compartments for loading simultaneously several different fuels.
The orders received by the customers are initially processed and organized
according to the geographical area of the customers and then sent to the
appropriate department for generating a preliminary dispatching schedule. In
this example, we consider the case where several tank trucks are available for
satisfying the orders shown in Table 5.2. Each order might correspond to a
single customer or customers aggregated according to their geographical
proximity. The aim is to satisfy each order by minimizing the potential devia-
tions from the initial order called “quantity adjustments.” These adjustments
Fig. 5.3 Tank trucks used in liquid fuel distribution by oil companies have several compart-
ments for loading products with different quality specifications
5.2 Examples of Integer Programming Formulations 231
are deemed necessary as it is impossible to “fit” all potential orders into the
available tank trucks. In this example, we only consider negative quantity
adjustments (delivering less than the volume ordered) at a cost which is
proportional to the adjustment made and which is usually determined at
managerial level. Our aim is to propose a mathematical formulation that can
be used to solve the problem.
To obtain some understanding of the problem, we consider order 1. To solve
the problem, we decide to satisfy first the fuel with the largest volume. We may
use compartments 2, 3, and 5 to load all 29 m3 of liquid fuel 3. Then we use
compartment 1 for liquid fuel 1 (but we will deliver 16 - 9 = 7 m3 less than the
order) and finally use compartment 4 to load liquid fuel 2. Even though the
total available volume in the tank truck is 47 m3 and the order is 48 m3, we will
be delivering only 41 m3, i.e., 15% quantity adjustment relative to the volume
of the order. This is clearly not very satisfactory, and we need to find out
whether we can do any better. We may keep on trying until we find a satisfac-
tory solution, but it will be much better if we can always find the best solution
using a computer to do all the hard work.
We first define the set c = {1, 2, 3, 4, 5} to denote the compartments of the
tank truck and the set f = {fuel 1, fuel 2, fuel 3} to denote the liquid fuels
included in the orders. We then define the binary (decision) variables yf,c as
follows:
1, if fuel f is placed in compartment c
yf ,c = ð5:43Þ
0, otherwise
The first requirement is that only one fuel is loaded in a compartment, i.e.:
X3
y
f = 1 f ,c
≤ 1, 8c ð5:44Þ
It should also be noted that a fuel in a specific order can be loaded in more than
one compartment to satisfy the demand, and all fuels must be loaded in at least
one compartment (i.e., we may deliver smaller volumes, but we must include
all fuels in the order):
232 5 Integer and Mixed Integer Programming Problems
X5
y
c = 1 f ,c
≥ 1, 8f ð5:45Þ
0 ≤ sf ≤ S f , 8f ð5:47Þ
where cf is the penalty that corresponds to volume adjustment for fuel type f.
The complete formulation is the following:
X3
min cs
f =1 f f
yf ,c ,sf ,V f ,c
s:t: ð5:50Þ
X3
y
f = 1 f ,c
≤ 1, 8c
X5
y
c = 1 f ,c
≥ 1, 8f
V c, min yf ,c ≤ V f ,c ≤ V c, max yf ,c ,8f ,c
X5
V þ sf = df , 8f
c = 1 f ,c
0 ≤ sf ≤ S f , 8f
yf ,c 2 f0, 1g, 8f ,c
5.2 Examples of Integer Programming Formulations 233
Example 5.5 ILP Model for Scheduling the Operation of Thermal Power Units
(the Unit Commitment Problem)
Thermal power units are complex production units with significant costs
associated with the starting up or the shutting down of a unit. There are also
important constraints related to the rate at which the power production can be
increased or decreased while the plant is in operation. Any thermal power unit
can be characterized by the following parameters of the unit:
Cup,i: the startup cost of unit i (in $)
Cdn,i: the shutdown cost of unit i (in $)
Cfx,i: is the fixed cost of operation of unit i (in $/h)
Cvr,i: is the unit variable cost of operation of unit i (in ($/h)/MW)
PM,i: is the maximum output power of unit i (in MW)
Pm,i: is the minimum output power of unit i (in MW)
Rup,i: is the maximum power increment or ramp-up limit (in MW/h) of unit i
Rdw,i: is the maximum power decrement ramp-down limit (in MW/h) of unit
i
The problem is to decide when to start up and when to shut down a set of
power plants i = {1, 2,. . ., N} so as to satisfy a varying demand Dt, where t is a
time period within the time horizon of interest t = {1, 2,. . ., 24} (i.e., one day
divided in 1 h time periods or any other appropriate selection of time periods
t = {1, 2, 3,. . ., H}).
To evaluate the operating cost, we need to define several binary variables to
indicate the state of each power unit at each time period. All events are
assumed to take place at the beginning of each time interval and to remain at
the same state until the beginning of the next time interval. It is important to
note that each power unit can be:
1. In normal operation
2. In shutdown state (not in operation)
3. In starting up state
4. In shutting down state
Let’s define the binary variable yi,t as follows:
1, if plant i is in normal operation at time interval t
yi,t = ð5:51Þ
0, otherwise
For any unit to be in normal operation at time interval t, a start-up event must
have taken place at any time interval t’ < t, and no shutdown event has
occurred in the meantime. We need to define the binary variable ui,t to denote
a start-up event and the binary variable di,t to denote a shutdown event:
234 5 Integer and Mixed Integer Programming Problems
1, if plant i starts up at time interval t
ui,t = ð5:52Þ
0, otherwise
1, if plant i shuts down at time interval t
di,t = ð5:53Þ
0, otherwise
The binary variables are related through the following logical equation:
The power output from all available units must satisfy the demand Dt at time
interval t:
XN
P
i = 1 i,t
≥ Dt , 8t ð5:56Þ
In addition, in normal operating state, the output power can vary at each time
interval, but the increase or decrease in the output power between consecutive
time intervals is limited by the ramp-up and ramp-down limits:
XN XH
min i=1 t=1
C fx,i yi,t þ C vr,i Pi,t þ C up,i ui,t þ C dn,i di,t ð5:58Þ
yi,t ,ui,t ,di,t ,Pi,t
The first term accounts for the fixed costs and the second one for the variable
costs, and both contribute only when power plant i is in operation (yi,t = 1).
The third and fourth terms account for the cost of start-up (when ui,t = 1) and
shutdown (when di,t = 1) of plant i.
5.2 Examples of Integer Programming Formulations 235
Table 5.3 Data for the Paint color Due time Penalty
paint production scheduling (i) Processing time pti in h dti in h wi in $/h
problem
W 12 60 15
R 48 52 10
B 36 84 30
236 5 Integer and Mixed Integer Programming Problems
1, if task i is performed before task j
yi,j = ð5:59Þ
0, otherwise
In the solution shown in Fig. 5.4, yR,W = yR,B = yW,B = 1, and all other yi,j = 0. We
also define the continuous variable sti to denote the time at which task i starts
processing in the machine. It then follows that the time at which processing of
task i is completed, denoted by fti, is given by:
f t i = st i þ pt i , 8i ð5:60Þ
where pti is the processing time for task i. To determine whether there is a time
delay in completing task i, a non-negative delay time τi is used:
f t i - τi ≤ dt i , 8i ð5:61Þ
For the solution shown in Fig. 5.4, it follows that stR = 0, stW = 48, and stB = 60
and, using (5.60), ftR = 0 + 48 = 48, ftW = 48 + 12 = 60, and ftB = 60 + 36 = 96.
We now substitute the numbers in (5.61) to obtain:
Paint R 48 - τR ≤ 52 ð5:62Þ
Paint W 60 - τW ≤ 60 ð5:63Þ
Paint B 96 - τB ≤ 84 ð5:64Þ
The most complicating part of the formulation is the requirement that there
is no overlapping of the tasks. If task i starts at time sti and task j at time stj and
task i precedes (is performed before) task j (i.e. yi,j = 1), then:
st i þ pt i ≤ st j , 8i,j ð5:65Þ
st j þ pt j ≤ st i , 8i,j ð5:66Þ
Note that in the final formulation, only the combinations i,j for which j > i holds
true (i.e., R-W, R-B, and W-B) are used. This is correct as if we have assigned
value to yi,j, then knowledge of yj,i is redundant (as yi,j + yj,i = 1 must always
hold true).
238 5 Integer and Mixed Integer Programming Problems
min f = cT x þ dT y
x,y
s:t: ð5:69Þ
Ax þ By = b
Cx þ Dy ≤ e
- x ≤ 0,y 2 f0, 1gn
(k denotes the iteration counter) and at the same time an increasing sequence
of lower bounds:
f k - f k ≤ ε ð5:72Þ
then we can conclude that the optimal solution of (5.69) has been obtained. The
important question, from the practical point of view, is how one can generate
the decreasing sequence of upper bounds and the increasing sequence of lower
bounds.
For MILP problems of the form given by (5.69), it is important to note that if,
in the k-th iteration of the algorithm, we assign constant values to the binary
variables y = yk, then the problem is transformed to a LP problem in terms of x:
5.3 Solving Integer Programming Problems Using the Branch and Bound Method 239
min f = cT x þ dT yk
x
s:t: ð5:73Þ
e = b - Byk
Ax = b
Cx ≤ e
e = e - Dyk
-x≤0
As we have seen in the previous chapter, efficient algorithms are available for
solving LP problems today. Assume that an optimal solution of (5.73) exists
and is given by ( fk, xk, yk). We may conclude that f k is always an upper bound
on the optimal solution of (5.69), i.e., for a fixed vector of binary variables yk:
fk ≥f ð5:74Þ
The equality holds true only if yk = y*. It then follows that by fixing the binary
variables to any arbitrary values, the solution of the resulting LP problem is an
upper bound to the optimal solution. This also suggests a method for generat-
ing upper bounds: solving the initial problem for a constant vector of the
binary variables. As the algorithm proceeds, the best upper bound is updated:
n o
f k = min f k - 1 , f k ≥ f ð5:75Þ
It is important to note that if the solution of (5.73) is feasible and optimal, then
it is also feasible for Problem (5.69) (provided that yk is also a feasible set of
binary variables). The need is not to find any feasible solution but to find
“good” feasible solutions that provide tight upper bounds on the optimal
solution.
This general idea of producing upper bounds based on fixing the values of
the binary variables and solving the resulting LP problem to generate a feasible
solution is common to most MILP solution algorithms. They differ in the
methodology used to generate lower bounds. Here we will be presenting a
methodology known as LP-based Branch and Bound (B&B) methodology. In
this methodology, the generation of increasing lower bounds is based on the
linear programming relaxation idea. To understand the methodology, we need
first to define the term relaxation.
When we face a “difficult” problem, we can attack the problem by “relaxing”
the characteristics that make the problem difficult to solve and ensure that the
relaxed problem offers a lower bound on the objective function of the initial
problem. When it comes to binary programming problems, the complicating
factor is the requirement that the y variables are binary, i.e., yi2{0,1}. We may
relax the requirement that the yi variables obtain the values of either zero or
one by the requirement that yi are continuous variables in the interval between
zero and one, i.e., yi2[0,1]. We practically enlarge the feasible set over which we
240 5 Integer and Mixed Integer Programming Problems
seek to minimize the objective function. This is the reason why the relaxed
problem offers a lower bound. As we have more options (wider feasible space)
in trying to minimize the objective function, it is guaranteed that the objective
function will always be better (smaller) than the objective function obtained
when the complicating restrictions are taken into consideration.
We consider the general MILP problem given by Formulation (5.69). We
consider the following relaxed problem by replacing the yi2{0,1} requirement
with the yi2[0,1] requirement:
min f = cT x þ dT y
x,y
s:t: ð5:76Þ
Ax þ By = b
Cx þ Dy ≤ e
- x ≤ 0,yi 2 ½0, 1,8i
yk yk
R R
In case 1, the branch is fathomed (is not developed any further) as imposing
any additional constraints will not alter the infeasibility. In case 2, the branch is
also fathomed as imposing additional constraints will only worsen the objec-
tive function (and therefore the optimal solution corresponding to this branch
has already been found).
We use integer solutions (case 2 above) to generate upper bounds on the
objective function. The currently available best integer solution is called the
incumbent and is denoted by f *:
f ¼ incumbent
¼ value of the objective function at the best feasibleðbinaryÞ
solution that has been found so far
In the case we discover a new feasible solution with all yi obtaining binary
values, we compare the value of the objective function with the incumbent and
update the incumbent if an improved integer solution (with lower objective
function) has been discovered.
In case 3 we only update the lower bound for the descendants of this
subproblem, and we then generate a new branch by selecting a new branching
variable. It is interesting to note that subsequent “generations” created by the
branching of a particular subproblem must always have a larger value for the
solution of the relaxed problems as they are produced by adding new con-
straints on the binary variables (increasing lower bound on a branch of
the tree).
The procedure continues by selecting any active (not dismissed or
fathomed) node and solving the relaxed problem. We continue doing this
until we have fathomed all nodes and the incumbent corresponds to the
optimal solution. If no incumbent has been found, then the initial problem is
infeasible. We summarize the fathoming criteria:
1. The relaxed problem is infeasible.
2. The relaxed problem has a binary solution (for the y variables).
242 5 Integer and Mixed Integer Programming Problems
3. The relaxed problem does not have an integer solution, but the objective
function is greater than the currently available upper bound (incumbent).
We will now solve an extended case study to clarify the implementation details
of the B&B methodology.
We consider the Knapsack problem studied in Example 5.1:
y = 1.0000
1.0000
0.5000
0
f = -110
flag = 1
We note that the solution y = [1 1 0.5 0]T is not integral and that the
objective function is f 0 = -110. This is a lower bound on the objective function
(i.e., the optimal solution of (5.77) cannot be better/lower than -110). We
branch on the only non-integral variable which is y3. We create two nodes:
node R1 with y3 = 1 and node R2 with y3 = 0. This is also shown in Fig. 5.6. We
solve the relaxed problems in these two nodes to obtain the following results:
Node R1: y = [0.7143 1 1 0]T which is not integral with objective function
f 1 = -109.3.
Node R2: y = [1 1 0 0.6667]T which is not integral with objective function
f 2 = -108.3.
5.3 Solving Integer Programming Problems Using the Branch and Bound Method 243
y y
R R
y y
y y
R R R R
y y y y
-105
R R R R
OPTIMAL y y
R
R
Fig. 5.6 B&B tree for the Knapsack problem of Example 5.1
y = 0.7143
1.0000
(continued)
244 5 Integer and Mixed Integer Programming Problems
1.0000
0
f = -109.2857
flag = 1
The solutions of the relaxed problems R1 and R2 are also shown in Fig. 5.6.
Both solutions are non-integral and we continue.
We decide to develop further node R1 by creating two additional nodes:
node R3 with y1 = 1 and node R4 with y1 = 0. Node R3 has a non-integral
solution, but node R4 offers the first binary solution y = [0 1 1 1]T and the
objective function is f 4 = -90 (see Fig. 5.6). We have therefore an upper bound
for the optimal solution f = - 90 (incumbent).
We continue by examining nodes R5 and R6 which are obtained by assigning
binary values to y2 (the only nonintegral variable in the solution of the relaxed
problem at node R3). R5 is infeasible, and R6 gives an improved integer solution
and an improved upper bound f = - 105 (incumbent). Nodes R4 and R6 are
fathomed: node R6 has an integer solution, and node R5 is infeasible. Only node
R2 remains to be explored further, and we continue as shown in Fig. 5.6. The
reader is encouraged to repeat the steps using MATLAB. When all nodes have
been fathomed, we conclude that the best integer solution corresponds to node
R 6.
We summarize the steps taken at every iteration of the LP-based B&B
methodology when applied to mixed integer (binary) linear programming
(MILP) problems:
1. Select one subproblem (node) from the remaining ones (the most
recently created or the most promising) and among the binary vari-
ables that have a non-integral value in the solution (the first in the
natural ordering or the closest to be either 0 or 1). This is the
branching variable, and use it to create two new subproblems: the
one corresponds to the value of zero and the other to the value of one
for the branching variable.
2. Solve the LP relaxation of the two new subproblems, and obtain the
value of the objective function.
3. Apply the fathoming tests: the node is fathomed if:
(a) The LP relaxation is infeasible.
(b) The LP relaxation has binary solution (for the y variables).
(c) The LP relaxation has an optimal value that is worse (larger) than
the incumbent.
In case b above, if the objective function is better (smaller) than the
incumbent, then update the incumbent before checking case c.
(continued)
5.3 Solving Integer Programming Problems Using the Branch and Bound Method 245
min wW τW þ wR τR þ wB τB
yi,j ,st i ,τi
s:t: ð5:78Þ
st W - τW ≤ dt W - pt W
st R - τR ≤ dt R - pt R
st B - τB ≤ dt B - pt B
st W - st R þ MyW,R ≤ M þ pt W
st W - st B þ MyW,B ≤ M þ pt W
st R - st B þ MyR,B ≤ M þ pt R
st R - st W þ MyW,R ≤ - pt R
st B - st W þ MyW,B ≤ - pt B
st B - st R þ MyR,B ≤ - pt B
st W ,st R ,st B ,τW ,τR ,τB ≥ 0
yW,R ,yW,B ,yR,B 2 f0, 1g
The optimization variables are the starting times (stW, stR, and stB), the delay
time (τW, τR, τΒ), and the binary variables that denote the ordering of the
production sequence (yW,R, yW,B, yR,B). The due times dti, the processing times
246 5 Integer and Mixed Integer Programming Problems
pti, and the penalties for delayed delivery are all given in Table 5.3. To facilitate
the solution in MATLAB, we write the inequality constraints in matrix form:
2 3 2 3 2 3
1 0 0 -1 0 0 0 0 0 st W dt W - pt W
6 7 6 7 6 7
6
6 0 1 0 0 -1 0 0 0 0 7 6 7 6
7 6 st R 7 6 dt R - pt R 7
7
6 7 6 7 6 7
6
6 0 0 1 0 0 -1 0 0 0 7 6 7 6
7 6 st B 7 6 dt B - pt B 7
7
6 7 6 7 6 7
6
6 1 -1 0 0 0 0 M 0 0 7 6
7 6 τW 7 6
7 6 M þ pt W 7 7
6 7 6 7 6 7
6
6 1 0 -1 0 0 0 0 M 0 7 6 7 6
7 6 τR 7 ≤ 6 M þ pt W 7 7
6 7 6 7 6 7
6
6 0 1 -1 0 0 0 0 0 M 7 6
7 6 τB 7 6
7 6 M þ pt R 7 7
6 7 6 7 6 7
6
6 -1 1 0 0 0 0 -M 0 0 7 6 7 6
7 6 yW,R 7 6 - pt R 7 7
6 7 6 7 6 7
6
4 -1 0 1 0 0 0 0 -M 0 7 6 7 6
5 4 yW,B 5 4 - pt R 7 5
0 -1 1 0 0 0 0 0 -M yR,B - pt B
ð5:79Þ
Using the data on Table 5.3 and the compact Formulation (5.79), we can
solve the LP relaxation of the overall formulation in MATLAB as shown below
(script file):
clear all
% W R B
pt=[12 48 36];
dt=[60 52 84];
w =[15 10 30];
c=[zeros(3,1);w';zeros(3,1)];
M=100;
A=[1 0 0 -1 0 0 0 0 0;
0 1 0 0 -1 0 0 0 0;
0 0 1 0 0 -1 0 0 0;
1 -1 0 0 0 0 M 0 0;
1 0 -1 0 0 0 0 M 0;
0 1 -1 0 0 0 0 0 M;
-1 1 0 0 0 0 -M 0 0;
-1 0 1 0 0 0 0 -M 0;
0 -1 1 0 0 0 0 0 -M];
b=[dt(1)-pt(1);
dt(2)-pt(2);
dt(3)-pt(3);
M-pt(1);
M-pt(1);
M-pt(2);
-pt(2);
-pt(3);
-pt(3)];
(continued)
5.3 Solving Integer Programming Problems Using the Branch and Bound Method 247
LB=zeros(9,1);
UB=[M; M; M; M; M; M; 1; 1; 1];
[x,f,flag]=linprog(c,A,b,[],[],LB,UB)
>> introBnB3
Optimization terminated.
x = 21.2886
1.5376
18.5970
0.0000
0.0000
0.0000
0.4856
0.5894
0.6091
f = 1.5010e-11
flag = 1
Note that the solution of the initial LP relaxation gives a zero lower bound
for the objective function, and the binary variables obtain non-integer values.
At the initial node, we select the first binary variable yW,R as the branching
variable and create two new nodes R1 (yW,R = 1) and R2 (yW,R = 0). We then
proceed and solve the LP-relaxed subproblems. The results are shown in
Fig. 5.7. The results at node R1 can be used to obtain the improved lower
bound of 80. No node can be fathomed, and we repeat. We select node R1 and
yW,B as the branching variable and generate nodes R3 and R4 as shown in
Fig. 5.7. R3 and R4 give non-integer solutions, and we select R3 and yR,B as the
branching variable and generate nodes R5 and R6 which both have integer
solutions with equal objective functions. The common value of the objective
function becomes the first incumbent which is equal to 440. Using this incum-
bent, R4 can be fathomed, and R2 remains the only available node. We continue
to finally discover that the optimal solution corresponds to node R9 and the
optimal solution is identical to the one shown in Fig. 5.4. Note that B&B has not
been very efficient in this case study as we had to examine 13 nodes out of the
potential 15 nodes before we can guarantee optimality.
248 5 Integer and Mixed Integer Programming Problems
R
y
y
f f
R R
y
y y y
f f
f f
R R R R
y y
y y y
y
f f f f f
R R R R R R
OPTIMAL
Fig. 5.7 B&B tree for the single-machine scheduling problem of Example 5.6
The MILP solver available in MATLAB® is intlinprog and solves the prob-
lem given by (5.69). Its general structure is the following:
5.4 Solving MILP Problems in MATLAB® 249
Note that intlinprog solves the more general mixed integer linear pro-
gramming where the integers can obtain any integer value and not just binary
variables. In this book, we restrict attention to binary variables. Note however
that any integer Y can be expressed as a function of binary variables yi:
Y = 20 y1 þ 21 y2 þ ⋯ þ 2k - 1 yk þ ⋯ þ 2N - 1 yN ð5:80Þ
Note that for N = 10, we may express all integers up to Y = 1023 as a function
of ten binary variables (note that N = the smaller integer larger than log2(Y ),
log2(1023) = 9.9986, and N = 10, for instance).
We can now solve the Knapsack problem in MATLAB as follows:
x = 1.0000
0
1.0000
1.0000
f = -105.0000
flag = 1
This agrees well with the solution that it was found by our “manual”
application of the B&B methodology summarized in Fig. 5.6.
We will now also solve the single-machine scheduling problem in MATLAB:
250 5 Integer and Mixed Integer Programming Problems
clear all
% W R B
pt=[12 48 36];
dt=[60 52 84];
w =[15 10 30];
c=[zeros(3,1);w';zeros(3,1)];
M=100;
A=[1 0 0 -1 0 0 0 0 0;
0 1 0 0 -1 0 0 0 0;
0 0 1 0 0 -1 0 0 0;
1 -1 0 0 0 0 M 0 0;
1 0 -1 0 0 0 0 M 0;
0 1 -1 0 0 0 0 0 M;
-1 1 0 0 0 0 -M 0 0;
-1 0 1 0 0 0 0 -M 0;
0 -1 1 0 0 0 0 0 -M];
b=[dt(1)-pt(1);
dt(2)-pt(2);
dt(3)-pt(3);
M-pt(1);
M-pt(1);
M-pt(2);
-pt(2);
-pt(3);
-pt(3)];
LB=zeros(9,1);
UB=[M; M; M; M; M; M; 1; 1; 1];
INTEGERS=[7 8 9]
[x,f,flag,output]=intlinprog(c,INTEGERS,A,b,[],[],LB,UB)
(continued)
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 251
x = 48.0000
0
60.0000
0
0
12.0000
0
1.0000
1.0000
f = 360.0000
flag = 1
This solution agrees well with the solution obtained by “manual” application
of the B&B methodology and summarized in Fig. 5.7, as expected.
min f ðx, yÞ
x,y
s:t: ð5:81Þ
hðx, yÞ = 0
gðx, yÞ ≤ 0
x 2 X ⊆ Rn , y 2 f0, 1gm
(5.81). With these observations in mind, we can extend the B&B algorithm that
has been presented for MILP problems directly to MINLP problems. However,
in the case of MILP problems, we have the distinct advantage that for the
LP-based relaxations, we can always find the global minimum as they are
convex problems. This is, unfortunately, not the case of the general relaxed
MINLP (or RMINLP) problems as convexity is scarce in realistic problems. To
guarantee convergence, we need to ensure that we can locate, in each iteration
of the B&B algorithm, the global minimum of the relaxed problem. In most
cases, we are satisfied by using a local NLP solver and finally discover a near-
optimal solution or simply a good solution.
An algorithm that has been quite successful in solving MINLP problems is
the outer approximation algorithm. It is reminded that for a convex function
f(x), the tangent line approximation at each point has the following property:
f ðxÞ ≥ f xk þ ∇f T xk x - xk ð5:82Þ
min f ðxÞ þ cT y
x,y
s:t: ð5:83Þ
gðxÞ þ By ≤ 0
x 2 X ⊆ Rn , y 2 f0, 1gm
We also assume that the feasible space defined by the inequality constrains is
convex. Then, as shown in Fig. 5.8 for the case of a convex feasible region
defined by three inequalities, there are finite points xi, i2F such that:
g xi þ ∇gT xi x - xi ≤ 0, i 2 F ð5:84Þ
min μ þ cT y
x,y,μ
s:t: ) ð5:85Þ
f ðx Þ þ ∇f ðx Þ ðx - xi Þ ≤ μ
i T i
, 8i 2 F
gðxi Þ þ ∇gT ðxi Þ ðx - xi Þ þ By ≤ 0
x 2 X ⊆ Rn , y 2 f0, 1gm
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 253
x x
x
x
x
x
Fig. 5.8 The outer approximation of a convex region overestimates the feasible region
offers a lower bound on the optimal solution of problem (5.83). Note that
(5.85) is a MILP problem that can be solved to global optimality. The outer
approximation (5.85) involves an overestimation of the feasible region and an
underestimation of the objective function, and its solution is, therefore, a lower
bound to (or better than) the solution of the initial MINLP problem (5.83).
Furthermore, the solution of (5.85) at iteration k offers a new set of values for
the binary variables yk, and the resulting NLP problem:
min f ðxÞ þ cT yk
x
s:t: ð5:86Þ
gðxÞ þ By ≤ 0 k
x 2 X ⊆ Rn , y 2 f0, 1gm
offers an upper bound on the solution of the initial MINLP (5.83). This is the
basic idea on which the outer approximation methodology has been developed.
To avoid reexamining a specific combination of values for the binary variables,
we add the following integer cut constraints to Formulation (5.85):
X X
y
i2Bk i
- y
i2N k i
≤ Bk - 1 ð5:87Þ
where Bk consists of all i for which yki = 1, Nk consists of all i for which yki = 0,
and |S| denotes the cardinality (number of elements) of S.
254 5 Integer and Mixed Integer Programming Problems
R RR R
a
R – –R –R –R
R – –R R – –R R – –R
S S S
S S S
S S S
R R R R
min
nS ,nC ,nP
wS nS þ wC nC þ wP nP
s:t: ð5:88Þ
nS nC nP
½1 - ð1 - RS Þ ½1 - ð1 - RC Þ ½1 - ð1 - RP Þ ≥ RCCS, min
nS ,nC ,nP 2 f1, 2, 3g
where RCCS,min is the minimum acceptable reliability of the overall system and
nS, nC, and nP are the number of sensors, computers, and pumps, respectively.
This can be transformed to a MINLP with binary-only variables where the
binary variables appear linearly:
min w S xS þ w C x C þ wP xP
xS ,xC ,xP
y0,S ,y0,C ,y0,P ,y1,S ,y1,C ,y1,P
s:t: ð5:89Þ
RCCS, min - 1 - QxSS 1 - QxCC ½1 - QxPP ≤ 0
xS = 20 y0,S þ 21 y1,S
xC = 20 y0,C þ 21 y1,C
xP = 20 y0,P þ 21 y1,P
y0,S þ y1,S ≥ 1
y0,C þ y1,C ≥ 1
y0,P þ y1,P ≥ 1
xS ,xC ,xP 2 ½1, 3
y0,S ,y0,C ,y0,P ,y1,S ,y1,C ,y1,P 2 f0, 1g
function f=ObjFun(x)
f=8*x(1)+6*x(2)+10*x(3);
function [g,h]=NonLin(x)
h=[];
g=0.65-(1-0.1^x(1))*(1-0.2^x(2))*(1-0.3^x(3));
clear all
%X =[ xS xC xP y0S y1S y0C y1C yOP y1P]
x0 =[ 3 3 3 1 1 1 1 1 1];
LB =[ 1 1 1 0 0 0 0 0 0];
UB =[ 3 3 3 1 1 1 1 1 1];
A =[ 0 0 0 -1 -1 0 0 0 0;
0 0 0 0 0 -1 -1 0 0;
0 0 0 0 0 0 0 -1 -1];
b =-ones(3,1);
Aeq=[ 1 0 0 -1 -2 0 0 0 0;
0 1 0 0 0 -1 -2 0 0;
0 0 1 0 0 0 0 -1 -2];
beq=[0;0;0];
[xopt,fopt,flag]=fmincon(@ObjFun,x0,A,b,Aeq,beq,LB,UB,
@NonLin)
>> reliabilityOptimMINLP
fopt = 30.0483
flag = 1
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 257
The value obtained by the binary variables is shown in Fig. 5.11. We note
that the objective function of R0 node is a lower bound on the objective
function. As the first binary variable (in the ordering used) is closest to be
integer, we branch on y0,S to obtain nodes R1 (y0,S = 0) and R2 (y0,S = 1). The
solutions of the relaxed problem at the two nodes do not give a binary solution,
and we continue by branching first on y0,C and then on y0,P. The first integer
solution is obtained at node R5 with an objective function of 35 (incumbent).
We continue to develop the B&B tree which is shown in Fig. 5.11. Nodes R1, R8,
R9, and R10 are fathomed for the following reasons:
R 1: the objective function of the relaxed problem is greater than the
incumbent.
R 8: the objective function of the relaxed problem is greater than the
incumbent.
R 9: the relaxed problem is infeasible.
R10: the relaxed problem has a binary solution.
Expanding node R3 is left as an exercise to the reader (to show that no
improved integer solution can be obtained).
The optimal solution corresponds the solution at node R5 and is shown in
Fig. 5.12. It involves the use of one sensor, one controller, and two pumps with
an overall cost of 34 monetary units and an overall reliability that is slightly
greater than the minimum acceptable overall reliability.
Example 5.8 A Numerical MINLP Example and Solution Using B&B
We will consider the following numerical example of an MINLP problem:
min x21 þ x22 þ ðy1 þ 1:5y2 þ 0:5y3 Þ
y1 ,y2 ,y3 ,x1 ,x2
s:t:
ðx 1 - 2 Þ 2 - x 2 ≤ 0
- x1 þ 2y1 ≤ 0
x1 - x2 - 4ð1 - y2 Þ ≤ 0
- x 1 þ ð1 - y 1 Þ ≤ 0
- x2 þ y2 ≤ 0
- x1 - x2 þ 3y3 ≤ 0
- y1 - y2 - y3 þ 1 ≤ 0
0 ≤ x1 ≤ 4
0 ≤ x2 ≤ 4
y1 ,y2 ,y3 2 f0, 1g
258 5 Integer and Mixed Integer Programming Problems
f R
y
y
f
R f R
y
y
f R f R
y
y
f=34
R f R
binary
1
0 y
1
y
0
0 f
1
f R
R
y y
infeasible f R
R
binary
Fig. 5.11 B&B tree for the reliability-optimization problem of Example 5.7
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 259
R – – R – – R – –
S S S
S S S
S S S
R R R R – –
min f ðx Þ þ c T y
y1 ,y2 ,y3 ,x1 ,x2
s:t:
gðxÞ ≤ 0
Ax þ By ≤ d
0 ≤ x1 ≤ 4
0 ≤ x2 ≤ 4
y1 ,y2 ,y3 2 f0, 1g
function obj=minlp_obj(X)
y=X(1:3); % binary variables
x=X(4:5); % continuous variables
obj = (x(1)^2+x(2)^2) + [1; 1.5; 0.5]'*y;
end
function [g,h]=minlp_constr(X)
y=X(1:3); % binary variables
x=X(4:5); % continuous variables
h=[]; g =(x(1)-2)^2-x(2);
end
>> runNumericalMINLP
(continued)
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 261
Norm of First-order
Iter F-count f(x) Feasibility Steplength step optimality
0 6 2.500000e+00 2.000e+00 2.000e+00
1 12 2.686736e+00 1.132e-04 1.000e+00 1.265e+00 1.021e+00
2 18 2.494607e+00 3.453e-02 1.000e+00 4.284e-01 5.403e-01
3 24 2.531718e+00 4.995e-04 1.000e+00 7.831e-02 1.285e-02
4 30 2.532344e+00 1.192e-06 1.000e+00 1.741e-03 1.699e-03
5 36 2.532346e+00 5.142e-09 1.000e+00 1.440e-04 3.296e-05
6 42 2.532346e+00 1.030e-12 1.000e+00 2.031e-06 5.415e-08
xopt =
0.3767
0
0.6233
1.1539
0.7159
fopt = 2.5323
flag = 1
We therefore note that the solution of the relaxed problem is not an integer
solution and the value of the objective function (+2.5323) is a lower bound on
the optimal solution of the MINLP problem. We branch on the first binary
variable (y1) to obtain two nodes: node R1 (y1 = 0) and node R2 (y1 = 1). We
solve the new relaxed problems:
xopt = 1
0
0
2
0
(continued)
262 5 Integer and Mixed Integer Programming Problems
fopt = 5
flag = 1
xopt = 0
0.3740
0.6260
1.1424
0.7355
fopt = 2.7200
flag = 1
We note that the solution at node R1 does not give an integer solution (see
Fig. 5.13) but the solution at node R2 is integer, and this becomes the incum-
bent solution. Node R1 is the only active node and we branch on y2. The relaxed
problems at nodes R3 (y1 = y2 = 0) and R4 (y1 = 0, y2 = 1) have integer
solutions, and the algorithm terminates as there is no active node. Node R4
corresponds to the new incumbent and is also the optimal solution to the
MINLP problem. The complete enumeration tree is shown in Fig. 5.13. Note
that in this case study, all nodes are fathomed due to the fact that the relaxed
problems have integer solution.
Norm of First-order
Iter F-count f(x) Feasibility Steplength step optimality
0 6 2.500000e+00 2.000e+00 2.000e+00
1 12 3.750000e+00 0.000e+00 1.000e+00 1.803e+00 1.000e+00
2 18 3.500000e+00 0.000e+00 1.000e+00 5.000e-01 4.615e-01
3 24 3.500000e+00 0.000e+00 1.000e+00 0.000e+00 0.000e+00
(continued)
5.5 Solving MINLP Problems Using the B&B and Outer Approximation 263
0.3767
0.0000
0.6233
f R
y y
0 1
0.3740 0
0.6260 0
f R f R
binary
y y
0 0
0 1
f R 1 f R4 0
binary binary
Fig. 5.13 B&B tree for the numerical MINLP problem of Example 5.8
xopt =
0
1
0
1
1
fopt =
3.5000
flag =
(continued)
264 5 Integer and Mixed Integer Programming Problems
Norm of First-order
Iter F-count f(x) Feasibility Steplength step optimality
0 6 2.500000e+00 2.000e+00 2.000e+00
1 12 5.500000e+00 0.000e+00 1.000e+00 2.236e+00 2.000e+00
2 18 5.031250e+00 0.000e+00 1.000e+00 8.839e-01 6.250e-01
3 24 5.000000e+00 0.000e+00 1.000e+00 1.768e-01 2.645e-08
xopt =
0
0
1.0000
1.5000
1.5000
fopt =
5.0000
flag =
Learning Summary
min f = cT x þ dT y
x,y
s:t:
Ax þ By = b
Cx þ Dy ≤ e
- x ≤ 0,y 2 f0, 1gn
min f ðx, yÞ
x,y
s:t:
hðx, yÞ = 0
gðx, yÞ ≤ 0
x 2 X ⊆ Rn , y 2 f0, 1gm
Problems
5.1. Solve Example 5.2 using the B&B methodology. Validate your results
using MATLAB.
5.2. Use MATLAB and intlinprog to find all integer solutions in Example
5.2 that correspond to the same optimal value of the objective function.
5.3. Solve the problem presented in Example 5.4 for Orders 1, 2, and 3. Con-
sider the case where our aim is to minimize quantity adjustments.
266 5 Integer and Mixed Integer Programming Problems
5.4. You are considering the inclusion of a new product in the production line
of your company. The forecast for the demand of the new product for the
coming year is as follows (in t/month):
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
800 800 1600 1600 2400 2500 2600 2800 2200 1600 1200 600
Cost
Raw material (Relative) %A %B %C %D Amount available
RM1 1.5 4.0 0.0 0.9 2.3 +1
RM2 3.5 0.0 10.0 4.5 15.0 +1
RM3 3.0 0.0 0.0 0.0 40.0 +1
RM4 5.0 0.0 0.0 60.0 18.0 +1
RM5 1.1 0.4 0.0 1.0 0.0 0.1 t
RM6 1.05 0.1 0.0 0.3 0.0 0.1 t
RM7 1.0 0.1 0.0 0.3 0.0 0.1 t
tdij (min) to
from City A City B City C City D City E City F City G
City A 0 15 25 30 40 22 29
City B 15 0 22 28 31 17 22
City C 25 22 0 16 33 24 27
City D 30 28 16 0 19 23 33
City E 40 31 33 19 0 16 21
City F 22 17 24 23 16 0 33
City G 29 22 27 33 21 33 0
- 18 ln ð1 þ x2 Þ - 19:2 ln ð1 þ x1 - x2 Þ
s:t:
- 0:8 ln ð1 þ x2 Þ - 0:96 ln ð1 þ x1 - x2 Þ þ 0:8x3 ≤ 0
- 2 - ln ð1 þ x2 Þ - 1:2 ln ð1 þ x1 - x2 Þ þ x3 þ 2y3 ≤ 0
x2 - x1 ≤ 0
x2 - 2y1 ≤ 0
x1 - x2 - 2y2 ≤ 0
y1 þ y2 - 1 ≤ 0
y1 ,y2 ,y3 2 f0, 1g,0 ≤ x1 ,x2 ≤ 2,0 ≤ x3 ≤ 1
min μ þ cT y
y1 ,y2 ,y3 ,x1 ,x2,μΟΑ ΟΑ
s:t:
f ðxÞ ≤ μΟΑ
Ax þ By ≤ d
0 ≤ x1 ≤ 4
0 ≤ x2 ≤ 4
y1 ,y2 ,y3 2 f0, 1g
2 3 2 3 2 3
-1 0 þ2 0 0 0
2 3 6 -17 6 þ4 07 6 þ4 7
6 þ1 7 6 0 7 6 7
1 6 7 6 7 6 7
6 7 6 -1 07 6 -1 0 07 6 -17
c = 4 1:5 5, A = 6 7, B = 6 7, d = 6 7
6 0 -177 6 þ1 07 6 07
6 6 0 7 6 7
0:5 6 7 6 7 6 7
4 -1 -15 4 0 0 þ3 5 4 05
0 0 -1 -1 -1 -1
270 5 Integer and Mixed Integer Programming Problems
5.11. This problem refers to Example 4 of the paper Kocis and Grossmann,
Industrial and Engineering Chemistry Research, 27, pp. 1407–1421, 1988.
Study the mathematical formulation (use also the paper by Grossmann &
Sargent from the same journal, 18, pp. 343–348, 1978 for further infor-
mation). Solve the case study presented below using B&B. Use MIPB1
formulation as it features a smaller number of binary variables. Show
clearly the development of the B&B tree (Fig. P5.10).
Data:
Products: product A and product B
Stages: stage 1: mixing, stage 2: reaction, stage 3: separation
Cost data:
Mixing vessels: C 1 = 250 V 0:6
1 , V in L, C in $
Reaction vessels: C 2 = 500 V 0:6:
2
Separatores: C 3 = 350 V 0:6
3
Problems 271
Processing time:
Production capacity:
Product A: QA = 200,000 kg/y
Product B: QB = 150,000 kg/y
Mathematical formulation:
1 þ n2 500V 2 þ n3 350V 2
min n1 250V 0:6 0:6 0:6
yj ,V j ,M i ,CTi
s:t:
QA Q
CTA þ B CTB ≤ H
MA MB
S ij Mi ≤ V j ,8i,j
t ij ≤ nj CTi ,8i,j
nj = 1 þ yj ,8j
250 ≤ V j ≤ 2500
M Lj ≤ M j ≤ M Uj
t ij
max ≤ CTi ≤ max t ij
j 2 j
1 ≤ nj ≤ 2
yj 2 f0, 1g
272 5 Integer and Mixed Integer Programming Problems
6.1 Introduction
min L
xi ,yi ,L
s:t: ð6:1Þ
2 2
xi - xj þ yi - yj ≥ ð2r Þ2 ,8i,j,j > i
)
r ≤ xi ≤ L - r
8i = 1,2, . . . :,n
r ≤ yi ≤ L - r
where (xi, yi) are the coordinates of the center of circle i, i 2 {1, 2, . . ., n}. r is the
radius of the circles and for unit circles r = 1.
i 2 f 1, 2, . . . , n g
Data: The input data of each GAMS model can be SCALARS, PARAMETERS, or
TABLES. SCALARS are single-value quantities (constants), while PARAME-
TERS and TABLES are defined over the sets and constitute vector and
matrix quantities. In the unit circle packing in a square problem, we need
to define the circle radius r, π (=3.14159. . .), and two integers constants
Nmin and Nmax such that Nmin2 ≤ card(i) ≤ Nmax2 (card(A), where A is any
set, is the “number of elements” in the set, in the case of the unit circle
packing in a square problem card(i) = n).
Variables: The decision variables of the optimization model are defined as
VARIABLES in the GAMS modelling language. VARIABLES can obtain any
value (from -1 to +1), while we can also define POSITIVE VARIABLES
(from 0 to +1), NEGATIVE VARIABLES (from -1 to 0), BINARY VARI-
ABLES (0 or 1), and INTEGER VARIABLES (0, 1, 2,. . ., 100).
Equations: The equations describe the mathematical model. Equations can be
defined over the SETS and must be declared and defined in separate
statements. First comes the keyword, EQUATIONS in this case, followed
by the name, domain, and text of one or more groups of equations or
inequalities being declared. In the case of the unit circle packing in a square
problem, we have three inequalities, the first is defined for every i and j with
j > i, and the other two are defined for every i.
Model and Solve Statements: The model is defined as a set of equations which
contain an objective function. The solve statement asks GAMS to solve the
model.
Lines beginning with an asterisk (*) are ignored by GAMS as they are
comments. With this introduction in place, we present our first GAMS model
in Table 6.1. The model consists of six parts. In the first part, the set of circles is
defined:
6.2 Elements of a GAMS® Model 275
Table 6.1 GAMS model for the unit circle packing in a square problem
Although GAMS is case insensitive (SET, Set, and set are the same for
GAMS), we will be using capital letters for reserved word in GAMS. First the
keyword SET is given followed immediately by the index i and the optional
comment “define number of circles”. You should note the typographical
differences between the GAMS format and the usual mathematical format for
listing the elements of a set. GAMS uses slashes “/ /” rather than curly braces “{
}” to delineate the set. A convenient feature to use when you are assigning
members to a set is the asterisk. It applies to cases when the elements follow a
sequence, i.e.:
is equivalent to:
/Circle1*Circle5/
SCALAR pi /3.141592654/;
SCALAR r radius of circle i in m /1/;
SCALARS Nmax,Nmin;
Nmax = CEIL(SQRT(CARD(i)));
Nmin = FLOOR(SQRT(CARD(i)));
6.2 Elements of a GAMS® Model 277
We can avoid using the SCALAR keyword multiple times in the way shown
below:
SCALARS pi /3.141592654/,
r radius of circle i in m /1/,
Nmax,Nmin;
Nmax = CEIL(SQRT(CARD(i)));
Nmin = FLOOR(SQRT(CARD(i)));
CEIL, SQRT, and FLOOR are functions in GAMS. The most used functions
in GAMS are summarized in Table 6.2. CARD is used to determine the number
of elements in a set. In the particular case where i 2 {Circle1, Circle2, . . .,
Circle5}, CARD(i) = 5 (i.e., the set has five elements).
In the third part of the program, we declare the variables appearing in the
model. The unit circle packing in a square problem has as variables the x-y
coordinates of the center of each circle (xi, yi) which are always positive vari-
ables (POSITIVE VARIABLES that obtain values between 0 and +1). The
other variable appearing in the model is the length of the side of the square,
but, as this is also our objective function, we are forced to define L as an
unrestricted variable (VARIABLE which obtains values from -1 to +1):
The fourth part is arguably the most important as it is the part where we
define the set of equality and inequality constraints of the mathematical model.
It starts with the keyword EQUATIONS followed by a list of equation names
separated by commas. The names can be descriptive or arbitrary but always
start with a letter and can only contain up to 63 alphanumeric characters. The
equation name can be followed by optional text to describe the equation. The
declaration of the equations is followed by their definition:
278 6 Solving Optimization Problems in GAMS®
EQUATIONS Ineq1,Ineq2,Ineq3;
Ineq1(i,j)$ (ORD(i)<ORD(j))..
POWER(x(i)-x(j),2) + POWER(y(i)-y(j),2) =G= (2*r)**2;
Ineq2(i).. x(i)+r =L= L;
Ineq3(i).. y(i)+r =L= L;
In the definition of any equation, the name of the equation is stated first
followed by the domain of its definition. Ineq1, for instance, is defined for all
pairs of i and j for which j > i. To achieve that, we first declare, immediately
after the name, the domain of its definition, i.e., (i,j). To enforce the condi-
tion j > i, we use the dollar operator $ which is a logical operator. The ORD
operator is used to determine the order of an element in a set (relative position
of a member of a set). Apparently if i precedes j, then ord(i) < ord(j), and the
condition $(ORD(i) < ORD(j)) is true. In this way, when five circles are
considered, only the pairs 1–2, 1–3, 1–4, 1–5, 2–3, 2–4, 2–5, 3–4, 3–5, and 4–5
are used when equations are generated. Ineq2 and Ineq3 are both defined
for each element of the set i. Note the two dots “..” that are always used
between the name and domain definition and the start of the algebra. Finally,
equations are defined using common mathematical operations, variables, and
parameters and consist of the left-hand-side expression (lhs_expression)
and the right-hand-side expression (rhs_expression):
8 9
< =E=
> >
=
lhs expression = G = rhs expression
>
: >
;
=L=
are used to define lower bounds (*.lo), upper bounds (*.up), and initial
values (*.l) for all variables appearing in the model. This part is optional but
greatly improves our chances of finding a solution to our problem and is highly
recommended.
6.2 Elements of a GAMS® Model 279
Up to this point, we have defined the set and indices, the parameters, and the
constants of the model and the equations. What remains to be done is to define
the equations that form our mathematical model and then solve the problem.
The MODEL statement is used to collect equations into a group and to label
them so that they can be solved. The simplest form of the model statement uses
the keyword ALL, i.e., the model consists of all equations that have been
declared:
OPTION NLP=KNITRO;
and, finally, solve the model using the SOLVE . . . USING . . . MINIMIZING/
MAXIMIZING reserved words:
The remaining elements of this last line are self-evident. The specific prob-
lem is a nonlinear programming problem or NLP. Other types of problems are:
LP Linear programming (proposed solver CPLEX)
MIP Mixed integer linear programming (proposed solver CPLEX)
MINLP Mixed integer nonlinear programming (proposed solvers DICOPT,
SBB, BARON)
The variable that is optimized, as we have already mentioned, must always
be an unrestricted variable.
At this point, we have completed building our first model in GAMS, and we
may press F9 or the run GAMS button in the GAMS environment (see Fig. 6.1)
to solve the problem. GAMS activates a new window that supplies information
about the progress in completing the task, and when finished it generates a
280 6 Solving Optimization Problems in GAMS®
Fig. 6.1 GAMS programming environment after solving the unit circle packing in a square
problem
Fig. 6.2 GAMS output for the solution of the unit circle packing in a square problem: (a)
solution report and (b) variables at the solution
short report (see window on the right of Fig. 6.1) and an *.lst file with the
solution of the problem and more information that can be useful. The reader is
referred to the GAMS manual for more information.
The reader needs to study carefully Fig. 6.2 and to make sure that she/he
always check the SOLVE SUMMARY in the *.lst file to make sure that the
SOLVER STATUS is NORMAL COMPLETION and MODEL STATUS is LOCALLY
OPTIMAL (or OPTIMAL for the case of LP or MILP models). If this is not the
case, then the results are not of any value as the solver has apparently failed to
6.2 Elements of a GAMS® Model 281
provide a solution. If a valid solution has been obtained, then we can use the
results reported in the *.lst file and in the SolVAR section to recover all
details about the solution obtained.
For the case study under study, the results obtained when five circles are
considered are given by the length of the side of the square L = 5.093 and the
coordinates of the centers of the five circles (what follows is an extract from the
*.lst file):
---- VAR x
LOWER LEVEL UPPER MARGINAL
Circle1 1.000 2.676 5.000 7.2682E-8
Circle2 1.000 1.000 5.000 0.303
Circle3 1.000 1.000 5.000 0.197
Circle4 1.000 4.091 5.000 -2.920E-7
Circle5 1.000 3.000 5.000 7.9222E-9
---- VAR y
LOWER LEVEL UPPER MARGINAL
Circle1 1.000 4.091 5.000 -2.920E-7
Circle2 1.000 3.000 5.000 7.9365E-9
Circle3 1.000 1.000 5.000 0.197
Circle4 1.000 2.676 5.000 7.2672E-8
Circle5 1.000 1.000 5.000 0.303
3
y
0
0 1 2 3 4 5 6
x
Fig. 6.3 GAMS generated local solution for the unit circle packing in a square problem using
KNITRO solver (5 circles) and all circles initially placed at (r, r) point in x–y space
---- VAR x
LOWER LEVEL UPPER MARGINAL
Circle1 1.000 1.000 5.000 0.500
Circle2 1.000 2.414 5.000 .
Circle3 1.000 3.828 5.000 .
Circle4 1.000 3.828 5.000 .
Circle5 1.000 1.000 5.000 4.528E-13
---- VAR y
LOWER LEVEL UPPER MARGINAL
Circle1 1.000 1.000 5.000 0.500
Circle2 1.000 2.414 5.000 .
Circle3 1.000 3.828 5.000 .
Circle4 1.000 1.000 5.000 .
Circle5 1.000 3.828 5.000 .
Note the dots appearing in the marginal values (denoting zero values).
6.2 Elements of a GAMS® Model 283
3
y
0
0 1 2 3 4 5 6
x
Fig. 6.4 GAMS generated local solution for the unit circle packing in a square problem using
MSNLP or BARON solvers (five circles) and all circles initially placed at (r, r) point in x–y
space
TABLE Y(j,k)
pattern1 pattern2 pattern3 pattern4 pattern5 pattern6
rod5cm 2 1 0 1 0 0
rod3cm 0 1 3 0 2 1;
TABLE a(i,k)
pattern1 pattern2 pattern3 pattern4 pattern5 pattern6
rod10cm 1 1 1 0 0 0
rod7cm 0 0 0 1 1 0
rod4cm 0 0 0 0 0 1;
* SECTION 3: DEFINE VARIABLES .................................
POSITIVE VARIABLES x(k) number of times pattern k is cut;
VARIABLE Cost;
* SECTION 4: DEFINE EQUATIONS .................................
EQUATIONS Ineq1(i), Eq1(j), ObjFun;
Ineq1(i).. SUM(k,a(i,k)*x(k)) =L= S(i);
Eq1(j).. SUM(k,Y(j,k)*x(k)) =E= D(j);
ObjFun.. Cost =E=
SUM(i,c(i)*SUM(k,a(i,k)*x(k)))+Ccut*SUM(k,kappa(k)*x(k));
* SECTION 6: MODEL & SOLVE STATEMENTS .......................
MODEL CuttingStock /ALL/;
SOLVE CuttingStock USING LP MINIMIZING Cost;
6.2 Elements of a GAMS® Model 285
The most important new element available in GAMS that is introduced is the
summation operation used in both equations. The first inequality constraint:
m X
X n
cij xij = Cost
i=1 j=1
Table 6.4 GAMS model for the paint production scheduling problem
keyword which is used to assign a title to our program (in addition, the
$TITLE statement causes the subsequent text to be printed at the top of
each page of output). In the GAMS program of Table 6.4, binary variables are
defined and used:
The most important new element used in the program of Table 6.4 is the put
writing facility. The put writing facility generates documents automatically
when GAMS is executed. A document is written to an external file sequentially,
a single page at a time. In the first line of the put writing facility, the internal file
name out is defined and connected to the external file out.dat using the
keyword FILE:
The second line of this put writing facility example assigns the file out.dat
as the current file, that is, the file which is currently available to be written to.
In the third line of the writing to the document begins using a put statement
with a textual item:
Notice that the text is quoted. The slashes following the quoted text repre-
sent carriage returns. The example continues with another textual item
followed by the scalar card(i). Notice that these output items are separated
with commas:
Writing the results into the output file selected requires varying the index in
a systematic way. This is achieved in this case using the LOOP statement which
has the general format:
LOOP( i,
. . . .statements . . .
);
Within the LOOP statement, we use again the PUT statement to write into
the out file the elements that are of interest to us:
Note that: <>7:0 is used to format the way ORD(i) is written into the
output file. This is an example of the local format feature. The syntax of this
feature is as follows:
item:{<>}width:decimals
The item is followed by a justification symbol, the field width, and the
number of decimals to be displayed. The specification of the number of deci-
mals is only valid for numeric output. The following local justification symbols
are applicable:
> Right justified
< Left justified
<> Center justified
Omitting any of the components causes their corresponding global format
settings to be used. The item width and decimals are delimited with colons as
shown above. The output that is automatically generated (out.dat) after
execution is the following:
6.3 Two Recreational Problems Solved in GAMS® 289
8
>
< 1, if i is on the near ðleftÞ bank of the river at time t
zi,t =
>
:
0, if i is not on the near ðleftÞ bank of the river at time t
8
< 1, if i is on the far ðrightÞ bank of the river at time t
>
yi,t =
>
:
0, if i is not on the far ðrightÞ bank of the river at time t
Having defined the basic variables of the model, we then define the param-
eter directiont which shows when the crossing at t is from the near bank to the
far bank (= -1) or from the far bank to the near bank (= +1):
directiont = ð - 1Þ1þt
As the boat can only carry the farmer and up to one additional item, it
follows that:
X
ui,t ≤ 2, 8t
i2fW, G, C, F g
The second constraint ensures that any item can cross the river if and only if
the farmer is on the boat (i.e., the wolf, the goat, or the cabbage cannot cross the
river alone). We may simplify the equations by using the fact that an item can
be at either the left bank or the right bank:
Finally, we need to exclude the “forbidden” states at which the wolf and the
goat or the goat and the cabbage are on the same bank of the river and also take
into consideration the fact that these states are allowable if the farmer is on the
same bank of the river (the items are under supervision, and they cannot eat
each other):
9
zW,t þ zG,t ≤ 1 þ zF,t >
>
>
yW,t þ yG,t ≤ 1 þ yF,t =
8t
zG,t þ zC,t ≤ 1 þ zF,t >
>
>
;
yG,t þ yC,t ≤ 1 þ yF,t
Finally, we use the following objective function with the aim to enforce the
fastest possible completion of the crossing:
X
n
max AllCrossedt
t=0
X
n
max AllCrossedt
zi,t , yi,t ,ui,t ,AllCrossedt
t=0
s:t: 9
zi,tþ1 = zi,t þ directiont ui,t > >
=
yi,tþ1 = 1 - zi,t 8i,t
>
>
;
AllCrossedt ≤ yi,t
X 9
ui,t ≤ 2 >
>
>
>
i2fW,G,C,F g >
>
>
>
ui,t ≤ uF,t , 8i 2 fW, G, C g > >
>
>
>
=
zW,t þ zG,t ≤ 1 þ zF,t 8t
>
>
yW,t þ yG,t ≤ 1 þ yF,t >
>
>
>
>
>
zG,t þ zC,t ≤ 1 þ zF,t >
>
>
>
>
;
yG,t þ yC,t ≤ 1 þ yF,t
zi,t ,yi,t ,ui,t ,AllCrossedt 2 f0, 1g,8i,t
We have only kept the nonzero elements for saving space. We note that at
the first crossing u(G.0) = 1 & u(F.0) = 1 and the farmer crosses the river
from the near to the far bank together with the goat. In the second crossing u
(F.1) = 1 only and returns to the near bank alone. In the third crossing, u
(W.2) = 1 & u(F.2) = 1, and the farmer crosses the river from the near to
the far bank together with the wolf. Then the farmer returns to the near bank
together with the goat as u(G.3) = 1 & u(F.3) = 1 (fourth crossing) and
then leaves the goat on the near bank and crosses the river carrying the
cabbage as u(C.4) = 1 & u(F.4) = 1 (fifth crossing). Then the farmer
returns alone to the near left bank (sixth crossing) and finally crosses the
river for seventh and final time together with the goat as u(G.6) = 1 & u
(F.6) = 1. There is a second completely equivalent solution in which in the
third crossing, instead of crossing the river carrying the wolf, the farmer can
select to carry the cabbage, then returns with the goat, and finally crosses the
river from the near bank to the far bank two additional times, initially carrying
the wolf and finally the goat. Again, seven crossings are necessary, and the
solution is equivalent.
We now move to the second problem that we will study in this section: the
Traveling Salesman (or Salesperson) Problem or simply TSP. In the TSP prob-
lem, we consider n cities, and the salesman wants to start from city 1, visit all
cities exactly one time, and finally return to city 1 by minimizing the “cost” of
travelling. We will assume that the cost of travelling between city i and city j is
cij, which is always a positive constant. We will also restrict attention to the
so-called symmetric TSP problem in which the cost of traveling between j and
i is exactly the same as the cost of traveling between i and j. We will also
consider that there are direct connections between all cities, and if this is not
the case, then we can always set dij = M, where M is a very large number, to
make the particular selection unattractive.
60 160
90 130
100
100
50
70
80
80
6.3 Two Recreational Problems Solved in GAMS® 295
An example TSP problem is shown in Fig. 6.6. The cost of travelling between
any two cities is independent of the direction of the movement and is given in
Fig. 6.6. To develop the mathematical model, we define the binary variables yij
that are equal to 1 if the salesperson travels from city i to city j, 8i, j 2 {1, 2, . . ., 5}.
The mathematical formulation is easy to derive as it follows easily from the
general assignment problem:
XX
min
y
cij yij
ij
i j
s:t:
X
yji = 1,8i
j,j ≠ i
X
yij = 1,8i
j,j ≠ i
yij 2 f0, 1g,8i,j
The first equality constraint ensures that the salesman arrives at each city
and the second one that the salesman departs from each city. Is this formula-
tion a complete representation of the TSP problem? The following is a GAMS
file that implements the formulation:
When we solve the model, we obtain the following solution (extract from the
*.lst file, only the nonzero elements are given to save space):
---- VAR x
LOWER LEVEL UPPER MARGINAL
1.2 . 1.000 1.000 60.000
2.3 . 1.000 1.000 50.000
3.1 . 1.000 1.000 90.000
4.5 . 1.000 1.000 70.000
5.4 . 1.000 1.000 70.000
LOWER LEVEL UPPER MARGINAL
---- VAR cost -INF 340.000 +INF .
90
70
50 70
6.3 Two Recreational Problems Solved in GAMS® 297
XX
xij = cardðvÞ
i2v j2v
In the case study of Fig. 6.6, we need to apply these inequalities for all
subsets with two elements, three elements, and four elements. How many
2-element subsets do we have? The answer is that the number of 2-element
subsets is equal to the ways that we may select two objects from a set of five
objects: n!/(n - m)!m! = 5!/3!2! = 10. We can therefore write the following
inequality constraints:
Clearly, despite the fact that many of these constraints are redundant, the
number of additional constraints that we need to integrate in our formulation
is significant. GAMS, however, makes this easy.
Instead of adding all these constraints in our formulation, we can follow a
step-by-step procedure where we initially ignore all of them, and we then add
them by increasing the cardinality of the sets considered in each step. In our
case, we start by adding all subtour elimination constraints that correspond to
2-element subsets:
---- VAR x
LOWER LEVEL UPPER MARGINAL
1.2 . 1.000 1.000 60.000
2.3 . 1.000 1.000 50.000
3.5 . 1.000 1.000 80.000
4.1 . 1.000 1.000 130.000
5.4 . 1.000 1.000 70.000
LOWER LEVEL UPPER MARGINAL
---- VAR cost -INF 390.000 +INF .
This solution is the optimal solution of the TSP case study and is shown in
Fig. 6.8. As there is no subtour involved in this solution, we do not need to add
any additional constraints. If a solution with disconnected subtours had been
obtained, then we would have added the subtour elimination constraints that
correspond to all subsets involving three elements, etc.
An alternative approach that is efficient in practice is to solve the relaxed
problem, i.e., the problem without the subtour elimination constraints, and
then if subtours are discovered, then integer cut constraints are added to
eliminate only the subtours that have already discovered. This can be achieved
in the case study we investigate by first solving the relaxed formulation to
obtain the results shown in Fig. 6.7. Then a constraint is added to eliminate the
subtour involving cities 1 and 4. Solving the problem again results in a new
solution where a subtour involving cities 1 and 2 appears. Using subtour
elimination constraints for subtours involving cities 1 & 4 and 1 & 2:
80
50 70
300 6 Solving Optimization Problems in GAMS®
ui - uj þ nxij ≤ n - 1, u1 = 1, 2 ≤ i ≠ j ≤ n
PARAMETER n; n=card(i);
TABLE c(i,j) cost of travelling between i & j
(continued)
6.3 Two Recreational Problems Solved in GAMS® 301
1 2 3 4 5
1 60 90 130 160
2 60 50 100 100
3 90 50 80 80
4 130 100 80 70
5 160 100 80 70 ;
BINARY VARIABLE x(i,j);
VARIABLES u(i), cost;
---- VAR x
LOWER LEVEL UPPER MARGINAL
1.4 . 1.000 1.000 130.000
2.1 . 1.000 1.000 60.000
3.2 . 1.000 1.000 50.000
4.5 . 1.000 1.000 70.000
5.3 . 1.000 1.000 80.000
---- VAR u
LOWER LEVEL UPPER MARGINAL
2 1.000 4.000 4.000 EPS
3 1.000 3.000 4.000 .
4 1.000 1.000 4.000 EPS
5 1.000 2.000 4.000 .
LOWER LEVEL UPPER MARGINAL
---- VAR cost -INF 390.000 +INF .
The solution is the same as the one obtained before. It is interesting to note
that the dummy variable ui, i ≥ 2 is actually an indication variable that denotes
tour ordering, such that ui < uj implies that city i is visited before city j.
The TSP problem is the most notorious problem in mathematical program-
ming and combinatorial optimization (problems at which the optimal solution
is a subset of a finite set). A characteristic case study of problems that are
particularly easy to describe but extremely difficult to solve is known as
NP-hard problems. One reason for that is the combinatorial explosion of the
302 6 Solving Optimization Problems in GAMS®
Learning Summary
Problems
X
└T┘
yjk = 1,8j 2 J
k = τj
Solve the problem in GAMS to determine the best schedule for com-
pleting the jobs.
6.11 An alternative formulation to the Pritsker, Watters, and Wolfe (PWW)
formulation for the job scheduling problem, presented in Problem 6.10,
is based on a continuous representation of time (and thus avoids the
time discretization which is the major drawback of the PWW formula-
tion). In this formulation, we define the binary variables yij to denote
whether job i precedes (executed before) job j (yij = 1). This alternative
model introduces the continuous variables xj which denote that (con-
tinuous) time at which the processing of job j starts (the completion time
is xj + τj). The complete mathematical formulation is as follows:
X
min
þ -
pj sj-
yij ,xj ,sj ,sj j2J
s:t:
xj þ τj þ sj - sj- = dj ,8j 2 J
þ
9
Myij þ xi ≥ xj þ τj >
>
=
,8i,j : i < j
>
>
M 1-y þ x ≥x þ τ ;
ij j i i
yij = 0,8i,j : i ≤ j
k k
k
k
y1 y2 y3 y4 y5
Time (h) a-pinene dipentene allo-ocimene pyronene dimmer
0 100 0 0 0 0
1230 88.35 7.3 2.3 0.4 1.75
3060 76.4 15.6 4.5 0.7 2.8
4920 65.1 23.1 5.3 1.1 5.8
7800 50.4 32.9 6.0 1.5 9.3
10,680 37.5 42.7 6.0 1.9 12.0
15,030 25.9 49.1 5.9 2.2 17.0
22,620 14.0 57.4 5.1 2.6 21.0
36,420 4.5 63.1 3.8 2.9 25.7
dy1
= - ðk 1 þ k 2 Þy1
dt
dy2
= k 1 y1
dt
dy3
= k2 y1 - ðk 3 þ k4 Þy3 þ k5 y5
dt
dy4
= k 3 y3
dt
dy5
= k 4 y3 - k 5 y5
dt
X 8
5 X 2
min yjexp ðt k Þ - yj ðt k Þ
ki
j=1 k=1
Use GAMS to solve the optimization problem, and estimate the reac-
tion rate constants. Solve the differential equations dy(t)/dt = f(y(t))
using the following simple rule of integration:
1
yðt Þ = yðt - δt Þ þ ½f ðyðt ÞÞ þ f ðyðt - δt ÞÞ
2
7.1 Introduction
L x T L x T
L0 ¼ L1 þ V 1 ð7:1Þ
L0 x0 ¼ L1 x1 ð7:2Þ
L0 hðx0 , T 0 Þ þ Q1 ¼ L1 hðx1 , T 1 Þ þ V 1 H ðT 1 Þ ð7:3Þ
where Q1 is the rate of heat transfer from the heating steam to the solution. The
heating steam has a mass flow rate V0 and is saturated at temperature T s0 . h is
the enthalpy of the liquid stream which is a function of the mass fraction of the
solids and the temperature, i.e., h ¼ h(x,T). H is the enthalpy of the steam, which
is a function of the steam temperature only, i.e., H ¼ H(T). Q1 can be expressed
through the following equations:
Q1 ¼ V 0 H T s0 h T s0 ð7:4Þ
Q1 ¼ A1 U 1 T 0s T 1 ð7:5Þ
where A1 is the heat transfer area and U1 is the overall heat transfer coefficient
which is assumed to be a decreasing function of the mass fraction of the solids,
i.e., U ¼ U(x).
An important element of the modelling of aqueous solution of solids is the
rise in the boiling point (BPR) relative to that of pure water at the same
pressure:
B
ln Ps ¼ A ð7:7Þ
C þ Ts
where: TAC is the approximate total annual cost ($/y); CCF is the capital charge
factor (1/3); FBM is the bare module factor (2.25); ty is the operating time
(8322 h/y); clps is the unit cost of the low-pressure steam (30 $/t); Cevap is the
purchase cost of a falling film evaporator given by (Turton et al., Analysis,
Synthesis, and Design of Chemical Processes, 4th ed., Prentice Hall, 2013):
Table 7.1 Properties of a sugar solution (x is the mass fraction of sugars, T is the temper-
ature, and Ts is the saturation temperature in C)
Property Equation Units
Boiling point rise BPR ¼ (1.8 þ 6.2x)x C
Overall heat transfer U ¼ exp (8.14 0.078 ln (x) þ 0.26 ln (x)2) kJ
h m2 C
coefficient
Specific enthalpy of hw ¼ 9.14 þ 3.8648T þ 3.3337 103T2 9.8 106T3 kJ
kg
liquid water
Specific enthalpy of H ¼ 2502.04 þ 1.8125T þ 2.585 104T2 9.8 106T3 kJ
kg
steam
Heat capacity of cps ¼ 1.84 kJ
kg C
sugars (solids)
Specific enthalpy of h ¼ x cpsT þ (1 x) hw(T ) kJ
kg
solution
Saturation pressure of Ps ¼ exp 11:622 T s3798:3 bar
þ227:03
pure water
310 7 Representative Optimization Problems in Chemical Engineering Solved. . .
Note that the solution is defined by the active constraints Ps 0.1 bar and
x 0.5 and that the cost-optimal evaporator has a heat transfer area of
98.545 m2 and consumes 6.017 kg lps steam/s. The steam economy (the
mass of water evaporated over the utility steam consumed) is (5.040/
6.017) ¼ 0.838, which is typical for single evaporator systems (usually in the
range 0.75–0.95).
In trying to improve the economics of the process, we may consider the case
of a double-effect evaporator shown in Fig. 7.2. We modify the GAMS program
of Table 7.2 to that of Table 7.3 (the only important difference being the
introduction of the index i to denote the evaporator). By solving the model
for two evaporators, we obtain the following solution:
(continued)
7.2 Optimization of a Multiple-Effect Evaporation System 311
VARIABLE ObjFun;
TotalMassBalance.. L0 =E= L + V;
SugarMassBalance.. L0*x0 =E= L*x;
EnergyBalance.. L0*h0 =E= L*hL + V*HV - Q;
UtilitySteam.. Q =E= V0*Dhs;
OverHeatTrCoef.. U*3600=E= exp(8.14+(-
0.078+0.26*log(x))*log(x));
HeatTransfArea.. Q =E= A*U*(Ts0-T);
BoilPointElev.. T =E= Ts + (1.8+6.2*x)*x;
SaturationPress.. Ps =E= exp(11.622-3798.3/(Ts+227.03));
CalculatehL.. hL =E= x*cps*T+(1-x)*hw;
Calculatehw.. hw =E= 9.14+3.8648*T+3.3337E-3*T**2-9.8E-
6*T**3;
(continued)
312 7 Representative Optimization Problems in Chemical Engineering Solved. . .
(continued)
7.3 Complex Chemical Reaction Equilibrium 313
V V
T T
V Ts
Q ,A ,P , Q ,A ,P ,
T , ,U T, ,U
L L
L x T
x x
T T
It is important to note that the TAC decreases from M$5.7 for a single-effect
evaporator to M$3.56 for a double-effect evaporator system. The total heat
transfer area increases from 98.5 to 162.43 m2, but the steam consumption
decreases from 6.017 to 3.412 kg/s (and the steam economy increases from
0.838 to 1.477). Further improvements can be obtained by increasing the
number of evaporators and/or introducing a heat recovery heat exchanger
that preheats the fresh feed.
(continued)
7.3 Complex Chemical Reaction Equilibrium 315
" #
X
NC
ΔGof,i X
NC
min G ðn i Þ ¼ ni þ ln ni ln ni
ni 0
i¼1
RT i¼1
s:t: ð7:10Þ
X
NC
ni ai,k ¼ a0k , k ¼ 1, 2, . . . , NE
i¼1
where ni are the mole of chemical species i at the product stream (there are NC
chemical species present), ΔGof,i is the standard-state Gibbs free energy of
formation of chemical species i, T is the temperature of the reaction, and R is
the ideal gas constant. aik denote the number of atoms of element k in chemical
species i, and NE are the elements present in the system. The atoms of element
k present in the feed are a0k . The main computational problem arising when we
need to determine the equilibrium at different temperatures is due to the fact
that ΔGof,i is a function of temperature. To automatically determine the equilib-
rium composition as a function of the temperature, we need to include into the
GAMS program the calculation of ΔGof,i at each temperature.
The analytic determination of ΔGof,i is discussed in most chemical engineer-
ing thermodynamics textbooks (such as Elliott & Lira, Introductory Chemical
Engineering Thermodynamics, Pearson, 2012, or Abbot Van Ness, Thermody-
namics with Chemical Applications, Schaum’s Series, 2nd ed., McGraw Hill,
316 7 Representative Optimization Problems in Chemical Engineering Solved. . .
1989). The calculation makes use of the definition of the ideal gas heat capacity
of chemical species i in polynomial form:
X
4
Cpi ¼ Cp1,i þ Cp2,i T þ Cp3,i T 2 þ Cp4,i T 3 ¼ Cpik T k1 ð7:11Þ
k¼1
The question that we need to answer is how, for any given chemical species, to
calculate ΔGof,T , i.e., the standard Gibbs free energy of formation at temperature
T, if ΔGof,T r is known, i.e., the standard Gibbs free energy of formation at the
reference temperature Tr ¼ 298.15 K. The answer is given by the van’t Hoff
equation:
Z
ΔGof,T ΔGof,T r T Δhof,T
¼ dT ð7:12Þ
RT RT Tr RT 2
where:
X Z T X
4
Δhof,T ¼ vi Δhof,T r ,i þ ΔCpk T k1 dT ð7:13Þ
i T r k¼1
P
where ΔCpk ¼ i vi ΔCpki , and vi are the stoichiometric numbers for the
formation reaction of species i from the elements in the naturally occurring
molecular form at the standard state (298.15 K and 1 bar). By taking these into
consideration, Eq. (7.13) can be written as:
X
4
Δhof,T ¼ Δhof,T r þ ΔCpk T k1
k¼1
or:
where J is a constant that can be calculated from the known pair of data:
T r , Δhof,T r . We finally substitute (7.14) into (7.13) to obtain:
ΔGof,T J 1 ΔCp2 ΔCp3 2 ΔCp4 3
¼ ΔCp1 ln T þ Tþ T þ T I ð7:15Þ
RT RT R 2 6 12
The final equation involves two integration constants J and I which are deter-
mined by applying Eqs. (7.14) and (7.15) for the reference temperature
Tr ¼ 298.15 K, for which values of Δhof,T r and ΔGof,T r are available in tables of
thermodynamic data.
7.4 Optimal Design of a Methanol-Water Distillation Column 317
Table 7.4 Experimental data for the catalytic (30% Ni/ZrO2) steam reforming of ethanol
Temperature mol H2/mol mol CO/mol mol CO2/mol mol CH4/mol
( C/K) EtOH EtOH EtOH EtOH
400/673.15 2.1 0.58 0.54 0.63
450/723.15 3.1 0.38 1.05 0.51
500/773.15 3.8 0.33 1.14 0.45
550/823.15 4.4 0.39 1.25 0.36
600/873.15 5.2 0.49 1.28 0.23
650/923.15 5.8 0.54 1.35 0.12
Data from Biswas & Kunzru, International Journal of Hydrogen Energy, 32, pp. 969–980, 2007
We will study the case study of the catalytic steam reforming of ethanol at
high temperatures (see Fig. 7.3) for which experimental results are available
and are summarized in Table 7.4. The GAMS file that solves this problem is
based on Formulation (7.10), and most of its lines implement Eqs. (7.11)–
(7.13). The GAMS file is given in Table 7.5. The results of the optimization
model are compared to the experimental results in Fig. 7.4. The agreement is
considered satisfactory.
(continued)
Table 7.5 (continued)
CH3CH2OH -0.5 -2 -3 0 0 0 0 0 +1 0 0
CH3CHO -0.5 -2 -2 0 0 0 0 0 0 +1 0
CH3COCH3 -0.5 -3 -3 0 0 0 0 0 0 0 +1 ;
SCALAR T /1000/; SCALAR Tr /298.15/; SCALAR Rg /8.314/;
PARAMETER DHf, DGf, Dcp(i,m), lnKeq, Jc, Ic, DGf_RT;
DHf(i) = sum(ip, Stoich_f(i,ip)*Dhfig(ip) ); Display DHf;
DGf(i) = sum(ip, Stoich_f(i,ip)*Dgfig(ip) ); Display DGf;
Dcp(i,m) = sum(ip, Stoich_f(i,ip)*Cp(ip,m) ) ; Display Dcp;
lnKeq(i) = -DGf(i)/(Rg*Tr); Display lnKeq;
Jc(i) = DHf(i) - sum(m,Dcp(i,m)*Tr**ord(m)/ord(m)); Display Jc;
Ic(i)=lnKeq(i)+Jc(i)/(Rg*Tr)-
(cp(i,'1')*log(Tr)+Dcp(i,'2')*Tr/2+Dcp(i,'3')*Tr**2/6+Dcp(i,'4')*Tr**3
/ 12)/Rg;
DGf_RT(i)= -(Ic(i)*Rg-
Jc(i)/T+(Dcp(i,'1')*log(T)+Dcp(i,'2')*T/2+Dcp(i,'3')*T**2/6+Dcp(i,'4')
*T**3/ 12))/Rg;
**************8 MOLE H2O per MOLE of CH3CH2OH are fed to the reactor
Parameter Water_2_EtOH_Ratio /8/;
Parameter b0; b0(k) = A(k,'CH3CH2OH')+A(k,'H2O') *
Water_2_EtOH_Ratio;
Fig. 7.4 Comparison of experimental data and model predictions (continuous lines) for the
catalytic steam reforming of ethanol
(a)
(b)
Li: molar flow rate of the liquid stream coming out from tray i
Vi: molar flow rate of the vapor stream coming out from tray i
ti: temperature on tray i
xi,j: molar fraction of component j on tray i-liquid phase
yi,j: molar fraction of component j on tray i-vapor phase
hL,i: specific enthalpy of the liquid on tray i
hV,i: specific enthalpy of the vapor on tray i
REFi: molar flow rate of reflux fed on tray i
BUi: molar flow rate of boilup fed on tray i
Using this notation, we may write the overall material balance, the compo-
nent material balances, and the energy balance for each tray:
i ¼ 1 (reb):
X
NF1
Liþ1 ¼ Li þ BUk
k¼2
!
X
NF1
Liþ1 xiþ1,j ¼ Li xi,j þ BUk yi,j
k¼2
!
X
NF1
Liþ1 hL,iþ1 þ Qreb ¼ Li hL,i þ BUk hV,i
k¼2
i ¼ NF (floc):
Liþ1 þ V i1 þ F ¼ Li þ V i
Liþ1 xiþ1,j þ V i1 yi1,j þ Fzf,j ¼ Li xi,j þ V i yi,j
Liþ1 hL,iþ1 þ V i1 hV,i1 þ Fhf ¼ Li hL,i þ V i hV,i
i ¼ NF þ 1, . . ., NT 1 (abovef):
i ¼ NT (con):
X
NT 1
V i1 ¼ D þ REFk
k¼NFþ1
!
X
NT1
V i1 yi1,j ¼ Dxi,j þ REFk xi,j
k¼NFþ1
!
X
NT1
V i1 hV,i1 Qcond ¼ DhL,i þ REFk hL,i
k¼NFþ1
X
NC X
NC
xi,j ¼ yi,j ¼ 1
j¼1 j¼1
REFU and BUU are upper bound on the corresponding variables. These con-
straints ensure that only one z is equal to 1, and all others are equal to 0 in both
the stripping and the rectifying sections. The trays for which zi ¼ 1 define the
first and the last tray of the column.
324 7 Representative Optimization Problems in Chemical Engineering Solved. . .
where AMe,W ¼ 0.7989 and AW,Me ¼ 0.5625. The saturation pressure of the two
components is calculated using the Antoine equation (temperature in C and
pressure in kPa):
3644:297
ln PsMe ¼ 16:5938
T þ 239:765
3799:887
ln PsW ¼ 16:262
T þ 226:346
where: TAC is an approximate total annual cost ($); CCF is the capital charge
factor (selected 1/3); FBM is the installed equipment cost factor; ty is the
operating time (8322 h/y); clps is the unit cost of the low-pressure steam
(14.05 $/GJ); ccw is the unit cost of the cooling water (0.354 $/GJ); Cequip is
the purchase cost of the column, trays, and the heat exchangers.
The purchase cost of the column (ccol), trays (ctray), and heat exchangers
(che) is calculated through the Guthrie’s correlations (in $@1968):
The number of trays can be inferred from the values of the binary variables zi:
X
NT1 X
NF1
N trays ¼ 1 þ i zi i zi
i¼NFþ1 i¼2
The model is now complete, and based on this model, a GAMS program is
developed to solve the methanol-water separation problem. The model is
presented in Table 7.6. The solution of the problem gives the optimal design
shown on Fig. 7.6. The column has 18 equilibrium stages (including the
reboiler), a diameter of 1.282 m, and a height of 10.746 m. The reflux ration
is 0.806, the reboiler duty is 3,275.95 MJ/h, and the condenser duty is
3221.19 MJ/h. The overall approximate TAC is $518,731.8 and is dominated
by the utilities cost which is $392,527.6 (75.6% of TAC).
All problems that we have studied in this book involved an underlying math-
ematical description that consists of algebraic equalities and inequalities.
However, there are important problems in chemical engineering in which the
performance of a systems is described by ordinary differential equations
(ODEs) or partial differential equations (PDEs) or a combination of differential
equations and algebraic equations (DAEs). The fact that differential equations
are involved in the description of the behavior of certain systems complicates
the solution of the optimization problems. This is due to the fact that the ODEs,
PDEs, or DAEs need first to be transformed into algebraic equations in order
for the problem to be posed in the general frameworks that have been
presented so far. An additional complication that arises is due to the fact that
the optimization variables can be a function of the independent variables (time
or space) and the size of the corresponding optimization variable vector is
infinite.
326 7 Representative Optimization Problems in Chemical Engineering Solved. . .
Table 7.6 GAMS program for the methanol-water distillation column design
$Ontext
Methanol-Water Distillation Column
$Offtext
OPTION OPTCR=1E-6;
OPTION OPTCA=1E-6;
SETS j components / Me , W /
i stages / 1*30 /
reb(i) reboiler
con(i) condenser
col(i) stages in the col
floc(i) location of the feed stage / 10 /
abovef(i) stages above the feed stage
belowf(i) feed stage and those below it ;
reb(i) = yes$(ord(i) eq 1) ;
con(i) = yes$(ord(i) eq card(i)) ;
col(i) = yes - (reb(i)+con(i)) ;
belowf(i) = yes $ ( (ord(i) le 9 ) and (ord(i) ge 2 ) );
abovef(i) = yes $ ( (ord(i) ge 11 ) and (ord(i) le 29 ) );
ALIAS (i,k);
(continued)
7.5 A Representative Optimal Control Problem 327
POSITIVE VARIABLES
x(i,j) mole-fr of j-th component in liquid on i-th tray.
y(i,j) mole-fr of j-th component in vapour on i-th tray
gama(i,j) activity of j-th component in liquid on i-th tray
L(i) flowrate of liquid leaving tray i (kmol per h)
V(i) flowrate of vapour leaving tray i (kmol per h)
t(i) temperature of tray i (degC)
REF(i) reflux molar flowrate entering tray i (kmol per h)
BU(i) boilup molar flowrate entering tray i (kmol per h)
D top product molar flow rate (kmol per h)
RefluxRatio reflux ratio
Qreb heat load of the reboiler (MJ per h)
Qcond heat load of the condenser (MJ per h)
termM(i) auxiliary (dummy) variable in the van Laar model
termW(i) auxiliary (dummy) variable in the van Laar model
densV(i) vapour density (kmol per m3)
Dc column diameter in m
Hc column height in m
Areb Heat transfer area in reboiler
Acond Heat transfer area in condenser
Ntrays number of equilibrium stages(reboiler plus trays)
UtlCost cost of utility steam in $ per y
EquipCost installed cost of column and trays in $ @ 1968
hl(i) molar sp.enthalpy of liquid on tray i in MJ per kmol
hv(i) molar sp.enthalpy of vapour on tray i in MJ per kmol;
VARIABLES cost
ObjFun;
BINARY VARIABLES
z(i) return tray (z=1) of reflux OR reboil;
(continued)
328 7 Representative Optimization Problems in Chemical Engineering Solved. . .
(continued)
7.5 A Representative Optimal Control Problem 329
DefTermW(i)..
termM(i)*(AMW*x(i,'Me')+AWM*x(i,'W'))=E=AWM*x(i,'W');
DefTermE(i)..
termW(i)*(AMW*x(i,'Me')+AWM*x(i,'W'))=E=AMW*x(i,'Me');
DefgamaW(i).. gama(i,'Me') =E= exp( AMW * termM(i) * termM(i) );
DefgamaE(i).. gama(i,'W') =E= exp( AWM * termW(i) * termW(i) );
(continued)
330 7 Representative Optimization Problems in Chemical Engineering Solved. . .
x.l(i,'W') = 0.98-0.96*(ord(i)-1)/(card(i)-1);
x.l(i,'Me')=1-x.l(i,'W'); x.up(i,j)=1; y.up(i,j)=1;
gama.l(i,'Me')=exp(AMW*(AWM*x.l(i,'W')
/(AMW*x.l(i,'Me')+AWM*x.l(i,'W')))**2);
gama.l(i,'W')
=exp(AWM*(AMW*x.l(i,'Me')/(AMW*x.l(i,'Me')+AWM*x.l(i,'W')))**2
);
gama.lo(i,J)=1; gama.up(i,J)=3;
termM.up(i)=1;termW.up(i)=1;
y.l(i,j) = x.l(i,j) * gama.l(i,j) * exp(A(j)-B(j)/(C(j)+t.l(i)))
/p(i);
hv.l(i)=40; hl.l(i)=10;
D.l=F/zf('Me'); L.l('1')=F-D.l;
RefluxRatio.l =0.8; RefluxRatio.lo=0.25; RefluxRatio.up=2;
L.l(i)$abovef(i)=RefluxRatio.l*D.l;
L.l(i)$belowf(i)=RefluxRatio.l*D.l+F;
L.l(i)$floc(i) =RefluxRatio.l*D.l+F;
V.l(i)$abovef(i)=(1+RefluxRatio.l)*D.l;
V.l(i)$belowf(i)=(1+RefluxRatio.l)*D.l;
V.l(i)$floc(i) =(1+RefluxRatio.l)*D.l;
Acond.lo=1;Acond.up=1000;Acond.l=10;
Areb.lo=1 ;Areb.up=1000; Areb.l=10;
densV.L(i)=0.04;
Dc.lo=0.5; Dc.up=5; Dc.l=1;
Ntrays.lo=3; Ntrays.up=30; Ntrays.l=15;
Hc.lo=1; Hc.up=Ntrays.up*0.6*1.2; Hc.l=Ntrays.l*0.6*1.2;
EquipCost.l=100000; UtlCost.l=300000;
OPTIONS NLP=CONOPT4;
OPTIONS miNLP=SBB;
SOLVE MeWDist USING miNLP MinIMIZING cost;
7.5 A Representative Optimal Control Problem 331
30
D
29
28
27
26 REF
25
24
23
22
21
20
19
18
17
16
15
14
13
12
F=100 kmol/h 11
50% Me 10
Tf=72.6 9
8
7
6
5
4
3 BU
2
1
B
Fig. 7.6 Structure and notation used in the distillation column optimization
332 7 Representative Optimization Problems in Chemical Engineering Solved. . .
CR t
CP t Qt
Tt
To make these ideas clear to the reader, we consider the batch reactor of
Fig. 7.7. The reactor has a constant active volume V ¼ 1 m3 and is loaded
initially with the reactant R with initial concentration CR(0) ¼ 1 kmol/m3. The
reacting mixture has constant properties with ρCp ¼ 10 kJ/(m3 K). The reac-
tions that take place are:
R!P!B
k1 k2
dC R ðt Þ
r 1 ðt Þ ð7:18Þ
dt
dC P ðt Þ
¼ r 1 ðt Þ r 2 ðt Þ ð7:19Þ
dt
dT ðt Þ ðΔHrxn,1 Þ ðΔH rxn,2 Þ Qðt Þ
¼ r 1 ðt Þ þ r 2 ðt Þ þ ð7:20Þ
dt ρC p ρC p ρC p V
E 1
r 1 ðt Þ ¼ k1,0 exp 1 C 2 ðt Þ ð7:21Þ
R T ðt Þ R
E 1
r 2 ðt Þ ¼ k 2,0 exp 2 C ðt Þ ð7:22Þ
R T ðt Þ P
There are several constraints that the reacting mixture needs to satisfy in
order to ensure a safe operation:
max C P ðt f Þ ð7:25Þ
Qðt Þ, T ðt Þ, C R ðt Þ, C P ðt Þ
The problem that we have just presented has two main differences com-
pared with the problems that we have seen in all other applications. The first
one is due to the fact that all variables are defined for t 2 [0, tf] which is an
infinite dimensional set. The second one is that all variables are given implicitly
as the solution of the set of ODEs describing the problem. One method for
solving ODEs is to use finite differences (other methods, such as polynomial
approximations, are available, and although they are more accurate, they are
also much more complex to present). We consider a discretization of the time
domain, which is the independent variable, using n þ 1 equidistance nodes (see
Fig. 7.8). Node 1 corresponds to t ¼ 0 and node n þ 1 to t ¼ tf. Node
i corresponds to t ¼ (i 1)Δt, where Δt ¼ tnf is the distance between the
nodes. For the general ODE:
dx
¼ f ðx Þ ð7:26Þ
dt
1 X
α x ¼ f ðx i Þ ð7:27Þ
βΔt j j j
xiþ1 xi
¼ f ðx i Þ ð7:28aÞ
Δt
xiþ1 xi1
¼ f ðx i Þ ð7:28bÞ
2Δt
xi xi1
¼ f ðx i Þ ð7:28cÞ
Δt
The accuracy of the forward and backward approximations is first order with
respect to Δt, while the accuracy of the central approximation is second order.
There are more complex but more accurate approximations such as the fol-
lowing (fourth-order accuracy):
Ztiþ1
xiþ1 ¼ xi þ f ðxÞdt ð7:29Þ
ti
1
xiþ1 ¼ xi þ Δt ðf ðxi Þ þ f ðxiþ1 ÞÞ ð7:30Þ
2
Table 7.7 GAMS program for the dynamic optimization of the batch reactor
* ----------------------------------------------------
* I N I T I A L G U E S S E S
* ----------------------------------------------------
* Known bounds
x.lo('R',j)=0; x.up('R',j)=1;
x.lo('P',j)=0; x.up('P',j)=1;
x.lo('T',j)=298.15; x.up('T',j)=398.15;
u.lo(j) = 0; u.up(j) = 1;
Q.lo(j) = 0; Q.up(j) = 3600;
(continued)
336 7 Representative Optimization Problems in Chemical Engineering Solved. . .
rate.lo(j,r)=0; rate.up(j,r)=10;
* Assume constant temperature profile
x.l('T',j)=350;
* Calculate concentrations using Eulers method
x.l('R',j+1)=x.l('R',j)-dt*4000*exp(-
2500/x.l('T',j))*x.l('R',j)**2;
x.l('P',j+1)=x.l('P',j)+dt*4000*exp(-
2500/x.l('T',j))*x.l('R',j)**2-
620000*exp(-5000/x.l('T',j))*x.l('P',j);
* Calculate rates and objective function
rate.l(j,'RtoP') = 4000*exp(-2500/x.l('T',j))*x.l('R',j)**2;
rate.l(j,'PtoB') = 620000*exp(-5000/x.l('T',j))*x.l('P',j);
Obj.l=x.l('P','201');
* -INITIAL CONDITIONS (temperature is free)
x.fx('R','1')=1;
x.fx('P','1')=0;
Qð t Þ
¼ uðt Þ ¼ C 0 exp ðC 1 t Þ ð7:31Þ
Q max
This turns out to be a reasonable profile for the manipulated variable that is
easy to implement in practice. Other functional form, such as polynomial
functions of time:
Qð t Þ
¼ C0 þ C1t þ C2t2 þ . . . ð7:32Þ
Q max
are equally valid, but for this particular application, (7.31) is sufficient from the
practical point of view. It is interesting to note that we can also optimize the
value obtained by the manipulated variable at each node. This will always
result in an improved objective function, but numerical problems are expected,
while the practical application of such a sequence of numbers can be challeng-
ing in a real application.
When 201 nodes are used (Δt ¼ 1/200 ¼ 0.005), then the maximum
concentration of P that can be achieved is 0.60848860 (slightly smaller than
0.610071345 which is obtained when no specific profile is assumed). The
optimal manipulated input profile is given by (7.31) with C0 ¼ 1 and
C1 ¼ 1.32404288. The profiles of the concentrations, temperature, and heat
transfer rate are presented in Figs. 7.9, 7.10, and 7.11.
Fig. 7.9 Variation of the reactant (○) and product () concentration in the batch reactor
An interesting extension of this case study arises when the rate of heat
transfer can only obtain discrete values. In the batch reactor case study, we
may investigate the case where the heat transfer rate can obtain four discrete
values:
kJ kJ kJ
Qðt Þ 2 0, 1200 , 2400 , 3600
h h h
This situation may arise when there are three independent, identical electrical
1/3 kW resistances installed in the reactor whose state is either on or off.
When none is active, Q ¼ 0. When any one is active, then Q ¼ 1200 kJ/h, while
when any two are active, Q ¼ 2400 kJ/h. When all are active, Q ¼ 3600 kJ/h.
The manipulated variable is now defined as a function of the binary vari-
ables y(k, s) where s 2 {1,2,3,4} is the set of states for the heat input and k is the
time interval over which the manipulated variable is assumed constant:
X
Qð k Þ ¼ Qs yðk, sÞ ð7:33aÞ
s2f1, 2, 3, 4g
7.6 Optimal Design of a Renewable Energy Production System 339
X
yðk, sÞ ¼ 1, 8k ð7:33bÞ
s2f1, 2, 3, 4g
In this case study, we consider that the heat input can be changed every 12 min
or 0.2 h, and it changes at the beginning of each interval and then remains
constant until the end of the time interval.
Given the fact that we have transformed the ODEs into nonlinear algebraic
equality constraints, the introduction of binary variables transforms our model
from an NLP model to a MINLP model. The GAMS model in Table 7.8 presents a
potential implementation of a representative mixed-integer, dynamic optimi-
zation problem. The reader must study the model carefully and to realize that
the model is developed by defining time intervals over which the input remains
constant and that the intervals are connected together by equating the values
of all differential variables at the end of each interval with their values at the
beginning of the next interval. The optimal profiles are presented in Figs. 7.12,
7.13, and 7.14. The objective function obtains the value of 0.60883088 (slightly
better than the one obtained with the control profile given by (7.31)).
Table 7.8 GAMS program for the dynamic optimization of the batch reactor—discrete
inputs
TABLE n(i,r)
RtoP PtoB
CR -1 0
CP +1 -1
T 0 0;
EQUATIONS
eq1(i,j,k),eq2(i,k),eq3(i,j,k),eq4(i,j,k),eq5(j,k),eq6(j,k),eq
7(k),eq8(k),
ObjFun;
eq1(i,j,k)$(ord(j) gt 1).. x(i,j,k)=E=
x(i,j-1,k)+.5*dt*(f(i,j,k)+f(i,j-1,k));
eq2(i,k)$(ord(k) gt 1).. x(i,'1',k) =E= x(i,'41',k-1);
eq3(i,j,k)$( ord(i) ne 3).. f(i,j,k) =E=
sum( r, n(i,r)*rate(j,r,k) );
eq4(i,j,k)$(ord(i) eq 3).. f(i,j,k)=E=
(( -DHrxn('RtoP')*rate(j,'RtoP',k)-
DHrxn('PtoB')*rate(j,'PtoB',k) )*V+Q(k))/(rhoCp*V);
eq5(j,k).. rate(j,'RtoP',k)=E=
4000*exp(-2500/x('T',j,k))*x('CR',j,k)**2;
eq6(j,k).. rate(j,'PtoB',k) =E=
620000*exp(-5000/x('T',j,k))*x('CP',j,k);
eq7(k).. Q(k) =e= sum(s, QS(s)*y(k,s) );
eq8(k).. sum(s,y(k,s)) =E= 1;
ObjFun.. Obj=e= x('CP','41','5');
* Known bounds
x.lo(i,j,k)=0;x.lo('T',j,k)=298;x.up(i,j,k)=1;
x.up('T',j,k)=398.15;
(continued)
Table 7.8 (continued)
rate.lo(j,r,k)=0; rate.up(j,r,k)=4000*exp(-2500/400);
Q.lo(k)=0; Q.up(k)=3600; Q.l(k)=0;
options nlp=CONOPT4;
options mip=CPLEX;
OPTIONS minlp=sbb;
SOLVE Ray_Reactor USING MINLP MAXIMIZING Obj;
Fig. 7.12 Variation of the reactant (○) and product () concentration in the batch reactor
for optimal operation with discrete input
Fig. 7.13 Variation of the absolute temperature in the batch reactor with discrete heat input
PD t
PS t
P t
PW t
PCB t
PDG t PDB t
Fig. 7.16 Data on electricity demand for the public building (day 1 is a representative
working day in January, day 2 is a public holiday, and day is a working day in July)
day (48–72 h) to a summer day. Both these days are working days. A public
holiday (or weekend day) is also included (24–48 h) as weekends, or public
holidays account for almost 30% of a year. In a realistic application, data for a
whole year (8760 h) would have been used, but here we restrict attention to
3 representative days for clarity of presentation. As can be observed from
Fig. 7.16, electricity demand is increasing during the morning hours and
reaches a peak around midday. There is also a background electricity demand
which is around 70 kW in our case. The maximum power demand is
344 7 Representative Optimization Problems in Chemical Engineering Solved. . .
approximately 245 kW and takes place around midday of the third day. As data
are giver for each hour, we can use units of kW or kWh (this holds true only
when the data are available every hour).
The electricity demand of the building can be satisfied using the grid (PG(t))
as this is a public building connected to the national grid. However, this may
not be the cost optimal solution, or its environmental performance can be
deemed unsatisfactory. For that reason, electric power can be supplied directly
from the wind generators (PW(t)) or the PV system (PS(t)) or by the battery
(PBD(t)). If the renewable energy generators cannot meet the demand and the
grid is unavailable or using the grid is not the preferred solution, then the
diesel generator (PDG(t)) can be used. Any renewable energy that is produced
in excess of demand can be stored in the battery (PBC(t)). At any time, the
following constraint needs to be satisfied to achieve feasible operation of our
system:
where PW,R is the rated power of the wind turbine and fw is the wind avail-
ability factor which is a function of the wind velocity at the wind turbine rotor
uW(t). fW is also a function of the rated wind velocity uR, the cut-in velocity ucin
(in the range of 2–4 m/s), and the cut-out velocity ucout (in the range of
25–35 m/s). These are characteristics of each wind turbine and are supplied
by the manufacturer. A general form of fW is the following:
8
>
> 0, uW ðt Þ ucin or uW ðt Þ ucout
>
< n
uW uncin
fw ¼ PW,R n , ucin < uW ðt Þ < uR ð7:36Þ
>
> uR uncin
>
:
PW,R , uR < uW ðt Þ < ucout
I ðt Þ
PS ðt Þ ¼ PS,R ð7:37Þ
IS
7.6 Optimal Design of a Renewable Energy Production System 345
Fig. 7.17 Measured wind potential for the public building RES model optimization
Fig. 7.18 Measured solar radiation for the public building RES model optimization
where PS,R is the rated power of the solar PV array, Is is the incident radiation at
standard test conditions (1 kW/m2), and I(t) is the solar radiation incident on
the PV array (which is measured using specialized equipment). The measured
fW(t) and I(t) at the specific location of the public building under study are
presented in Figs. 7.17 and 7.18. The wind potential is not significant, while the
solar irradiation is significant during day 3 (summer day) and less significant
during day 1 (winter day).
For the diesel generator, the important characteristic is the dependence of
the diesel consumption Dcons on the diesel generator rated power PDG, R and the
electrical power output of the generator (PDG(t)):
346 7 Representative Optimization Problems in Chemical Engineering Solved. . .
where PDG,R is the rated power output of the diesel generator. d0 and d1 are
constants characteristic for each diesel generator.
The final element of the grid is the battery bank. Energy storage is vital to all
renewable energy systems as the wind potential and solar radiation are avail-
able for a limited time only, and energy storage is necessary to balance supply
and demand. The state of a battery is described by its State of Charge (SOC(t),
the level of charge of an electric battery relative to its capacity in kWh). A
simple power “balance” gives the following equation:
PBD ðt Þ
SOCðt þ 1Þ ¼ SOCðt Þ þ ηC PBC ðt Þ Δt ð7:39Þ
ηD
For the same reason (to avoid damage of the battery), the rate of charging or
discharging of the battery is restricted to be less than 10% of its rated capacity:
1
0 PBC ðt Þ SOCR ð7:41aÞ
10
1
0 PBD ðt Þ SOCR ð7:41bÞ
10
1
0 PBC ðt Þ SOCR ð7:42aÞ
10
0 PBC ðt Þ φðt ÞSOCR, max ð7:42bÞ
1
0 PBD ðt Þ SOCR ð7:42cÞ
10
0 PBD ðt Þ εðt ÞSOCR, max ð7:42dÞ
φð t Þ þ εð t Þ 1 ð7:42eÞ
φðt Þ, εðt Þ 2 f0, 1g ð7:42fÞ
7.6 Optimal Design of a Renewable Energy Production System 347
The first term in the rhs accounts for the annualized cost of installed
equipment (including equipment replacement). CCF is the capital recovery
factor. Pi,R is the rated power for the wind turbines (i ¼ W ), the PV cells
(i ¼ S), the diesel generator (i ¼ DG), or the rated capacity of the battery
bank (i ¼ B). When the rated power or capacity is multiplied by the unit
equipment cost (UCi, in $/kW rated or $/kWh rated) gives the purchase cost
of the particular equipment. To account for all costs incurring when installing
the equipment, an installation factor Insti is introduced for each type of
equipment. This factor gives the additional cost incurring when installing the
equipment as percentage of the purchase cost of the equipment. When the
equipment lifetime exceeds the lifetime of the project, then no replacement is
necessary, and λi ¼ 1. However, if the lifetime of the equipment LTi is smaller
than the lifetime of the project LTp, then replacement is necessary every LTi
years and:
1 1 1
λi ¼ 0LTi
þ 1LTi
þ ... þ
ð1 þ r Þ ð1 þ r Þ ð1 þ rÞkLTi
or:
X 1
λi ¼ ð7:44Þ
k¼0, 1, 2...:kLTi LTp ð 1 þ r ÞkLTi
The second term in the rhs accounts for the maintenance cost which we
simply assume that it is proportional to the purchase cost of the equipment
(many other options are available, but this is the simplest one).
The third term in the rhs accounts for the cost of electricity supplied by the
grid (UCel is the unit cost of electricity in $/kWh) and the cost of diesel
consumed by the diesel generator (UCDsl is the unit cost of diesel in $/L).
This term is multiplied by the ratio of the hours in a complete calendar year
348 7 Representative Optimization Problems in Chemical Engineering Solved. . .
over the time horizon of the model (in h). When data for a complete calendar
year is available, then H ¼ 365 24, and the ratio is equal to 1. We summarize
the complete model:
min
PG ðt Þ, PW ðt Þ, PS ðt Þ, PBD ðt Þ, PDG ðt Þ, PBC ðt Þ, SOCðt Þ, φðt Þ, εðt Þ
PDG,R , PW,R , PS,R , SOCR
X
Insti
Cost ¼ CCF UCi Pi,R λi þ
100
i2fW, S, DG, Bg
X Mi
þ UCi Pi,R
100
i2fW, S, DG, Bg
X 365 24
þ ðUCel PG ðt Þ þ UCDsl Dcons ðt ÞÞ
t
H
s:t:
9
PG ðt Þ þ PW ðt Þ þ PS ðt Þ þ PBD ðt Þ þ PDG ðt Þ PD ðt Þ þ PBC ðt Þ >
>
>
>
PW ðt Þ ¼ PW,R f w ðt Þ > >
>
>
>
>
>
I ðt Þ >
>
PS ðt Þ ¼ PS,R >
IS > >
>
>
>
Dcons ðt Þ ¼ d0 PDG,R þ d1 PDG ðt Þ > >
>
>
> >
>
PBD ðt Þ >
>
SOCðt þ 1Þ ¼ SOCðt Þ þ ηC PBC ðt Þ Δt > >
>
ηD >
>
>
>
=
PDG ðt Þ PDG,R
8t
>
>
0:2SOCR SOCðt Þ SOCR > >
>
>
>
>
0 PBC ðt Þ
1
SOCR > >
>
>
10 >
>
>
>
1 >
>
0 PBD ðt Þ SOCR > >
10 >
>
>
>
PBC ðt Þ φðt ÞSOCR, max > >
>
>
>
>
PBD ðt Þ εðt ÞSOCR, max > >
>
>
>
;
φð t Þ þ εð t Þ 1
PG ðt Þ, PW ðt Þ, PS ðt Þ, PBD ðt Þ, PDG ðt Þ, PBC ðt Þ, SOCðt Þ 0
PDG,R , PW,R , PS,R , SOCR 0
φðt Þ, εðt Þf0, 1g
Table 7.9 GAMS program for the optimal energy management system case study
(continued)
350 7 Representative Optimization Problems in Chemical Engineering Solved. . .
48 72.6400 0 0.0992
49 81.0240 0 0
50 81.6640 0 0.0749
51 81.1520 0 0
52 80.7680 0 0.2248
53 80.7680 0 0.4478
54 81.6640 0 0.9401
55 82.0480 0.0115 1.0000
56 83.8400 0.1195 1.0000
57 121.2200 0.3048 1.0000
58 180.8600 0.4980 1.0000
59 230.2700 0.6755 1.0000
60 244.6100 0.8201 0.7806
61 244.8600 0.9152 0.6968
62 244.2200 0.9578 0.6321
63 224.0000 0.9074 0.4017
64 193.5400 0.8576 0.3238
65 185.6000 0.7238 0.3627
66 186.3700 0.5535 0.1168
67 152.0600 0.3447 0.0181
68 132.9900 0.1577 0
69 119.3000 0.0207 0
70 112.7700 0.0000 0.0036
71 107.5200 0 0
72 98.9440 0 0.0212 ;
PD(t) = data(t,'D'); I(t) = data(t,'S'); fw(t) = data(t,'W');
SCALARS
interest interest rate /0.1/
years time horizon of the project /25/
cS unit cost of solar panels per rated kW /2000/
cW unit cost of wind turbine per rated kW /2500/
cDG unit cost of diesel generator per rated kW /150/
cB unit cost of baterry per rated kWh /200/
MS maintenance cost of PV panels in % of initial invest /1/
MW maintenance cost of wind turbines in % of init invest /1/
MDG maintenance cost of diesel gen in % of init invest. /1/
MB maintenance cost of battery in % of initial invest /1/
cel unit cost of grid electricity in $ per kWh /0.18/
cD unit cost of diesel fuel in $ per L /0.6/
hCh efficiency of battery charging /0.95/
hDCh efficiency of battery discharging /0.85/
FinstS instal expens as %of initial inv in solar panels /30/
FinstW instal expens as %of initial inv in wind turbines /20/
FinstDG instal expens as %of initial inv. diesel gen. /5/
FinstB instal expens as %of initial inv in batteries /5/
CEF_El CO2 emission for grid elec. in kgCO2 per kWh /0.750/
CEF_Dsl CO2 emission for diesel fuel in kgCO2 per L /2.900/
CEF_S CO2 emission for PV electr. in kgCO2 per kWh /0.050/
CEF_W CO2 emission for wind turb. in kgCO2 per kWh /0.035/;
(continued)
7.6 Optimal Design of a Renewable Energy Production System 351
DISPLAY TotalCO2_grid;
PARAMETER CCF capital charge factor;
CCF = interest*(1+interest)**years/((1+interest)**years-1);
POSITIVE VARIABLES
PG(t) electrical energy from the grid in kW
PS(t) electrical energy from the solar panels in kW
PW(t) electrical energy from the wind turbines in kW
PDG(t) electrical energy from the diesel generator in kW
ConsD(t) diesel consumption in L per h
PCB(t) electrical energy charging battery in kW
PDB(t) electrical energy discharging battery in kW
Pdump(t) electrical energy dumped in kW
SOC(t) battery state of charge in kWh
PSR rated power of solar panels in kW
PWR rated power of wind turbine in kW
PDGR rated power of diesel generator in kW
SOCR rated capacity of battery in kWh
TotalCO2eq kg CO2eq emitted per year in kg;
EnergyBalance(t)..
PG(t)+PS(t)+PW(t)+PDG(t)+PDB(t)=G=PD(t)+PCB(t);
SolarPanels(t).. PS(t) =E=I(t) *PSR;
WindTurbine(t).. PW(t) =E=fw(t)*PWR;
DieselGener(t).. ConsD(t) =E=0.025*PDGR+0.275*PDG(t);
StateB(t)$(ord(t)>1).. SOC(t)=E=SOC(t-1)+hCh*PCB(t-1)-PDB(t-
1)/hDCh;
InitialStateBat.. SOC('1') =E=SOC('72');
UpperDG(t).. PDG(t) =L=PDGR;
UpperB1(t).. SOC(t) =L=SOCR;
Lower1(t).. SOC(t) =G=0.2*SOCR;
UpperB2(t).. PCB(t) =L=(SOCR/10);
UpperB3(t).. PDB(t) =L=(SOCR/10);
UpperB4(t).. PCB(t) =L=1000*phi(t);
UpperB5(t).. PDB(t) =L=1000*epsilon(t);
LogicalB(t).. phi(t) + epsilon(t) =L= 1;
CostCalc.. AnnualCost=E=CCF *(
cS*PSR *(lamdaS + FinstS/100) +
cW*PWR *(lamdaW + FinstW/100) +
cDG*PDGR*(lamdaDG+FinstDG/100)+
cB*SOCR*(lamdaB + FinstB/100))
+(MS /100)*cS *PSR +(MW /100)*cW *PWR
+(MDG/100)*cDG *PDGR +(MB /100)*cB *SOCR
+ SUM(t,PG(t)*cel+ConsD(t)*cD)*365/3;
(continued)
352 7 Representative Optimization Problems in Chemical Engineering Solved. . .
UCostCalc..UnitAnnualCost=E=AnnualCost/((365/3)*SUM(t,PD(t)));
CO2emissions.. TotalCO2eq =E= SUM( t,
PG(t)*CEF_El+PS(t)*CEF_S+PW(t)*CEF_W +ConsD(t)*CEF_Dsl)*365/3;
PerCentCO2.. CO2PerCentInitial=E=100*TotalCO2eq/TotalCO2_Grid;
$ontext
* USE THIS OBJECTIVE TO DETERMINE BEST ENVIRONMENTAL
PERFORMANCE
SOLVE EnergyGrid USING MIP MINIMIZING CO2PerCentInitial;
$offtext
Fig. 7.19 Optimal profiles for the design of the RES system for minimum cost
354 7 Representative Optimization Problems in Chemical Engineering Solved. . .
Fig. 7.20 Optimal profiles for the design of the RES system for minimum CO2 emissions
7.7 Metabolic Flux Analysis 355
Metabolic flux analysis (MFA) is a powerful technique for, among others, the
determination of the fluxes through various biochemical reaction networks.
MFA can, therefore, offer assistance to studies of metabolite production. The
basis of MFA is a stoichiometric model that describes the biochemistry of a
microorganism. The stoichiometric model is developed based on a postulated
set of biochemical reactions relating consumed substrates to metabolic prod-
ucts. As this reaction network can be extremely complex, a subset of the most
relevant reactions is usually considered. Using the assumption of the pseudo-
steady state for the concentrations of the intracellular metabolites, mass
balancing around each intracellular metabolite is performed resulting in a set
of linear equality constraints:
v
S ¼0 ð7:45Þ
r
B: r 1 v1 ¼ 0 ð7:46aÞ
C: 0:5 v1 v2 v3 ¼ 0 ð7:46bÞ
356 7 Representative Optimization Problems in Chemical Engineering Solved. . .
r2
v2 D P1
r1 v1
A B C
v3
E P2
r3
D: v2 r 2 ¼ 0 ð7:46cÞ
E: 2v3 r 3 ¼ 0 ð7:46dÞ
min c T v þ dT r
v, r
" s:t:
# ð7:48Þ
v
S ¼0
r
U
vL v v
U
rL r r
max r biomass
v, r
Pyruvate metabolism
29 PEP þ CO2 ) OAA
30 PEP þ CO2 þ ADP ) OAA þ ATP
31 MAL þ NADP ) PYR þ NADPH þ CO2
32 OAA ) PYR þ CO2
Fermentation pathways
33 PYR þ NADH , LAC þ NAD
34 PYR þ CoA , FORM þ AcCoA
35 FORM þ NAD ) NADH þ CO2
36 AcCoA , AcP þ CoA
37 AcP þ ADP , ACE þ ATP
38 AcP ) ACE
39 AcCoA þ NADH ) AcAld þ NAD þ CoA
40 AcAld þ NADH ) EtOH þ NAD
41 AcAld þ NAD ) ACE þ NADH
Energy metabolism
43 3 NADH þ 3 NADP þ ATP ) 3 NAD þ 3NADPH þ ADP
44 NADPH þ NAD ) NADP þ NADH
45 NADH þ MK ) NAD MKH
359
þ 0.853 RIBO5P
þ 36.655 ATP
þ 15.754 NADPH
þ 9.284 NH3
þ 3.094 NAD
þ 2.887 AcCoA
þ 2.745 PYR
þ 1.186 AKG
þ 0.223 E4P
þ 0.495 PEP
þ 0.091 H2S
þ 0.071 F6P
þ 0.205 G6P
þ 0.129 GAP
)
1.000 Biomass
þ 2.887 CoA
þ 15.754 NADP
þ 3.094 NADH
þ 36.655 ADP
þ 1.381 CO2
Adapted from Becker et al., Biotechnology and Bioengineering, 110(11), p. 3013, 2013
Representative Optimization Problems in Chemical Engineering Solved. . .
7.7 Metabolic Flux Analysis 361
Table 7.11 The reduced set of metabolites for the metabolic network of
B. succiniciproducens
Metabolites for which pseudo-steady state is assumed
ATP Adenosine triphosphate C10H16O13P3N5 1
ADP Adenosine diphosphate C10H15O10P2N5 2
NAD Nicotinamide adenine dinucleotide C21H27N7O14P2 3
NADH 4
NADP Nicotinamide adenine dinucleotide phosphate C21H29N7O17P3 5
NADPH 6
MK Menaquinone (coenzyme Q) C59H90O4 7
MKH Menaquinol (reduced form of coenzyme Q) 8
G6P Glucose-6-phosphate C6H13O9P 9
6PG 6-phosphogluconate C6H13O10P 10
RIB5P Ribulose 5-phosphate C5H11O8P 11
XYL5P D-Xylulose 5-phosphate C5H11O8P 12
RIBO5P D-ribose 5-phosphate C5H11O8P 13
GAP Glyceraldehyde 3-phosphate C3H7O6P 14
S7P Sedoheptulose 7-phosphate C7H15O10P 15
E4P Erythrose 4-phosphate C4H9O7P 16
F6P Fructose 6-phosphate C6H13O9P 17
FBP Fructose 1,6-bisphosphate C6H14O12P2 18
DAHP Dihydroxyacetone phosphate C3H7O6P 19
PG13 1,3-Bisphosphoglycerate C3H8O10P2 20
PG3 3-Phosphoglycerate C3H7O7P 21
PG2 2-Phosphoglycerate C3H7O7P 22
PEP Phosphoenolpyruvate C3H5O6P 23
PYR Pyruvate C3H4O3 24
AcCoA Acetyl-CoA C23H38N7O17P3S 25
OAA Oxaloacetate C4H4O5 26
CIT Citrate C6H8O7 27
ICIT Isocitrate C6H8O7 28
AKG a-Ketoglutarate C5H6O5 29
SUCC-CoA Succinyl-CoA C25H40N7O19P3S 30
FUM Fumarate C4H4O4 31
MAL Malate C4H6O5 32
AcP 33
AcAld 34
H2S 35
Metabolites with positive fluxes (products)
BIOMASS 36
ACE Acetate C2H4O2 37
LAC Lactate C3H6O3 38
FORM Formate CH2O2 39
EtOH Ethanol C2H6O 40
SUCC Succinate C4H6O4 41
(continued)
362 7 Representative Optimization Problems in Chemical Engineering Solved. . .
Si 0 v
¼0
Se I r
i.e., the stoichiometric matrix has been partitioned in a part involving only
internal fluxes and a part involving both internal and external fluxes. This is not
the only option available but is handy for this case study.
The results obtained using the GAMS model of Table 7.12 are presented in
Fig. 7.23. The continuous line represents the maximum theoretical yield of the
microorganism. All experimental points are expected to lie inside the feasible
region. Maximum theoretical yields can also be obtained from the figure.
Classical PID controllers have been used for almost one century in the chemical
industry and remain the most widely used type of controllers. Their design is
normally performed through rules of thumb that are the result of accumulated
experience and innovative research work. More recently, there has been a lot of
interest in designing optimal PID controllers through classical optimization
formulations. These methodologies are usually restricted by the type of the
objective function that can be used. Classical, least squares objectives are
normally implemented as they facilitate the analytic or numerical solution of
the resulting optimization problem. In addition, apart from the requirement for
the closed loop system to be stable, there is an additional requirement that the
system possesses robustness to variability in its parameters. In other words,
the parameters of the model obtain nominal values which are obtained through
classical process identification experiments (such as step response or fre-
quency response tests). However, the parameters of the model may vary due
to changes in the environment or operating point or through ageing. The
requirement is for the closed loop system to be stable and also have acceptable
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 363
Table 7.12 GAMS program for the analysis of the metabolic capabilities of Basfia
succiniciproducens
(continued)
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 365
SO4 #46
CoA #47 CoA C21 H36 O16 P3 S
N7/;
* STOICHIOMETRY
TABLE S(m,n)
v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17
ATP -2 -4 0 0 0 0 0 0 0 0 -1 0 0 0 0 +1 0
ADP +2 +4 0 0 0 0 0 0 0 0 +1 0 0 0 0 -1 0
NAD 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0
NADH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 0 0
NADP 0 +3 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0
NADPH 0 -3 +1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0
MK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MKH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
G6P +1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0
6PG 0 0 +1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0
RIB5P 0 0 0 +1 -1 -1 0 0 0 0 0 0 0 0 0 0 0
XYL5P 0 0 0 0 +1 0 +1 0 +1 0 0 0 0 0 0 0 0
RIBO5P 0 0 0 0 0 +1 +1 0 0 0 0 0 0 0 0 0 0
GAP 0 0 0 0 0 0 -1 -1 -1 0 0 0 +1 +1 -1 0 0
S7P 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0
E4P 0 0 0 0 0 0 0 +1 +1 0 0 0 0 0 0 0 0
F6P 0 0 0 0 0 0 0 +1 -1 +1 -1 +1 0 0 0 0 0
FBP 0 0 0 0 0 0 0 0 0 0 +1 -1 -1 0 0 0 0
DAHP 0 0 0 0 0 0 0 0 0 0 0 0 +1 -1 0 0 0
PG13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 -1 0
PG3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 -1
PG2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1
PEP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PYR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AcCoA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OAA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CIT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ICIT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AKG 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SUCCCoA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FUM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MAL 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AcP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AcAld 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
H2S 0 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Biomass 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ACE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LAC 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(continued)
366 7 Representative Optimization Problems in Chemical Engineering Solved. . .
FORM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EtOH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SUCC 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ATPmain 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GLC -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CO2 0 0 0 +1 0 0 0 0 0 0 0 0 0 0 0 0 0
NH3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SO4 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CoA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34
ATP 0 +1 0 0 0 0 0 +1 0 0 0 0 +1 0 0 0 0
ADP 0 -1 0 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0
NAD 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 0 +1
0
NADH 0 0 +1 0 0 0 +1 0 0 0 +1 0 0 0 0 -1 0
NADP 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0
NADPH 0 0 0 0 0 +1 0 0 0 0 0 0 0 +1 0 0 0
MK 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0
MKH 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0
G6P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6PG 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RIB5P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
XYL5P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RIBO5P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GAP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S7P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
E4P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
F6P 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FBP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DAHP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PG13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PG3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PG2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PEP +1 -1 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0
PYR 0 +1 -1 0 0 0 0 0 0 0 0 0 0 +1 +1 -1 -1
AcCoA 0 0 +1 -1 0 0 0 0 0 0 0 0 0 0 0 0 +1
OAA 0 0 0 -1 0 0 0 0 0 0 +1 +1 +1 0 -1 0 0
CIT 0 0 0 +1 -1 0 0 0 0 0 0 0 0 0 0 0 0
ICIT 0 0 0 0 +1 -1 0 0 0 0 0 0 0 0 0 0 0
AKG 0 0 0 0 0 +1 -1 0 0 0 0 0 0 0 0 0 0
SUCCCoA 0 0 0 0 0 0 +1 -1 0 0 0 0 0 0 0 0 0
FUM 0 0 0 0 0 0 0 0 +1 -1 0 0 0 0 0 0 0
MAL 0 0 0 0 0 0 0 0 0 +1 -1 0 0 -1 0 0 0
AcP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AcAld 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
H2S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Biomass 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ACE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LAC 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 0
FORM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1
EtOH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SUCC 0 0 0 0 0 0 0 +1 -1 0 0 0 0 0 0 0 0
ATPmain 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GLC 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CO2 0 0 +1 0 0 +1 +1 0 0 0 0 -1 -1 +1 +1 0 0
NH3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SO4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CoA 0 0 -1 +1 0 0 -1 +1 0 0 0 0 0 0 0 0 -1
+ v35 v36 v37 v38 v39 v40 v41 v42 v43 v44 v45 v46
ATP 0 0 +1 0 0 0 0 -36.655 -1 0 0 -1
ADP 0 0 -1 0 0 0 0 +36.655 +1 0 0 +1
NAD -1 0 0 0 +1 +1 -1 -3.094 +3 -1 +1 0
(continued)
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 367
NADH +1 0 0 0 -1 -1 +1 +3.094 -3 +1 -1 0
NADP 0 0 0 0 0 0 0 +15.754 -3 +1 0 0
NADPH 0 0 0 0 0 0 0 -15.754 +3 -1 0 0
MK 0 0 0 0 0 0 0 0 0 0 -1 0
MKH 0 0 0 0 0 0 0 0 0 0 +1 0
G6P 0 0 0 0 0 0 0 -0.205 0 0 0 0
6PG 0 0 0 0 0 0 0 0 0 0 0 0
RIB5P 0 0 0 0 0 0 0 0 0 0 0 0
XYL5P 0 0 0 0 0 0 0 0 0 0 0 0
RIBO5P 0 0 0 0 0 0 0 -0.853 0 0 0 0
GAP 0 0 0 0 0 0 0 -0.129 0 0 0 0
S7P 0 0 0 0 0 0 0 0 0 0 0 0
E4P 0 0 0 0 0 0 0 -0.223 0 0 0 0
F6P 0 0 0 0 0 0 0 -0.071 0 0 0 0
FBP 0 0 0 0 0 0 0 0 0 0 0 0
DAHP 0 0 0 0 0 0 0 0 0 0 0 0
PG13 0 0 0 0 0 0 0 0 0 0 0 0
PG3 0 0 0 0 0 0 0 -1.221 0 0 0 0
PG2 0 0 0 0 0 0 0 0 0 0 0 0
PEP 0 0 0 0 0 0 0 -0.495 0 0 0 0
PYR 0 0 0 0 0 0 0 -2.745 0 0 0 0
AcCoA 0 -1 0 0 -1 0 0 -2.887 0 0 0 0
OAA 0 0 0 0 0 0 0 -1.724 0 0 0 0
CIT 0 0 0 0 0 0 0 0 0 0 0 0
ICIT 0 0 0 0 0 0 0 0 0 0 0 0
AKG 0 0 0 0 0 0 0 -1.186 0 0 0 0
SUCCCoA 0 0 0 0 0 0 0 0 0 0 0 0
FUM 0 0 0 0 0 0 0 0 0 0 0 0
MAL 0 0 0 0 0 0 0 0 0 0 0 0
AcP 0 +1 -1 -1 0 0 0 0 0 0 0 0
AcAld 0 0 0 0 +1 -1 -1 0 0 0 0 0
H2S 0 0 0 0 0 0 0 -0.091 0 0 0 0
Biomass 0 0 0 0 0 0 0 +1 0 0 0 0
ACE 0 0 +1 +1 0 0 +1 0 0 0 0 0
LAC 0 0 0 0 0 0 0 0 0 0 0 0
FORM -1 0 0 0 0 0 0 0 0 0 0 0
EtOH 0 0 0 0 0 +1 0 0 0 0 0 0
SUCC 0 0 0 0 0 0 0 0 0 0 0 0
ATPmain 0 0 0 0 0 0 0 0 0 0 0 +1
GLC 0 0 0 0 0 0 0 0 0 0 0 0
CO2 +1 0 0 0 0 0 0 +1.381 0 0 0 0
NH3 0 0 0 0 0 0 0 -9.284 0 0 0 0
SO4 0 0 0 0 0 0 0 0 0 0 0 0
CoA 0 +1 0 0 +1 0 0 +2.887 0 0 0 0 ;
$ONTEXT
v(42) is the biomass production and corresponds to g of biomass
per mmol => biomass production per mol of glucose
is given by v42 * 1000/|v(Glucose)|
$OFFTEXT
* positive fluxes
r.lo('Biomass')=0; r.lo('ACE')=0; r.lo('LAC')=0; r.lo('FORM')=0;
(continued)
368 7 Representative Optimization Problems in Chemical Engineering Solved. . .
PUT out;
PUTCLOSE out;
performance not only for the nominal values of its parameters but for all
potential values of its uncertain parameters.
In this section, we will consider the case of low-order mathematical models,
commonly used to describe chemical process dynamics, such as:
First-order plus deadtime (FOPDT) model:
Y ð sÞ k
Gðs; k, τ, dÞ ¼ ¼ eds ð7:49Þ
U ðsÞ τs þ 1
Y ðsÞ k ds
Gðs; k, dÞ ¼ ¼ e ð7:50Þ
U ð sÞ s
Y ð sÞ k
Gðs; k, τ, ζ, dÞ ¼ ¼ eds ð7:51Þ
U ðsÞ τs2 þ 2ζτs þ 1
where k is the gain of the process, τ is the dominant time constant, ζ is the
damping coefficient of the second-order system, and d is the deadtime (or time
delay) of the process (see Kravaris & Kookos, Understanding Chemical Process
Dynamics and Control, CUP, 2021, for the physical meaning of these
parameters).
All these low-order models can be used to capture the dynamics of the
majority of chemical process systems and can be stated in the time domain
using the following state-space form with input delay:
dxðt Þ
¼ Axðt Þ þ buðt dÞ ð7:52aÞ
dt
yðt Þ ¼ cx ðt Þ ð7:52bÞ
where A is a constant matrix and b and c are constant vectors. For a FOPDT
system, for instance, the state-space model obtains the following form:
dxðt Þ 1 k
x ðt Þ þ u ðt d Þ ð7:53aÞ
dt τ τ
y ðt Þ ¼ x ðt Þ ð7:53bÞ
dx ðt Þ
¼ Ax ðt Þ þ buðt Þ ð7:54aÞ
dt
yðt Þ ¼ cxðt dÞ ð7:54bÞ
dxðt Þ 1 k
xðt Þ þ uðt Þ ð7:55aÞ
dt τ τ
y ðt Þ ¼ x ð t d Þ ð7:55bÞ
The solution of the linear differential equation (7.54a) for given initial
conditions x(0) and constant input u can be obtained through several alterna-
tive methods with the simplest to be through the use of the integrating factor
e2At. We first multiply both sides of (7.54a) by the integrating factor:
dx ðt Þ
e 2 At e 2 At Ax ðt Þ þ e 2 At buðt Þ
dt
dðe 2 At x ðt ÞÞ
¼ e 2 At buðt Þ
dt
We integrate the last equation between 0 and an arbitrary time t with constant
input u ¼ u(0), to obtain:
0 1
Zt
θ¼t
e 2 Aθ x ðθÞ θ¼0
¼@ e 2 Aθ dθ bA u
0
or:
0 1
Zt
x ðt Þ ¼ eAt x ð0Þ þ @ e 2 Aðt 2 θÞ dθ bA u
0
We may follow exactly the same approach to integrate the differential equation
between time t and t þ Ts to obtain:
0 tþT 1
Z s
x ðt þ T s Þ ¼ eAT s x ðt Þ þ @ e 2 Aðt 2 θÞ dθ bA uðt Þ ð7:56Þ
t
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 371
where u(t) is the input at time t which remains constant in the interval [t, t þ Ts).
We will use the index n to denote the time point with the understanding that
t ¼ n Ts and t þ Ts ¼ (n þ 1)Ts. We may therefore express the analytic solution
of the differential equation (7.54a) in the following discrete form:
ZT s
Ad ¼ e AT s
, bd ¼ b eAðT s 2 θÞ dθ ð7:58Þ
0
For the FOPDT system, for instance, A 1/τ, and b ¼ k/τ (scalars), and
performing the integration, we obtain:
A d ¼ e τ , b d ¼ k 1 e τ
Ts Ts
ð7:59Þ
i.e., the discrete solution of the FOPDT system to a constant input is given by:
xðn þ 1Þ ¼ e τ xðnÞ þ k 1 e τ uðnÞ
Ts Ts
ð7:60aÞ
For the case of input delay, the equivalent discrete form of the dynamics is:
xðn þ 1Þ ¼ e τ xðnÞ þ k 1 e τ uðn δÞ
Ts Ts
ð7:61aÞ
X
N
min y y ðn Þ ð7:62Þ
sp
xðnÞ, yðnÞ, uðnÞ
n¼1
where tf ¼ N Ts is the final time of the simulation. The absolute values of the
deviations are a more useful measure of system performance when compared
372 7 Representative Optimization Problems in Chemical Engineering Solved. . .
X
N X
N
min y yðnÞ þ ρ juðnÞ uðn 1Þj ð7:63Þ
sp
xðnÞ, yðnÞ, uðnÞ
n¼1 n¼1
Note that the objective function has been multiplied by the sampling time Ts to
approximate the continuous time integration.
Formulation (7.64) is an optimistic approach as no special structure has
been assumed for the control law. Classical feedback control laws have the
drawback that they react after detecting the deviation of the output from the
reference signal or set point. This feedback structure is vital to the practical
implementation but results in a suboptimal control variation when compared
to the results of Formulation (7.64).
The GAMS implementation of Formulation (7.64) is presented in Table 7.13
for a FOPDT process with τ ¼ d ¼ 1 s and k ¼ 1. The results obtained are shown
in Fig. 7.24. Note that the controller acts as a predictive controller and rumps
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 373
Table 7.13 GAMS program for the open-loop optimal control of a FOPDT system
Duplus.up(n) =+Dumax*Ts;
Duminus.up(n)=+Dumax*Ts;
u.up(n) = umax;
u.lo(n) = umin;
x.fx('0')=0;
Fig. 7.24 Open-loop optimal control of a FOPDT system with τ ¼ 1, k ¼ 1, and d ¼ 1 with
rate and bound constraints on the control (sampling time Ts ¼ 0.1)
where kc (the controller gain) and τI (the integral time) are the two adjustable
parameters of the PI controller. For t ¼ t þ Ts we have that:
0 1
Z s
tþT
1
uðt þ T s Þ ¼ kc @eðt þ T s Þ þ eðθÞdθ A
τI
0
0 1
Zt Z s
tþT
1 1
¼ k c @e ð t þ T s Þ þ eðθÞdθ þ eðθÞdθ A
τI τI
0 t
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 375
The input remains constant between t and t þ Ts, and if assumed equal to its
value at t þ Ts, we obtain the discrete form of a PI controller (usually called the
velocity form of a PI controller):
Ts
uðn þ 1Þ ¼ uðnÞ þ k c eðn þ 1Þ eðnÞ þ eðn þ 1Þ
τI
Duplus.up(n) =+Dumax*Ts;
Duminus.up(n)=+Dumax*Ts;
u.up(n) = umax;
u.lo(n) = umin;
x.fx('0')=0;
k_c.l = k;
invtau_I.l =1/tau;
MODEL FOPDT_CLOSED_LOOP_PI /ALL/;
OPTION NLP=CONOPT4;
SOLVE FOPDT_CLOSED_LOOP_PI USING NLP MINIMIZING ObjFun;
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 377
Fig. 7.25 Closed loop optimal control of a FOPDT system with τ ¼ 1, k ¼ 1, and d ¼ 1 with
rate and bound constraints on the control (sampling time Ts ¼ 0.1, optimal controller
parameters kc ¼ 0.06493670 and τI ¼ 0.18519845)
Fig. 7.26 Closed loop control of a FOPDT system with τ ¼ 1, k ¼ 2, and d ¼ 2 with rate and
bound constraints on the control (sampling time Ts ¼ 0.1, controller parameters
kc ¼ 0.06493670 and τI ¼ 0.18519845 which are optimal for τ ¼ 1, k ¼ 1 and d ¼ 1)
ð1 þ τ I s Þ k
LðsÞ ¼ k c eds ð7:69Þ
τI s ðτs þ 1Þ
π
argfLðω; kc , τI , k, τ, dÞg þ tan 1 ðωτI Þ ωd tan 1 ðωτÞ ð7:71Þ
2
The phase crossover frequency ωp is the frequency at which the phase of the
loop transfer function L(s) ¼ Gc(s)G(s) (Gc(s) is the transfer function of the
controller and G(s) is the transfer function of the process) becomes equal to
180 .
π
þ tan 1 ωp τI ωp d tan 1 ωp τ ¼ 0 ð7:72aÞ
2
π
PM ¼ þ tan 1 ωg τI ωg d tan 1 ωg τ ð7:72dÞ
2
0 PMðks , τs , ds Þ, s ¼ 1, 2, . . . , N s ð7:73aÞ
1 GMðks , τs , ds Þ, s ¼ 1, 2, . . . , Ns ð7:73bÞ
The minimum values are normally selected to be GMmin ¼ 1.7 and PMmin ¼ 30
or π/6.
By adding constraints (7.73) and (7.74) to the optimal PI parameter selec-
tion formulation (7.68), we obtain the mathematical formulation for optimizing
the nominal performance of the closed loop system while ensuring stability for
all potential values of the FOPDT model parameters. There is a more demand-
ing and challenging approach in which Formulation (7.68) is applied for all
potential model parameters. A new performance criterion is defined which is a
weighted sum of the values of the performance criterion for all potential
realizations of the model parameters. This is the most comprehensive
approach but can be computationally intensive. Using Eq. (7.74), acceptable
performance is expected even for the worst case combination of the parame-
ters of the FOPDT model.
The GAMS model that implements Formulation (7.68) with the additional
stability and robustness constraints (7.72) and (7.74) is presented in
Table 7.15. The solution of the problem for the FOPDT system:
Y ð sÞ k
GðsÞ ¼ ¼ eds ð7:75Þ
U ðsÞ τs þ 1
0:5 k, τ, d 1:5
MODEL FOPDT_CLOSED_LOOP_robustPI/ALL/;
OPTION NLP=CONOPT4;
SOLVE FOPDT_CLOSED_LOOP_robustPI USING NLP MINIMIZING ObjFun;
382 7 Representative Optimization Problems in Chemical Engineering Solved. . .
Fig. 7.27 Parameters of the FOPDT system for the closed loop simulations shown in Fig. 7.28
Fig. 7.28 Closed loop dynamics of the FOPDT system with model parameters shown in
Fig. 7.27
7.8 Optimal Design of Proportional-Integral-Derivative (PID) Controllers 383
then formed using the optimal PI controller parameters, and the closed loop
system is simulated. In this way, Fig. 7.28 is created (the white line shows the
response of the nominal system). The overall performance of the FOPDT
system and the optimal PI controller is more than satisfactory.
It is important to stress at this point that many researchers have proposed
using mathematical programming formulations for designing classical and
modern control laws using computational methods, but the acceptance from
the community is limited. Despite the fact that the mathematical programming
approach is theoretically consistent and very powerful, the control community
insists on accepting only methodologies that can offer results in closed form.
This is unfortunate as the methodologies that do offer results in closed form
are based on very limiting assumptions and their practical usefulness is
questionable.
Before concluding this interesting application, we will present the solution
to a closely related problem. Assume that we have a low-order model for a
process and we have designed a controller for the nominal system. An inter-
esting question of great practical value is the following: What is the minimum
combined variation of the model parameters that drives the system to the
verge of instability? Note that the problem now is to determine the parameters
of the model for a fixed controller that results in an unstable closed loop
system. We are, more specifically, looking for the parameters that cause
instability, but their scaled distance from the nominal values is minimal:
where wk, wτ, and wd are the scaling parameters (which can be selected to be
wk ¼ 1/kN, wτ ¼ 1/τN, and wd ¼ 1/dN). When the systems is at the verge of
instability, its GM is one when the phase is π (i.e., |L(ωc)| ¼ 1, and arg
{L(ωc} π, or GM ¼ 1 and PM ¼ 0 must hold simultaneously).
Table 7.16 GAMS program for the closed loop stability analysis of FOPDT system and PI
control
SCALAR pi /3.14159265/;
VARIABLES L2normSq;
Magn.. k*kc*sqrt(1+(wc*tauI)**2)-wc*tauI*sqrt(1+(wc*tau)**2)
=E=0;
Phase.. pi/2+arctan(wc*tauI)-wc*d-arctan(wc*tau) =E=0;
Obj.. L2normSq =E= power(k/kN-1,2)+power(tau/tauN-1,2)+
power(d/dN-1,2);
The designer needs to decide at this point whether the distance from the
instability is sufficient for the system under study. The decision is usually
based on the experience, how critical the process unit is (if this is an unstable
reactor with the potential of a run-away reaction we may need to go back to the
controller design step and sacrifice performance for improving the robust-
ness), and the uncertainty in the low-order model relative to the actual process.
7.9 The Control Structure Selection Problem 385
In Fig. 7.29, a mixing tank process is presented. A hot stream with temperature
TH and volumetric flow rate FH and a cold stream with temperature TC and
volumetric flow rate FC are fed to a mixing tank together with a process stream
with temperature Td and volumetric flow pffiffiffirate Fd. The volumetric flow rate of
the product stream is given by F ¼ k h , where k is a constant. We can
manipulate the hot and the cold stream with the aim to achieve given specifi-
cation (or set point value) on the temperature of the product stream T. The
liquid level in the tank (h) needs also to remain within certain bounds for
avoiding overflow of the tank. The tank has constant cross-sectional area (Ac),
while the density and heat capacity of all streams are constant. The objective is
to design an optimal decentralized proportional controller (optimal in terms of
structure and parameters) that uses the two manipulated variables (FH and FC)
to control the two controlled variables (T and h).
The problem of selecting the best decentralized multivariable controller is
both a structural and parametric optimization problem. There are six potential
control structures (two 2 2 control structures and four 1 1 structures) in
addition to the open-loop (no control) structure:
Structure 1: FH ! T & FC ! h
Structure 2: FH ! h & FC ! T
Structure 3: FH ! T
Structure 4: FH ! h
Structure 5: FC ! T
Structure 6: FC ! h
There is also the need to determine, for each alternative control structure, the
optimal parameters of the controllers. We may follow a complete enumeration
approach in which each structure is evaluated, and then they are compared to
386 7 Representative Optimization Problems in Chemical Engineering Solved. . .
determine the best overall structure. This strategy will work for this small
problem, but the alternative structures increase very fast with the number of
inputs and outputs.
We can formulate the problem of control structure selection as an optimi-
zation problem. To achieve that, we need a performance criterion and a
methodology to describe mathematically the alternative control structures.
We can then solve the problem using classical mathematical programming
techniques.
The first problem is how to select an appropriate performance criterion so
as to efficiently evaluate the alternative control structures. This is clearly a very
complex and multifaceted problem and has no easy solution. The ideal perfor-
mance criterion is related to (in one way or another) the process economics
and the cost of building a process unit or the cost of operating the unit. For the
small case study that we investigate, we will use a more humble criterion that
is based on the squared deviation of the two controlled variables from their set
points hsp and Tsp:
Zt¼H " 2 #
hðt Þ hsp T ðt Þ T sp 2
min þ dt ð7:78Þ
controller structure hsp T sp
and parameters t ¼0
The second problem that we face is the definition of the scenario under
which we will determine what is the optimal structure. In other words, we
need to define the time variation of the uncertain parameters and disturbances
that will cause the controlled variables to deviate from their desired values.
This is also a very important and complex issue as the best control structure
can depend on the assumed scenario. For demonstration purposes and for our
small case study, we will consider a relatively simple scenario: step change in
the set point of one of the controlled variables.
We now present the mathematical formulation of the problem. We first
develop the mathematical model of the process that consists of the material
and energy balance:
dh pffiffiffi
Ac ¼ FH þ FC þ Fd k h ð7:79Þ
dt
dT
Ac h ¼ F H ðT H T Þ þ F C ð T C T Þ þ F d ð T d T Þ ð7:80Þ
dt
where subscript s denotes steady-state values and kFH,h, kFH,T, kFC,h, and kFC,T
are the controller gains. The controller description is not complete as we need
to express the logical condition that the controller needs to be a decentralized
controller. To this end, we define the binary variables ymn to denote that
manipulated variable m (m2{FH, FC}) is used to control the controlled variable
n (n2{h, T}). The following inequality constraints enforce a decentralized
control structure:
Equations (7.83)–(7.86) ensure that when ymn ¼ 0, then kmn ¼ 0, while kmn can
obtain any value in [BM,BM] when ymn ¼ 1, where BM is a sufficient large
positive constant. Equations (7.87) and (7.88) ensure that each manipulated
variable is assigned to at most one controlled variable. Equations (7.89) and
(7.90) ensure that at most one manipulated variable is selected for each
controlled variable.
To have a complete mathematical description, we need to define the initial
conditions of the system which is assumed to be initially at steady state:
pffiffiffiffi
F H,s þ F C,s þ F d,s k hs ¼ 0 ð7:92Þ
F H,s ðT H,s T s Þ þ F C,s ðT C,s T s Þ þ F d,s ðT d,s T s Þ ¼ 0 ð7:93Þ
where hs, Ts, TH,s, TC,s, Fd,s, and Td,s are known at the initial steady state. hsp and
Tsp are also known functions of time. The unknowns are the variables ymn, kmn,
h(t), and T(t). ymn and kmn are obtained from the solution of the resulting
optimization formulation and define the best control structure and its param-
eters. h(t) and T(t) are determined from the solution of the differential equa-
tion for a given control structure and parameters.
To demonstrate the application of the control structure selection formula-
tion, we consider that the mixing tank is initially at steady state with
hs ¼ hsp ¼ 6.25 m and Ts ¼ Tsp ¼ 25 C and that the set point temperatures
388 7 Representative Optimization Problems in Chemical Engineering Solved. . .
changes for t > 0 to Tsp ¼ 30 C. The cross-sectional area of the tank (Ac ¼ 1),
the constant of the output flow rate (k ¼ 3 m5/2/min), the temperature of the
hot and cold streams (TH ¼ 65 C, TC ¼ 15 C), and the flow rate and
temperature of the process stream (Fd ¼ 1 m3/min, Td ¼ 40 C) remain
constant (i.e., only the temperature set point varies). The GAMS model
presented in Table 7.17 is created, and the control structure selection problem
is solved. The best integer solution is the following:
Integer cuts are then added to find the remaining promising structures:
We note that the two structures that use both manipulated variables to
control both controlled variables are significantly better than the two struc-
tures that use either FH or FC to control only the temperature T. The fifth best
structure is the open-loop (or no control) structure. Needless to say that any
solution that does not control the level of the liquid in the tank is not acceptable
from the practical point of view as overflow is highly possible.
Learning Summary
Problems
7.1 Investigate the effect that the minimum pressure has on the economics
of the single evaporator process (assume that the minimum pressure
can be varied in the range 0.1–1 bar). Explain why the minimum always
corresponds to the minimum pressure.
7.2 The single-effect evaporator has been optimized using the CONOPT4
solver. Compare the performance of CONOPT4 with other NLP solvers
(SNOPT, MINOS, BARON, KNITRO, etc.). Generate a table to compare
their performance.
7.3 Increase the number of evaporators in the program of Table 7.3. What is
the optimum number of effects? Prepare a short report.
7.4 Use the GAMS program of Table 7.6 to determine the optimal design for
the case where the top purity varies from 0.9 to 0.999. Make a plot of the
main process variables as a function of the purity of the top product.
What do you observe?
7.5 For the batch reactor optimization problem and its implementation in
GAMS (Table 7.7), study the cases of a linear and then a quadratic profile
for the manipulated variable, and compare your results with the results
obtained using the exponentially decreasing profile.
7.6 Start with the GAMS program given in Table 7.8, and increase the
number of elements and nodes. What is the best objective that you can
achieve? How does it compare with the optimal value of 0.610071345?
Was the improvement obtained worth the effort (from the practical
implementation point of view)?
7.7 Solve the following optimal control problem (Goh & Teo, Automatica,
24(1), pp. 3–18, 1988), and compare your results with the optimal
solution reported in the literature.
Z 1
min J ¼ x21 ðt Þ þ x22 ðt Þ þ 0:005u2 ðt Þ dt
uðt Þ 0
s:t:
x_ 1 ðt Þ ¼ x2 ðt Þ
x_ 2 ðt Þ ¼ x2 ðt Þ þ uðt Þ
x2 ðt Þ 8ðt 0:5Þ2 þ 0:5 0, 8t
x ð0Þ ¼ 0 1 T
Z 1
min J ¼ x2 ðt Þ þ u2 ðt Þ dt
uðt Þ 0
s:t:
dxðt Þ
¼ uðt Þ, xð0Þ ¼ 1
dt
7.9 Several investigators have proposed to use monetary values for the CO2
emission so as to account for the financial and social impact of pollution
on the human health and on the environment. The values that have been
suggested vary over several orders of magnitude and range from 0.02 $/
kg CO2eq (20 $/t CO2eq) up to 650 $/kg CO2eq. Modify the GAMS program
of Table 7.9 so as to be able to minimize a combined objective function
that incorporates the unit electricity cost and the cost of the CO2eq
emissions. Use the indicative value of 0.1 $/kg CO2eq, and present the
solution obtained.
7.10 Ladakis et al. (Biochemical Engineering Journal, 137, p. 262, 2018) have
studied experimentally and theoretically the metabolic capabilities of
Actinobacillus succinogenes and Basfia succiniciproducens grown on
spent sulfite for succinic acid production. The metabolic network of
B. succiniciproducens was modified in order to obtain the metabolic
pathway of A. succinogenes. A. succinogenes lacks a complete TCA cycle
resulting in only one pathway for succinate production (nonexistent
reactions, reactions 22, 23, 24, and 33 in Fig. 7.22). Collect all information
necessary, and propose modifications of the GAMS model of Table 7.12 to
produce the theoretical maximum yields of A. succinogenes (see Fig 7.23)
when grown on glucose. The equation for biomass production for
A. succinogenes is the following:
7.11 The following reactions are taking place in a batch reactor of constant
volume:
k1
A!B
k2
B!C
k3
AþB!BþB
392 7 Representative Optimization Problems in Chemical Engineering Solved. . .
k4
AþB!BþC
k5
AþB!BþD
where ki, i ¼ 1,2,. . .,5 are the reaction rate constants given by:
E
k i ¼ k 0i exp i
RT
k0i are the pre-exponential constants, R the ideal gas constant, and Ei the
activation energy. Values for these constants are given in the table that
follows:
698:15 T ðt Þ 748:15
dC A ðt Þ
k 1 C A ðt Þ ðk3 þ k4 þ k5 ÞC A ðt ÞC B ðt Þ
dt
dC B ðt Þ
¼ þ k 1 C A ðt Þ þ k 3 C A ðt ÞC B ðt Þ k 2 C B ðt Þ
dt
mol
C A ð0Þ ¼ 1 , C B ð0Þ ¼ 0
L
0 1
Zt
1 deðt ÞA
u ð t Þ ¼ k c @e ðt Þ þ eðθÞdθ þ τD ð7:650 Þ
τI dt
0
is given by:
Modify the GAMS model given in Table 7.14 to incorporate the D part
of the controller, and also eliminate the rate constraints on the input.
Perform the optimization. Compare the results obtained using optimal
open-loop, P, PI, and PID controller. Does the PID controller significantly
improve the performance for the system as compared to an optimal PI
controller (this is a usual argument in the literature)?
Appendix A: Introduction to MATLAB®
Introduction
>> x=2
x=
2
>> y=5
y=
5
© The Editor(s) (if applicable) and The Author(s), under exclusive license 395
to Springer Nature Switzerland AG 2022
I. K. Kookos, Practical Chemical Process Optimization, Springer Optimization
and Its Applications 197, https://doi.org/10.1007/978-3-031-11298-0
396 Appendix A: Introduction to MATLAB®
You can then multiply (*), divide (/), add (+), and subtract (-) x and y:
>> x*y
ans =
10
>> x/y
ans =
0.4000
>> x+y
ans =
7
>> x-y
ans =
-3
>> x^y
ans =
32
>>
>> 2*5
ans =
10
>> 2+5;
>>
Appendix A: Introduction to MATLAB® 397
In the same way, we may define vectors and matrices in MATLAB. To define
the vector x and the table A
2 3 2 3
1 1 2 3
6 7 6 7
x = 4 3 5, A = 4 4 5 65
7 7 8 9
>> x=[1;3;7]
x=
1
3
7
>> A=[1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
>>
>> A*x
ans =
28
61
94
>> x*A
Error using *
C ij = Aij ± Bij
>> n=4;
>> m=3;
>> A=ones(n,m)
A=
1 1 1
1 1 1
1 1 1
1 1 1
>> B=zeros(n,m)
B=
0 0 0
0 0 0
0 0 0
0 0 0
>> I=eye(n)
I=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
A - 1 A = AA - 1 = I
Appendix A: Introduction to MATLAB® 399
A=
1 4 3
2 9 6
7 8 5
>> inv(A)*A
ans =
1.0000 0 -0.0000
0 1.0000 0
-0.0000 -0.0000 1.0000
>> A*inv(A)
ans =
1.0000 0 -0.0000
0 1.0000 -0.0000
0 0 1.0000
A=
1 2 3
4 5 6
>> B=A'
B=
1 4
2 5
3 6
[V,D] = eig(A) Computes the eigenvalues (diagonal elements of V) and the eigenvec-
tors (columns of D) of A
d = det(A) Computes the determinant of A
400 Appendix A: Introduction to MATLAB®
A x=b
x=
0.2500
0
0.2500
or
>> x=inv(A)*b
x=
0.2500
0
0.2500
The same can be performed symbolically using the syms command from the
symbolic toolbox:
A=
[ a, b]
[ c, d]
>> inv(A)
ans =
[ d/(a*d - b*c), -b/(a*d - b*c)]
[ -c/(a*d - b*c), a/(a*d - b*c)]
>> det(A)
(continued)
Appendix A: Introduction to MATLAB® 401
ans =
a*d - b*c
>> eig(A)
ans =
a/2 + d/2 - (a^2 - 2*a*d + d^2 + 4*b*c)^(1/2)/2
a/2 + d/2 + (a^2 - 2*a*d + d^2 + 4*b*c)^(1/2)/2
which gives the analytic expression for the inverse, determinant, and eigen-
values of a 2-by-2 matrix.
The clear command can be used at any point to clear the variables from
the workspace. Other useful commands are the who, whos, and the help
commands:
>> who
Your variables are:
A a ans b c d
>> whos
Name Size Bytes Class Attributes
A 2x2 8 sym
a 1x1 8 sym
ans 2x1 8 sym
b 1x1 8 sym
c 1x1 8 sym
d 1x1 8 sym
>> clear
>> who
>> whos
>> help clear
clear Clear variables and functions from memory.
clear removes all variables from the workspace.
clear VARIABLES does the same thing.
clear GLOBAL removes all global variables.
clear FUNCTIONS removes all compiled MATLAB and MEX-functions.
Calling clear FUNCTIONS decreases code performance and is usually
unnecessary.
For more information, see the clear Reference page.
x=
0 1 2 3 4 5 6 7 8 9 10
>> logspace(-2,2,5)
ans =
0.0100 0.1000 1.0000 10.0000 100.0000
There is a wide set of build in functions available in MATLAB, and the most
commonly used are the following:
Appendix A: Introduction to MATLAB® 403
We may use sin and cos to calculate the values of sin and cos for x=[0 π/6 π/
3 π/2]:
>> clear
>> x=pi*[0 1/6 1/3 1/2];
>> sin(x)
ans =
0 0.5000 0.8660 1.0000
>> cos(x)
ans =
1.0000 0.8660 0.5000 0.0000
Note that as x is defined as a row vector, sin(x) and cos(x) are row
vectors as well. It is more informative if we use the plotting facilities in
MATLAB to plot sin(x) and cos(x). The basic plotting command in MATLAB is
plot(x,y):
>> clear
>> x=linspace(0,2*pi,101);
>> plot(x,sin(x))
404 Appendix A: Introduction to MATLAB®
The figure generated needs improvement which can be achieved using the
following commands (in case their effect is not obvious to the reader, then use
the help command to explore them further—observe also their effect on the
figure produced when they are applied)
>> plot(x,sin(x),'k-','Linewidth',1.2)
>> grid on
>> axis tight
>> xlabel('x')
>> ylabel('sin(x)')
>> title('Sin(x)')
>> hold on
>> plot(x(1:10:length(x)),sin(x(1:10:length(x))),'ko')
We may plot both the sin(x) and the cos(x) in the same figure:
>> figure(2)
>> plot(x,sin(x),'k-','Linewidth',1.2)
>> hold on
>> plot(x,cos(x),'k--','Linewidth',1.2)
>> xlabel('x')
(continued)
Appendix A: Introduction to MATLAB® 405
>> figure(3)
>> subplot(2,1,1)
>> plot(x,sin(x),'k-','Linewidth',1.2)
>> xlabel('x')
>> ylabel('sin(x)')
>> grid on
>> axis tight
>> subplot(2,1,2)
>> plot(x,cos(x),'k-','Linewidth',1.2)
>> grid on
>> xlabel('x')
>> ylabel('cos(x)')
>> axis tight
406 Appendix A: Introduction to MATLAB®
Other plotting commands are the bar, stems, and stairs commands:
>> figure(4)
>> x=linspace(0,2*pi,21);
>> subplot(3,1,1)
>> bar(x,sin(x))
>> title('Subplot 1-1-bar')
>> subplot(3,1,2)
>> stem(x,sin(x))
>> title('Subplot 2-1-stem')
>> subplot(3,1,3)
>> stairs(x,sin(x))
>> title('Subplot 3-1-stairs')
Appendix A: Introduction to MATLAB® 407
y yellow
m magenta
c cyan
r red
g green
b blue
w white
k black
. point
v triangle (down)
o circle
^ triangle (up)
x x-mark
< triangle (left)
+ plus
> triangle (right)
* star
p pentagram
s square
408 Appendix A: Introduction to MATLAB®
h hexagram
d diamond
It is also possible to control the line style using one of the following options:
- solid
: dotted
-. dashdot
-- dashed
>> clear
>> x=linspace(-8,8,21);
>> y=linspace(-8,8,21);
>> [X,Y]=meshgrid(x,y);
>> plot(X,Y,'ko')
>> xlabel('x');
>> ylabel('y')
>> grid on
Appendix A: Introduction to MATLAB® 409
(note that MATLAB is case sensitive, i.e., x and X are different variables). Then
the surface of the function:
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
sin x2 þ y2
z = f ðx, yÞ = pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
x2 þ y2
>> r=sqrt(X.^2+Y.^2);
>> r=r+(r==0)*eps;
>> z = sin(r)./r;
>> surf(X,Y,z)
>> mesh(X,Y,z)
410 Appendix A: Introduction to MATLAB®
can be used to compare two arrays of the same size or an array to a scalar.
Combinations of logical expressions can be performed using the logical
operators:
& and
| or
~ not.
x=
1 2 3 5 11
>> y=(x<=2)|(x>10)
y=
1 1 0 0 1
>> z=(x>2)&(x<=10)
z=
0 0 1 1 0
>> (y==~z)
ans =
1 1 1 1 1
Appendix A: Introduction to MATLAB® 411
Another new feature that was introduced is the use of the dot (.) operator:
>> r=sqrt(X.^2+Y.^2);
When the dot operator is used, then the intended mathematical operation is
performed on an element-by-element basis:
A=
1 2
3 4
>> A^2
ans =
7 10
15 22
>> A.^2
ans =
1 4
9 16
Note that while A^2 is the usual operation of raising a matrix to a power
of 2:
1 2
1 2 11þ23 12þ24 7 10
A =A A=
2
= =
3 4 3 4 31þ43 32þ44 15 22
We will now demonstrate the use of flow control through some simple
examples.
We will first demonstrate the use of the if element. Let assume that you have
been asked to determine the drag coefficient for a spherical object, given the
Reynolds number which must be greater that 0.0001 (NRe > 0.0001). It is known
that the Drag coefficient of a sphere decreases with the Reynolds number and drag
coefficient becomes almost a constant (CD = 0.44) for a Reynolds number between
103 and 2 × 105. More specifically, you have been given the following information:
8 24
>
> , 0:0001 ≤ N Re < 0:2
>
> N Re
>
>
< 24
C D = N Re þ 0:44, 0:2 ≤ N Re < 1000
>
>
>
>
>
> 0:44, 103 ≤ N Re ≤ 2 105
:
0:05, N Re > 2 105
The calculation for a given value of the Reynolds number can be performed as
follows:
if (NRe<1e-4)
disp(‘Equation not available for N_{Re}<1e-4)
CD = NaN;
(continued)
Appendix A: Introduction to MATLAB® 413
elseif ((Nre>=1e-4)&(Nre<0.2))
CD = 24/Nre;
elseif ((Nre>=0.2)&(Nre<1e3))
CD = 24/Nre+0.44;
elseif ((Nre>=1e3)&(Nre<2*1e5))
CD = 0.44;
else
CD = 0.05;
end
We then save our file by selecting Save/Save As. Be careful to save the file in
your current directory of MATLAB.
After this small but important diversion, we return to demonstrate now the
for element. Let now assume that we want to prepare a plot of the drug
coefficient. We first create a vector with values of the Reynolds number in
the range [10-3,106] and then use the for element to evaluate the drug
coefficient for each element of the vector of the Reynolds numbers (use help
to find information about the length, semilog, and loglog commands in
MATLAB):
When we run this script file (an m-file that is not a function), we obtain the
graph of the drag coefficient:
Appendix A: Introduction to MATLAB® 415
To demonstrate the use of while element, we will use the analytic solution
for the temperature distribution at the center of a slab, with uniform initial
temperature T0, in which the surface temperature changes suddenly to T1 and
remains constant. If the thermal diffusivity is a and the thickness of the slab is
2b, then (see Bird et al., Introductory Transport Phenomena, Wiley, 2015,
p. 350):
T ð0, τÞ - T 1 X1
n exp - λn τ
2
1 at
Θ ðτ Þ = =2 ð - 1Þ , λn = n þ π, τ = 2
T1 - T0 n=0
λ n 2 b
The while element is the most appropriate for performing this calculation:
416 Appendix A: Introduction to MATLAB®
Vectorization
1 e=D 15
pffiffiffi = - 2 log 10 þ
f 3:715 N Re
clear
NRe=logspace(log10(3000),8,20000);
e_D=[0.5 0.75 1 2.5 5 7.5 10 25 50 75 100 250 500]*1e-4;
tstart1 = tic;
for i=1:length(NRe)
for j=1:length(e_D)
X=-2*log10(e_D(j)/3.715+15/NRe(i));
f(i,j)=1/X^2;
end
end
telapsed1 = toc(tstart1);
loglog(NRe,f)
grid on
axis([1e3 1e8 1e-2 1e-1])
xlabel('Reynolds Number')
ylabel('Moody friction factor f')
Vectorized:
tstart2 = tic;
f1=1./(-2*log10(e_D'/3.715+15./NRe)).^2;
telapsed2 = toc(tstart2);
ratio=telapsed1/telapsed2
>> EckLoop
ratio =
100.8723
We therefore observe that the vectorized form “runs” 100 times faster (!) to
produce the following graph:
418 Appendix A: Introduction to MATLAB®
2882
ln = 15.88 −
222 +
L
x
f 1 ðL, V Þ = F - L - V = 0
f 2 ðL, V, x, yÞ = Fz - Lx - Vy = 0
f 3 ðx, yÞ = xPsA - yP = 0
so that:
2 3
f 1 ðx Þ
6 f ðx Þ 7
6 2 7
f ðxÞ = 6 7=0
4 f 3 ðx Þ 5
f 4 ðx Þ
420 Appendix A: Introduction to MATLAB®
We can solve this problem in MATLAB using the fsolve command. We first
create an m-file with the equalities:
function f=flash(X)
% flash tank problem
L=X(1); V=X(2); x=X(3); y=X(4);
F = 1 ; % feed molar flowrate kmol/min
z = 0.5; % feed composition
P = 760; % pressure mmHg
T = 75; % temperature deg C
Avp=[15.81 15.88];
Bvp=[ 2653 2882];
Cvp=[ 226 222];
Ps = exp(Avp-Bvp./(Cvp+T));
f(1) = F - L - V;
f(2) = F*z - L*x -V*y;
f(3) = x*Ps(1) - y*P;
f(4) = (1-x)*Ps(2) - (1-y)*P;
f=f(:);
return
>> fsolve(@flash,[0.5;0.5;0.4;0.6])
Equation solved.
ans =
0.7805
0.2195
0.4562
0.6557
= ( )⋅
/ =
V
X ( )=
S +
dX ðt Þ
= r X ðS, X Þ, X ð0Þ = 0:1
dt
dS ðt Þ
= - r S ðS, X Þ, S ð0Þ = 100
dt
There are also two algebraic equations for calculating the rates of biomass
formation and substrate consumption:
S
μ - μ max =0
KS þ S
rX - μ X = 0
rX
rS - =0
Y xs
We may solve directly the system of differential and algebraic equations (DAE),
as given above, which has the following general mathematical description:
dx
= f ðt, x, zÞ
dt
0 = gðt, x, zÞ
dX ðt Þ S ðt Þ
= μ max X ðt Þ, X ð0Þ = 0:1
dt K S þ S ðt Þ
dS ðt Þ μ S ðt Þ
= - max X ðt Þ, S ð0Þ = 100
dt Y x=s K S þ Sðt Þ
with μmax = 1 1/h, Ks = 1 g/L and Yx/s = 0.1 g/g. To achieve that we create the
following m-file with the right-hand side of the ODE system:
function dxdt=BatchBio(t,x)
rX = miu_max*S*X/(Ks+S);
We then solve the ODE using the ODE solver ode15s available in MATLAB
and plot the results:
clear
x0=[0.1;100]
[t,y]=ode15s(@BatchBio,[0 5],x0)
figure(1)
subplot(2,1,1)
plot(t,y(:,2),'k','Linewidth',1)
xlabel('Time (h)')
ylabel('S(t) (g/L)')
axis([0 5 0 100])
grid on
subplot(2,1,2)
plot(t,y(:,1),'k','Linewidth',1)
xlabel('Time (h)')
ylabel('X(t) (g/L)')
axis([0 5 0 12])
grid on
Appendix A: Introduction to MATLAB® 423
Other commonly used ODE solvers in MATLAB are the ode113 and ode45.
We will now solve the problem as a DAE problem. We first create the rhs of
the differential and algebraic equations in an m-file:
function dxdt=BatchBioDAE(t,x)
clear
X0 =0.1;
S0 =100;
miu0=1*S0/(1+S0);
rX0 = miu0*X0;
rS0 = rX0/0.1;
x0=[X0;S0;miu0;rX0;rS0];
M=diag([1;1;0;0;0])
options=odeset('Mass',M);
[t,y]=ode15s(@BatchBioDAE,[0 5],x0,options)
figure(2)
clf
subplot(3,1,1)
plot(t,y(:,3),'k','Linewidth',1)
xlabel('Time (h)')
ylabel('\mu(t) (1/L)')
axis([0 5 0 1])
grid on
subplot(3,1,2)
plot(t,y(:,4),'k','Linewidth',1)
xlabel('Time (h)')
ylabel('r_{X}(t) (g/(L h))')
axis([0 5 0 10])
grid on
subplot(3,1,3)
plot(t,-y(:,5),'k','Linewidth',1)
xlabel('Time (h)')
ylabel('r_{S}(t) (g/(L h))')
axis([0 5 -100 0])
grid on
Note how Tex Markup is used (\mu) to introduce letters of the Greek
alphabet or create subscripts (r_{X}). Special symbols of character formatting
can be used through Tex Markup to improve the quality of the figures created
in MATLAB.
Appendix A: Introduction to MATLAB® 425
λZ= 1
Eb = Ε ðλÞdλ
λ=0
where λ is wavelength of radiation per unit area and unit time and E(λ) is the
“monochromatic” emissive power given by the notorious Plank’s equation:
1 C1
E ðλÞ =
λ5 exp λΤ
C2
-1
426 Appendix A: Introduction to MATLAB®
clear all
C1=3.742E8; C2=14388;
T=[5777 5500 5000 4500 4000];
lamda=linspace(0.1,3,1000);
for i=1:length(T)
Eb=(C1./lamda.^5)./(exp(C2./(lamda*T(i)))-1);
plot(lamda,Eb/1e8,'Linewidth',1.2)
hold on
end
grid on
xlabel('\lambda (\mum)')
ylabel('E_{b} 10^{-8} (J/(\mum s m^{2})')
λZ= 1
E b = σΤ = 4
Ε ðλÞdλ
λ=0
Appendix A: Introduction to MATLAB® 427
where σ = 5.67 10-8 W/(m2 K4) is the Stefan-Boltzmann constant. To this end
we will use the trapz command available in MATLAB for performing numer-
ical integration using the trapezoidal rule:
clear all
C1=3.742E8; C2=14388;
T=linspace(100,6000,51);
lamda=linspace(0.01,1000,100000)';
Eb=[]
for i=1:length(T)
E=(C1./lamda.^5)./(exp(C2./(lamda*T(i)))-1);
Eb=[Eb E];
end
dlamda=lamda(2)-lamda(1);
Integral=dlamda*trapz(Eb);
sigma=mean(Integral./T.^4)
>> plank
sigma =
5.6703e-08
For the case of a plug flow reactor (PFR), the volume for achieving a specific
conversion X is given by the following integral equation (page 50 of the same
reference):
ZX
V PFR 1
= dX
F0 - r ðX Þ
0
428 Appendix A: Introduction to MATLAB®
We have been asked to determine the volume of a PFR necessary that will
achieve 80% conversion of the reactant A. We will first fit the “experimental
data to a polynomial function:
clear
X= [0.0 0.1 0.2 0.4 0.6 0.7 0.8];
r=-[0.450 0.370 0.300 0.195 0.113 0.079 0.050];
c=polyfit(X,r,2);
figure(1)
plot(X,-r,'o')
hold on
plot(X,-(c(1)*X.^2+c(2)*X+c(3)),'k-')
axis([0 0.8 0 0.5])
grid on
xlabel('Conversion X [-]')
ylabel('-r (mol/(m^{3} s))')
Using the polynomial function for the rate, we may determine the volume of
the PFR reactor using the integral command:
Appendix A: Introduction to MATLAB® 429
>> pfr_volume
f=
@(X)-1./(c(1)*X.^2+c(2)*X+c(3))
Vpfr_F0 =
5.3936
Literature and Notes for Further Study
The following books can be used for a formal and comprehensive introduction
to the general theory of nonlinear programming (all books with the symbol a
following the book are strongly recommended):
[1]. Arora J.A. Introduction to Optimum Design, Academic Press, London, UK,
4th ed., 2017.a
[2]. Bazaraa M. A., H. D. Sherali, and C. M. Shetty. Nonlinear programming –
Theory and algorithms. Wiley, Hoboken, 3rd ed., 2006.a
[3]. Beck A. Nonlinear optimization Theory, Algorithms, and Applications with
MATLAB. SIAM, Philadelphia, PA, 2014.
[4]. Betts J. T. (2001), Practical Method for Optimal Control using Nonlinear
Programming, SIAM, 2nd ed., Philadelphia, 2010.
[5]. Biegler L. T. Nonlinear Programming – Concepts, Algorithms and Applica-
tions to Chemical Processes. SIAM, Philadelphia, 2010.
[6]. Boyd S. and L. Vandenberghe. Convex optimization. Cambridge University
Press, New York, 2009.
[7]. Butenko S. and Pardalos P.M. Numerical Methods and Optimization: Ana
Introduction. CRC Press, Boca Raton, FL, 2014.a
[8]. Eiselt H.A. and C. L. Sandblom. Nonlinear Optimization, Methods and
Applications. Springer Nature Switzerland AG, Cham, 2019.
[9]. Fletcher R. Practical Methods of Optimization. Wiley, Chichester, 1991.
[10]. Floudas C.A., Nonlinear and Mixed-Integer Optimization, Fundamentals
and Applications, Oxford University Press, USA, 1995.a
[11]. Gill P. E., W. Murray, and M. H. Wright. Practical optimization. Academic
Press, London, 1981.
[12]. Griva I., Nash S.G. and Sofer A. Linear and Nonlinear Optimization, SIAM,
2nd ed., Philadelphia, 2009.a
[13]. Luenberger D. G. and Y. Ye. Linear and Nonlinear Programming. Springer,
Heidelberg, 4th ed., 2016.
© The Editor(s) (if applicable) and The Author(s), under exclusive license 431
to Springer Nature Switzerland AG 2022
I. K. Kookos, Practical Chemical Process Optimization, Springer Optimization
and Its Applications 197, https://doi.org/10.1007/978-3-031-11298-0
432 Literature and Notes for Further Study
B
Backtracking C
algorithm, 68 Carbon capture, 161
in multivariable optimization, 68 Cardinality, 253
rudimentary, 32 Cement hardening, 208
Basfia succiniciproducens, 357, 391 Characteristic size, 2
Basic solution Chemical reaction equilibrium, 113, 147
in linear programming, 177 Circle packing, 273
Basic variables Circle packing problem, 119
in linear programming, 177 Closed loop stability, 380
Batch process, 160 CO2eq emitted, 352
Batch reactor, 79–84, 332 Combinatorial explosion, 301
Battery, 346 Combinatorial optimization, 221, 301
Betz limit, 43 Complementary slackness, 115
Betz’s law, 43 Complete enumeration, 385
BFGS method, 74 Compression ratio, 18, 72
Big-M method, 194 Constitutive laws, 119
Binary distillation column, 48 Continuous stirred tank reactor, 19
Binary variables, 219 Controller gain, 374
© The Editor(s) (if applicable) and The Author(s), under exclusive license to 435
Springer Nature Switzerland AG 2022
I. K. Kookos, Practical Chemical Process Optimization, Springer Optimization
and Its Applications 197, https://doi.org/10.1007/978-3-031-11298-0
436 Index
Control structure selection problem, 385–388 Fenske, Underwood and Gilliland (FUG)
Convex function, 11–13, 55, 101 method, 48
examples, 12 Finite differences, 74
Convexity, 101 central, 74
local criterion, 12 forward, 74
& nonlinear equality constraints, 101 First derivative
Convex sets, 101 numerical approximation, 74
Critical computer controlled system, 254 First order plus dead-time model, 97, 369
Critical thickness, 40 First order reaction, 19, 107
Crude oil, 166 Flash separation unit, 158
Crude oil distillation unit (CDU), 166 Flue gas, 161
Crystalline solids, 13 Flu vaccine, 201
CSTR in series, 75–79, 107 Food industry, 307
Current density, 27 Frequency response, 362
Cutting stock problem, 120, 195, 197, 199 Fuel cell, 85, 87, 108, 126
maximum power, 28
solid oxide, 27, 88
D
Depth of Discharge, 346
Differential and algebraic equations, 325 G
Dilution rate, 22 Gain margin, 378
Directed arc, 191 General Algebraic Modelling System
Direction (GAMS), 273
of fastest decrease, 62 Gibbs energy, 113
of fastest increase, 62 Gibbs free energy of formation, 316
Dispatching schedule, 230 Global minimum, 6, 11
Distillation, 317 Gradient vector, 54, 61
Double-effect evaporator, 310
Dual feasibility, 115
H
Heat exchanger network, 150
E Heat exchanger network design, 158
Electrical energy, 27 Heat transfer area, 151
from fuel cell, 27 Hessian matrix, 54
Ellipse, 59 indefinite, 59
Employee Scheduling Models, 199, 201 High pressure steam, 216
Energy balance, 119 Hungarian algorithm, 191
Engraving, 225 Hydrogen, 27
Equality constrained problem, 5, 102 Hydrogen production, 157
Equality constraint, 4 Hyperbola, 60
Equilibrium reactions, 313
Equilibrium thermodynamics, 27, 146
Ethane decomposition, 146 I
Exact line search, 32 Impulse response, 46
Incumbent, 241
Inequality constrained problem, 5, 114–121
F Inequality constraint, 4
Face-centered cubic (FCC), 13 Inexact line search, 33
Facility location models, 204, 206 Armijo's, 68
Fathomed, 241 Initial feasible solution
Feasible solution, 1 in linear programming, 177
Feasible space, 101, 114 Input delay, 369
Feedback control law, 46 Instability, 383
Index 437
W
T Water formation reaction, 27
Tangent plane, 62 Wind availability, 344
Taylor approximation, 5, 54 Wind turbine, 43, 339
Taylor series, 6
Theoretical maximum yields, 391
Thermal isomerization of a-pinene, 304 Y
Thermal power units, 233, 234 Yield coefficient, 22
Tour ordering, 301