DOTcvp Dynamic Optimization Toolbox With

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

T ECHNICAL R EPORT

DOTcvp: Dynamic Optimization Toolbox with


Control Vector Parameterization approach
Authors:
Tomáš Hirmajer† , Miroslav Fikar† ,
Eva Balsa-Canto‡ , and Julio Rodrı́guez Banga‡

E-mails:
{tomas.hirmajer, miroslav.fikar}@stuba.sk,
{ebalsa, julio}@iim.csic.es


I NSTITUTE OF I NFORMATION E NGINEERING ,
AUTOMATION , AND M ATHEMATICS
Department of Information Engineering and Process Control
Faculty of Chemical and Food Technology STU
Radlinského 9, 812 37 Bratislava, Slovakia


I NSTITUTO DE I NVESTIGACIONES M ARINAS (C.S.I.C.)
Process Engineering Group
Spanish Council for Scientific Research
C/Eduardo Cabello 6, 36208 Vigo, Spain

June 5, 2008
Abstract:
This report deals with the description of dynamic optimization toolbox (DOTcvp) which is able to solve con-
strained optimal control problems (OCP) with the control vector parameterization (CVP) approach. The original
continuous problem is transformed into the finite dimensional OCP. Then it is possible to solve the resulting non-
linear programming (NLP) problem with the help of any gradient method with the combination of initial value
problem (IVP) solver. For all of this is used SUNDIALS tool which was modified for automatic generation of the
necessary gradients in two ways. One of them is a finite difference and the second one, a more accurate method,
is the sensitivity equations approach. Several NLP solvers, deterministic and stochastic were implemented in
order to ensure higher accuracy not only for small problems. All of this is covered by the MATLAB environment,
which offers to us a comfortable control and a pretty graphical output. The toolbox contains an environment
for a FORTRAN compiler too, for enabling this option it is needed to have installed a FORTRAN compiler in a
MATLAB environment.

Keywords: Dynamic optimization toolbox, control vector parameterization, sensitivity equations, ordinary dif-
ferential equations

Internet
The basic information about the toolbox is possible to get from the following web page:
http://www.kirp.chtf.stuba.sk/˜hirmajer/dotcvp.html

Download
The toolbox is available without fee on the basis on the GPL license. You can download it and use. It is not
necessary to install the toolbox, it is enough to extract it from a ’.zip’ archive. The name of the zip archive
contains information about the actual version, e.g. ’.zip’ with the name DOTcvp-06-Dec-2007 implies that the zip
archive is from 6 of December 2007.
http://www.kirp.chtf.stuba.sk/˜hirmajer/files/research/dotcvp/DOTcvp_old.zip

Reference
T. Hirmajer, M. Fikar, E. Balsa-Canto, and J. R. Banga, DOTcvp: Dynamic Optimization Toolbox with Control
Vector Parameterization approach, User’s Guide, Technical Report, FCHPT STU Bratislava, Slovak Republic,
2007.

Future and Outlook


The presented toolbox is a first version and we hope that this tool will be continuously updated and new things
will be inserted following the comments and suggestions from the researchers. The latest version and information
about the toolbox is possible to get from the web page mentioned before or you can contact us on the already
mentioned email addresses. Finally, we would like to emphasize that the usage of the toolbox is very easy,
because one needs to modify only one file and everything else is generated automatically. The accuracy of the
computations is checked in the last section by several chemical engineering problems. The solved problems
confirmed that the toolbox is able to get good results in reasonable CPU time.

The Toolbox Requirements


You need to have installed in a MATLAB environment the Symbolic Math Toolbox (for automatic derivation of the
Jacobian and sensitivities) and Optimization Toolbox (only if you would like to use FMINCON as NLP solver).
There is implemented an environment for a FSQP solver too, but because it is only for the commercial purposes
it can not be inserted into the toolbox directly. However, it is enough to copy the solver into the NLP/FSQP
directory. For the LINUX compatible version you need to install the SUNDIALS from the following web page:
https://computation.llnl.gov/casc/sundials/main.html

Acknowledgments
The authors would like to thank the whole CSIC group for their help with the implementation of the presented
toolbox, especially to José Alberto Egea Larrosa.
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Contents

1 Introduction 5
1.1 What is DOTcvp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Optimal Control Problem 7


2.1 System and Cost Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Control Vector Parametrization 8


3.1 Implemented Gradient Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.1 Sensitivity Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.2 Finite Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Gradients with Respect to Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Algorithm Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 From the ’Input’ to the ’Output’ 10


4.1 Van der Pol Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.1 Formulation of the Problem for DOTcvp . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.2 Graphical Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5 GUI for DOTcvp 14


5.1 Step by Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6 Illustrative Examples 18
6.1 Optimal Control Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.1.1 Nishida Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.1.2 Plug-flow Reactor with a Singular Arc . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.1.3 Optimal Control of a Non-differentiable System . . . . . . . . . . . . . . . . . . . . . . . 19
6.1.4 Lee-Ramirez Bioreactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.1.5 Optimal Production of Secreted Protein in a Fed-batch Reactor . . . . . . . . . . . . . . . 20
6.1.6 Nonlinear CSTR Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.2 Equality and Inequality Constraints Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.2.1 Terminal and Interior Point Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.2.2 Inequality State Path Constraint Problem . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.2.3 Chemical Reactor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.2.4 Fed Batch Reactor for Ethanol Production . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.2.5 Optimal Control of a Fed Batch Fermenter for Penicillin Production . . . . . . . . . . . . 25
6.3 Free Time Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.3.1 Modified Denbigh Reaction System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.3.2 Simple Batch Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Bibliography 28

Page – 2
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Appendix 30
Gradients Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Page – 3
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

List of Figures

1.1 Organization of the toolbox code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4.1 Optimal solution for a van der Pol oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.1 GUI for a van der Pol oscillator problem (Introduction Screen) . . . . . . . . . . . . . . . . . . . 14
5.2 GUI for a van der Pol oscillator problem (NLP Definition) . . . . . . . . . . . . . . . . . . . . . 15
5.3 GUI for a van der Pol oscillator problem (Initialization of the Optimization) . . . . . . . . . . . . 15
5.4 GUI for a van der Pol oscillator problem (Problem Definition) . . . . . . . . . . . . . . . . . . . 15
5.5 GUI for a van der Pol oscillator problem (In/Equality Constraints) . . . . . . . . . . . . . . . . . 16
5.6 GUI for a van der Pol oscillator problem (ODE and Sensitivities Initialization) . . . . . . . . . . . 16
5.7 GUI for a van der Pol oscillator problem (Output) . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.8 GUI for a van der Pol oscillator problem (MATLAB Output) . . . . . . . . . . . . . . . . . . . . 17

6.1 Optimal solution for a Nishida problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18


6.2 Optimal solution for a plug-flow reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.3 Optimal solution for a non-differentiable system . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.4 Optimal solution for a Lee-Ramirez bioreactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.5 Optimal solution for a fed-batch reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.6 Optimal solution for the nonlinear CSTR reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.7 Optimal solution for a terminal and interior point constraints with the piecewise constant and linear
optimal profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.8 Optimal solution for an inequality state path constraint problem . . . . . . . . . . . . . . . . . . . 23
6.9 Optimal solution for a chemical reactor problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.10 Optimal solution for a fed batch reactor for ethanol production . . . . . . . . . . . . . . . . . . . 25
6.11 Optimal solution for a fed batch fermenter for penicillin production . . . . . . . . . . . . . . . . 26
6.12 Optimal solution for a modified Denbigh reaction system . . . . . . . . . . . . . . . . . . . . . . 27
6.13 Optimal control trajectories for a simple batch reactor . . . . . . . . . . . . . . . . . . . . . . . . 27

Page – 4
CHAPTER 1

Introduction

