Matlab Dynamic Optimization of Batch Fermentation Processes
Matlab Dynamic Optimization of Batch Fermentation Processes
TOMLAB REGISTER (TOMLAB)
LOGIN myTOMLAB
TOMLAB /PROPT Manual
Contents « Previous « Start » Next »
1 PROPT Guide Overview
2 Introduction to PROPT
3 Modeling optimal control problems 11 Batch Fermentor
4 Multiphase optimal control
5 Scaling of optimal control problems
6 Setting solver and options Dynamic optimization of bioprocesses: efficient and robust numerical
7 Solving optimal control problems strategies 2003, Julio R. Banga, Eva BalsaCantro, Carmen G. Moles and
8 | | OPTIMAL CONTROL EXAMPLES | | Antonio A. Alonso
9 Acrobot
10 A Linear Problem with Bang Bang Control Case Study I: Optimal Control of a FedBatch Fermentor for Penicillin
11 Batch Fermentor Production
11.1 Problem description
11.2 Solving the problem on multiple grids.
11.3 Plot result 11.1 Problem description
12 Batch Production
13 Batch Reactor Problem This problem considers a fedbatch reactor for the production of penicillin, as
14 The Brachistochrone Problem studied by Cuthrell and Biegler (1989). This problem has also been studied
15 The Brachistochrone Problem (DAE
formulation) by many other authors (Dadebo & McAuley 1995, Banga & Seider 1996,
16 Bridge Crane System Banga et al. 1997). We consider here the free terminal time version where
17 BrysonDenham Problem the objective is to maximize the amount of penicillin using the feed rate as the
18 BrysonDenham Problem (Detailed) control variable. It should be noted that the resulting NLP problem (after using
19 BrysonDenham Problem (Short version) CVP) does not seem to be multimodal, but it has been reported that local
20 BrysonDenham Two Phase Problem gradient methods do experience convergence problems if initialized with far
21 Bryson Maxrange fromoptimum profiles, or when a very refined solution is sought. Thus, this
22 Catalyst Mixing example will be excellent in order to illustrate the better robustness and
23 Catalytic Cracking of Gas Oil
24 Flow in a Channel efficiency of the alternative stochastic and hybrid approaches. The
25 Coloumb Friction 1 mathematical statement of the free terminal time problem is:
26 Coloumb Friction 2
27 Continuous State Constraint Problem Find u(t) and t_f over t in [t0; t_f ] to maximize
28 Curve Area Maximization
29 Denbigh’s System of Reactions J = x2(tf)*x4(tf)
30 Dielectrophoresis Particle Control
31 Disturbance Control
32 Drug Displacement Problem
33 Optimal Drug Scheduling for Cancer
Chemotherapy subject to:
34 Euler Buckling Problem
35 MK2 5Link robot dx1 u*x1
36 Flight Path Tracking = h1*x1 −
37 Food Sterilization dt 500*x4
38 Free Floating Robot
39 Fuller Phenomenon dx2 u*x2
40 Genetic 1 = h2*x1 − 0.01*x2 −
41 Genetic 2 dt 500*x4
42 Global Dynamic System
43 Goddard Rocket, Maximum Ascent dx3 h1*x1 h2*x1 x1*0.029*x3 x3
44 Goddard Rocket, Maximum Ascent, Final = − − + u*x4*(1− )
time free, Singular solution dt 0.47 1.2 0.0001+x3 500
45 Goddard Rocket, Maximum Ascent, Final
time fixed, Singular solution dx4 u
46 Greenhouse Climate Control =
47 Grusins Metric dt 500
48 Hang Glider Control
49 Hanging Chain
50 High Dimensional Control
51 Hyper Sensitive Optimal Control
52 Initial Value Problem 0.11*x3
53 Isometrization of alpha pinene h1 =
0.006*x1+x3
54 Isoperimetric Constraint Problem
55 Jumbo Crane Container Control h2 = 0.0055 * x3 * (0.0001 + x3*(1 + 10*x3))
56 LeeRamirez Bioreactor
57 Linear Tangent Steering Problem
58 Linear Gas Absorber
59 Linear Pendulum
60 Linear Problem with Bang Bang Control where x1, x2, and x3 are the biomass, penicillin and substrate concentrations
61 LQR Problem (g=L), and x4 is the volume (L). The initial conditions are:
62 Marine Population Dynamics
https://tomopt.com/docs/propt/tomlab_propt012.php 1/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
63 Max Radius Orbit Transfer x(t0) = [1.5 0 0 7]′
64 Sequential Activation of Metabolic
Pathways
65 Methanol to Hydrocarbons
66 Min Energy Orbit Transfer
67 Minimum Climb Time (English Units) There are several path constraints (upper and lower bounds) for state
68 Missile Intercept variables (case III of Cuthrell and Biegler, 1989):
69 Moonlander Example
70 Nagurka Problem 0 <= x1 <= 40
71 Nishida problem
72 Nondifferentiable system 0 <= x3 <= 25
73 Nonlinear CSTR 0 <= x4 <= 10
74 Obstacle Avoidance
75 Oil Shale Pyrolysis
76 One Dimensional Rocket Ascent
77 Parametric Sensitivity Control
78 Orbit Raising Maximum Radius The upper and lower bounds on the only control variable (feed rate of
79 Orbit Raising Minimum Time substrate) are:
80 Parallel Reactions in Tubular Reactor
81 Parameter Estimation Problem 0 <= u <= 50
82 ParkRamirez bioreactor
83 Path Tracking Robot
84 Path Tracking Robot (TwoPhase)
85 Pendulum Gravity Estimation
86 Penicillin Plant Reference: [3]
87 PlugFlow Tubular Reactor
88 Quadratic constraint problem
89 Quadruple Integral 11.2 Solving the problem on multiple grids.
90 Radio telescope
91 Rayleigh Unconstrained The problem is solved in two stages. First, a solution is computed for a small
92 Rigid Body Rotation
93 Robot Arm Movement number of collocation points, then the number of collocation points is
94 Timeoptimal Trajectories for Robot increased, and the problem is resolved. This saves time, compared to using
Manipulators the fine grid immediately.
95 Satellite Control
96 Second Order System toms t
97 Space Shuttle Reentry toms t_f
98 Simple Bang Bang Problem
99 Singular Arc Problem nvec = [35 70 80 90 100];
100 Singular CSTR
101 Singular Control 1 for i=1:length(nvec)
102 Singular Control 2
103 Singular Control 3 n = nvec(i);
104 Singular Control 4 p = tomPhase('p', t, 0, t_f, n);
105 Singular Control 5 setPhase(p);
106 Singular Control 6
107 Spring Mass Damper (2 Degree tomStates x1 x2 x3 x4
Freedom)
108 Stirred Tank tomControls u
109 Temperature Control
% Initial guess
110 A Simple Terminal Constraint Problem % Note: The guess for t_f must appear in the list before
111 Third order system % expression involving t.
112 Time Delay 1 if i==1
113 Time Delay 1 (Approximate) x0 = {t_f == 126
114 Time Delay 2 icollocate(x1 == 1.5)
115 Time Delay 2 (Approximate) icollocate(x2 == 0)
116 Transfer Min Swing icollocate(x3 == 0)
117 Tubular Reactor icollocate(x4 == 7)
118 Turbo Generator collocate(u==11.25)};
119 TwoLink Robot else
120 TwoLink Robotic Arm % Copy the solution into the starting guess
121 TwoPhase Schwartz x0 = {t_f == tf_init
122 Two Stage CSTR icollocate(x1 == x1_init)
123 Van der Pol Oscillator icollocate(x2 == x2_init)
icollocate(x3 == x3_init)
124 Zermelos problem (version 1)
icollocate(x4 == x4_init)
125 Zermelos problem (version 2) collocate(u == u_init)};
References end
Notes
% Box constraints
% Setting the lower limit for t, x1 and x4 to slightly more than zero
% ensures that division by zero is avoided during the optimization
% process.
cbox = {1 <= t_f <= 256
1e‐8 <= mcollocate(x1) <= 40
0 <= mcollocate(x2) <= 50
0 <= mcollocate(x3) <= 25
1 <= mcollocate(x4) <= 10
0 <= collocate(u) <= 50};
https://tomopt.com/docs/propt/tomlab_propt012.php 2/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
% Various constants and expressions
h1 = 0.11*(x3./(0.006*x1+x3));
h2 = 0.0055*(x3./(0.0001+x3.*(1+10*x3)));
% Boundary constraints
cinit = initial({x1 == 1.5; x2 == 0
x3 == 0; x4 == 7});
% This final condition is not necesary, but helps convergence speed.
cfinal = final(h2.*x1‐0.01*x2) == 0;
% ODEs and path constraints
ceq = collocate({
dot(x1) == h1.*x1‐u.*(x1./500./x4)
dot(x2) == h2.*x1‐0.01*x2‐u.*(x2./500./x4)
dot(x3) == ‐h1.*x1/0.47‐h2.*x1/1.2‐x1.*...
(0.029*x3./(0.0001+x3))+u./x4.*(1‐x3/500)
dot(x4) == u/500});
% Objective
objective = ‐final(x2)*final(x4);
options = struct;
options.name = 'Batch Fermentor';
%options.scale = 'auto';
%if i==1
% options.solver = 'multiMin';
% options.xInit = 20;
%end
solution = ezsolve(objective, {cbox, cinit, cfinal, ceq}, x0, options);
Problem type appears to be: qpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB ‐ Tomlab Optimization Inc. Development license 999001. Valid to 2011‐02‐05
=====================================================================================
Problem: ‐‐‐ 1: Batch Fermentor f_k ‐87.746072952335396000
sum(|constr|) 0.000000000591461608
f(x_k) + sum(|constr|) ‐87.746072951743940000
f(x_0) 0.000000000000000000
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2‐5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 924 ConJacEv 924 Iter 275 MinorIter 4942
CPU time: 8.250000 sec. Elapsed time: 8.485000 sec.
Problem type appears to be: qpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB ‐ Tomlab Optimization Inc. Development license 999001. Valid to 2011‐02‐05
=====================================================================================
Problem: ‐‐‐ 1: Batch Fermentor f_k ‐87.965550967205928000
sum(|constr|) 0.000000291694933232
f(x_k) + sum(|constr|) ‐87.965550675510997000
f(x_0) ‐87.746072952334629000
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2‐5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 98 ConJacEv 98 Iter 58 MinorIter 1466
CPU time: 6.328125 sec. Elapsed time: 6.453000 sec.
Problem type appears to be: qpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB ‐ Tomlab Optimization Inc. Development license 999001. Valid to 2011‐02‐05
=====================================================================================
Problem: ‐‐‐ 1: Batch Fermentor f_k ‐87.989983108591034000
sum(|constr|) 0.000000063125343100
f(x_k) + sum(|constr|) ‐87.989983045465692000
f(x_0) ‐87.966078735435829000
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2‐5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 116 ConJacEv 116 Iter 92 MinorIter 2087
CPU time: 14.265625 sec. Elapsed time: 14.438000 sec.
https://tomopt.com/docs/propt/tomlab_propt012.php 3/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
Problem type appears to be: qpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB ‐ Tomlab Optimization Inc. Development license 999001. Valid to 2011‐02‐05
=====================================================================================
Problem: ‐‐‐ 1: Batch Fermentor f_k ‐88.030366209342986000
sum(|constr|) 0.000000440801301912
f(x_k) + sum(|constr|) ‐88.030365768541685000
f(x_0) ‐87.990147691715819000
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2‐5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 99 ConJacEv 99 Iter 88 MinorIter 1713
CPU time: 15.859375 sec. Elapsed time: 16.078000 sec.
Problem type appears to be: qpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB ‐ Tomlab Optimization Inc. Development license 999001. Valid to 2011‐02‐05
=====================================================================================
Problem: ‐‐‐ 1: Batch Fermentor f_k ‐88.044843218600391000
sum(|constr|) 0.000000326396054727
f(x_k) + sum(|constr|) ‐88.044842892204343000
f(x_0) ‐88.030366874603772000
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2‐5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 142 ConJacEv 142 Iter 122 MinorIter 2743
CPU time: 32.906250 sec. Elapsed time: 33.547000 sec.
11.3 Plot result
subplot(2,1,1);
ezplot([x1; x2; x3; x4]);
legend('x1','x2','x3','x4');
title('Batch Fermentor state variables');
subplot(2,1,2);
ezplot(u);
legend('u');
title('Batch Fermentor control');
drawnow
% Copy solution for initializing next round
x1_init = subs(x1,solution);
x2_init = subs(x2,solution);
x3_init = subs(x3,solution);
x4_init = subs(x4,solution);
u_init = subs(u,solution);
tf_init = subs(t_f,solution);
https://tomopt.com/docs/propt/tomlab_propt012.php 4/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
https://tomopt.com/docs/propt/tomlab_propt012.php 5/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
https://tomopt.com/docs/propt/tomlab_propt012.php 6/7
20181213 Matlab Dynamic Optimization of Batch Fermentation Processes
end
« Previous « Start » Next »
https://tomopt.com/docs/propt/tomlab_propt012.php 7/7