The maximum of the benefit or on the other hand minimum of all the costs are very important not only for the areas
of process, chemical and pharmaceutical industries. This is satisfied with the optimal control trajectories or with
the optimal set of parameters. These classes of problems are generally called as optimal control problems (OCP).
There are many numerical and analytical methods by which the optimal control problems can be solved.
One possibility is to use Bellman’s optimal principle or Pontryagin’s maximum principle [10] which are analytical
methods that solve two-point boundary value problems (TPBVP). Other possibility is to use some iterative methods
represented by control vector iteration (CVI), boundary condition iteration (BCI) or to transform OCP into the finite
dimensional optimal control problem through a parameterization scheme. The total parameterization (control and
state variables) in the case of the orthogonal collocation (OC) [20] can be used or only control parameterization
if the control vector parameterization method [29] is chosen. A good overview of the optimal control methods is
possible to found in [8]. It is important to emphasize that each of the method has advantages and disadvantages
and it depends on the type of the problem which one will be used. The advantage of the CVP method lies in the
parametrization only of the control trajectory. This has an impact on the total number of the decision variables.
The implementation of any method is often very time consuming process and many times some bugs can
occur. This slows down the implementation. For this reason it is sometimes reasonable to use tools that do this
without the complicated implementation from the view of the user. The Internet offers a lot of useful tools, i.e. the
toolboxes from [16; 36] and many more, which differ on the basis of the environment, method, etc.
1.1 WHAT IS DOTCVP
The DOTcvp is a dynamic optimization toolbox designated for a Matlab1 . The toolbox provides envi-
ronment for a FORTRAN compiler to create the ’.dll’ files of the ODE, Jacobian, and sensitivities. However, a
FORTRAN compiler has to be installed in a MATLAB environment. The toolbox uses the CVP method for the
calculation of the optimal control profiles. The problem which has to be defined in ODE form solves with the
algorithm presented in Section 3.3. For the solving of NLP several deterministic or stochastic solvers can be used:
• deterministic
1. IPOPT [37] (Interior Point OPTimizer) implements a primal-dual interior point method, and uses line
searches based on Filter methods (Fletcher and Leyffer);
2. FMINCON [12] (Find MINimum of CONstrained nonlinear multivariable function) a part of the MAT-
LAB optimization toolbox uses sequential quadratic programming (SQP);
3. FSQP [38] (Feasible Sequential Quadratic Programming) is a modified SQP algorithm that evaluates
the objective function only at feasible points.
• and stochastic
1. DE [31] (Differential Evolution) uses population based approach for minimizing of the cost function;
2. SRES [30] (Stochastic Ranking Evolution Strategy) uses an evolution strategy combined with an ap-
proach to balance objective and penalty functions;
1 trademark of The Math Works, Inc., http://www.mathworks.com
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

The NLP solver FSQP is not implemented on the basis of the license into the public version, but there is
an interface to do so from the side of the user. The modified SUNDIALS tool [17] is used for solving the IVP
and for the automatic generation of the gradients and Jacobian. Forward integration of the ODE system is ensured
by CVODES, a part of SUNDIALS, which is able to perform the simultaneous or staggered sensitivity analysis
too. The IVP problem can be solved with the Newton or Functional iteration module and with the Adams or BDF
linear multistep method (LMM). Note that the sensitivity equations are provided analytically and the error control
strategy for the sensitivity variables could be enabled.
The accuracy of the computation can be improved by hybrid approach, i.e. first part of the optimization is
secured by stochastic NLP solver and the second one by determinstic solver. This is possible to do with the help
of DOTcvp after a minor change of the input file. The effectivity of this approach is shown in [5].

Figure 1.1 – Organization of the toolbox code

The organization of the toolbox code is shown in Figure 1.1 where the toolbox files have the name:
’DOT cvp ’ and the temporary files: ’temp ’. Note that the temporary files are generated and latter deleted auto-
matically, because they are problem dependent. Finally it is needed to emphasize that DOTcvp contains packages
that are an open-source.

Page – 6
CHAPTER 2

Optimal Control Problem

2.1 SYSTEM AND COST DESCRIPTION


Consider a dynamical system described by the vector of ordinary differential equations (ODEs)
ẋ = f (t, x, u, p) (2.1)
with given initial and terminal conditions
x(0) = x0 , x(tF ) = xF (2.2)
where x ∈ Rnx is the vector of state variables, u ∈ Rnu is the vector of control variables, p ∈ Rnp is the vector
of parameters and tF is the final time of the process. The OCP is to find optimal control policy u(t), vector of the
parameters and the final time tF , when minimum or free time problem is considered that minimize the objective
function (l = 0) with satisfied constraints (m = me + mi ; me – equality constraints, mi – inequality constraints)
in general Mayer form
min Jl = Gl (tF , xF , u, p), l = 0, m (2.3)
tF ,u,p

Note that if the cost function contains an integral part, this could be transformed into a new state variable
of the ODE. We assume that the original continuous control trajectory can be approximated on the finite number
of the time intervals N as piecewise constant
u(t) = ui , ti−1 ≤ t < ti , i = 1, N (2.4)
or piecewise linear
u(t) = ui1 + ui2 t (2.5)
where the different ∆ti = ti − ti−1 is denoted as the time interval length.
For the simplicity we consider that the state variables are continuous at the boundaries
x(t+ −
i ) = x(ti ) (2.6)
where t− +
i denotes the ending time of stage i and ti the beginning time of stage i + 1.
The further constraints are defined as lower and upper boundaries of the optimized variables
∆ti ∈ [∆tmin max
i , ∆ti ] (2.7)
ui ∈ [umin max
i , ui ] (2.8)
min max
p ∈ [p ,p ] (2.9)
ny
The vector of decision variables y ∈ R contains information about ∆ti – lengths of the time intervals,
ui – control variables, and pi – parameters
y T = (∆t1 , . . . , ∆tN , uT1 , . . . , uTN , p) (2.10)
CHAPTER 3

Control Vector Parametrization

The basis of the CVP method rests only in the parameterization of control trajectories, the state trajectories remain
continuous. The original problem of dynamic optimization is transformed into the finite dimensional problem
(NLP) – static optimization. Further, a suitable gradient method with a NLP type algorithm is needed. The
gradients can be obtained by finite difference, adjoint or sensitivity approach. Each of the gradient method has
advantages and disadvantages, the summary is shown in [29]. The algorithm has an iterative character and when
the optimality conditions are satisfied the computation stops. Finally, it is good to emphasize that the CVP method
is only of a local nature and for this reason it is more effective to use a combination of the deterministic and
stochastic method to get the vicinity of a global optimum. Another option is to optimize a process with several
different initial conditions – multistart method.
3.1 IMPLEMENTED GRADIENT METHODS
3.1.1 Sensitivity Equations
The sensitivities are defined as partial derivation of state variables with respect to decision variables. Then
the sensitivity coefficients sj (t) with initial conditions are defined as follows
∂x(t)
sj (t) = , sj (0) = 0, j = 1, ny (3.1)
∂yj
where ny denotes the number of decision variables.
The sensitivity coefficients contain information about the sensitivities of the state values to the decision
variables. The partial derivative of ODE (2.1) with respect to decision variables (2.10) gives
 T T  T T  T T
∂f ∂f ∂ui+1 ∂f ∂p
ṡj (t) = sj (t) + + (3.2)
∂x ∂u ∂yj ∂p ∂yj
where ti−1 ≤ t ≤ ti and i = 0, (N − 1). With the forward integration of sensitivity equations (3.2) we obtain the
necessary information to compute the cost function (2.3) gradient.
When the sensitivity is computed with respect to time interval ti the discontinuity must be taken into ac-
count. If the situation is considered when the state values are continuous (2.6) at the time interval boundaries then
the total differential for a state variable gives
δx(t+ +

dx(ti ) = i ) + ẋ(ti )dti , i = 1, (N − 1)
(3.3)
δx(ti ) + ẋ(t−

i )dt i

as well as dx(t+ −
i ) = dx(ti ) which gives

δx(t+ + − −
i ) + ẋ(ti )dti = δx(ti ) + ẋ(ti )dti (3.4)
Differentiating (3.4) with respect to the decision variables yields
∂x(t+
i ) ∂x(t−
i )
 ∂ti
+ ẋ(t− +

= i ) − ẋ(ti ) (3.5)
∂yj ∂yj ∂yj
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

When the sensitivity coefficients (3.1) are used, formula (3.5) is simplified
∂ti
sj (t+ −
i ) = sj (ti ) + [f i − f i+1 ]ti (3.6)
∂yj
The partial derivations of the cost function or constraints (2.3) with respect to optimized variables gives
   T  T  T
∂Jl ∂Jl ∂tF ∂Jl ∂xF ∂Jl ∂u ∂Jl ∂p
= + + + (3.7)
∂yj ∂tF ∂yj ∂xF ∂yj ∂u ∂yj ∂p ∂yj
where it is considered that the variation of xF following (3.3) gives
∂xF ∂tF ∂xF
= f (tF , xF , uF , p) + (3.8)
∂yj ∂yj ∂yj
Taking into account (3.7) and (3.8) the final equation for the computation of the gradients is given as
   T  T  T  
∂Jl ∂Jl ∂tF ∂Jl ∂u ∂Jl ∂p ∂Jl ∂tF
= + + + sj (tF ) + f (tF , xF , uF , p)
∂yj ∂tF ∂yj ∂u ∂yj ∂p ∂yj ∂xF ∂yj
(3.9)
Derivation of the sensitivity equations for computation of the problem presented in the subsection 6.3.2 is
showed in the appendix 6.3.2.
3.1.2 Finite Difference
The system (2.1) is integrated ny times and in every integration one of the optimized variables (2.10)
changes only a little. At the end of all integrations, in one iteration it is possible to calculate all necessary gradients
by the following equation
Jl (y1 , . . . , yj + ∆yj , . . . , yny ) − Jl (y)
∇yj Jl = , l = 0, m (3.10)
∆yj
3.2 GRADIENTS WITH RESPECT TO TIME
For numerical reasons, time increments ∆ti will be optimized, rather than absolute time values ti . There-
fore, the gradients with respect to time have to be modified correspondingly. The relations between times and their
increments are given as
N
X
tF = ∆ti (3.11)
i=1

Therefore, the following holds for the derivatives


N
∂Jl X ∂Jl ∂tr
= (3.12)
∂∆ti r=1
∂tr ∂∆ti

3.3 ALGORITHM OUTLINE


1. Initialization of the optimized variables y = y 0 .
2. Forward integration of the system (2.1) and sensitivity equations (3.2), the trajectories of the states x(t) and
sensitivities s(t) are obtained.
3. When the minimum time problem is investigated sensitivities s(ti ) (i = 1, (N − 1)) have discontinuity
following the equation (3.6).
4. Calculation of the value of the cost function (2.3), and appropriate gradients (3.9) for the cost function and
constraints. Note that if free time is solved, the gradients are modified following the Section 3.2.
5. Iterative solution of the NLP:
(a) If the optimum is achieved, the conditions of the optimality are satisfied and the algorithm will stop y =
y optimal
(b) else it is needed to repeat algorithm from 2 with new values of decision variables y = y new , which are
set on the basis of gradients from 4.

Page – 9
CHAPTER 4

From the ’Input’ to the ’Output’

4.1 VAN DER POL OSCILLATOR


The van der Pol oscillator problem is taken from [34] and has been solved by many authors [32; 6; 3]. The
system with the integral term of the cost function is described with the following set of differential equations with
the vector of process initial conditions: x(0) = [0; 1; 0] and with the initial control trajectory: u(0) = [0.7]

ẋ1 = (1 − x22 )x1 − x2 + u (4.1)


ẋ2 = x1 (4.2)
ẋ3 = x21 + x22 + u2 (4.3)

The aim of the optimization is to minimize the cost function in the fixed final time (tF = 5)

min J0 = x3 (tF ) (4.4)


ui

subject to the inequality path constraints

−0.4 ≤ x1 (t) ≤ 0.0 (4.5)

and equality constraint at the end of the optimization

x2 (tF ) = −0.1 (4.6)

4.1.1 Formulation of the Problem for DOTcvp


From the position of the user it is needed only to modify the main file which contains all necessary infor-
mation. If the output is saved, then the results will be located in the following directory:
DOTcvp\simulation results
1 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
2 % Initialization of the optimization:
3 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
4 clear mex; clear all; close all; global data;
5 data.Name = {'VanDerPolOscilator'};
6 data.problem.solution = 'MATLAB'; %['MATLAB'|'FORTRAN'] FORTRAN option needs instaled a fortran compliler
7 data.ic.Anum = 30; %number of piecewise constants
8 data.ic.NUMc = 1; %number of control variables (u)
9 data.ic.NUMs = 3; %number of state variables (s)
10 data.ic.t0 = 0d0; %initial time
11 data.ic.tf = 5d0; %final time
12 data.ic.FreeTime = 'off'; %['on'|'off']
13 data.nlp.t0TIME = data.ic.tf/data.ic.Anum; %initial size of the time intervals e.g. [data.ic.tf/data.ic.Anum] or for the each time interval [dt1 dt2 dt3]
14 data.nlp.lbTIME = 0.01d0; %lower bound of the time intervals
15 data.nlp.ubTIME = data.ic.tf; %upper bound of the time intervals
16 data.nlp.PenaltyFunctionTime = 'off'; %['on'|'off'] penalty function of time
17 data.nlp.PenaltyCoefficientTime = 1d0; %J0=J0+PenaltyCoefficientTime*(TotalTime)

The first option in this part of the file clears old information from a MATLAB environment. The second contains
name of the problem. The third option has information about the code compiler. The rest of this part of the file
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

contains information about the optimized process which are: the number of the piecewise constants, the number
of control and state variables, initial and final time of the optimization as well as information if free or fixed time
problem is investigated. If free time problem is solved the upper and lower bounds have to be defined and the
penalty function can be enabled.
18 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
19 % Problem definition:
20 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
21 data.odes.ConstantDefinitionFORTRAN = {}; %this option is needed only for FORTRAN parameters definition e.g. {'double precision k10, k20, ..'}
22 data.odes.ConstantParameters = {}; %constant parameters before ODE {'T=300','..}
23 data.odes.ConstantDefinitionMATLAB = {}; %this option is needed only for MATLAB parameters definition
24 data.odes.res(1) = {'(1d0−y(2)ˆ2d0)*y(1)−y(2)+u(1)'};
25 data.odes.res(2) = {'y(1)'};
26 data.odes.res(3) = {'y(1)ˆ2d0+y(2)ˆ2d0+u(1)ˆ2d0'};
27 data.odes.ic = [0d0; 1d0; 0d0];

There is a place for the constant parameters or for the formulas e.g. conditional conditions, description of the
problem in the ODE form and the vector of the initial values. Note that the notation y(number), u(number) has to
be used for the state and control variables, respectively.

Example If you would like to use constant parameters for a FORTRAN compiler the character of the parameters
has to be defined and these parameters has to be inserted into a MATLAB parameters too, because the
final simulation of the process is performed always in a MATLAB environment. For details please check:
report SimpleBatchReactor – problem described in the Subsection 6.3.2.

28 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
29 % ODE and sensitivities initialization:
30 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
31 data.odes.NonlinearSolver = 'Newton'; %['Newton'|'Functional']
32 data.odes.LinearSolver = 'Dense'; % Analytical Jacobian ['Dense'|'Diag'|'Band']; Numerical Jacobian ['GMRES'|'BiCGStab'|'TFQMR'] /for the Newton NLS
33 data.odes.LMM = 'Adams'; %['Adams'|'BDF'] Linear Multistep Method
34 data.odes.MaxNumStep = 500; %maximum number of steps
35 data.odes.RelTol = 1*10ˆ(−7); %IVP relative tolerance level
36 data.odes.AbsTol = 1*10ˆ(−7); %IVP absolute tolerance level
37 data.sens.SensAbsTol = 1*10ˆ(−7); %absolute tolerance for sensitivity variables
38 data.sens.SensMethod = 'Simultaneous'; %['Staggered'|'Staggered1'|'Simultaneous']
39 data.sens.SensErrorControl = 'on'; %['on'|'off']

In this place it is possible to initialize the ODE and sensitivities as for example nonlinear and linear solver, linear
multistep method, maximum number of the step, relative and absolute tolerance for the ODE and sensitivities. The
last option in this part contains information about the sensitivities error control. When this option is set at the value
of ’on’ then the CPU time will be larger and the sensitivities will be controlled.
40 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
41 % NLP definition:
42 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
43 data.nlp.solver = 'FMINCON'; %['FMINCON'|'IPOPT'|'FSQP'|'SRES'|'DE']
44 data.nlp.NLPtol = 1*10ˆ(−5); %NLP tolerance level
45 data.nlp.GradMethod = 'SensitivityEq'; %['SensitivityEq'|'FiniteDifference'|'None']
46 data.nlp.MaxFunEvals = 1000; %Maximum number of function evaluations
47 data.nlp.MaxTime = 1000; %Maximum time of the optimization
48 data.nlp.problem = 'min'; %['min'|'max']
49 data.nlp.J0 = 'y(3)'; %Cost function: data.nlp.problem(data.nlp.J0)
50 data.nlp.u0 = [ 0.7d0]; %initial value for control values
51 data.nlp.lb = [−0.3d0]; %lower bounds
52 data.nlp.ub = [ 1d0]; %upper bounds
53 data.nlp.approximation = 'PW'; %['PW'|'PWL'] only for: FMINCON & without the free time problem

This part of the file contains information needed for the NLP solver as NLP tolerance, gradient method and maxi-
mum number of function evaluation. The second part has an information about the cost function and initial control
trajectory with lower and upper bounds. In the last option it is possible to switch the piecewise constant (PW)
control trajectory to the piecewise linear (PWL) control trajectory. Note that this option is available only for
FMINCON and non free time problems.
54 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
55 % Equality constraint/s:
56 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
57 data.nlp.equality.status = 'on'; %['on'|'off'] equality constraint/s
58 data.nlp.equality.NEC = 1; %number of active equality constraint/s
59 data.nlp.equality.eq(1) = {'y(2)+0.1d0'};
60 data.nlp.equality.time(1) = data.ic.Anum; %time of the 1 eq. constraint
61 data.nlp.PenaltyFunctionEq = 'off'; %['on'|'off'] penalty function of the equality constraint/s
62 data.nlp.PenaltyCoefficientEq = [1d0]; %J0=J0+PenaltyCoefficientEq*ViolationOfEqualityConstraint /* only for DE, SRES */

This place is necessary for defining the number of the equality constraints with the time at which they are active,
i.e. after which segment. The penalty function for the equality constraints can also be actived.

Page – 11
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Example The equality constraint of the type ’data.nl.equality.eq(1)={’y2 +0.1’}’ is active, the status is set on the value
of ’on’ what means that the equation

x2 = −0.1 (4.7)

is active in the final segment ’data.nlp.equality.time(1)=data.ic.Anum’. This direction – timing is equal to


the final time. If we would like to set the active equality constraint on the half time of the optimization, we
have to define the before mentioned option on the value of 15 or ’data.ic.Anum/2’.

63 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
64 % Inequality /path/ constraint/s:
65 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
66 data.nlp.inequality.status = 'on'; %['on'|'off'] inequality constraint/s
67 data.nlp.inequality.NEC = 2; %number of active inequality constraint/s
68 data.nlp.inequality.InNUM = 1; % how many inequality constraint/s is/are '>' else '<'
69 data.nlp.inequality.eq(1) = {'y(1)+0.4d0'};
70 data.nlp.inequality.eq(2) = {'y(1)−0d0'};
71 data.nlp.inequality.Tol = 0.0005d0; %tolerance level of violation of the inequality constraints
72 data.nlp.PenaltyFunctionInEq = 'off'; %['on'|'off'] penalty function of the inequality constraint/s
73 data.nlp.PenaltyCoefficientInEq = [1d0 1d0]; %J0=J0+PenaltyCoefficientInEq(i)*ViolationOfInequalityConstraint(i) /* for every inequality constraint one parameter */

This part of the function contains information about the inequality constraints and their penalty functions. The user
can insert the number of inequality constrains and choose type: ’>’ or ’<’. Note that all inequality constraints are
solved with the help of the slack variables [15].

Example There are 2 inequality constraints ’data.nlp.inequality.NEC=2’ active. The first one and the second one is of
the type ’>’ and ’<’, respectively. This is declared in the ’data.nlp.inequality.InNUM=1’ option. In other
words:

x1 (t) ≥ −0.4 (4.8)


x1 (t) ≤ 0 (4.9)

or we can talk about the path constraints. These constrains are solved with the help of the slack variables
which must be relaxed by some tolerance level. This can be done in the option: ’data.nlp.inequality.Tol=0.0005’.
If there is a problem with the convergence, we can set an active penalty function, same as in the equality
constraints, the value of which is implemented in the option: ’data.nlp.PenlatyCoefficentInEq=[1 1]’. This
penalty function is incorporated directly into the cost function.

74 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
75 % Output:
76 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
77 data.options.intermediate = 'off'; %['on'|'off'] display of the intermediate results
78 data.options.display = 'on'; %['on'|'off']
79 data.options.title = 'on'; %['on'|'off']
80 data.options.state = 'on'; %['on'|'off']
81 data.options.control = 'on'; %['on'|'off']
82 data.options.ConvergenceCurves = 'off'; %['on'|'off']
83 data.options.PicturesFormat = 'eps'; %['eps'|'wmf'|'both']
84 data.options.report = 'off'; %['on'|'off']
85 data.options.commands = {''}; %additional commands e.g. 'figure(1), grid'
86 data.options.trajectories = data.ic.NUMs; %how many state trajectories will be displayed
87 data.options.profiler = 'off'; %['on'|'off']

There are settings for the output. First option in this part is related with the display of the intermediate results.
Other settings are connected with the figures which show the state, control or convergence curves or save the results
into the ’.dat’ file. There is an option to insert additional commands for the depicted pictures and an option for the
turning ’on/of f ’ of the profiler function. If the profiler function is set to the value of ’on’ the toolbox after the
optimization shows all parts with the relevant CPU time. Note that if this option is active, this has an impact on the
total CPU time.
88 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
89 % Call of the main program (you do not change this!):
90 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
91 cd ../src;
92 DOTcvp NLP
93 cd MATLAB examples;

On this place the main function of the toolbox with the data structure is called.
Several parts of this input function contain information which is described in detail in the manuals for
SUNDIALS, IPOPT, FMINCON, SRES, DE and that is the reason for the absence of their description.

Page – 12
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

min J0=2.96099523 [CVODEs: 1e−007, Newton, Simultaneous, Adams] min J0=2.96099523 [CVODEs: 1e−007, Newton, Simultaneous, Adams]
[NLP: 1e−005, N=30, iter=97, FMINCON, SensitivityEq] − MATLAB [NLP: 1e−005, N=30, iter=97, FMINCON, SensitivityEq] − MATLAB
1.2 3

1 2.5

0.8 2

State variable/s, x
0.6 1.5
Control/s, u

0.4 1

0.2 0.5

0 0

−0.2 −0.5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time Time

Figure 4.1 – Optimal state trajectories (left) [x1 – blue, x2 – green, x3 – red] and the optimal control profile (right)
for a van der Pol oscillator, N = 30

4.1.2 Graphical Output


The Figure 4.1 shows the constrained state trajectories and the optimal control trajectory for the scenario
N = 30 on the basis of the settings presented in the Subsection 4.1.1. These are the figures from the DOTcvp
output. It is possible to see in the title of figures the value of the cost function and the resulting settings for
IVP (tolerance level, nonlinear solver, sensitivity correction method, LMM) and NLP (tolerance level, number
of piecewise constants, number of iterations, NLP solver, gradient method). This can be done with the option:
’data.output.title’. The above mentioned problem with the presented settings (as well as other problems pre-
sented in the next section) is possible to run from the toolbox: report VanDerPolOscilator

Page – 13
CHAPTER 5

GUI for DOTcvp

5.1 STEP BY STEP


The GUI for DOTcvp toolbox was developed in order to help users work with the toolbox, mainly at the
beginning. The procedure consists of several steps. The input screens for a van der Pol oscillator problem are
shown here:
How the GUI can be run and used?
1. You need to set in the subdirectory ’GUI examples’ which is a part of the toolbox

DOTcvp\GUI examples
2. Then you need to type ’DOTcvpGUI’ in the command prompt and press enter.
3. After the GUI is opened you can load and edit the previously created problem (some .dotcvp file), or you
can define the new problem.
4. The problem input file of the form .m and .dotcvp (mat) is generated after the last GUI screen. If the problem
is saved, the *.m file is running.
Be careful if you use GUI, because the problems will be saved and run from the MATLAB command path.
It is good to be set in the before mentioned subdirectory.

Figure 5.1 – Introduction screen, here the user can choose if he wants to create a new problem, or if he would like
to continue editing the previously created problem.
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Figure 5.2 – NLP Definition, here is set everything regarding the NLP settings, gradient method, cost function,
and constraints on the control variables and on time-independent parameters, with a convenient approximation.

Figure 5.3 – Initialization of the Optimization, in this step it is needed to insert number of constants, control,
time-independent parameters, and state variables with initial and final time. If the free time problem is considered,
there is a place to define the initial conditions for time variables.

Figure 5.4 – Problem Definition, there is a place for the definition of the model with the help of ordinary differential
equations (ODEs), the initial conditions, and parameters for MATLAB or FORTRAN if they are used. The form
how the ODEs have to be inserted is shown on the beginning of this screen.

Page – 15
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Figure 5.5 – In/Equality Constraints, place for the before mentioned constraints, if they are active, it is needed to
set the switch on the value of ’on’. The violation of the constraints can be penalized directly with the help of the
penalty coefficients.

Figure 5.6 – ODE and Sensitivities Initialization, this screen is used for the initialization (set the tolerance levels)
of the integrated equations, both system and sensitivities.

Figure 5.7 – Output, the last screen. Here it is possible to set many settings for the output (figures and data). The
most important option is to save the data into a .dotcvp file, which can be later used for the loading and editing of
the problem. All presented problems in the report can be loaded and edited directly from the toolbox package as a
.dotcvp file.

Page – 16
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

Figure 5.8 – MATLAB Output: At the end of the optimization the graphic output can be obtained together with
the numerical solution.

Page – 17
CHAPTER 6

Illustrative Examples

6.1 OPTIMAL CONTROL PROBLEMS


6.1.1 Nishida Problem
This problem [report NishidaProblem] is taken from [28] and later solved e.g. in [35]. The aim of the
optimization is to minimize the cost function of the form
4
X
min J0 = x2i (tF ) (6.1)
ui
i=1

subject to
ẋ1 = −0.5x1 + 5x2 (6.2)
ẋ2 = −5x1 − 0.5x2 + u (6.3)
ẋ3 = −0.6x3 + 10x4 (6.4)
ẋ4 = −10x3 − 0.6x4 + u (6.5)
with the process initial conditions: x(0) = [10; 10; 10; 10] and final time tF = 4.2. The control variable is initially
set on the value of 0 and it is constrained with the lower and upper bound: u ∈ [−1; 1].
15
x1 1
x2
x3 0.8
10 x4
0.6

0.4
5
State variables, x1:4

0.2
Control, u1

0 0

−0.2

−5
−0.4

−0.6

−10
−0.8

−1
−15
0 0.5 1 1.5 2 2.5 3 3.5 4 0 0.5 1 1.5 2 2.5 3 3.5 4
Time Time

Figure 6.1 – Optimal state trajectories (left) and the control profile (right) for a Nishida problem, N = 15

6.1.2 Plug-flow Reactor with a Singular Arc


This problem, initially formulated by [19], latter solved e.g. in [6; 1] consists of a plug-flow reactor
[report PlugFlowReactor] with the following chemical reactions: A ↔ B → C. The aim of the optimiza-
tion is to adjust the fraction of the first catalyst defined by reversible reaction so as to maximize the production of
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

the component C. This is done with the following cost function

max J0 = 1 − xA (zF ) − xB (zF ) (6.6)


u(zi )

subject to

dxA (z)
= u(z)(10xB (z) − xA (z)) (6.7)
dz
dxB (z)
= −u(z)(10xB (z) − xA (z)) − (1 − u(z))xB (z) (6.8)
dz
where xA and xB represents the mole fractions of components A and B. The control variable u(z) represents the
fraction of the catalyst associated with the reversible reaction at the position z in the plug-flow reactor of the length
one. The control variable is constrained as follows: u(z) ∈ [0; 1]. The process and control initial values are
x0 = [1; 0] and u0 = [0.95], respectively.

x1 1
1 x2
0.9

0.8
0.8
0.7
State variables, x1:2

0.6
Control, u1

0.6
0.5

0.4
0.4
0.3

0.2
0.2
0.1

0
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Time

Figure 6.2 – Optimal state trajectories (left) and the control profile (right) for a plug-flow reactor, N = 50

6.1.3 Optimal Control of a Non-differentiable System


This problem [report NonDifferentiableSystem] has been solved by several authors [25; 7]. The aim of
the optimization is to find the optimal control trajectory that minimizes x3 in the final time

min J0 = x3 (tF ) (6.9)


ui

subject to

ẋ1 = x2 (6.10)
ẋ2 = −x1 − x2 + u + d (6.11)
ẋ3 = 5x21 + 2.5x22 + 0.5u2 (6.12)

with the disturbance term given as

d = 100[U (t − 0.5) − U (t − 0.6)] (6.13)

where U = 0 for [(t − α) < 0] else U = 1 for [(t − α) > 0]. This means that between t = 0.5 and t = 0.6 is a
rectangular pulse of magnitude with the value of 100. The vector of process initial conditions is set on the value of
x(0) = [0; 0; 0] and the final time on tF = 2.

6.1.4 Lee-Ramirez Bioreactor


Considering a bioreactor [report LeeRamirezBioreactor], which was first solved in [22] and later slightly
modified in [33]. The objective is to maximize the profitability of the process using the nutrient u1 and the inducer
feeding rates u2 . Different scenarios with the various value of Q are considered.

Page – 19
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

60
x1
x2 0

50 x3

−2
40

−4
State variables, x1:3

30

Control, u1
−6
20

−8
10

0 −10

−10 −12
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time Time

Figure 6.3 – Optimal state trajectories (left) and the control profile (right) for a non-differentiable system, N = 50

The mathematical formulation of the problem is as follow: find the control trajectories that maximize the
cost function at the final time
Z tF
max J0 = x1 (tF )x4 (tF ) − Q u2 (t)dt (6.14)
ui to

subject to

x˙1 = u1 + u2 (6.15)
u1 + u2
x˙2 = g1 x2 − x2 (6.16)
x1
100u1 u1 + u2 g1
x˙3 = − x3 − x2 (6.17)
x1 x1 0.51
u1 + u2
x˙4 = Rf p x2 − x4 (6.18)
x1
4u2 u1 + u2
x˙5 = − x5 (6.19)
x1 x1
x˙6 = −k1 x6 (6.20)
x˙7 = k2 (1 − x7 ) (6.21)

where

 
x3 0.22x7
g1 = x6 + (6.22)
14.35 + x3 (1 + x3 /111.5) 0.22 + x5
  
0.233x3 0.0005 + x5
Rf p = (6.23)
14.35 + x3 (1 + x3 /111.5) 0.022 + x5
0.09x5
k1 = k2 = (6.24)
0.034 + x5
The scenario with Q = 0 and 2.5 is considered. The final time is specified as 10 h and the vector process
and control initial conditions as x(0) = [1; 0.1; 40; 0; 0; 1; 0; 0] and u1,2 = [0.5; 0.5] respectively. The additional
constrains on the control variables are the following: u1,2 ∈ [0; 1]

6.1.5 Optimal Production of Secreted Protein in a Fed-batch Reactor


Consider a fed-batch reactor [report OptimalProductionOfSecretedProtein] where the goal of the opti-
mization is to achieve the maximum amount of the secreted protein at the end of the batch time. This optimal
control problem has been studied by many authors [2; 24; 6].
The cost function is defined as follows

max J0 = x1 (tF )x5 (tF ) (6.25)


ui

Page – 20
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

1 u1 1 u1
u2 u2
0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6
Control, u1:2

Control, u1:2
0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0

0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
Time Time

Figure 6.4 – Optimal control trajectories for a Lee-Ramirez bioreactor, left for Q = 0 and right for Q = 2.5 case,
N = 25

where x1 is the concentration of the protein (L−1 ) and x5 is the culture volume (L) at the final time tF = 15 h.
The optimal control problem is solved subject to
u
x˙1 = g1 (x2 − x1 ) − x1 (6.26)
x5
u
x˙2 = g2 x3 − x2 (6.27)
x5
u
x˙3 = g3 x3 − x3 (6.28)
x5
u
x˙4 = −7.3g3 x3 + (20 − x4 ) (6.29)
x5
x˙5 = u (6.30)
where
4.75g3
g1 = (6.31)
0.12 + g3
x4 e−5x4
g2 = (6.32)
0.1 + x4
21.87x4
g3 = (6.33)
(x4 + 0.4)(x4 + 62.5)
with the vector of a process initial conditions: x(0) = [0; 0; 1; 5; 1] and the initial control trajectory: u(0) = [0.5].
The value of u is the feed flow rate (L h−1 ), x2 is the concentration of the total protein (L−1 ), x3 and x4 are the
glucose and the substrate concentration (g L−1 ). The lower and upper bound on the control value is: u ∈ [0; 2].
6.1.6 Nonlinear CSTR Reactor
Consider a problem given in [23; 3]. In the isothermal continuous stirred tank reactor four simultaneous
chemical reactions are taking place. The problem [report NonlinearCSTR] consists of determining four optimal
control profiles for obtaining a maximum economic benefit. The controls are the flowrates of three feed streams
and an electrical energy input used to promote a photochemical reaction. The system with the integral term of the
cost function (ẋ8 ) is described by following set of differential equations
ẋ1 = u4 − qx1 − 17.6x1 x2 − 23x1 x6 u3 (6.34)
ẋ2 = u1 − qx2 − 17.6x1 x2 − 146x2 x3 (6.35)
ẋ3 = u2 − qx3 − 73x2 x3 (6.36)
ẋ4 = −qx4 + 35.2x1 x2 − 51.3x4 x5 (6.37)
ẋ5 = −qx5 + 219x2 x3 − 51.3x4 x5 (6.38)
ẋ6 = −qx6 + 102.6x4 x5 − 23x1 x6 u3 (6.39)
ẋ7 = −qx7 + 46x1 x6 u3 (6.40)
ẋ8 = 5.8(qx1 − u4 ) − 3.7u1 − 4.1u2 + q(23x4 + 11x5 + 28x6 + 35x7 ) − 5u23 − 0.099 (6.41)

Page – 21
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

14
x1
2
x2

12 x3 1.8
x4
x5 1.6
10
1.4
State variables, x1:5

1.2
8

Control, u1
1

6
0.8

0.6
4

0.4

2 0.2

0
0
0 5 10 15 0 5 10 15
Time Time

Figure 6.5 – Optimal state trajectories (left) and the control profile (right) for a fed-batch reactor, N = 15

where q = (u1 + u2 + u4 ). The additional constraints on the control variables, i.e. the lower and upper bounds
are following u1 ∈ [0; 20], u2 ∈ [0; 6], u3 ∈ [0; 4], and u4 ∈ [0; 20]. The vector of initial controls and process
variables is [10; 3; 2; 6] and [0.1883; 0.2507; 0.0467; 0.0899; 0.1804; 0.1394; 0.1046; 0.0000], respectively.
The target is to maximize the amount of the component x8 at the final time tF (0.2 h)
max J0 = x8 (tF ) (6.42)
ui

0.5 20 6
x1
5
0.45 x2 15
4
Control, u1

x3 Control, u2
x4 10 3
0.4
x5
2
x6 5
0.35
x7 1

0 0
State variables, x1:7

0.3
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time Time
0.25

0.2 4 20

0.15 3 15
Control, u3

Control, u4

2 10
0.1

1 5
0.05

0 0
0
0 0.05 0.1 0.15 0.2 0.25 0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time Time Time

Figure 6.6 – Optimal state trajectories (left) and the control profiles (right) for the nonlinear CSTR reactor, N = 11

6.2 EQUALITY AND INEQUALITY CONSTRAINTS PROBLEMS


6.2.1 Terminal and Interior Point Constraints
The problem [report TerminalInteriorPointConstraint1,2] with the terminal and the interior point con-
straint was solved. This problem is presented in [16]. The scenarios with the piecewise constant and linear control
trajectory were solved. The aim of the optimization is to minimize the cost function of the form until the final
time tF = 1 come
min J0 = x2 (tF ) (6.43)
ui

subject to
ẋ1 = u (6.44)
ẋ2 = x21 +u 2
(6.45)
and the point constraints as follow
x1 (0.6) = 0.8 (6.46)
x1 (1) = 0.5 (6.47)

Page – 22
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

1 0

0.9
−0.1

0.8
−0.2

0.7
−0.3
State variables, x1:2

0.6

Control, u1
−0.4
0.5

−0.5
0.4

−0.6
0.3

−0.7
0.2

0.1 x1 −0.8 u1 − piecewise constant


x2 u1 − piecewise linear
0 −0.9
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Time

Figure 6.7 – The state profiles (left) and the piecewise constant (N = 10) and linear (N = 2) control profile
(right) for a terminal and interior point constraints

6.2.2 Inequality State Path Constraint Problem


Consider a problem initially solved by [18]. The problem consists of the minimization of the following cost
function

min J0 = x3 (6.48)
ui

subject to

ẋ1 = x2 (6.49)
ẋ2 = −x2 + u (6.50)
ẋ3 = x21 + x22 + 0.005u2 (6.51)

and subject to the path constraint on the whole time interval (tF = 1)

x2 − 8(t − 0.5)2 + 0.5 ≤ 0 (6.52)

The vector of the initial control, process trajectory is set on the value of u(0) = [1], x(0) = [0; −1; 0],
respectively. The problem was the first one [report InequalityStatePathConstraint1] solved with the inequality
constraint and the second one [report InequalityStatePathConstraint2] with transformed inequality constraint
as the next ODE equation as it is shown in [16].
12
0.5
J1

10

−0.5
6
Constraint, J1

Control, u1

−1 4

2
−1.5

−2
−2

−2.5 −4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Time

Figure 6.8 – The constraint profile (left) and the control profile (right) for an inequality state path constraint
problem (1), N = 20

Page – 23
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

6.2.3 Chemical Reactor Control


The chemical reactor [report ChemicalReactorControl] with the first-order reversible chemical reaction:
A ↔ B as studied by [21; 26; 27] is considered. The system with the initial conditions: x(0) = [0; 380] is
described by the following set of differential equations

x˙1 = (1 − x1 )k1 − x1 k2 (6.53)


x˙2 = 300[(1 − x1 )k1 − x1 k2 ] − u(x2 − 290) (6.54)

where
−1.1374x104
 
5
k1 = 1.7536x10 e 1.9872x2
(6.55)
−2.2748x104
 
k2 = 2.4885x1010 e 1.9872x2
(6.56)

The x1 denotes the concentration of the desired product, x2 is the temperature, and u is the coolant flow
rate. The aim of the optimization is to get a maximum product of the first component until the final time tF = 5 min

max J0 = x1 (tF ) (6.57)


ui

subject to the upper (path) constraint on the temperature

x2 (t) ≤ 460 (6.58)

and constraints on the control variable: u ∈ [0; 0.5] with initial control trajectory: u(0) = 0.25.
470
x1
0.5
460

450
0.4
440
State variables, x1

430 0.3
Control, u1

420

0.2
410

400
0.1
390

380
0

370
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time Time

Figure 6.9 – Optimal state trajectory (left) and the control profile (right) for a chemical reactor problem, N = 42

6.2.4 Fed Batch Reactor for Ethanol Production


The problem of the fed batch reactor [report FedBatchReactorForEthanolProduction] which was ini-
tially solved by [11] with final time tF = 54 was considered. This problem was later solved in e.g. [4] and it
consists of the finding of the optimal control policy over the whole time t ∈ [t0 ; tF ] that maximizes

max J0 = x3 (tF )x4 (tF ) (6.59)


ui

subject to
 
x1
ẋ1 = g1 x1 − u (6.60)
x4
 
150 − x2
ẋ2 = −10g1 x1 + u (6.61)
x4
 
x3
ẋ3 = g2 x1 − u (6.62)
x4
ẋ4 = u (6.63)

Page – 24
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

where
 
0.408 x2
g1 = (6.64)
1 + x3 /16 0.22 + x2
  
1 x2
g2 = (6.65)
1 + x3 /71.5 0.44 + x2

The state values x1 , x2 , x3 , and x4 are the cell mass, the substrate, the ethanol concentration (g/L), and
the volume (L), respectively. The initial conditions for the process variables were initially set on the value of:
x(0) = [1; 150; 0; 10] and the lower and upper bound of the control value (feed rate) is: u(0) ∈ [0; 12]. The
volume of the container (x4 ) is bound with the equation as follows

0 ≤ x4 (t) ≤ 200 (6.66)

220
x1
12
200 x2
x3
180 x4
10

160

140 8
State variables, x1:4

Control, u1

120
6
100

80
4

60

2
40

20
0
0
0 5 10 15 20 25 30 35 40 45 50 0 5 10 15 20 25 30 35 40 45 50
Time Time

Figure 6.10 – Optimal state trajectories (left) and the control profile (right) for a fed batch reactor for ethanol
production, N = 25

6.2.5 Optimal Control of a Fed Batch Fermenter for Penicillin Production


The problem of the feed batch fermenter for the penicillin production has been solved e.g. in [14; 5]. The
scenario with fixed final time is considered. The aim is to maximize until the final time (tF = 132) the cost
function of the form

max = x2 (tF )x4 (tF ) (6.67)


ui

subject to
 
x1
ẋ1 = g1 x1 − u (6.68)
500x4
 
x2
ẋ2 = g2 x1 − 0.01x2 − u (6.69)
500x4
g x  g x  
1 1 2 2 0.029x3 u  x3 
ẋ3 = − − − x1 + 1− (6.70)
0.47 1.2 0.0001 + x3 x4 500
u
ẋ4 = (6.71)
500
where
 
x3
g1 = 0.11 (6.72)
0.006x1 + x3
 
x3
g2 = 0.0055 (6.73)
0.0001 + x3 (1 + 10x3 )

Page – 25
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

with the vector of process and control initial conditions: x(0) = [1.5; 0; 0; 7], u(0) = [11.25]. The values of the
biomass, penicillin, substrate concentration (g/L) and volume (L) are marked as x1 , x2 , x3 , and x4 , respectively.
There are several path constraints

0 ≤ x1 ≤ 40 (6.74)
0 ≤ x2 ≤ 25 (6.75)
0 ≤ x3 ≤ 10 (6.76)

with bounds on the control variable (feed rate of the substrate) u ∈ [0; 50].
26
x1
30
x2
24
x3
x4
25 22

20
20
State variables, x1:4

Control, u1
18

15
16

14
10

12

5
10

0 8
0 20 40 60 80 100 120 140 160 0 20 40 60 80 100 120 140
Time Time

Figure 6.11 – Optimal state trajectories (left) and the control profile (right) for a fed batch fermenter for penicillin
production, N = 10

6.3 FREE TIME PROBLEMS


6.3.1 Modified Denbigh Reaction System
Consider a batch reactor [report ModifiedDenbighReactionSystem] taken from [9], where five chemical
reactions take place

A+B→X (6.77)
A+B→P (6.78)
X→Y (6.79)
X→Q (6.80)
Y→Z (6.81)

where A and B are reactants, Y is the desired product, X is an intermediate and P, Q, and Z are waste products.
The optimal control problem is to find an optimal control trajectory – the temperature profile (K) and the final time
which yields the maximum amount of the product B

max J0 = x3 (tF ) (6.82)


ui ,ti

subject to

ẋ1 = −k1 x1 − k2 x1 (6.83)


ẋ2 = k1 x1 − (k3 + k4 )x2 (6.84)
ẋ3 = k3 x2 − k5 x3 (6.85)

where the rate constants are given by


Ei
ki = ki0 e( RT ) , i = 1, 5 (6.86)

and x1 , x2 , and x3 denote concentration of the A, B, and C, respectively. The initial process conditions are set
as: x(0) = [1; 0; 0] and the boundaries on the control trajectory as: u ∈ [273; 415]. The penalty function with the
value of 10−7 on the final time was used.

Page – 26
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

420
x1
x2
x3 400
1

380
0.8

360
State variables, x1:3

Control, u1
0.6
340

0.4 320

300
0.2

280
0

260
0 50 100 150 200 250 300 350 400 450 500 550 0 50 100 150 200 250 300 350 400 450 500 550
Time Time

Figure 6.12 – Optimal state trajectories (left) and the control profile (right) for a modified Denbigh reaction system,
N = 15

6.3.2 Simple Batch Reactor


The simple batch reactor [report SimpleBatchReactor] given in [13] was considered with the chemical
reaction: A → B → C. The parameters of the reactor are: e1 = 18000 cal mol−1 , e2 = 30000 cal mol−1 ,
k10 = 0.535x1011 min−1 , k20 = 0.461x1018 min−1 , r = 2 cal mol−1 K−1 , β1 = 0.53 mol l−1 , β2 = 0.43 mol l−1 ,
α = ee12 , c = kk20
α and final time tF = 8.0 min.
10
The objective of the optimization is to maximize an amount of the product B at the final time

max J0 = x2 (tF ) (6.87)


ui ,ti

subject to

ẋ1 = −ux1 (6.88)


ẋ2 = ux1 − cuα x2 (6.89)

with the process: x(0) = [β1 ; β2 ] and control: u(0) = [0.5] initial variables. Next it is defined the additional
equality constraint that holds the total time of simulation on the fixed value
N
X
ti = tF (6.90)
i=1

0.175 0.19
u1 − piecewise constant (free time), max J0 = 0.67941706 u1 − piecewise constant (fixed time), max J0 = 0.67941127
u1 − piecewise linear (fixed time), max J0 = 0.67943676
0.17
0.18

0.165

0.17
0.16

0.155
0.16
Control, u1
Control, u1

0.15

0.15
0.145

0.14 0.14

0.135
0.13
0.13

0.125 0.12
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Time Time

Figure 6.13 – Optimal control profile for a free time scenario (left) and the control profile with the piecewise
constant and linear approximation (right) for a simple batch reactor, N = 6

Page – 27
Bibliography

[1] E. BALSA -C ANTO, Algoritmos Eficientes para la optimización dinámica de procesos distribuidos, PhD the-
sis, University of Vigo, Vigo, Spain, 4 2001.
[2] E. BALSA -C ANTO , J. R. BANGA , A. A. A LONSO , AND V. S. VASSILIADIS, Efficient optimal control of
bioprocesses using second-order information, Industrial and Engineering Chemistry Research, 39 (2000),
pp. 4287–4295.
[3] , Restricted second order information for the solution of optimal control problems using control vector
parameterization, Journal of Process Control, 12 (2002), pp. 243–255.
[4] J. R. BANGA , A. A. A LONSO , AND R. P. S INGH, Stochastic dynamic optimization of batch and semicon-
tinuous bioprocesses, Biotechnology Progress, 13 (1997), pp. 326–335.
[5] J. R. BANGA , B. E. C ANTO , E. G. M OLES , AND A. A. A LONSO, Dynamic optimization of bioprocesses:
Efficient and robust numerical strategies, Journal of Biotechnology, 117 (2005), pp. 407–419.
[6] J. R. BANGA , R. I RIZARRY-R IVERA , AND W. D. S EIDER, Stochastic optimization for optimal and model-
predictive control, Computers and Chemical Engineering, 22 (1998), pp. 603–612(10).
[7] J. R. BANGA AND W. D. S EIDER, Global optimization of chemical processes using stochastic algorithms, in
State of the art in global optimization (Princeton, NJ, 1995), vol. 7, Kluwer Acad. Publ., 1996, pp. 563–583.
[8] L. T. B IEGLER AND I. E. G ROSSMANN, Retrospective on optimization, Computers and Chemical Engineer-
ing, 28 (2004), pp. 1169–1192.
[9] B. B OJKOV AND R. L UUS, Optimal control of nonlinear systems with unspecified final times, Chemical
Engineering Science, 51 (1996), pp. 905–919.
[10] A. E. B RYSON AND Y. C. H O, Applied Optimal Control - Optimization, Estimation and Control, Hemisphere
Publishing corporation, Washington, 1975.
[11] C.-T. C HEN AND C. H WANG, Optimal control computation for differential-algebraic process systems with
general constraints, Chemical Engineering Communications, 97 (1990), pp. 9–26.
[12] T. C OLEMAN , M. A. B RANCH , AND A. G RACE, Optimization toolbox for use with matlab user’s guide
version 2, 1998.
[13] S. C RESCITELLI AND S. N ICOLETTI, Near optimal control of batch reactors, Chemical Engineering Sci-
ence, 28 (1973), pp. 463–471.
[14] S. A. DADEBO AND K. B. M C AULEY, Dynamic optimization of constrained chemical engineering problems
using dynamic programming, Computers and Chemical Engineering, 19 (1995), pp. 513–525. 10: Diversen.
[15] W. F. F EEHERY AND P. I. BARTON, Dynamic optimization with state variable path constraints, Computers
and Chemical Engineering, 22 (1998), pp. 1241–1256.
[16] M. F IKAR AND M. A. L ATIFI, User’s guide for FORTRAN dynamic optimisation code DYNO, Tech. Report
mf0201, LSGC CNRS, Nancy, France; SUT Bratislava, Slovak Republic, 2001.
[17] A. C. H INDMARSH , P. N. B ROWN , K. E. G RANT, S. L. L EE , R. S ERBAN , D. E. S HUMAKER , AND C. S.
W OODWARD, Sundials: Suite of nonlinear and differential/algebraic equation solvers,, ACM Transactions
on Mathematical Software, 31 (2005), pp. 363–396.
[18] D. JACOBSON AND M. L ELE, A transformation technique for optimal control problems with a state variable
inequality constraint, IEEE Transactions on Automatic Control, 5 (1969), pp. 457–464.
[19] R. JACZSON, Optimal use of mixed catalysts for two successive chemical reactions, Journal of Optimization
Theory and Applications, 2 (1968), pp. 27–39.
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

[20] S. K AMESWARAN AND L. T. B IEGLER, Simultaneous dynamic optimization strategies: Recent advances
and challenges, Computers and Chemical Engineering, 30 (2006), pp. 1560–1575.
[21] D. Y. C. KO AND W. F. S TEVENS, Study of singular solutions in dynamic optimization, AIChE Journal, 17
(1971), pp. 160–166.
[22] J. L EE AND W. F. R AMIREZ, Optimal fed-batch control of induced foreign protein production by recombi-
nant bacteria, AIChE Journal, 40 (1994), pp. 899–907.
[23] R. L UUS, Application of dynamic programming to high-dimensional non-linear optimal control problems,
International Journal of Control, 52 (1990), pp. 239–250.
[24] , On the application of iterative dynamic programming to singular optimal control problems, 37 (1992),
pp. 1802–1806.
[25] , Piecewise linear continuous optimal control by iterative dynamic programming, Industrial and Engi-
neering Chemistry Research, 32 (1993), pp. 859–865.
[26] , Optimal control of batch reactors by iterative dynamic programming, Journal of Process Control, 4
(1994), pp. 218–226.
[27] W. M EKARAPIRUK AND R. L UUS, Optimal control of inequality state constrained systems, Industrial and
Engineering Chemistry Research, 36 (1997), pp. 1686–1694.
[28] N. N ISHIDA , Y. A. L IU , L. L APIDUS , AND S. H IRATSUKA, An effective computational algorithm for
suboptimal singular and/or bang-bang control i. theoretical developments and applications to linear lumped
systems, AIChE Journal, 22 (1976), pp. 505–513.
[29] O. ROSEN AND R. L UUS, Evaluation of gradients for piecewise constant optimal control, Computers and
Chemical Engineering, 15 (1991), pp. 273–281.
[30] T. P. RUNARSSON AND X. YAO, Stochastic ranking for constrained evolutionary optimization, IEEE Trans-
actions Evolutionary Computation, 4 (2000), pp. 284–294.
[31] R. S TORN AND K. P RICE, Differential evolution - a simple and efficient heuristic for global optimization
over continuous spaces, Journal of Global Optimization, 11 (1997), pp. 341–359.
[32] P. TANARTKIT AND L. T. B IEGLER, Stable decomposition for dynamic optimization, Industrial and Engi-
neering Chemistry Research, 34 (1995), pp. 1253–1266.
[33] A. T HOLUDUR AND W. F. R AMIREZ, Obtaining smoother singular arc policies using a modified iterative
dynamic programming algorithm, International Journal of Control, 68 (1997), pp. 1115–1128.
[34] V. VASSILIADIS, Computational Solution of Dynamic Optimization Problems with General Differential-
Algebraic Constraints, PhD thesis, University of London, London, UK, 1993.
[35] V. S. VASSILIADIS , E. BALSA -C ANTO , AND J. R. BANGA, Second-order sensitivities of general dynamic
systems with application to optimal control problems, Chemical Engineering Science, 54 (1999), pp. 3851–
3860.
[36] M. Č I ŽNIAR , M. F IKAR , AND M. A. L ATIFI, Matlab dynamic optimisation code dynopt. user’s guide,
tech. report, Department of Information Engineering and Process Control, FCFT STU, Bratislava, Slovak
Republic, 2006.
[37] A. W ÄCHTER AND L. T. B IEGLER, On the implementation of a primal-dual interior point filter line search
algorithm for large-scale nonlinear programming, Mathematical Programming, 106 (2006), pp. 25–57.
[38] J. L. Z HOU , A. L. T ITS , AND C. T. L AWRENCE, User’s guide for ffsqp version 3.7: A fortran code for
solving constrained nonlinear (minimax) optimization problems, generating iterates satisfying all inequality
and linear constraints, tech. report, Electrical Engineering Department and Institute for Systems Research
University of Maryland, College Park, MD 20742, USA, 1997.

Page – 29
Appendix

GRADIENTS DERIVATION
The simple batch reactor given in Subsection 6.3.2 is considered. Firstly, the scenario with fixed time
intervals is solved. The problem of the optimization is to find the optimal control trajectory which minimizes

min J0 = −x2 (tF ) (6.91)


ui

subject to

ẋ1 = −ui x1 (6.92)


ẋ2 = ui x1 − cuα
i x2 (6.93)

For simplicity and demonstrative purposes only 3 piecewise constant control variables with fixed time were
chosen. The gradients with respect to the control are defined as follows

∂J0
= −s2i (tF ), i = 1, 3 (6.94)
∂ui
To obtain the necessary gradients (6.94) it is needed to integrate sensitivity equations over the whole time
(tF ). The sensitivity coefficients for i = 1, 3 are defined as

∂x1
s1i = (6.95)
∂ui
∂x2
s2i = (6.96)
∂ui
together with the sensitivity equations
1 x1 ) ∂x1 ∂(−u1 x1 ) ∂(−u1 x1 )
= ∂(−u ∂x2 ∂u1


 ṡ11 ∂x1 ∂u1 + ∂x2 ∂u1 + ∂u1 ∂u1 = −u1 s11 − x1 , t ∈ [t0 , t1 ]
2 x1 ) ∂x1 ∂(−u2 x1 ) ∂(−u2 x1 )
= ∂(−u ∂x2 ∂u2




 ṡ11 ∂x1 ∂u1 + ∂x2 ∂u1 + ∂u2 ∂u1 = −u2 s11 , t ∈ [t1 , t2 ]
 ∂(−u3 x1 ) ∂x1 ∂(−u3 x1 ) ∂x2 ∂(−u3 x1 ) ∂u3



 ṡ11 = ∂x1 ∂u1 + ∂x2 ∂u1 + ∂u3 ∂u1 = −u3 s11 , t ∈ [t2 , tF ]
 ṡ12 = −u1 s12 , t ∈ [t0 , t1 ]
ṡ12 = −u2 s12 − x1 , t ∈ [t1 , t2 ] (6.97)

ṡ12 = −u3 s12 , t ∈ [t2 , tF ]




ṡ13 = −u1 s13 , t ∈ [t0 , t1 ]




ṡ13 = −u2 s13 , t ∈ [t1 , t2 ]




ṡ13 = −u3 s13 − x1 , t ∈ [t2 , tF ]
DOTcvp: Dynamic Optimization Toolbox with Control Vector Parameterization approach – June 5, 2008

∂(u1 x1 −cuα ∂(u1 x1 −cuα ∂(u1 x1 −cuα


      
1 x2 ) ∂x1 1 x2 ) ∂x2 1 x2 ) ∂u1

 ṡ21 = ∂x1 ∂u1 − ∂x2 ∂u1 + ∂u1 ∂u1 , t ∈ [t0 , t1 ]

 α α−1


 = u
1 s11 − cu1αs21 + x1 − αcu
 1 x2 α 
∂(u2 x1 −cuα
  
 ∂(u2 x1 −cu2 x2 ) ∂x1 ∂(u2 x1 −cu2 x2 ) ∂x2 2 x2 ) ∂u2



 ṡ21 = ∂x1 ∂u1 − ∂x2 ∂u1 + ∂u2 ∂u1 , t ∈ [t1 , t2 ]
α
= 2 s11 − cu2αs21 
u




∂(u3 x1 −cuα ∂(u3 x1 −cuα
   
∂(u3 x1 −cu3 x2 ) ∂x1 3 x2 ) 3 x2 )

∂x2 ∂u3
 ṡ21 = − + ∂u1 , t ∈ [t2 , tF ]


∂x1 ∂u1 ∂x2 ∂u1 ∂u3
= u3 s11 − cuα (6.98)
 3 s21
ṡ22 = u1 s12 − cuα 1 s22 , t ∈ [t0 , t1 ]



− αcuα−1

ṡ22 = u2 s12 − cuα 2 s22 + x1 x2 , t ∈ [t1 , t2 ]


 2
u3 s12 − cuα

ṡ22 = 3 s22 , t ∈ [t2 , tF ]



u1 s13 − cuα



 ṡ23 = 1 s23 , t ∈ [t0 , t1 ]
ṡ23 = u2 s13 − cuα 2 s23 , t ∈ [t1 , t2 ]




u3 s13 − cuα − αcuα−1

ṡ23 = 3 s23 + x1 3 x2 , t ∈ [t2 , tF ]

or in a more compact form



 ṡ11 = −us11 − x1 R1 , t ∈ [t0 , tF ]
ṡ12 = −us12 − x1 R2 , t ∈ [t0 , tF ] (6.99)
 ṡ = −us − x R , t ∈ [t0 , tF ]
13 13 1 3

 ṡ21 = us11 − cu s21 + (x1 − αcuα−1 x2 )R1 ,
α
t ∈ [t0 , tF ]
ṡ22 = us12 − cuα s22 + (x1 − αcuα−1 x2 )R2 , t ∈ [t0 , tF ] (6.100)
 ṡ = us − cuα s + (x − αcuα−1 x )R , t ∈ [t0 , tF ]
23 13 23 1 2 3

where Ri is equal to 1 or 0 depending on the time interval ti and relevant control value. Note that not all equations
need to be integrated in each time interval, because the optimized variable in the interval ti+1 does not affect on
the interval ti .
Secondly, is the scenario with the free time intervals considered. In this case it is required to integrate new
sensitivities with respect to time

ṡ14 = −us14 , t ∈ [t0 , tF ]
(6.101)
ṡ15 = −us15 , t ∈ [t0 , tF ]
ṡ24 = us14 − cuα s24 ,

t ∈ [t0 , tF ]
(6.102)
ṡ25 = us15 − cuα s25 , t ∈ [t0 , tF ]

At the end of the time interval it is needed to compute discontinuity of sensitivity equations (6.101), (6.102)
following (3.6)

s14 (t+ −
1 ) = s14 (t1 ) + [f1 (t, x, u1 , p) − f1 (t, x, u2 , p)]t1 (6.103)
s15 (t+
2) = s15 (t−
2) + [f1 (t, x, u2 , p) − f1 (t, x, u3 , p)]t2 (6.104)
+ −
s24 (t1 ) = s24 (t1 ) + [f2 (t, x, u1 , p) − f2 (t, x, u2 , p)]t1 (6.105)
s25 (t+
2) = s25 (t−
2) + [f2 (t, x, u2 , p) − f2 (t, x, u3 , p)]t2 (6.106)

Then the resulting gradients are derived from the equation (3.9)

∂J0
= −s24 (tF ) (6.107)
∂t1
∂J0
= −s25 (tF ) (6.108)
∂t2
The gradients with respect to final time are the following (3.9) in this case equal to −f2 . Note that all time
gradients should be modified as is shown in the Section 3.2.

Page – 31

View publication stats

You might also like