0% found this document useful (0 votes)
282 views66 pages

DOTcvp

coding

Uploaded by

IonutBogdanBaciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
282 views66 pages

DOTcvp

coding

Uploaded by

IonutBogdanBaciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

TECHNICAL REPORT

DOTcvp: Dynamic Optimization Toolbox with


Control Vector Parameterization approach
for handling continuous and mixed-integer
dynamic optimization problems
Authors:
Tom Hirmajer
a
, Eva Balsa-Canto, and Julio R. Banga
E-mails:
[email protected]
[email protected]
[email protected]
Web page of the project:
http://www.iim.csic.es/~dotcvp/
INSTITUTO DE INVESTIGACIONES MARINAS, IIM-CSIC
Process Engineering Group
Spanish Council for Scientic Research
C/Eduardo Cabello 6, 36208 Vigo, Spain
a
Corresponding author
January 9, 2010
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Abstract:
This report deals with the description of the dynamic optimization toolbox (DOTcvp) which is able to solve
constrained optimal control problems (OCP) with the control vector parameterization (CVP) approach. The
original continuous problem is transformed into the nite dimensional OCP. Then it is possible to solve the
resulting nonlinear 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 modied for automatic
generation of the necessary gradients in two ways. One of them is a nite difference and the second one, a more
accurate method, is the sensitivity equations approach.
The environment for several mixed-integer (MI) or only NLP solvers, deterministic, stochastic, and hybrid able
handling continuous and mixed-integer variables was implemented in order to ensure higher accuracy not only
for small problems. It is assumed, that the optimized constrained or unconstrained system is described by a set
of ordinary differential equations (ODEs). All of this is covered by MATLAB environment, which offers to us
a comfortable control and a nice graphical output. The toolbox allows the combination of MATLAB with FOR-
TRAN for the sake of efciency FORTRAN, for enabling this option it is needed to have installed a FORTRAN
compiler in a MATLAB environment.
Key features:
handling of a wide class of dynamic optimization problems, including constrained, unconstrained, xed,
and free terminal time problems described by ordinary differential equations (ODEs), as well as continuous
and mixed integer decision variables;
the inner initial value problem (IVP) is solved using the state-of-the-art methods available in SUNDIALS
[24];
the outer (MI)NLP problemcan be solved using a number of advanced solvers, including local deterministic
methods, stochastic global optimization methods, and hybrid metaheuristics;
in addition to the traditional single optimization approach, the toolbox also offers more sophisticated strate-
gies, like multistart, sucessive re-optimization [2], and hybrid strategies [4];
a graphical user interface (GUI) which makes the denition and edition of a problem more easy and clear;
many output options for the results, including detailed gures.
Keywords: Dynamic optimization toolbox, control vector parameterization, sensitivity equations, ordinary dif-
ferential equations, MATLAB
Page 1
Main Web Page
It is possible to get the basic information about the toolbox from the following web page:
http://www.iim.csic.es/~dotcvp/
The Toolbox Requirements
MATLAB 7.0 or later is required, and the MATLAB Optimisation Toolbox and Symbolic Math Toolbox are highly
recommended. The toolbox distribution includes most of the needed external solvers: IVP solver CVODE (part
of SUNDIALS suite), and (MI)NLP solvers ACOmi, DE, IPOPT, MISQP, MITS and SRES. The Optimization
Toolbox is needed if the user wants to use FMINCON as a NLP solver. FORTRAN compilation to speed-up
computations is secured by a combination of gnumex and MinGW, packages which are distributed with the
toolbox as well. On the other hand, the Symbolic Math Toolbox is needed if automatic generation of sensitivities
and Jacobian are desired (recommended). For more information about the MATLAB MEX les, please have a
look on the following web link from the Mathworks web page:
http://www.mathworks.com/support/tech-notes/1600/1605.html
License
The DOTcvp toolbox is completely free of charge under the creative commons license. It is possible to nd the
conditions of the license on the following web page:
http://creativecommons.org/licenses/by-nc-nd/3.0/
Reference
If you are using our toolbox to obtain results for a publication, we politely ask you for your support by citation of
the following report:
@TechReport{dotcvp,
author = {Hirmajer, T. and Balsa-Canto, E. and Banga, J. R.},
title = {{DOT}cvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems},
institution = {Instituto de Investigaciones Marinas, IIM CSIC},
address = {C/Eduardo Cabello 6, 36208 Vigo, Spain},
year = {2008},
month = {4},
note = {Available at: www.iim.csic.es/$\sim$dotcvp/}
}
T. HIRMAJER, E. BALSA-CANTO, AND J. R. BANGA, DOTcvp: Dynamic optimization toolbox with control
vector parameterization approach for handling continuous and mixed-integer dynamic optimization problems,
Technical Report, Instituto de Investigaciones Marinas - CSIC, C/Eduardo Cabello 6, 36208 Vigo, Spain, 2008.
Acknowledgments
The authors would like to thank the whole CSIC group for their help with the implementation of the present
toolbox, especially to Jos Alberto Egea Larrosa. Author Tom Hirmajer also thanks to Miroslav Fikar from
Institute of Information Engineering, Automation, and Mathematics, Faculty of Chemical and Food Technology,
Slovak University of Technology for several suggestions that have led to the improvement of the presented
toolbox. The authors also would like to thank other people who contribute with their comments or ideas: Marin
Podmajersk;
Feedback
If you nd any problems, or you have only comments, questions, please do not hesitate to contact us!
THANK YOU FOR USING THE DOTCVP TOOLBOX!
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Contents
1 Introduction 8
1.1 Toolbox description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2 Description of main modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1 Utility modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.2 Optimization modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 Numerical optimization methods (NLP and MINLP solvers) . . . . . . . . . . . . . . . . . . . . 9
1.4 Numerical simulation method (IVP solvers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Recommended operating procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.6 Toolbox download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7 Toolbox installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2 Optimal control problem 13
2.1 System and cost description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 Control vector parametrization 14
3.1 NLP formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Implemented gradient methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.1 Sensitivity equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.2 Finite differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3 Gradients with respect to time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4 Algorithm outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.5 Brief information about the implemented modules . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5.1 Single optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5.2 Hybrid optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5.3 Sucessive re-optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5.4 Simulation module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Single optimization 18
4.1 From the input to the output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.1.1 Problem formulation for DOTcvp, a simple input le . . . . . . . . . . . . . . . . . . . . 18
4.1.2 Problem formulation for DOTcvp, a regular input le . . . . . . . . . . . . . . . . . . . . 19
4.1.3 Initialization, nal results, and optimal trajectories . . . . . . . . . . . . . . . . . . . . . 22
5 Sucessive re-optimization 24
5.1 Application of the mesh renement algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 GUI for DOTcvp 26
6.1 Step by step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Page 3
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
7 Chemical engineering problems 31
7.1 Simple batch reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.2 Bifunctional catalyst blend problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.3 Modied Denbigh reaction system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.4 Optimal control of an oil shale pyrolysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.5 Nonlinear CSTR reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.6 Chemical reactor control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.7 Two-stage CSTR system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.8 Plug-ow reactor with a singular arc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.9 Plug ow reactor, a MIDO problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.9.1 The scenario with xed transition times . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.9.2 The scenario with free transition times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8 Biochemical engineering problems 42
8.1 Lee-Ramirez bioreactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
8.2 Optimal production of protein in the fed-batch reactor . . . . . . . . . . . . . . . . . . . . . . . . 43
8.3 Fed-batch fermenter for penicillin production . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.4 Fed-batch reactor for ethanol production . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9 Other benchmarks 47
9.1 Linear quadratic problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9.2 Nishida problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9.3 Minimum fuel consumption problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.4 Optimal control of the non-differentiable system. . . . . . . . . . . . . . . . . . . . . . . . . . . 49
9.5 Terminal and interior point constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.6 Inequality state path constraint problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
9.7 Van der Pol oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10 Default settings 54
10.1 Default settings of the single optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
10.2 Default settings of the sucessive re-optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.3 Default settings of the hybrid strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.4 Default settings of the simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.5 Default settings of NLP or MINLP solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.5.1 ACOmi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.5.2 DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.5.3 FMINCON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.5.4 IPOPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.5.5 MISQP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.5.6 MITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
10.5.7 SRES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Bibliography 59
11 Appendix 62
11.1 Final data structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
11.2 Sensitivities and gradients derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Page 4
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
List of Figures
1.1 Organization of the toolbox code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1 Scheme of the solution of the resulting dynamic optimization problem with sensitivity equations
approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1 Optimal solution from DOTcvp for the van der Pol oscillator. . . . . . . . . . . . . . . . . . . . . 23
5.1 The optimal control proles obtained by mesh renement algorithm for the van der Pol oscillator
problem for 10, 30, 90, and 270 time intervals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.1 GUI for a van der Pol oscillator: introduction screen. . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2 GUI for a van der Pol oscillator: NLP denition. . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.3 GUI for a van der Pol oscillator: settings related to the initialization, NLP, and IVP. . . . . . . . . 28
6.4 GUI for a van der Pol oscillator: problem denition. . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.5 GUI for a van der Pol oscillator: equality and inequality constraints. . . . . . . . . . . . . . . . . 29
6.6 GUI for a van der Pol oscillator: ODE and sensitivities initialization. . . . . . . . . . . . . . . . . 29
6.7 GUI for a van der Pol oscillator: output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.8 GUI for a van der Pol oscillator: MATLAB output. . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.1 Optimal control trajectories for the simple batch reactor. . . . . . . . . . . . . . . . . . . . . . . 32
7.2 Optimal solution for the bifunctional catalyst blend problem. . . . . . . . . . . . . . . . . . . . . 33
7.3 Optimal solution for the modied Denbigh reaction system. . . . . . . . . . . . . . . . . . . . . . 34
7.4 Optimal solution for the oil shale pyrolysis problem. . . . . . . . . . . . . . . . . . . . . . . . . 35
7.5 Optimal solution for the nonlinear CSTR reactor. . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.6 Optimal solution for the chemical reactor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.7 Optimal solution for the two-stage CSTR system. . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.8 Optimal solution for the plug-ow reactor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.9 Optimal solution for the plug ow reactor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
7.10 Histogram for the scenario with the free time interval for the plug ow reactor. . . . . . . . . . . . 41
8.1 Optimal solution for the Lee-Ramirez bioreactor. . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8.2 Optimal solution for the fed-batch reactor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.3 Optimal solution for the fed-batch fermenter for penicillin production. . . . . . . . . . . . . . . . 45
8.4 Optimal solution for the fed-batch reactor for ethanol production. . . . . . . . . . . . . . . . . . . 46
9.1 Optimal solution for the LQR problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.2 Optimal solution for the Nishida problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.3 Optimal solution for the minimum fuel consumption problem . . . . . . . . . . . . . . . . . . . . 49
9.4 Optimal solution for the non-differentiable system. . . . . . . . . . . . . . . . . . . . . . . . . . 50
Page 5
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
9.5 Optimal solution for the terminal and interior point constraints problem with the piecewise constant
and linear optimal prole. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
9.6 Optimal solution for the inequality state path constraint problem (case: A). . . . . . . . . . . . . . 52
9.7 Optimal solution for the van der Pol oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Page 6
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
List of Tables
7.1 The value of the solid catalyst for the various reaction stages of the plug ow reactor. . . . . . . . 40
Page 7
CHAPTER 1
Introduction
Dynamic optimization (DO) allows the computation of optimal operating policies for processes or systems. Dy-
namic optimization seeks the maximization of a pre-dened performance index (usually, a productivity, or an
economical index derived from the operation prole and the nal states). Once computed in a reliable way, these
operating policies can be implemented using different control strategies, such as adaptive control or model predic-
tive control. Dynamic optimization is equivalent to open-loop optimal control.
There are many numerical and analytical methods by which the optimal control problems can be solved.
One possibility is to use Bellmans optimal principle or Pontryagins maximum principle [12] 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 transformOCP into the nite
dimensional optimal control problem through a parameterization scheme. The total parameterization (control and
state variables) in the case of the orthogonal collocation (OC) [27] can be used or only control parameterization if
the control vector parameterization method (CVP) [37] is chosen. A good overview of the optimal control methods
is possible to found in [10]. 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 which is
implemented in our toolbox lies in the parametrization only of the control trajectory. This has an impact on the
total number of the decision variables.
The implementation of new methods or problems is often a 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 non-commercial tools, i.e. the toolboxes from [21; 47] and many more, which differ on the basis of the
environment, method, etc.
1.1 TOOLBOX DESCRIPTION
DOTcvp has been implemented in MATLAB (http://www.mathworks.com) environment. The original
dynamic optimization or mixed-integer dynamic optimization problem is solved numerically by the use of a suit-
able optimizer (outer iteration) which requires the solution of an IVP (inner iteration) which will in general consist
on a set of ODEs plus a set of sensitivities to compute gradient information. The solution of the inner IVP is
accomplished by calls to tailored solvers from the SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
(SUNDIALS) [24], more specically CVODES. Since these simulations are the most computationally demanding
task in the CVP method, our toolbox can automatically create compiled dynamically linked subroutines (known as
MEX les in MATLAB) for the ODEs, Jacobian, and sensitivities, thus ensuring high performance.
1.2 DESCRIPTION OF MAIN MODULES
The toolbox contains a number of modules (implemented as MATLAB functions) which can be grouped in
two categories:
utility modules: graphical user interface (GUI) and simulation modules;
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
optimization modules: offering several optimization strategies, namely single optimization, multi-start, suc-
cessive re-optimization, and hybrid optimization modules.
1.2.1 Utility modules
The utility modules offer several facilities for the denition, checking, and handling of problems. The
toolbox can be operated through two equivalent approaches: by the use of the GUI, or directly from the command
line (from where scripts with problem denitions can be created and executed).
Graphical User Interface (GUI) module: this module was developed in order to help users in the denition
and execution of problems. With the help of this module, which follows an intuitive wizard-like approach,
problem denitions and modications are guided in an easy and convenient stepwise manner, especially
indicated for entry users.
Simulation module: this module carries out the dynamic simulation of the user-dened dynamics (plus
assigned initial conditions and controls) generating the corresponding state trajectories. This module is
especially useful for checking the model correctness during the denition phase, which is particularly error-
prone. Typical errors like those related with units inconsistencies can be readily identied with this proce-
dure.
1.2.2 Optimization modules
The optimization modules offers a suite of four different optimization strategies, each one with different
options for the optimization solvers, following the "Swiss Army knife" approach mentioned previously. All these
modules are described in more detail below.
Single optimization module: this module makes a single call to one of the optimization solvers, which can
be either a local deterministic or global stochastic method (see available solvers below). This procedure can
be sufcient for well conditioned, convex problems, or non-convex problems which are cheap to evaluate.
In any case, it is recommended as the rst strategy to try with any new problem.
Multi-start optimization module: this modules runs a selected optimization solver (typically a local one)
repeatedly. The set of solutions (performance index values) obtained can then be analyzed (e.g. plotting
a histogram) in order to check the multimodality of the problem.
Sucessive re-optimization module: Sucessive re-optimization can be used to speed up the convergence for
problems where a high discretization level is desired (e.g. those where the control proles behave wildly).
This procedure runs several successive single optimizations automatically increasing the control discretiza-
tion, NLP, and IVP tolerances after each run.
Hybrid optimization module: Hybrid optimization is characterized by the combination of a stochastic
global method plus a deterministic local method. This procedures ensures a compromise between the ro-
bustness of global methods and the efciency of local ones. This module is especially indicated for difcult
multimodal problems. In any case, tweaking the hybrid method requires a deep knowledge of the solvers,
and this approach will be almost always more costly (in CPU time) than the single optimization procedures
using local methods (the price to pay for the increased robustness).
1.3 NUMERICAL OPTIMIZATION METHODS (NLP AND MINLP SOLVERS)
The toolbox provides interfaces to several optimization state-of-the-art solvers:
local deterministic
1. IPOPT [48] (Interior Point OPTimizer) implements a primal-dual interior point method, and uses line
searches based on Filter methods;
2. FMINCON [15] (Find MINimum of CONstrained nonlinear multivariable function) is a part of the
MATLAB optimization toolbox which uses sequential quadratic programming (SQP);
3. MISQP [19] (Mixed-Integer Sequential Quadratic Programming) solves mixed-integer non-linear pro-
gramming problems by a modied sequential quadratic programming method;
stochastic global
Page 9
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
1. DE [41] (Differential Evolution) uses population based approach for minimizing the performance in-
dex;
2. SRES [38] (Stochastic Ranking Evolution Strategy) uses an evolution strategy combined with an ap-
proach to balance objective and penalty functions;
and hybrid metaheuristics
1. ACOmi [40] (Ant Colony Optimization for Mixed Integer nonlinear programming problems) is in-
spired by ants foraging behavior and for the local search it uses MISQP;
2. MITS [18] (Mixed-Integer Tabu Search algorithm) is based on extensions of the metaheuristic Tabu
Search algorithm and for local search it uses MISQP too;
where the deterministic MISQP solver and all hybrid solvers are able to handle mixed-integer problems directly.
The problem is automatically reformulated on the basis of users option.
1.4 NUMERICAL SIMULATION METHOD (IVP SOLVERS)
Forward integration of the ODE, Jacobian, and sensitivities if it is needed is ensured by CVODES, a part of
SUNDIALS [24], 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). The Adams method is recommended for solving of the non-stiff problems while BDF is recommended
for solving of the stiff problems. Note that the sensitivity equations are provided analytically and the error control
strategy for the sensitivity variables could be enabled.
Figure 1.1 Organization of the toolbox code.
The organization of the toolbox code is shown in Figure 1.1 where the toolbox les have the name: dotcvp_
and the temporary les: temp_. Note that the temporary les are generated and later deleted automatically,
because they are problem dependent. Finally it is needed to emphasize that DOTcvp contains packages that are an
open-source.
Page 10
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
1.5 RECOMMENDED OPERATING PROCEDURE
It should be noted that, for a general MIDO formulation, there is no a priori way to distinguish if the
resulting MINLP will be convex or not, so the user has no clue on which optimization strategy should be using.
Thus, we recommend that, for any new problem, the user follows this protocol:
Step 1: try solving the problem with the single optimization strategy and a local deterministic method, such
as FMINCON or IPOPT for DO problems, or MISQP for MIDO problems, using a rather crude control
discretization (e.g. 10 elements). After obtaining a solution, repeat changing the initial guess for the control
variable. If a rather different solution is obtained, suspect multimodality and go to step 2 below. If not, solve
the problem again using a ner discretization. For faster and more satisfactory results regarding control
discretization, use the successive re-optimization module.
Step 2: solve the problem using the multi-start optimization module. In general 100 runs is a sensible
number for this task, but for costly problems the user might want to reduce this. Plotting an histogram of
the resulting set of solutions will give a good view of the problem multimodality. For clearly multimodal
problems, go to step 3. If not, stop, or go back to step 1 if e.g. more rened control levels are desired.
Step 3: use the single optimization strategy as in step 1, but use a global stochastic method, like DE or SRES
for DO problems, or ACOmi or MITS for MIDO problems. If satisfactory results are obtained in reasonable
computation times, stop. If the computational cost is excessive, go to step 4.
Step 4: use a hybrid global-local strategy. More advanced users can tweak the different options to increase
efciency and/or robustness.
This protocol is especially recommended for novel users who are not familiar with numerical optimization
methods. Advanced users can tweak the hybrid strategy options, or even create their own strategies combining
calls to the different solvers in a MATLAB script.
1.6 TOOLBOX DOWNLOAD
The toolbox can be downloaded from the afore mentioned web page. The name of the toolbox is as follows:
DOTcvp_RXXXX_YN.zip. The letters mean:
XXXX - [number] represents the toolbox year version
Y - [letter] represents the major changes, usually the changes in the input le
N - [number] represents the minor changes
1.7 TOOLBOX INSTALLATION
The installation procedure consists of several steps listed below:
1. If you have an older installation of DOTcvp, please remove it. This helps to avoid possible compatibility
problems.
2. Unzip the packed le into any directory. The unziped le contains the name and date when the zip package
was created. This helps to recognize a new package of the toolbox. It is recommended to use the latest
version of the toolbox.
3. You can try to download and use some demonstrative examples from afore mentioned web page and extract
them into a dotcvp_examples directory. Of course any different directory can be used.
4. The next step is the toolbox installation. First, you should start MATLAB and change to the directory where
DOTcvp was unpacked, and then run dotcvp_install.m install le. If everything is all right the user will see
the following output procedure:
1 Installation in progress .................................
2 Checking the previous version of DOTcvp .................. not found - OK!
3 Setting paths for DOTcvp into a MATLAB environment ....... done!
4 Generation of a MATLAB file with path settings ........... done!
5 Getting MATLAB version ................................... done!
6 The right mex file of SUNDIALS is preparing .............. done!
7 Creating f77.bat file needed for the FORTRAN compilation . done!
Page 11
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
8
9 You can freely modify the following file with the toolbox path settins:
10 D:/ your directory /DOTcvp/DOTcvp_paths.m
11
12 The installation passed without any problems, enjoy this toolbox!
This procedure inserts all necessary paths into a MATLAB environment. If you use a different directory
for illustrative examples you should specify a proper path into the dotcvp_paths.m le which is generated
during the installation procedure. In this le, it is possible to set all necessary paths for saving results from
the optimization, simulations, etc. Note, if you quit MATLAB environment, all paths will be deleted, so you
need to run the dotcvp_install.m le with the new start of MATLAB again. This time, the dotcvp_paths.m
le stays unmodied.
5. From this moment, everything should work correctly. Enjoy this toolbox!
Page 12
CHAPTER 2
Optimal control problem
2.1 SYSTEM AND COST DESCRIPTION
Consider a dynamical system described by the vector of ordinary differential equations (ODEs)
x = f(t, x, u, p) (2.1)
with given initial and terminal conditions
x(0) = x
0
, x(t
F
) = x
F
(2.2)
where x R
n
x
is the vector of state variables, u R
n
u
is the vector of control (continues and/or integer)
variables, p R
n
p
is the vector of time-independent parameters, and t
F
is the nal time of the process. The
function vector f R
n
x
describes the right hand sides of differential equations. The OCP is to nd optimal
control policy u(t), vector of the time-independent parameters, and the nal time t
F
, when minimum or free time
problem is considered that minimizes the cost function (or performance index, objective function)
min
t
F
,u
i
,p
J
0
= G
0
(t
F
, x
F
, u, p) (2.3)
subject to the constraints, introduced also in general Mayer form as the cost function
J
l
= G
l
(t
F
, x
F
, u, p), l = 1, m
e
+ m
i
(2.4)
where m
e
and m
i
represent the equality and inequality constraints, respectively. The total number of constraints
is marked with the letter m (m
e
+ m
i
). The equality constraints in other words point constraints may represent
a desired value of the nal product. The inequality constraints also known as path constraints may include very
often the safety conditions or a limit of the production devices. These constraints are usually very difcult to
satisfy and for this reason some methods exist which are able to deal with it. The DOTcvp toolbox transforms
these constraints to new state variables and integrates the violations of these constraints. The additional equality
constraints are introduced to minimize the integrated violations to a permitted value. Note that if the cost function
contains an integral part, this could be transformed into a new state variable of the ODE too. For the simplicity we
consider that the state variables are continuous at the boundaries
x(t
+
i
) = x(t

i
) (2.5)
where t

i
denotes the ending time of stage i and t
+
i
the beginning time of stage i + 1.
Some solvers implemented in the toolbox marked as mixed-integer (MI) NLP solvers are able to handle
besides the continuous variables the integer variables too. Presence of integer variables makes the problem a new
one, usually called as a mixed-integer optimal control problem. The integer variables are introduced in the toolbox
as new control variables.
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 nite dimensional problem
(NLP) static optimization. Further, a suitable gradient method with a NLP type algorithm is needed. The
gradients can be obtained by nite difference, adjoint or sensitivity approach. Each of the gradient method has
advantages and disadvantages, the summary is shown in [37]. The algorithm has an iterative character and when
the optimality conditions are satised 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. This combination is directly used in the hybrid methods.
Another option is to optimize a process with several different initial conditions, what is called as multistart method.
This option is possible to choose in the DOTcvp toolbox.
3.1 NLP FORMULATION
As mentioned at the beginning of this chapter the dynamic optimization problem is transformed into the
static optimization problem. It follows that the original continuous control trajectory can be approximated on the
nite number of the time intervals N as piecewise constant
u(t) = u
i
, t
i1
t < t
i
, i = 1, N (3.1)
or piecewise linear
u(t) = u
i1
+u
i2
t (3.2)
where the different t
i
= t
i
t
i1
is denoted as the time interval length. The further constraints are dened as
lower and upper boundaries of the optimized variables
t
i
[t
min
i
, t
max
i
] (3.3)
u
i
[u
min
i
, u
max
i
] (3.4)
p [p
min
, p
max
] (3.5)
Subsequently can be dened the vector of decision variables y R
n
y
which contains information about
lengths of the time intervals (t
i
), control variables (u
i
), and time-independent parameters (p)
y
T
= [t
1
, . . . , t
N
, u
T
1
, . . . , u
T
N
, p] (3.6)
The vector of decision variables (3.6) together with corresponding lower and upper bounds (3.3-3.5) is
suitable to handle with any MI/NLP solver which is able to minimize the cost function (2.3) with respect to
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
constraints (2.4) if a minimum problem is considered. It follows a general NLP formulation given by
min
y
J
0
(3.7)
s.t. J
l
(y) = 0, l = 1, m
e
(3.8)
J
l
(y) 0, l = m
e
+ 1, m
e
+ m
i
(3.9)
where the problem is dened as to nd the feasible optimal decision variables (y
optimal
) so that J
0
(y
optimal
)
J
0
(y). As mentioned before some optimization methods may require cost and constraints gradient information
with respect to the vector of decision variables (3.6). To compute such gradients two methods were implemented:
sensitivity equations and nite difference. These method are described in detail in the next subsections.
3.2 IMPLEMENTED GRADIENT METHODS
3.2.1 Sensitivity equations
The sensitivities [46] are dened as partial derivation of state variables with respect to decision variables.
Then the sensitivity coefcients s
j
(t) with initial conditions are dened as follows
s
j
(t) =
x(t)
y
j
, s
j
(0) = 0, j = 1, n
y
(3.10)
where n
y
denotes the number of decision variables.
The sensitivity coefcients 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 (3.6) gives
s
j
(t) =
_
f
T
x
_
T
s
j
(t) +
_
f
T
u
_
T
u
i+1
y
j
+
_
f
T
p
_
T
p
y
j
(3.11)
where t
i1
t t
i
and i = 0, (N 1). With the forward integration of sensitivity equations (3.11) we obtain
the necessary information to compute the cost function (2.3) gradient.
When the sensitivity is computed with respect to time interval t
i
the discontinuity must be taken into ac-
count. If the situation is considered when the state values are continuous (2.5) at the time interval boundaries then
the total differential for a state variable gives
dx(t
i
) =
_
x(t
+
i
) + x(t
+
i
)dt
i
, i = 1, (N 1)
x(t

i
) + x(t

i
)dt
i
(3.12)
as well as dx(t
+
i
) = dx(t

i
) which gives
x(t
+
i
) + x(t
+
i
)dt
i
= x(t

i
) + x(t

i
)dt
i
(3.13)
Differentiating (3.13) with respect to the decision variables yields
x(t
+
i
)
y
j
=
x(t

i
)
y
j
+
_
x(t

i
) x(t
+
i
)

t
i
y
j
(3.14)
When the sensitivity coefcients (3.10) are used, formula (3.14) is simplied
s
j
(t
+
i
) = s
j
(t

i
) + [f
i
f
i+1
]
t
i
t
i
y
j
(3.15)
The partial derivations of the cost function or constraints (2.3) with respect to optimized variables gives
J
l
y
j
=
_
J
l
t
F
_
t
F
y
j
+
_
J
l
x
F
_
T
x
F
y
j
+
_
J
l
u
_
T
u
y
j
+
_
J
l
p
_
T
p
y
j
(3.16)
where it is considered that the variation of x
F
following (3.12) gives
x
F
y
j
= f(t
F
, x
F
, u
F
, p)
t
F
y
j
+
x
F
y
j
(3.17)
Page 15
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Taking into account (3.16) and (3.17) the nal equation for the computation of the gradients is given as
J
l
y
j
=
_
J
l
t
F
_
t
F
y
j
+
_
J
l
u
_
T
u
y
j
+
_
J
l
p
_
T
p
y
j
+
_
J
l
x
F
_
T
_
s
j
(t
F
) +f(t
F
, x
F
, u
F
, p)
t
F
y
j
_
(3.18)
Derivation of the sensitivity equations for computation of the problem presented in the subsection 7.1 is
showed in the appendix 11.
3.2.2 Finite differences
The system (2.1) is integrated n
y
times and in every integration one of the optimized variables (3.6) 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

y
j
J
l
=
J
l
(y
1
, . . . , y
j
+ y
j
, . . . , y
n
y
) J
l
(y)
y
j
, l = 0, m (3.19)
3.3 GRADIENTS WITH RESPECT TO TIME
For numerical reasons, time increments t
i
will be optimized, rather than absolute time values t
i
. There-
fore, the gradients with respect to time have to be modied correspondingly. The relations between times and their
increments are given as
t
F
=
N

i=1
t
i
(3.20)
Therefore, the following holds for the derivatives
J
l
t
i
=
N

r=1
J
l
t
r
t
r
t
i
(3.21)
3.4 ALGORITHM OUTLINE
This algorithm is valid only for the deterministic and partly for the hybrid methods with sensitivity equation
approach. If the user chooses a nite difference method instead of sensitivities then the gradients will be counted
on the basis of the perturbances of each decision variable. However, if a stochastic method is selected neither the
sensitivities nor the perturbances are counting.
1. Initialization of the optimized variables, y = y
0
. The initial control trajectory is usually set at the constant
value, u
0
= u
guess
.
2. Forward integration of the system (2.1) and sensitivity equations (3.11), the trajectories of the states x(t)
and sensitivities s(t) are obtained.
3. When the minimum time problem is investigated sensitivities s(t
i
) (i = 1, (N 1)) have discontinuity
following the equation (3.15).
4. Calculation of the value of the cost function (2.3), and appropriate gradients (3.18) for the cost function and
constraints. Note that if free time is solved, the gradients are modied following the section 3.3.
5. Iterative solution of the MI/NLP:
(a) If the optimumis achieved, the conditions of the optimality are satised and the algorithmwill stop y =
y
optimal
(b) else it is needed to repeat the algorithm from 2 with new values of decision variables y = y
new
, which
are set on the basis of gradients from 4.
In the Figure 3.1 is shown a basic scheme for the NLP algorithm with sensitivity equations approach.
Page 16
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Figure 3.1 Scheme of the solution of the resulting dynamic optimization problem with sensitivity equations
approach.
3.5 BRIEF INFORMATION ABOUT THE IMPLEMENTED MODULES
3.5.1 Single optimization
It consists on solving the master NLP problem in a single pass (i.e. a single optimization run). For many
problems this approach is sufcient. But, very frequently, and especially for nonlinear dynamic optimization
problems, the user nds (or suspects) that the problem is multimodal (multiple local optima), so it is necessary to
use more robust approaches, as outlined below.
3.5.2 Hybrid optimization
Hybrid optimization is characterized by the combination of a stochastic global method plus a deterministic
local method. This procedures meets and compromise between the robustness of global methods and the ef-
ciency of local ones. In any case, this approach will be almost always more costly (in CPU time) than the single
optimization procedures using local methods. That is the price to pay for the increased robustness.
3.5.3 Sucessive re-optimization
Sucessive re-optimization can be used to speed up the convergence for problems where a high discretization
level is desired (e.g. those where the control proles behave wildly). This procedure runs several successive single
optimizations automatically increasing the control discretization after each run.
3.5.4 Simulation module
Simulation module serves for problem simulation and state trajectories generation.
Page 17
CHAPTER 4
Single optimization
4.1 FROM THE INPUT TO THE OUTPUT
The van der Pol oscillator problem is taken from [44] and has been solved by many authors [42; 7; 3]. In
our case we have expanded this problem with two inequality constraints and one equality constraint. 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]
x
1
= (1 x
2
2
)x
1
x
2
+ u (4.1)
x
2
= x
1
(4.2)
x
3
= x
2
1
+ x
2
2
+ u
2
(4.3)
The aim of the optimization is to minimize the cost function in the xed nal time (t
F
= 5)
min
u
i
J
0
= x
3
(t
F
) (4.4)
subject to the inequality, path constraints
0.4 x
1
(t) 0.0 (4.5)
and equality constraint at the end of the optimization
x
2
(t
F
) = 0.1 (4.6)
Finally, the control trajectory has the boundaries dened as follows: u [0.3; 1]
4.1.1 Problem formulation for DOTcvp, a simple input le
DOTcvp: cdop_VanDerPolOscillator_simple.m
From the position of the user it is needed only to modify one input le which contains all necessary infor-
mation and everything else is generated automatically. The van der Pol oscillator problem, as any other problem,
may be dened in DOTcvp toolbox with the shortest input le. The options which are not dened are taken from
the default settings. These settings are shown in the chapter 10.1. The user may modify the default settings by
editing the appropriate le. Note that in this simplest le for the van der Pol oscillator problem the constraints
are not introduced, but it is possible to do so. For more details, please check the simple input les located in the
toolbox.
1 % A MATLAB simple example described in detail in the technical report
2 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
3 % DOTcvp - Dynamic Optimization Toolbox with CVP approach for %
4 % handling continuous and mixed-integer dynamic optimization problems %
5 % Copyright (C) 2007-2010 %
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
6 % Tomas Hirmajer et al., [email protected] %
7 % %
8 % The DOTcvp toolbox is completely free of charge under the creative %
9 % commons license. The conditions of the license can be found on the %
10 % following web page: %
11 % http://creativecommons.org/licenses/by-nc-nd/3.0/ %
12 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
13
14 clear mex; clear all; close all; global data;
15 % --------------------------------------------------- %
16 % Initialization:
17 % --------------------------------------------------- %
18 data.name = 'VanDerPolOscillator_simple';
19
20 % --------------------------------------------------- %
21 % Settings for IVP (ODEs, sensitivities)
22 % --------------------------------------------------- %
23 data.odes.res(1) = {'(1-y(2)^2)
*
y(1)-y(2)+u(1)'};
24 data.odes.res(2) = {'y(1)'};
25 data.odes.res(3) = {'y(1)^2+y(2)^2+u(1)^2'};
26 data.odes.ic = [0.0 1.0 0.0];
27 data.odes.tf = 5.0; %final time
28
29 % --------------------------------------------------- %
30 % NLP definition:
31 % --------------------------------------------------- %
32 data.nlp.RHO = 10; %number of time intervals
33 data.nlp.J0 = 'y(3)'; %cost function: min-max(cost function)
34 data.nlp.u0 = [ 0.7]; %initial value for control values
35 data.nlp.lb = [-0.3]; %lower bounds for control values
36 data.nlp.ub = [ 1.0]; %upper bounds for control values
37
38 % --------------------------------------------------- %
39 % Call of the main function (you do not change this!):
40 % --------------------------------------------------- %
41 dotcvp_main(data)
4.1.2 Problem formulation for DOTcvp, a regular input le
DOTcvp: cdop_VanDerPolOscillator.m
The second possibility, a more advanced one is to dene a new problem with the full toolbox input le.
This input le looks as follows:
1 % A MATLAB example described in detail in the technical report
2 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
3 % DOTcvp - Dynamic Optimization Toolbox with CVP approach for %
4 % handling continuous and mixed-integer dynamic optimization problems %
5 % Copyright (C) 2007-2010 %
6 % Tomas Hirmajer et al., [email protected] %
7 % %
8 % The DOTcvp toolbox is completely free of charge under the creative %
9 % commons license. The conditions of the license can be found on the %
10 % following web page: %
11 % http://creativecommons.org/licenses/by-nc-nd/3.0/ %
12 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
13
14 clear mex; clear all; close all; global data;
15 % --------------------------------------------------- %
16 % Initialization:
17 % --------------------------------------------------- %
18 data.name = 'VanDerPolOscillator';
19 data.compiler = 'None'; %['None'|'FORTRAN']
20
21 % --------------------------------------------------- %
22 % Settings for IVP (ODEs, sensitivities):
23 % --------------------------------------------------- %
24 data.odes.Def_FORTRAN = {}; %this option is needed only for FORTRAN parameters definition, e.g. {'double precision k10, k20, ..'}
25 data.odes.parameters = {}; %constant parameters before ODE {'T=300','..}
26 data.odes.Def_MATLAB = {}; %this option is needed only for MATLAB parameters definition
27 data.odes.res(1) = {'(1-y(2)^2)
*
y(1)-y(2)+u(1)'};
28 data.odes.res(2) = {'y(1)'};
29 data.odes.res(3) = {'y(1)^2+y(2)^2+u(1)^2'};
30 data.odes.black_box = {'None','1','FunctionName'}; %['None'|'Full'],[penalty coefficient for all constraints],[a black box model
31 function name]
32 data.odes.ic = [0.0 1.0 0.0];
33 data.odes.NUMs = size(data.odes.res,2); %number of state variables (y)
34 data.odes.t0 = 0.0; %initial time
35 data.odes.tf = 5.0; %final time
36 data.odes.NonlinearSolver = 'Newton'; %['Newton'|'Functional'] /Newton for stiff problems; Functional for non-stiff problems
37 data.odes.LinearSolver = 'Dense'; %direct ['Dense'|'Diag'|'Band']; iterative ['GMRES'|'BiCGStab'|'TFQMR'] /for the Newton NLS
38 data.odes.LMM = 'Adams'; %['Adams'|'BDF'] /Adams for non-stiff problems; BDF for stiff problems
39 data.odes.MaxNumStep = 500; %maximum number of steps
40 data.odes.RelTol = 1
*
10^(-7); %IVP relative tolerance level
41 data.odes.AbsTol = 1
*
10^(-7); %IVP absolute tolerance level
42 data.sens.SensAbsTol = 1
*
10^(-7); %absolute tolerance for sensitivity variables
43 data.sens.SensMethod = 'Simultaneous'; %['Staggered'|'Staggered1'|'Simultaneous']
44 data.sens.SensErrorControl= 'on'; %['on'|'off']
45
46 % --------------------------------------------------- %
47 % NLP definition:
48 % --------------------------------------------------- %
49 data.nlp.RHO = 30; %number of time intervals
Page 19
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
50 data.nlp.problem = 'min'; %['min'|'max']
51 data.nlp.J0 = 'y(3)'; %cost function: min-max(cost function)
52 data.nlp.u0 = [ 0.7]; %initial value for control values
53 data.nlp.lb = [-0.3]; %lower bounds for control values
54 data.nlp.ub = [ 1.0]; %upper bounds for control values
55 data.nlp.p0 = []; %initial values for time-independent parameters
56 data.nlp.lbp = []; %lower bounds for time-independent parameters
57 data.nlp.ubp = []; %upper bounds for time-independent parameters
58 data.nlp.solver = 'FMINCON'; %['FMINCON'|'IPOPT'|'SRES'|'DE'|'ACOMI'|'MISQP'|'MITS']
59 data.nlp.SolverSettings = 'None'; %insert the name of the file that contains settings for NLP solver, if does not exist use ['None']
60 data.nlp.NLPtol = 1
*
10^(-5); %NLP tolerance level
61 data.nlp.GradMethod = 'SensitivityEq'; %['SensitivityEq'|'FiniteDifference'|'None']
62 data.nlp.MaxIter = 1000; %Maximum number of iterations
63 data.nlp.MaxCPUTime = 60
*
60
*
0.25; %Maximum CPU time of the optimization (60
*
60
*
0.25) = 15 minutes
64 data.nlp.approximation = 'PWC'; %['PWC'|'PWL'] PWL only for: FMINCON & without the free time problem
65 data.nlp.FreeTime = 'off'; %['on'|'off'] set 'on' if free time is considered
66 data.nlp.t0Time = [data.odes.tf/data.nlp.RHO]; %initial size of the time intervals, e.g. [data.odes.tf/data.nlp.RHO]
67 or for the each time interval separately [dt1 dt2 dt3]
68 data.nlp.lbTime = 0.01; %lower bound of the time intervals
69 data.nlp.ubTime = data.odes.tf; %upper bound of the time intervals
70 data.nlp.NUMc = size(data.nlp.u0,2); %number of control variables (u)
71 data.nlp.NUMi = 0; %number of integer variables (u) taken from the last control variables, if not equal to 0 you need
72 to use some MINLP solver ['ACOMI'|'MISQP'|'MITS']
73 data.nlp.NUMp = size(data.nlp.p0,2); %number of time-independent parameters (p)
74
75 % --------------------------------------------------- %
76 % Equality constraints (ECs):
77 % --------------------------------------------------- %
78 data.nlp.eq.status = 'on'; %['on'|'off'] ECs
79 data.nlp.eq.NEC = 1; %number of active ECs
80 data.nlp.eq.eq(1) = {'y(2)+0.1'};
81 data.nlp.eq.time(1) = data.nlp.RHO;
82 data.nlp.eq.PenaltyFun = 'off'; %['on'|'off'] ECs penalty function
83 data.nlp.eq.PenaltyCoe = [1.0]; %J0=J0+data.nlp.eq.PenaltyCoe
*
ViolationOfEqualityConstraint /
*
only for stochastic solvers
*
/
84
85 % --------------------------------------------------- %
86 % Inequality /path/ constraints (INECs):
87 % --------------------------------------------------- %
88 data.nlp.ineq.status = 'on'; %['on'|'off'] INECs
89 data.nlp.ineq.NEC = 2; %number of active INECs
90 data.nlp.ineq.InNUM = 1; %how many inequality constraints are '>' else '<'
91 data.nlp.ineq.eq(1) = {'y(1)+0.4'};
92 data.nlp.ineq.eq(2) = {'y(1)-0.0'};
93 data.nlp.ineq.Tol = 0.0005; %tolerance level of violation of INECs
94 data.nlp.ineq.PenaltyFun = 'off'; %['on'|'off'] INECs penalty function
95 data.nlp.ineq.PenaltyCoe = [1.0 1.0]; %J0=J0+data.nlp.ineq.PenaltyCoe
*
ViolationOfInequalityConstraint /
*
for every inequality
96 constraint one parameter
*
/
97
98 % --------------------------------------------------- %
99 % Options for setting of the final output:
100 % --------------------------------------------------- %
101 data.options.intermediate = 'off'; %['on'|'off'|'silent'] display of the intermediate results
102 data.options.display = 'on'; %['on'|'off'] display of the figures
103 data.options.title = 'on'; %['on'|'off'] display of the figure title
104 data.options.state = 'on'; %['on'|'off'] display of the state trajectory
105 data.options.control = 'on'; %['on'|'off'] display of the control trajectory
106 data.options.ConvergCurve = 'on'; %['on'|'off'] display of the convergence curve
107 data.options.Pict_Format = 'eps'; %['eps'|'wmf'|'both'] save figures as
108 data.options.report = 'on'; %['on'|'off'] save data in the dat file
109 data.options.commands = {''}; %additional commands, e.g. 'figure(1),.. '
110 data.options.trajectories = data.odes.NUMs; %how many state trajectories will be displayed
111 data.options.profiler = 'off'; %['on'|'off']
112 data.options.multistart = 1; %set 1 if the multistart is off, otherwise you have to put here some integer value
113
114 data.options.action = 'single-optimization'; %['single-optimization'|'re-optimization'|'hybrid-strategy'|'simulation']
115
116 % --------------------------------------------------- %
117 % Call of the main function (you do not change this!):
118 % --------------------------------------------------- %
119 dotcvp_main(data)
Line: 1-12 The license conditions. The DOTcvp toolbox is completely free of charge under the creative commons
license. It is possible to nd thee conditions of license at the following web page:
http://creativecommons.org/licenses/by-nc-nd/3.0/
Line: 14 These orders clear the old information from MATLAB environment. In this line is also the global structure
enabled with the name data (see the appendix 11.1). At the end of the optimization all information is saved
into this structure.
Line: 15-19 Here, the initialization of the optimization is performed. The second option serves for the choose of a
compiler.
Note If you would like to use some constant parameters for the FORTRAN compiler then these parame-
ters have to be dened for both environments, MATLAB and FORTRAN, because the nal simula-
tion of the process is performed always in MATLAB environment. For details please check in the
DOTcvp toolbox a le that has dened parameters for FORTRAN and MATLAB environment, e.g.
cdop_SimpleBatchReactor. This problem is also described in the subsection 7.1.
Page 20
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Line: 21-44 There is a place for the constant parameters or for the formulas, e.g. conditions, description of the problem in
the ODE form, possible black box denition option, and the vector of the initial values. Note that the notation
y(number), u(number), p(number) has to be used for the state, decision variables, and time-independent
parameters, respectively. Next options serve for the denition of the number of state variables with the
initial and nal time. The last group of the options is related with the settings for both, system and sensitivity
module. 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 steps, 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.
Note The last version of the DOTcvp toolbox was extended to solve black box models. The models have
to be dened as function in the form [J0,Ji]=FunctionName(x), where J0, Ji, and x represent the
cost function, constraints violation in the vector form, and vector of optimized variables, respec-
tively. Firstly, these models have to be copied to the following folder DOTcvp/src_black_box and
then run the toolbox installation le (to save all new paths into the MATLAB environment). The
user can change the option regarding the black box models in the input le: data.odes.black_box =
None,1,FunctionName where in the rst part can be dened an argument None if ODE are pro-
vided or Full if black box function is dened. The second parameter is the penalty coefcient for the
summary of the constraints violation and the last one is the name of the black box function.
Line: 46-73 This part of the input le contains options related with the NLP denition. First, the number of time intervals
has to be dened, then the minimization or maximization option is chosen. After the denition of the cost
function is done it is needed to dene the upper and lower bounds of the decision variables and/or time-
independent parameters. Next the NLP or MINLP solver can be chosen together with the default input le
(note that this le contains default settings for every MI/NLP solver, the user can change it), NLP tolerance
level, gradient method, and maximum number of function evaluation. Next it is possible to set if free time
problem is solved, if yes, then the upper and lower bounds have to be dened and the penalty function can
be enabled. In the next option it is possible to switch the piecewise constant (PWC) control trajectory to the
piecewise linear (PWL) control trajectory. Note, this option is available only for FMINCON and non-free
time problems. At the end of this group of options it is needed to dene the number of decision, integer
variables, and time-independent parameters.
Note The number of state variables and decision, time-independent variables is counted automatically, but
the user can change it. The user can also introduce a non-constant initial control trajectories for the
optimization or simulation. If we consider two time intervals and two control variables, then the option
data.nlp.u0 will be dened as follows: [u
011
u
012
; u
021
u
022
]
Line: 75-83 This place is necessary for dening 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 active.
Note The equality constraint of the type data.nl.eq.eq(1) = {y(2)+0.1} is active, the status is set on the
value of on what means that the equation
x
2
(t
F
) = 0.1 (4.7)
is active in the nal segment data.nlp.eq.time(1) = data.nlp.RHO. This direction timing is equal to
the nal time. If we would like to set the active equality constraint on the half time of the optimization,
we have to dene the before mentioned option on the value of 15 or data.nlp.RHO/2.
Line: 85-96 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 [20].
Note There are 2 inequality constraints data.nlp.ineq.NEC = 2 active. The rst one and the second one is
of the type >= and <=, respectively. This is declared in the data.nlp.ineq.InNUM = 1 option. In
other words:
x
1
(t) 0.4 (4.8)
x
1
(t) 0 (4.9)
Page 21
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
or we can talk about the path constraints. These constrains are solved by the conversion to the integral
form which must be relaxed by some tolerance level. This can be done in the option: data.nlp.ineq.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.ineq.PenaltyCoe
= [1 1]. This penalty function is incorporated directly into the cost function.
Line: 98-112 There are settings for the output. The rst option in this part is related with the display of the intermediate
results. Other settings are connected with the gures which show the state, control or convergence curves or
save the results into the .dat le. There is an option to insert additional commands for the depicted pictures
and an option for the turning on/off of the proler function. If the proler 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.
Line: 114 In this option the user can choose a ag for the single optimization, sucessive re-optimization, hybrid strat-
egy or for the simulation. The re-optimization is secured by modied mesh rening algorithm [2] and the
principle lies in renition of the control trajectory, so the number of control variables together with the IVP
and NLP tolerances is increased. This method is described in detail in the next chapter 5. The hybrid strat-
egy [4] is characterized by the combination of the stochastic and deterministic method. If the simulation
module is selected the system will be integrated during the whole time. The default settings for all modules
are shown in the chapter 10.
Line: 116-119 Here the main function of the toolbox is called together with the data input structure.
Several parts of this input function contain information which is described in detail in the manuals for
SUNDIALS, IPOPT, FMINCON, SRES, DE, ACOmi, MISQP, MITS, and that is the reason for the absence of
their description.
4.1.3 Initialization, nal results, and optimal trajectories
1 ________________________________________________________
2
3 DOTcvp: Dynamic Optimization Toolbox with CVP approach
4 for handling continuous and mixed-integer DO problems
5
6 Main author: Tomas Hirmajer, [email protected]
7 Coauthors: Eva Balsa-Canto and Julio R. Banga
8 Web pages: http://www.iim.csic.es/~dotcvp/
9 http://www.iim.csic.es/~dotcvpsb/
10 Core version: DOTcvp_R2010_E3
11 ________________________________________________________
12
13 ________________________________________________________
14
15 DOTcvp - a Module for Single Optimization
16 ________________________________________________________
17
18 Saving of the ODE ................................................. done!
19 Saving of the inequality constraints .............................. done!
20 Generation of the file: cvm_rhs.m (ODE - MATLAB) .................. done!
21 Saving of the parameters .......................................... done!
22 Generation of the file: cvm_d/bjac.m (Jacobian - MATLAB) .......... done!
23 Saving of the cost function (J0) .................................. done!
24 Generation of the gradients (J0) .................................. done!
25 Generation of the file: cvm_rhsS.m (sensitivities - MATLAB) ....... done!
26 Saving of the in/equality constraints (Ji) ........................ done!
27 Generation of the gradients (Ji) .................................. done!
28 Generation of the file: temp_cvfdx.m (main IVP file) .............. done!
29 Optimizing of the process (N=30; min(J0); FMINCON; VanDerPolOscillator) ... in progress
30 Default settings are loading ...................................... done!
31 Generation of the file: cvm_rhs.m (ODE - MATLAB) .................. done!
32 Generation of the file: temp_cvfdx.m (main IVP file) .............. done!
33 Simulation of the process ......................................... done!
34 Save of the data .................................................. done!
35 Deleting of the temporary files ................................... done!
36 ____________________________
37 Final results [single-optimization]:
38 ............. Problem name: VanDerPolOscillator
39 ...... NLP or MINLP solver: FMINCON
40 . Number of time intervals: 30
41 ... IVP relative tolerance: 1.000000e-007
42 ... IVP absolute tolerance: 1.000000e-007
43 . Sens. absolute tolerance: 1.000000e-007
44 ............ NLP tolerance: 1.000000e-005
45 ....... Final state values: 1.892634e-002 -1.000018e-001 2.924821e+000
46 ...... 1th optimal control: -1.927935e-001 2.017685e-001 5.470906e-001 8.083584e-001 9.140475e-001 9.387560e-001 9.207990e-001
47 8.861899e-001 8.577802e-001 8.471769e-001 8.308007e-001 7.890242e-001 7.335549e-001 6.662662e-001
48 5.923498e-001 5.156350e-001 4.392108e-001 3.655986e-001 2.967516e-001 2.342226e-001 1.792525e-001
49 1.318771e-001 9.175374e-002 5.884850e-002 3.270859e-002 1.294192e-002 -8.947570e-004 -8.743508e-003
50 -9.794536e-003 -1.106268e-003
Page 22
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
51 . 1th inequality constrain violation [without the penalty coefficient]: 5.003195e-004
52 . 2th inequality constrain violation [without the penalty coefficient]: 1.995099e-005
53 ____________________________
54 ............ Final CPUtime: 4.98437500 seconds
55 . Cost function [min(J_0)]: 2.92482468
56
57 The detailed information is saved to the workspace structure with the name 'data'.
58
59 data =
60
61 name: 'VanDerPolOscillator'
62 compiler: 'None'
63 odes: [1x1 struct]
64 sens: [1x1 struct]
65 nlp: [1x1 struct]
66 options: [1x1 struct]
67 version: 'DOTcvp_R2010_E3'
68 output: [1x1 struct]
69 p: [-0.0011 30 -5.0000e-004 -1.9905e-005]
70 gradJ0: [1x32 double]
71 gradJi: [3x32 double]
72 J0: 2.9248
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.5
0
0.5
1
1.5
2
2.5
3
Time
S
t
a
t
e

V
a
r
ia
b
le
s
,
x
min J
0
=2.92482468 [FMINCON: 1e005; CVODEs: 1e007; N=30; MATLAB]


x
1
x
2
x
3
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.2
0
0.2
0.4
0.6
0.8
1
1.2
Time
C
o
n
t
r
o
ls
,
u
min J
0
=2.92482468 [FMINCON: 1e005; CVODEs: 1e007; N=30; MATLAB]


u
1
Figure 4.1 Optimal state trajectories (left) and the optimal control prole (right) for the van der Pol oscillator.
The Figures 4.1 show 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.2. These are the gures from the DOTcvp
output. It is possible to see in the title of gures the value of the cost function and the resulting settings for NLP as
tolerance level, number of time intervals, name of the MI/NLP solver, used gradient method and settings for IVP
as tolerance level, nonlinear solver, sensitivity correction method, LMM, and compiler. This information can be
done with the option: data.output.title.
The above mentioned problem with the presented settings, as well as other problems presented in the next
sections is possible to run directly from the toolbox. The names of the van der Pol oscillator problem in the
DOTcvp toolbox are the following: cdop_VanDerPolOscillator_simple; cdop_VanDerPolOscillator
Page 23
CHAPTER 5
Sucessive re-optimization
For reaching a high level of the control discretization in a very effective way, sucessive re-optimization module was
implemented into the toolbox. The basis of this module is secured by a modied mesh renement algorithm, which
was rst proposed and described in detail in [2]. This algorithm allows to use a high level of control discretization
with relative low computational cost.
5.1 APPLICATION OF THE MESH REFINEMENT ALGORITHM
DOTcvp: cdop_VanDerPolOscillator_reoptimization.m
The problem of the van der Pol oscillator, investigated in the previous section 4.1, is in this case solved
without constraints. The re-optimization was run with the default settings presented in the section 10.2.
The nal control trajectories for 10, 30, 90, and 270 piecewise time constants are shown in Figure 5.1. It
should be noted that the increased number of time intervals smooths the control prole and this has an inuence on
the cost function value. Fromthe above mentioned default le all options are taken, where data.option.Mesh_NRO,
data.option.Mesh_Increasing represent the number of mesh renings and how quickly will the number of time
intervals be increased the actual number of time intervals is multiplied by this number. The default le also
contains all tolerances needed for the re-optimization. At the beginning of the re-optimization these tolerances are
taken into account and at the end, when the last re-optimization is running, the tolerances are taken from the user
input le. Between the rst and the last re-optimization, the tolerances are interpolated as it is possible to see in
the box below.
1 ______________
2 Final results [1/4 re-optimization]:
3 ............. Problem name: VanDerPolOscillator
4 ...... NLP or MINLP solver: IPOPT
5 . Number of time intervals: 10
6 ... IVP relative tolerance: 1.000000e-005
7 ... IVP absolute tolerance: 1.000000e-005
8 . Sens. absolute tolerance: 1.000000e-005
9 ............ NLP tolerance: 1.000000e-003
10 ....... Final state values: 7.120680e-002 -5.283990e-002 2.926158e+000
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 2.92623292
15
16 ______________
17 Final results [2/4 re-optimization]:
18 ............. Problem name: VanDerPolOscillator
19 ...... NLP or MINLP solver: IPOPT
20 . Number of time intervals: 30
21 ... IVP relative tolerance: 2.154435e-006
22 ... IVP absolute tolerance: 2.154435e-006
23 . Sens. absolute tolerance: 2.154435e-006
24 ............ NLP tolerance: 2.154435e-004
25 ....... Final state values: 6.712704e-002 -5.209653e-002 2.873413e+000
26 ...... 1th optimal control: ...
27 ______________
28 ............ Final CPUtime: ... seconds
29 . Cost function [min(J_0)]: 2.87350824
30
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l

v
a
r
i
a
b
l
e
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l

v
a
r
i
a
b
l
e
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l

v
a
r
i
a
b
l
e
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l

v
a
r
i
a
b
l
e
Figure 5.1 The optimal control proles obtained by mesh renement algorithm for the van der Pol oscillator
problem for 10, 30, 90, and 270 time intervals.
31 ______________
32 Final results [3/4 re-optimization]:
33 ............. Problem name: VanDerPolOscillator
34 ...... NLP or MINLP solver: IPOPT
35 . Number of time intervals: 90
36 ... IVP relative tolerance: 4.641589e-007
37 ... IVP absolute tolerance: 4.641589e-007
38 . Sens. absolute tolerance: 4.641589e-007
39 ............ NLP tolerance: 4.641589e-005
40 ....... Final state values: 6.697208e-002 -5.209121e-002 2.867859e+000
41 ...... 1th optimal control: ...
42 ______________
43 ............ Final CPUtime: ... seconds
44 . Cost function [min(J_0)]: 2.86792692
45
46 ______________
47 Final results [4/4 re-optimization]:
48 ............. Problem name: VanDerPolOscillator
49 ...... NLP or MINLP solver: IPOPT
50 . Number of time intervals: 270
51 ... IVP relative tolerance: 1.000000e-007
52 ... IVP absolute tolerance: 1.000000e-007
53 . Sens. absolute tolerance: 1.000000e-007
54 ............ NLP tolerance: 1.000000e-005
55 ....... Final state values: 6.689103e-002 -5.211250e-002 2.867308e+000
56 ...... 1th optimal control: ...
57 ______________
58 ............ Final CPUtime: ... seconds
59 . Cost function [min(J_0)]: 2.86735242
Page 25
CHAPTER 6
GUI for DOTcvp
6.1 STEP BY STEP
DOTcvp: dotcvp_gui.p
The GUI (Graphical User Interface) for DOTcvp toolbox was developed in order to help users work with
the toolbox, mainly at the beginning. How the GUI can be run and used?
1. The user needs to have installed the toolbox into MATLAB environment.
2. Then it is needed to type dotcvp_gui in the command prompt and press enter.
3. After the GUI is opened it is possible to dene a new problem or load and edit the previously created
problem, which is saved as some .dotcvp le.
4. The problem input le of the form .m and .dotcvp is generated after the last GUI screen. If the problem
is saved, the m-le is running. The new problems will be standardly saved into the following directory:
DOTcvp/dotcvp_examples/examples_gui
The procedure of inserting a new problem consists of several steps. The input screens for a van der Pol
oscillator problem are shown here:
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Figure 6.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.
Figure 6.2 NLP denition: here is set everything regarding the NLP settings, gradient method, cost function,
and bounds on the control variables and on time-independent parameters, with a convenient approximation.
Page 27
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Figure 6.3 Settings related to the initialization, NLP, and IVP: in this step it is needed to insert a problem name,
select a compiler, and than the user can change the number of control, time-independent parameters, and state
variables with initial and nal time. If the free time problem is considered, there is a place to dene the initial
conditions for time variables.
Figure 6.4 Problemdenition: there is a place for the denition 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 28
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Figure 6.5 Equality an inequality 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 coefcients.
Figure 6.6 ODE and sensitivities initialization: this screen is used for the initialization (set the tolerance levels)
of the integrated equations, both system and sensitivities.
Page 29
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Figure 6.7 Output: the last screen. Here it is possible to set many settings for the output (gures and data). The
most important option is to save the data into a .dotcvp le, 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 le.
Figure 6.8 MATLAB output: At the end of the optimization the graphic output can be obtained together with
the numerical solution.
Page 30
CHAPTER 7
Chemical engineering problems
7.1 SIMPLE BATCH REACTOR
DOTcvp: cdop_SimpleBatchReactorA, B.m
The simple batch reactor given in [16] was considered with the following chemical reaction
A B C (7.1)
The parameters of the reactor are: e
1
= 18000 cal mol
1
, e
2
= 30000 cal mol
1
, k
10
= 0.535x10
11
min
1
,
k
20
= 0.461x10
18
min
1
, r = 2 cal mol
1
K
1
,
1
= 0.53 mol l
1
,
2
= 0.43 mol l
1
, =
e
2
e
1
, c =
k
20
k

10
, and
nal time t
F
= 8.0 min.
The objective of the optimization is to maximize an amount of the product B at the nal time
max
u
i
,t
i
J
0
= x
2
(t
F
) (7.2)
subject to
x
1
= ux
1
(7.3)
x
2
= ux
1
cu

x
2
(7.4)
with the process: x(0) = [
1
;
2
] and decision: u(0) = [0.5] initial variables. The decision variables have dened
lower and upper bounds as follows: u [0.1; 2.0]. The additional equality constraint was dened. This constraint
holds the total time of simulation at the xed value
N

i=1
t
i
= t
F
(7.5)
1 ______________
2 Final results [single-optimization; the scenario with the free time and with the piecewise constant control trajectory]:
3 ............. Problem name: SimpleBatchReactorA
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 6
6 ... IVP relative tolerance: 1.000000e-012
7 ... IVP absolute tolerance: 1.000000e-012
8 . Sens. absolute tolerance: 1.000000e-012
9 ............ NLP tolerance: 1.000000e-010
10 ....... Final state values: 1.704654e-001 6.794171e-001
11 ...... 1th optimal control: ...
12 ..... Final size of the dt: 7.469692e-001 1.247365e+000 1.420018e+000 1.495831e+000 1.534227e+000 1.555590e+000
13 ..... Final time [sum(dt)]: 8.000000e+000
14 ______________
15 ............ Final CPUtime: ... seconds
16 . Cost function [max(J_0)]: 0.67941706
17
18 ______________
19 Final results [single-optimization; the scenario with the fixed time and with the piecewise constant control trajectory]:
20 ............. Problem name: SimpleBatchReactorB
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
21 ...... NLP or MINLP solver: FMINCON
22 . Number of time intervals: 6
23 ... IVP relative tolerance: 1.000000e-012
24 ... IVP absolute tolerance: 1.000000e-012
25 . Sens. absolute tolerance: 1.000000e-012
26 ............ NLP tolerance: 1.000000e-010
27 ....... Final state values: 1.704776e-001 6.794113e-001
28 ...... 1th optimal control: ...
29 ______________
30 ............ Final CPUtime: ... seconds
31 . Cost function [max(J_0)]: 0.67941127
32
33 ______________
34 Final results [single-optimization; the scenario with the fixed time and with the piecewise linear control trajectory]:
35 ............. Problem name: SimpleBatchReactorB
36 ...... NLP or MINLP solver: FMINCON
37 . Number of time intervals: 6
38 ... IVP relative tolerance: 1.000000e-012
39 ... IVP absolute tolerance: 1.000000e-012
40 . Sens. absolute tolerance: 1.000000e-012
41 ............ NLP tolerance: 1.000000e-010
42 ....... Final state values: 1.704362e-001 6.794368e-001
43 ...... 1th optimal control: ...
44 ...... 2th optimal control: ...
45 ______________
46 ............ Final CPUtime: ... seconds
47 . Cost function [max(J_0)]: 0.67943676
0 1 2 3 4 5 6 7 8
0.125
0.13
0.135
0.14
0.145
0.15
0.155
0.16
0.165
0.17
0.175
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le


u
1
piecewise constant (free time), max J
0
= 0.67941706
0 1 2 3 4 5 6 7 8
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le


u
1
piecewise constant (fixed time), max J
0
= 0.67941127
u
1
piecewise linear (fixed time), max J
0
= 0.67943676
Figure 7.1 Optimal control prole for the free time scenario (left) and the control prole with the piecewise
constant and linear approximation (right) for the simple batch reactor.
7.2 BIFUNCTIONAL CATALYST BLEND PROBLEM
DOTcvp: cdop_BifunctionalCatalystBlend.m
Consider a tubular reactor [34; 39] where methylcyclopentane is converted into benzene. This procedure
consists of the blending of two components, for hydrogenation and isomerization which is characterized by the
mass fraction u of the catalyst hydrogenation. The aim of the optimization is to nd the optimal catalyst blend
along the reactor which maximizes the concentration of benzene
max
u
i
J
0
= x
7
(t
F
) (7.6)
subject to
x
1
= k
1
x
1
(7.7)
x
2
= k
1
x
1
(k
2
+ k
3
)x
2
+ k
4
x
5
(7.8)
x
3
= k
2
x
2
(7.9)
x
4
= k
6
x
4
+ k
5
x
5
(7.10)
x
5
= k
3
x
2
+ k
6
x
4
(k
4
+ k
5
+ k
8
+ k
9
)x
5
+ k
7
x
6
+ k
10
x
7
(7.11)
x
6
= k
8
x
5
k
7
x
6
(7.12)
x
7
= k
9
x
5
k
10
x
7
(7.13)
Page 32
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
where the rate constants are expressed as cubic functions of the catalyst blend u
k
i
= c
i1
+ c
i2
u + c
i3
u
2
+ c
i4
u
3
, i = 1, 10 (7.14)
The detailed values of the coefcients c
ij
(j = 1, 4) for the cubic functions are given by [34]. The state
variables represent the mole fractions of the chemical species, i = 1, 6 for methylcyclopentane and i = 7 for
benzene. The nal time is xed at the value of t
F
= 2000 g h mol
1
. The initial values of the state and decision
variables were set at the values of x(0) = [1; 0; 0; 0; 0; 0; 0] and u(0) = [0.9], respectively. The decisions variables
have dened upper and lower bounds as follows: u [0.6; 0.9].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: BifunctionalCatalystBlend
4 ...... NLP or MINLP solver: ACOMI
5 . Number of time intervals: 10
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: none
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 7.906696e-001 1.148378e-003 1.507881e-001 2.874896e-002 1.457187e-004 1.840506e-002 1.009413e-002
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: -0.01009413
0 200 400 600 800 1000 1200 1400 1600 1800 2000
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
x
5
x
6
x
7
0 200 400 600 800 1000 1200 1400 1600 1800 2000
0.6
0.65
0.7
0.75
0.8
0.85
0.9
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 7.2 Optimal state trajectories (left) and the control prole with the upper and lower boundary (right) for
the bifunctional catalyst blend problem.
7.3 MODIFIED DENBIGH REACTION SYSTEM.M
DOTcvp: cdop_ModiedDenbighReactionSystem.m
Consider a batch reactor taken from [11], where ve chemical reactions take place
A + B X (7.15)
A + B P (7.16)
X Y (7.17)
X Q (7.18)
Y Z (7.19)
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 nd an optimal control trajectory the temperature prole (K) and the nal time
which yields the maximum amount of the product B
max
u
i
,t
i
J
0
= wx
3
(t
F
) (7.20)
Page 33
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
subject to
x
1
= k
1
x
1
k
2
x
1
(7.21)
x
2
= k
1
x
1
(k
3
+ k
4
)x
2
(7.22)
x
3
= k
3
x
2
k
5
x
3
(7.23)
where the rate constants are given by
k
i
= k
i0
e
(
E
i
RT
)
, i = 1, 5 (7.24)
and x
1
, x
2
, and x
3
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 initial control trajectory was
set at the value of: u(0) = [273]. The penalty function (w) with the value of 10
7
on the nal time was used.
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: ModifiedDenbighReactionSystem
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 15
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: -9.693128e-043 3.826990e-002 5.451427e-001 5.799364e+002
11 ...... 1th optimal control: ...
12 ..... Final size of the dt: 1.019258e+002 2.747132e+001 2.109317e+002 1.131862e+002 2.401461e+001 1.081159e+001 9.232204e+000
13 1.078086e+001 1.026602e+001 8.363291e+000 7.449659e+000 8.007621e+000 9.785122e+000 1.237959e+001 1.533071e+001
14 ..... Final time [sum(dt)]: 5.799364e+002
15 ______________
16 ............ Final CPUtime: ... seconds
17 . Cost function [max(J_0)]: 0.54508470
0 100 200 300 400 500 600
0
0.2
0.4
0.6
0.8
1
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
0 100 200 300 400 500 600
260
280
300
320
340
360
380
400
420
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 7.3 Optimal state trajectories (left) and the control prole (right) for the modied Denbigh reaction
system.
7.4 OIL SHALE PYROLYSIS
DOTcvp: cdop_OilShalePyrolysis.m
Consider an oil shale pyrolysis problem solved by several authors [33; 13]. The process is described by the
following set of ve chemical reactions
A
1
A
2
(7.25)
A
2
A
3
(7.26)
A
1
+ A
2
A
2
+ A
2
(7.27)
A
1
+ A
2
A
3
+ A
2
(7.28)
A
1
+ A
2
A
4
+ A
2
(7.29)
Page 34
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
that can be mathematically modeled with the help of differential equations
x
1
= k
1
x
1
(k
3
+ k
4
+ k
5
)x
1
x
2
(7.30)
x
2
= k
1
x
1
k
2
x
2
+ k
3
x
1
x
2
(7.31)
x
3
= k
2
x
2
+ k
4
x
1
x
2
(7.32)
x
4
= k
5
x
1
x
2
(7.33)
where the rate expressions are given by [33]
k
i
= k
i0
e
(
E
i
RT
)
, i = 1, 5 (7.34)
The state variables are the concentrations represented by a related letter and number: x
i
= A
i
, i = 1, 4. The
initial concentration of the state variables was set at the value of: x(0) = [1; 0; 0; 0]. The aim of the optimization
is to nd an optimal control trajectory that maximizes the performance index, the amount of the pyrolytic bitumen
max
u
i
,t
i
J
0
= x
2
(t
F
) (7.35)
with no specied nal time of the optimization (0 t t
F
). The temperature with an initial value equal to 725 is
a decision variable with boundaries as follows
698.15 T 748.15 (7.36)
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: OilShalePyrolysis
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 5
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 1.311160e-001 3.537690e-001 3.386586e-001 1.764564e-001
11 ...... 1th optimal control: ...
12 ..... Final size of the dt: 2.128512e+000 1.241545e+000 1.343369e+000 2.780861e-001 4.099151e+000
13 ..... Final time [sum(dt)]: 9.090664e+000
14 ______________
15 ............ Final CPUtime: ... seconds
16 . Cost function [max(J_0)]: 0.35376917
0 1 2 3 4 5 6 7 8 9 10
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 1 2 3 4 5 6 7 8 9 10
690
700
710
720
730
740
750
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 7.4 Optimal state trajectories (left) and the control prole (right) for the oil shale pyrolysis problem.
7.5 NONLINEAR CSTR REACTOR
DOTcvp: cdop_NonlinearCSTR.m
Consider a problem given in [30; 3]. In the isothermal continuous stirred tank reactor four simultaneous
chemical reactions are taking place. The problemconsists of determining four optimal control proles for obtaining
a maximum economic benet. The controls are the owrates of three feed streams and an electrical energy input
Page 35
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
used to promote a photochemical reaction. The system with the integral term of the cost function ( x
8
) is described
by following set of differential equations
x
1
= u
4
qx
1
17.6x
1
x
2
23x
1
x
6
u
3
(7.37)
x
2
= u
1
qx
2
17.6x
1
x
2
146x
2
x
3
(7.38)
x
3
= u
2
qx
3
73x
2
x
3
(7.39)
x
4
= qx
4
+ 35.2x
1
x
2
51.3x
4
x
5
(7.40)
x
5
= qx
5
+ 219x
2
x
3
51.3x
4
x
5
(7.41)
x
6
= qx
6
+ 102.6x
4
x
5
23x
1
x
6
u
3
(7.42)
x
7
= qx
7
+ 46x
1
x
6
u
3
(7.43)
x
8
= 5.8(qx
1
u
4
) 3.7u
1
4.1u
2
+ q(23x
4
+ 11x
5
+ 28x
6
+ 35x
7
) 5u
2
3
0.099 (7.44)
where q = (u
1
+ u
2
+ u
4
). The additional constraints on the decision variables, i.e. the lower and upper bounds
are the following: u
1
[0; 20], u
2
[0; 6], u
3
[0; 4], and u
4
[0; 20]. The vector of initial decision 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 x
8
at the nal time t
F
(0.2 h)
max
u
i
J
0
= x
8
(t
F
) (7.45)
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: NonlinearCSTR
4 ...... NLP or MINLP solver: IPOPT
5 . Number of time intervals: 11
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 4.005279e-001 3.008107e-001 8.289032e-002 8.226305e-002 8.935221e-002 2.008944e-002 2.406640e-002 2.175750e+001
11 ...... 1th optimal control: ...
12 ...... 2th optimal control: ...
13 ...... 3th optimal control: ...
14 ...... 4th optimal control: ...
15 ______________
16 ............ Final CPUtime: ... seconds
17 . Cost function [max(J_0)]: 21.75750255
0 0.05 0.1 0.15 0.2 0.25
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
x
5
x
6
x
7
0 0.05 0.1 0.15 0.2
0
5
10
15
20
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
1
0 0.05 0.1 0.15 0.2
0
1
2
3
4
5
6
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
2
0 0.05 0.1 0.15 0.2
0
1
2
3
4
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
3
0 0.05 0.1 0.15 0.2
0
5
10
15
20
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
4
Figure 7.5 Optimal state trajectories (left) and the control proles (right) for the nonlinear CSTR reactor.
7.6 CHEMICAL REACTOR CONTROL
DOTcvp: cdop_ChemicalReactorControl.m
The chemical reactor with the rst-order reversible chemical reaction
A B (7.46)
Page 36
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
as studied by [28; 33; 35] is considered. The systemwith the process initial conditions: x(0) = [0; 380] is described
by the following set of differential equations
x
1
= (1 x
1
)k
1
x
1
k
2
(7.47)
x
2
= 300[(1 x
1
)k
1
x
1
k
2
] u(x
2
290) (7.48)
where
k
1
= 1.7536x10
5
e

1.1374x10
4
1.9872x
2

(7.49)
k
2
= 2.4885x10
10
e

2.2748x10
4
1.9872x
2

(7.50)
The x
1
denotes the concentration of the desired product, x
2
is the temperature, and u is the coolant ow
rate. The aim of the optimization is to get a maximum product of the rst component until the nal time t
F
(5 min)
max
u
i
J
0
= x
1
(t
F
) (7.51)
subject to the upper path constraint on the temperature
x
2
(t) 460 (7.52)
and constraints on the decisions variables: u [0; 0.5] with initial control trajectory: u(0) = [0.25].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: ChemicalReactorControl
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 42
6 ... IVP relative tolerance: 1.000000e-008
7 ... IVP absolute tolerance: 1.000000e-008
8 . Sens. absolute tolerance: 1.000000e-008
9 ............ NLP tolerance: 1.000000e-006
10 ....... Final state values: 6.771858e-001 4.295669e+002
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: 0.67718577
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
370
380
390
400
410
420
430
440
450
460
470
Time
S
t
a
t
e

v
a
r
ia
b
le
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.1
0.2
0.3
0.4
0.5
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 7.6 Optimal state trajectory with the path constraint (left) and the control prole (right) for the chemical
reactor problem.
7.7 TWO-STAGE CSTR SYSTEM
DOTcvp: cdop_TwoStageCSTRsystem.m
Consider a two-stage CSTR system solved e.g. in [34; 1]. The aim of the optimization is to minimize the
time needed to get the state variables from the initial to the desired values
min
u
i
,t
i
J
0
= t
F
(7.53)
Page 37
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
subject to
x
1
= 3x
1
+ g
1
(7.54)
x
2
= 11.1558x
2
+ g
1
8.1558(x
2
+ 0.1592)u
1
(7.55)
x
3
= 1.5(0.5x
1
x
3
) + g
2
(7.56)
x
4
= 0.75x
2
4.9385x
4
+ g
2
3.4385(x
4
+ 0.122)u
2
(7.57)
where coefcients g
1
, g
2
are dened as follows
g
1
= 1.5x10
7
(0.5251 x
1
)e

10
x
2
+0.6932

1.5x10
10
(0.4748 + x
1
)e

15
x
2
+0.6932

1.4280 (7.58)
g
2
= 1.5x10
7
(0.4236 x
2
)e

10
x
4
+0.6560

1.5x10
10
(0.5764 + x
3
)e

15
x
4
+0.6560

0.5086 (7.59)
The state variables are initially set at the value of: x(0) = [0.1962 0.0372 0.0946 0.0] and the desired
values are 0.0 for all of them. This denition adds the new set of equality constraints at the end of the optimization.
The decision variables are initially set at the value of 0.0 and the lower and upper boundaries are as follows:
u [1.0, 1.0].
This multimodal problem is solved with the help of the hybrid strategy. At rst a stochastic NLP solver is
used and then a deterministic NLP solver, MISQP in our case. This improves the nal value of the cost function
mainly for this kind of problems. For the stochastic part were always used the penalty coefcients with the value
of 100.0.
1 ______________
2 Final results [deterministic part - hybrid-strategy]:
3 ............. Problem name: TwoStageCSTRsystem
4 ...... NLP or MINLP solver: MISQP
5 . Number of time intervals: 5
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-004
10 ....... Final state values: 7.918207e-006 -1.598586e-005 9.428117e-006 6.352826e-005 3.262017e-001
11 ...... 1th optimal control: ...
12 ...... 2th optimal control: ...
13 ..... Final size of the dt: 1.356909e-001 1.245352e-001 1.854300e-002 1.584765e-002 3.158494e-002
14 ..... Final time [sum(dt)]: 3.262017e-001
15 ______________
16 ............ Final CPUtime: ... seconds
17 . Cost function [min(J_0)]: 0.32629392
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
0.05
0
0.05
0.1
0.15
0.2
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
s


u
1
u
2
Figure 7.7 Optimal state trajectories (left) and the control proles (right) for the two-stage CSTR system.
7.8 PLUG-FLOW REACTOR WITH A SINGULAR ARC
DOTcvp: cdop_PlugFlowReactor.m
This problem, initially formulated by [26], latter solved e.g. in [7; 1] consists of a plug-ow reactor with
the following chemical reactions
A B C (7.60)
Page 38
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
The aim of the optimization is to adjust the fraction of the rst catalyst dened by reversible reaction so as
to maximize the production of the component C. This is done with the following cost function
max
u(z
i
)
J
0
= 1 x
A
(z
F
) x
B
(z
F
) (7.61)
subject to
dx
A
(z)
dz
= u(z)(10x
B
(z) x
A
(z)) (7.62)
dx
B
(z)
dz
= u(z)(10x
B
(z) x
A
(z)) (1 u(z))x
B
(z) (7.63)
where x
A
and x
B
represents the mole fractions of components A and B. The decision variable u(z) represents the
fraction of the catalyst associated with the reversible reaction at the position z in the plug-ow reactor of the length
one. The decision variable is constrained as follows: u(z) [0; 1]. The process and decision initial variables are
x(0) = [1; 0] and u(0) = [0.95], respectively.
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: PlugFlowReactor
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 50
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 8.993421e-001 5.268869e-002
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: 0.04796964
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
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
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 7.8 Optimal state trajectories (left) and the control prole (right) for the plug-ow reactor.
7.9 PLUG FLOW REACTOR, A MIDO PROBLEM
Consider a nonconvex mixed-integer problem solved by global deterministic approach in [9]. This problem
was dened with (i) xed and (ii) free transition times. The above mentioned authors guaranteed a global optimality
of their results. Our results will be compared with them and the accuracy of the toolbox will be shown, rstly with
the hybrid solver and secondly, with a local solver using of the multistart method.
The aim of the optimization is to nd the optimal transient regime from the rst to the second operational
stage and so on. This problem is then dened as hybrid and the transition can be handled with the help of binary
variables. These variables can reach the value of 1, if the stage is active, otherwise 0. The isothermal plug ow
reactor is operating at a steady state and can be loaded with three possible choices of solid catalysts. The values
of the catalyst are introduced in Table 7.1. The aim of the optimization is to maximize the amount of the product
(x
5
) and minimize the cost on the waste treatment of the by-products (x
3
, x
4
)
min
u
i
J
0
= 0.01x
3
+ 0.1x
4
x
5
(7.64)
Page 39
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Stage Catalyst
k
1
k
2
k
3
k
4
1 2.098 1.317 0.021 0.033
2 29.53 110.2 0.295 0.079
3 182.6 2325 1.826 0.143
Table 7.1 The value of the solid catalyst for the various reaction stages of the plug ow reactor.
subject to
x
1
= (k
1
+ k
2
)x
1
(7.65)
x
2
= k
1
x
1
(k
3
+ k
4
)x
2
(7.66)
x
3
= k
2
x
1
(7.67)
x
4
= k
4
x
2
(7.68)
x
5
= k
3
x
2
(7.69)
where x
i
represents the molar concentrations of the chemical species i (mol m
3
) and k
j
represents the rate con-
stants for the reaction j (min
1
). The independent value t is considered as the position along the reactor. The
constant volumetric ow rate and the cross-sectional area are 0.05 m
3
min
1
and 0.05 m
2
, respectively.
The value of the reactor length is 1 and the initial concentrations are as follows: x(0) = [1000; 0; 0; 0; 0].
The decision variables are binaries, where each binary variable represents one reaction stage. This reaction stage
is characterized by the catalyst the value of which is dened in the Table 7.1.
7.9.1 The scenario with xed transition times
DOTcvp: midop_PlugFlowReactorA.m
We consider that only one stage can be active in one piecewise interval. This is satised by the additional
equality constraints. Although this problem was solved for different stages and with different approaches in the
above mentioned literature, for our demonstrative purposes, the scenario only with 15 piecewise constant is chosen.
This case introduces 45 binary variables and 15 equality constraints.
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: PlugFlowReactorA
4 ...... NLP or MINLP solver: ACOMI
5 . Number of time intervals: 15
6 ... IVP relative tolerance: 1.000000e-008
7 ... IVP absolute tolerance: 1.000000e-008
8 . Sens. absolute tolerance: none
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 3.6795062e-063 1.4395773e+002 5.1476153e+002 2.8786128e+001 3.1249462e+002
11 ...... 1th optimal control: ...
12 ...... 2th optimal control: ...
13 ...... 3th optimal control: ...
14 ______________
15 ............ Final CPUtime: ... seconds
16 . Cost function [min(J_0)]: 304.46839195
The presented scenario was solved with ACOmi, which is a hybrid MINLP solver. We obtained the value of
the cost function 304.5 (the computation time was 862.3 CPU seconds) which is exactly the same result as is men-
tioned in the literature, where global deterministic algorithm was used. Detailed analyzes of the results (see Figure
7.9) are skipped, because this is out of the scope of this report. The results show that the presented toolbox is able
to solve MIDO problems with high accuracy.
7.9.2 The scenario with free transition times
DOTcvp: midop_PlugFlowReactorB.m
In this case following the results from the earlier section and from [9] consider the free transition times.
We xed the number of time intervals at the value of 3 and the order of stages to the value of 1, 2, and 3. This
is done with the help of additional equality constraints. For this case are introduced 6 equality constraints and 1
Page 40
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
100
200
300
400
500
600
700
800
900
1000
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
x
5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.5
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.5
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.5
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
,
u
3
Figure 7.9 Optimal state trajectories (left) and the control proles (right) for the plug ow reactor.
additional that x the total time of the simulation on the value of 1. The global optimum reported by the above
mentioned literature is 314.2. In our case we chose the local MINLP solver MISQP with multistart method (the
initial size of time intervals and the value of the binary variables were generated in respect of upper and lower
bounds randomly) and 100 runs. This option is possible to set in the toolbox directly in the input le.
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: PlugFlowReactorB
4 ...... NLP or MINLP solver: MISQP
5 . Number of time intervals: 3
6 ... IVP relative tolerance: 1.000000e-008
7 ... IVP absolute tolerance: 1.000000e-008
8 . Sens. absolute tolerance: 1.000000e-008
9 ............ NLP tolerance: 1.000000e-005
10 ...... 1th optimal control: ...
11 ...... 2th optimal control: ...
12 ...... 3th optimal control: ...
13 ______________
14 Best cost function [max(J_0), using of finite difference]: 314.19855083
15 ... Best cost function [max(J_0), using of sensitivities]: 314.19882774
50 0 50 100 150 200 250 300 350
0
10
20
30
40
50
60
70
80
90
100
Objective Function Value []
F
r
e
q
u
e
n
c
y
50 0 50 100 150 200 250 300 350
0
10
20
30
40
50
60
70
80
90
100
Objective Function Value []
F
r
e
q
u
e
n
c
y
Figure 7.10 Histogram for the scenario with the free time interval for the plug ow reactor, left with nite
difference and right with sensitivity equations.
Two cases were considered, rst one, the multistart with the gradients provided by MISQP solver with the
help of nite difference and the second one, where the gradients of the continuous variables are provided directly
from the toolbox by sensitivities. The applicable performance is shown in the Figures 7.10.
Page 41
CHAPTER 8
Biochemical engineering problems
8.1 LEE-RAMIREZ BIOREACTOR
DOTcvp: cdop_LeeRamirezBioreactor.m
Considering a bioreactor, which was rst solved in [29] and later slightly modied in [43]. The objective
is to maximize the protability of the process using the nutrient u
1
and the inducer feeding rates u
2
. Different
scenarios with the various value of Q are considered.
The mathematical formulation of the problem is as follow: nd the control trajectories that maximize the
cost function at the nal time
max
u
i
J
0
= x
1
(t
F
)x
4
(t
F
) Q
_
t
F
t
o
(u
2
) dt (8.1)
subject to
x
1
= u
1
+ u
2
(8.2)
x
2
= g
1
x
2

u
1
+ u
2
x
1
x
2
(8.3)
x
3
=
100u
1
x
1

u
1
+ u
2
x
1
x
3

g
1
0.51
x
2
(8.4)
x
4
= R
fp
x
2

u
1
+ u
2
x
1
x
4
(8.5)
x
5
=
4u
2
x
1

u
1
+ u
2
x
1
x
5
(8.6)
x
6
= k
1
x
6
(8.7)
x
7
= k
2
(1 x
7
) (8.8)
where
g
1
=
_
x
3
14.35 + x
3
(1 + x
3
/111.5)
__
x
6
+
0.22x
7
0.22 + x
5
_
(8.9)
R
fp
=
_
0.233x
3
14.35 + x
3
(1 + x
3
/111.5)
__
0.0005 + x
5
0.022 + x
5
_
(8.10)
k
1
= k
2
=
0.09x
5
0.034 + x
5
(8.11)
The scenario with Q = 0 and 2.5 is considered. The nal time is specied as 10 h and the vector process and
decision initial conditions as x(0) = [1; 0.1; 40; 0; 0; 1; 0; 0] and u
1,2
(0) = [0.5; 0.5], respectively. The additional
constrains on the decision variables are the following: u
1,2
[0; 1]
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
1 ______________
2 Final results [single-optimization; Q=0.0]:
3 ............. Problem name: Lee-RamirezBioreactor
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 25
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 4.182486e+000 6.413670e+000 3.893872e+001 1.470736e+000 1.367472e+000 7.134128e-001 2.865872e-001 1.429858e+000
11 ...... 1th optimal control: ...
12 ...... 2th optimal control: ...
13 ______________
14 ............ Final CPUtime: ... seconds
15 . Cost function [max(J_0)]: 6.15123355
16
17 ______________
18 Final results [single-optimization; Q=2.5]:
19 ............. Problem name: Lee-RamirezBioreactor
20 ...... NLP or MINLP solver: FMINCON
21 . Number of time intervals: 25
22 ... IVP relative tolerance: 1.000000e-007
23 ... IVP absolute tolerance: 1.000000e-007
24 . Sens. absolute tolerance: 1.000000e-007
25 ............ NLP tolerance: 1.000000e-005
26 ....... Final state values: 1.910086e+000 1.479996e+001 3.497523e+001 3.131412e+000 1.878273e-001 7.134005e-001 2.865995e-001 8.969161e-002
27 ...... 1th optimal control: ...
28 ...... 2th optimal control: ...
29 ______________
30 ............ Final CPUtime: ... seconds
31 . Cost function [max(J_0)]: 5.75694021
0 1 2 3 4 5 6 7 8 9 10
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
s


u
1
u
2
0 1 2 3 4 5 6 7 8 9 10
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
s


u
1
u
2
Figure 8.1 Optimal control trajectories for the Lee-Ramirez bioreactor, left for Q = 0 and right for Q = 2.5
case.
8.2 OPTIMAL PRODUCTION OF PROTEIN IN THE FED-BATCH REACTOR
DOTcvp: cdop_OptimalProductionOfSecretedProtein.m
Consider a fed-batch reactor where the goal of the optimization 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;
31; 7]. The cost function is dened as follows
max
u
i
J
0
= x
1
(t
F
)x
5
(t
F
) (8.12)
where x
1
is the concentration of the protein (L
1
) and x
5
is the culture volume (L) at the nal time t
F
= 15 h.
The optimal control problem is solved subject to
x
1
= g
1
(x
2
x
1
)
u
x
5
x
1
(8.13)
x
2
= g
2
x
3

u
x
5
x
2
(8.14)
x
3
= g
3
x
3

u
x
5
x
3
(8.15)
x
4
= 7.3g
3
x
3
+
u
x
5
(20 x
4
) (8.16)
x
5
= u (8.17)
Page 43
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
where
g
1
=
4.75g
3
0.12 + g
3
(8.18)
g
2
=
x
4
e
5x
4
0.1 + x
4
(8.19)
g
3
=
21.87x
4
(x
4
+ 0.4)(x
4
+ 62.5)
(8.20)
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 ow rate (Lh
1
), x
2
is the concentration of the total protein (L
1
), x
3
, and x
4
are the
glucose and the substrate concentration (g L
1
). The lower and upper bounds on the decision variables are dened
as follows: u [0; 2].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: OptimalProductionOfSecretedProtein
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 15
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 2.347980e+000 2.699309e+000 2.643206e+000 1.445502e-001 1.374892e+001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: 32.28218810
0 5 10 15
0
2
4
6
8
10
12
14
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
x
5
0 5 10 15
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 8.2 Optimal state trajectories (left) and the control prole (right) for the fed-batch reactor.
8.3 FED-BATCH FERMENTER FOR PENICILLIN PRODUCTION
DOTcvp: cdop_FedBatchFermenterForPenicillinProduction.m
The problem of the feed batch fermenter for the penicillin production has been solved e.g. in [17; 6]. The
scenario with xed nal time is considered. The aim is to maximize until the nal time (t
F
= 132) the cost
function of the form
max
u
i
J
0
= x
2
(t
F
)x
4
(t
F
) (8.21)
subject to
x
1
= g
1
x
1
u
_
x
1
500x
4
_
(8.22)
x
2
= g
2
x
1
0.01x
2
u
_
x
2
500x
4
_
(8.23)
x
3
=
_
g
1
x
1
0.47
_

g
2
x
2
1.2
x
1
_
0.029x
3
0.0001 + x
3
_
+
u
x
4
_
1
x
3
500
_
(8.24)
x
4
=
u
500
(8.25)
Page 44
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
where
g
1
= 0.11
_
x
3
0.006x
1
+ x
3
_
(8.26)
g
2
= 0.0055
_
x
3
0.0001 + x
3
(1 + 10x
3
)
_
(8.27)
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 x
1
, x
2
, x
3
, and x
4
, respectively.
There are dened several path constraints
0 x
1
40 (8.28)
0 x
2
25 (8.29)
0 x
3
10 (8.30)
with bounds on the decision variables (feed rate of the substrate) u [0; 50].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: FedBatchFermenterForPenicillinProduction
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 10
6 ... IVP relative tolerance: 1.000000e-006
7 ... IVP absolute tolerance: 1.000000e-006
8 . Sens. absolute tolerance: 1.000000e-006
9 ............ NLP tolerance: 1.000000e-004
10 ....... Final state values: 2.802555e+001 8.796238e+000 1.511141e-003 1.000434e+001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: 88.00031256
0 20 40 60 80 100 120 140 160
0
5
10
15
20
25
30
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 20 40 60 80 100 120 140
8
10
12
14
16
18
20
22
24
26
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 8.3 Optimal state trajectories (left) and the control prole (right) for the fed-batch fermenter for penicillin
production.
8.4 FED-BATCH REACTOR FOR ETHANOL PRODUCTION
DOTcvp: cdop_FedBatchReactorForEthanolProduction.m
The problem of the fed-batch reactor which was initially solved by [14] with nal time t
F
= 54 was
considered. This problem was later solved in e.g. [5] and it consists of the nding of the optimal control policy
over the whole time t [t
0
; t
F
] that maximizes
max
u
i
J
0
= x
3
(t
F
)x
4
(t
F
) (8.31)
Page 45
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
subject to
x
1
= g
1
x
1
u
_
x
1
x
4
_
(8.32)
x
2
= 10g
1
x
1
+ u
_
150 x
2
x
4
_
(8.33)
x
3
= g
2
x
1
u
_
x
3
x
4
_
(8.34)
x
4
= u (8.35)
where
g
1
=
_
0.408
1 + x
3
/16
__
x
2
0.22 + x
2
_
(8.36)
g
2
=
_
1
1 + x
3
/71.5
__
x
2
0.44 + x
2
_
(8.37)
The state values x
1
, x
2
, x
3
, and x
4
are the cell mass, the substrate, the ethanol concentration (g/L), and the
volume (L), respectively. The initial conditions for the process and decision variables were initially set at the value
of: x(0) = [1; 150; 0; 10] and u(0) = [6]. The lower and upper bound of the decision variables (feed rate) was
dened as follows: u [0; 12]. The volume of the container (x
4
) is bound with the equation as follows
0 x
4
(t) 200 (8.38)
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: FedBatchReactorForEthanolProduction
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 25
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 1.504808e+001 1.916873e-002 1.021811e+002 2.000084e+002
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [max(J_0)]: 20437.07128407
0 5 10 15 20 25 30 35 40 45 50
0
20
40
60
80
100
120
140
160
180
200
220
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 5 10 15 20 25 30 35 40 45 50
0
2
4
6
8
10
12
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 8.4 Optimal state trajectories (left) and the control prole (right) for the fed-batch reactor for ethanol
production.
Page 46
CHAPTER 9
Other benchmarks
9.1 LINEAR QUADRATIC PROBLEM
DOTcvp: cdop_LQR.m
Consider a linear one-dimensional control problem with a quadratic cost function (LQR) rst solved in [23]
and later e.g. [39]. The objective is to minimize the performance index of the form
min
u
i
J
0
=
_
1
0
_
0.625x
2
1
+ 0.5x
1
u + 0.5u
2
_
dt (9.1)
subject to
x
1
=
1
2
x
1
+ u (9.2)
with the initial state value equal to 1 and with the unconstrained control initially set at the value of 1. The decision
variables do not have dened the lower and upper boundaries: u [inf, inf]
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: LQR
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 10
6 ... IVP relative tolerance: 1.000000e-012
7 ... IVP absolute tolerance: 1.000000e-012
8 . Sens. absolute tolerance: 1.000000e-012
9 ............ NLP tolerance: 1.000000e-010
10 ....... Final state values: 6.480548e-001 3.807976e-001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 0.38079763
In the Figure 9.1 is possible to see two state trajectories although the system is described only by one. This
is because in our implementation we have transformed the cost function as additional state variable with initial
value equal to 0. This new state variable shows the change of the performance index in the time.
9.2 NISHIDA PROBLEM
DOTcvp: cdop_NishidaProblem.m
This problem is taken from [36] and later solved e.g. in [45]. The aim of the optimization is to minimize
the cost function of the form
min
u
i
J
0
=
4

i=1
x
2
i
(t
F
) (9.3)
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
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
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1.3
1.2
1.1
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.1 The state proles (left) and control prole (right) for the LQR problem.
subject to
x
1
= 0.5x
1
+ 5x
2
(9.4)
x
2
= 5x
1
0.5x
2
+ u (9.5)
x
3
= 0.6x
3
+ 10x
4
(9.6)
x
4
= 10x
3
0.6x
4
+ u (9.7)
with the process initial conditions: x(0) = [10; 10; 10; 10] and nal time t
F
= 4.2. The decision variables
are initially set at the value of 0 and they were constrained with the lower and upper bound dened as follows:
u [1; 1].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: NishidaProblem
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 15
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 1.872311e-001 -7.532267e-001 -7.509157e-001 2.615626e-001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 1.23469791
0 0.5 1 1.5 2 2.5 3 3.5 4
15
10
5
0
5
10
15
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 0.5 1 1.5 2 2.5 3 3.5 4
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.2 Optimal state trajectories (left) and the control prole (right) for the Nishida problem.
9.3 MINIMUM FUEL CONSUMPTION PROBLEM
DOTcvp: cdop_MinimumFuelConsumption.m
Page 48
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
The aim of this problem described in detail [22] and later solved, e.g. [39] is to minimize the whole fuel
consumption at the nal time (t
F
= 25)
min
u
i
J
0
=
_
t
F
t
0
(u) dt (9.8)
subject to
x
1
= x
3
(9.9)
x
2
= x
4
(9.10)
x
3
= x
1
+ x
2
+ u (9.11)
x
4
= 0.1x
1
1.02x
2
+ d (9.12)
where d = 0 if t 9.75, otherwise d = 0.3 sin(4t). The state variables x
1
and x
2
represent deviations of masses
from the equilibrium, x
3
and x
4
represent the velocities of the masses, and the decision variables u represents the
fuel consumption per second. The initial state variables were set at the value of: x(0) = [0; 0; 2; 1] and the decision
variables at the value of: u(0) = [1] with lower and upper bound dened as follows: u [0; 1].
The problem is solved with respect of nal equality constraints given as
x
i
(t
F
) = 0, i = 1, 4 (9.13)
(9.14)
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: MinimumFuelConsumption
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 30
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 8.131152e-006 -8.977053e-007 1.161981e-005 1.930543e-006 7.384969e+000
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 7.38496867
0 5 10 15 20 25
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
3
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
x
4
0 5 10 15 20 25
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.3 Optimal state trajectories (left) and the control prole (right) for the minimum fuel consumption
problem
9.4 OPTIMAL CONTROL OF THE NON-DIFFERENTIABLE SYSTEM.
DOTcvp: cdop_NonDifferentiableSystem.m
This problem has been solved by several authors [32; 8]. The aim of the optimization is to nd the optimal
control trajectory that minimizes x
3
in the nal time
min
u
i
J
0
= x
3
(t
F
) (9.15)
Page 49
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
subject to
x
1
= x
2
(9.16)
x
2
= x
1
x
2
+ u + d (9.17)
x
3
= 5x
2
1
+ 2.5x
2
2
+ 0.5u
2
(9.18)
with the disturbance term given as
d = 100[U(t 0.5) U(t 0.6)] (9.19)
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 and decision initial conditions is set
at the value of x(0) = [0; 0; 0], u(0) = [0], respectively with the nal time set at the value of t
F
= 2. The decision
variables have dened lower and upper bound as follows: u [20; 20].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: NonDifferentiableSystem
4 ...... NLP or MINLP solver: IPOPT
5 . Number of time intervals: 50
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 8.498247e-001 -4.342213e-001 5.808299e+001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 58.08288497
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
10
0
10
20
30
40
50
60
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
12
10
8
6
4
2
0
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.4 Optimal state trajectories (left) and the control prole (right) for the non-differentiable system.
9.5 TERMINAL AND INTERIOR POINT CONSTRAINTS
DOTcvp: cdop_TerminalInteriorPointConstraintA, B.m
The problem with the terminal and the interior point constraint was solved. This problem is presented
in [21]. 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 nal time t
F
= 1 come
min
u
i
J
0
= x
2
(t
F
) (9.20)
subject to
x
1
= u (9.21)
x
2
= x
2
1
+ u
2
(9.22)
Page 50
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
and the point constraints as follow
x
1
(0.6) = 0.8 (9.23)
x
1
(t
F
) = 0.5 (9.24)
The process and decision variables were initially set at the value of: x(0) = [1; 0], u(0) = [0], respectively.
Next the following lower and upper bound for the decision variables was dened: u [1; 1].
1 ______________
2 Final results [single-optimization; the scenario with the piecewise constant control trajectory]:
3 ............. Problem name: TerminalInteriorPointConstraintA
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 10
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 5.000000e-001 9.358783e-001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 0.93587894
15
16 ______________
17 Final results [single-optimization, the scenario with the piecewise linear control trajectory]:
18 ............. Problem name: TerminalInteriorPointConstraintB
19 ...... NLP or MINLP solver: FMINCON
20 . Number of time intervals: 2
21 ... IVP relative tolerance: 1.000000e-012
22 ... IVP absolute tolerance: 1.000000e-012
23 . Sens. absolute tolerance: 1.000000e-012
24 ............ NLP tolerance: 1.000000e-010
25 ....... Final state values: 5.000000e-001 9.353755e-001
26 ...... 1th optimal control: ...
27 ...... 2th optimal control: ...
28 ______________
29 ............ Final CPUtime: ... seconds
30 . Cost function [min(J_0)]: 0.93537546
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
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le


u
1
piecewise constant
u
1
piecewise linear
Figure 9.5 The state proles (left) and the piecewise constant (N = 10) and linear (N = 2) control prole
(right) for the terminal and interior point constraints problem.
9.6 INEQUALITY STATE PATH CONSTRAINT PROBLEM
DOTcvp: cdop_InequalityStatePathConstraintA, B.m
Consider a problem initially solved by [25]. The problem consists of the minimization of the following cost
function
min
u
i
J
0
= x
3
(9.25)
subject to
x
1
= x
2
(9.26)
x
2
= x
2
+ u (9.27)
x
3
= x
2
1
+ x
2
2
+ 0.005u
2
(9.28)
Page 51
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
and subject to the path constraint on the whole time interval (t
F
= 1)
x
2
8(t 0.5)
2
+ 0.5 0 (9.29)
The vector of the control and process trajectory is set at the value of u(0) = [1] and x(0) = [0; 1; 0],
respectively. The problem was the rst one (case: A) solved with the inequality constraint and the second one
(case: B) with transformed inequality constraint as the next ODE equation as it is shown in [21]. The decision
variables do not have dened lower and upper bounds: u [inf; inf].
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: InequalityStatePathConstraintA
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 20
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: -2.240264e-001 3.854104e-002 1.726373e-001
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 0.17263712
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2.5
2
1.5
1
0.5
0
0.5
Time
I
n
e
q
u
a
lit
y

c
o
n
s
t
r
a
in
t

v
io
la
t
io
n
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
4
2
0
2
4
6
8
10
12
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.6 The constraint prole (left) and the control prole (right) for the inequality state path constraint
problem (case: A).
9.7 VAN DER POL OSCILLATOR
DOTcvp: cdop_VanDerPolOscillator.m
The van der Pol oscillator problem is taken from [44] and has been solved by many authors [42; 7; 3]. In
our case we have expanded this problem with two inequality constraints and one equality constraint. 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]
x
1
= (1 x
2
2
)x
1
x
2
+ u (9.30)
x
2
= x
1
(9.31)
x
3
= x
2
1
+ x
2
2
+ u
2
(9.32)
The aim of the optimization is to minimize the cost function in the xed nal time (t
F
= 5)
min
u
i
J
0
= x
3
(t
F
) (9.33)
subject to the inequality path constraints
0.4 x
1
(t) 0.0 (9.34)
and equality constraint at the end of the optimization
x
2
(t
F
) = 0.1 (9.35)
The control trajectory has the boundaries dened as follows: u [0.3; 1]
Page 52
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
1 ______________
2 Final results [single-optimization]:
3 ............. Problem name: VanDerPolOscillator
4 ...... NLP or MINLP solver: FMINCON
5 . Number of time intervals: 30
6 ... IVP relative tolerance: 1.000000e-007
7 ... IVP absolute tolerance: 1.000000e-007
8 . Sens. absolute tolerance: 1.000000e-007
9 ............ NLP tolerance: 1.000000e-005
10 ....... Final state values: 1.009875e-002 -1.000017e-001 2.960991e+000
11 ...... 1th optimal control: ...
12 ______________
13 ............ Final CPUtime: ... seconds
14 . Cost function [min(J_0)]: 2.96099523
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.5
0
0.5
1
1.5
2
2.5
3
Time
S
t
a
t
e

v
a
r
ia
b
le
s


x
1
x
2
x
3
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.2
0
0.2
0.4
0.6
0.8
Time
C
o
n
t
r
o
l
v
a
r
ia
b
le
Figure 9.7 Optimal state trajectories (left) with the upper and lower path constraint for the state variable one
(dotted lines) and the control prole (right) for the van der Pol oscillator.
Page 53
CHAPTER 10
Default settings
The user can adjust the default parameters of every module that performs of the single optimization, sucessive
re-optimization, hybrid strategy or simulation. This can be done directly, by editing appropriate les located in the
following path:
DOTcvp/src_default_values
Each NLP or MINLP solver has its own default le with the appropriate name located into the before mentioned
path. The user can modify these default les and/or save these les under different names. Each problem can be
called and solved with the different default le what makes work with the toolbox more comfortable.
10.1 DEFAULT SETTINGS OF THE SINGLE OPTIMIZATION
DOTcvp: dotcvp_single_optimization_default.m
option description type options default value
Initialization
data.name name of the problem string no_name
data.compiler compiler for the dynamic, sensitivi-
ties, and Jacobian
string [None|FORTRAN] None
Initialization
data.odes.Def_FORTRAN option needed only for FORTRAN
parameters denition
string {}
data.odes.parameters constant parameters before ODE string [structure] {}
data.odes.Def_MATLAB option needed only for MATLAB
parameters denition
string [structure] {}
data.odes.res problem denition in ODE form string [structure] {}
data.odes.black_box if black box model will be used string [structure] {None,FunName}
data.odes.ic vector of initial conditions real [vector] [ ]
data.odes.NUMs number of state variables (y) integer size(data.odes.res,2)
data.odes.t0 initial time real 0.0
data.odes.tf nal time real 10.0
data.odes.NonlinearSolver [reference to SUNDIALS] string [Newton|Functional] Newton
data.odes.LinearSolver [reference to SUNDIALS] string [Dense|Diag|Band Dense
|GMRES|BiCGStab|TFQMR]
data.odes.LMM Linear Multistep Method [reference
to SUNDIALS]
string [Adams|BDF] Adams
data.odes.MaxNumStep maximum number of steps [refer-
ence to SUNDIALS]
integer 500
data.odes.RelTol IVP relative tolerance level [refer-
ence to SUNDIALS]
real [positive] 1*10 (-7)
data.odes.AbsTol IVP absolute tolerance level [refer-
ence to SUNDIALS]
real [positive] 1*10 (-7)
data.sens.SensAbsTol absolute tolerance for sensitivity
variables [reference to SUNDIALS]
real [positive] 1*10 (-7)
data.sens.SensMethod [reference to SUNDIALS] string [Staggered|Staggered1 Staggered
|Simultaneous]
data.sens.SensErrorControl sensitivities correction [reference to
SUNDIALS]
string [on|off] on
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
NLP denition
data.nlp.RHO number of time intervals integer 10
data.nlp.problem problem denition string [min|max] min
data.nlp.J0 cost function (performance index) string
data.nlp.u0 initial value for control values real [vector] []
data.nlp.lb lower bounds for control values real [vector] []
data.nlp.ub upper bounds for control values real [vector] []
data.nlp.p0 initial values for time-independent
parameters
real [vector] []
data.nlp.lbp lower bounds for time-independent
parameters
real [vector] []
data.nlp.ubp upper bounds for time-independent
parameters
real [vector] []
data.nlp.solver NLP or MINLP solver which will be string [FMINCON|IPOPT FMINCON
used for the optimization |SRES|DE
|ACOMI|MISQP|MITS]
data.nlp.SolverSettings insert the name of the le that con-
tains settings for NLP or MINLP
solver, if does not exist use [None]
string [None]
data.nlp.NLPtol NLP tolerance level real 1*10 (-5)
data.nlp.GradMethod gradient method used for determinist string [SensitivityEq SensitivityEq
NLP or MINLP solvers |FiniteDifference
|None]
data.nlp.MaxIter maximum number of function evalu-
ations
integer [positive] 1000
data.nlp.MaxCPUTime maximumCPUtime of the optimiza-
tion (60*60*0.25) = 15 minutes
real [positive] 60*60*0.25
data.nlp.approximation control approximation string [PWC|PWL] PWC
data.nlp.FreeTime set on if free time is considered string [on|off] off
data.nlp.t0Time initial size of the time intervals,
e.g. [data.odes.tf/data.nlp.RHO] or
for the each time interval separately
[dt1 dt2 dt3]
real [vector positve] [data.odes.tf/data.nlp.RHO]
data.nlp.lbTime lower bound of the time intervals real [positive] 0.01
data.nlp.ubTime upper bound of the time intervals real [positive] data.odes.tf
data.nlp.NUMc number of control variables (u) integer [positive] size(data.nlp.u0,2)
data.nlp.NUMi number of integer variables (u)
taken from the last control vari-
ables, if not equal to 0 you
need to use some MINLP solver
[ACOMI|MISQP|MITS]
integer [0 or positive] 0
data.nlp.NUMp number of time-independent param-
eters (p)
integer [0 or positive] size(data.nlp.p0,2)
Equality constraints (ECs)
data.nlp.eq.status if equality constraints are presented string [on|off] off
data.nlp.eq.NEC number of active ECs integer [0 or positive] 1
data.nlp.eq.eq equality constraints string [structure] {}
data.nlp.eq.time time when equality constraints are
active
string [structure] data.nlp.RHO
data.nlp.eq.PenaltyFun on or off the penalty function string [on|off] off
data.nlp.eq.PenaltyCoe penalty function for equality con-
straints
real 1.0
Inequality /path/ constraints (INECs)
data.nlp.ineq.status if inequality constraints are pre-
sented
string [on|off] off
data.nlp.ineq.NEC number of active inequality con-
straints
integer [0 or positive] 2
data.nlp.ineq.InNUM how many inequality constraints are
more else less
integer [0 or positive] 1
data.nlp.ineq.eq inequality constraints string [structure] {}
data.nlp.ineq.PenaltyFun on or off the penalty function string [on|off] off
data.nlp.ineq.PenaltyCoe penalty function for the inequality
constraints
real [vector] [1.0 1.0]
Options for setting of the nal output
data.options.intermediate display of the intermediate results string [on|off] off
data.options.display display of the gures string [on|off] on
data.options.title display of the titles string [on|off] on
data.options.state display of the state trajectory string [on|off] on
data.options.control display of the control trajectory string [on|off] on
data.options.ConvergCurve display of the convergence curve string [on|off] on
NLP denition
data.options.Pict_Format save gures as string [eps|wmf|both] eps
data.options.report save data in the dat le string [on|off] on
data.options.commands additional commands, e.g. g-
ure(1),..
string {}
data.options.trajectories how many state trajectories will be
displayed
string size(data.odes.res,2)
Page 55
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
data.options.proler test the performance of the toolbox string [on|off] off
data.options.multistart set 1 if the multistart is off, other-
wise you have to put here some in-
teger value
integer [positive] 1
data.options.action what will be done string [single-optimization single-optimization
|re-optimization
|hybrid-strategy
|simulation]
10.2 DEFAULT SETTINGS OF THE SUCESSIVE RE-OPTIMIZATION
DOTcvp: dotcvp_reoptimization_default.m.m
1 function [data] = dotcvp_reoptimization_default(data)
2
3 data.option.reoptimization.NRO = 4; % compute the number of refining optimizations
4 data.option.reoptimization.Increasing = 2; % how quickly will the mesh refinement be increased
5 data.option.reoptimization.NLPtol = 1e-003; % initial NLP tolerance level
6 data.option.reoptimization.IVPRelTol = 1e-005; % initial IVP relative tolerance level
7 data.option.reoptimization.IVPAbsTol = 1e-005; % initial IVP absolute tolerance level
8 data.option.reoptimization.SensAbsTol = 1e-005; % initial absolute tolerance for sensitivity variables
9
10 % Note that values of NLP and IVP tolerances will be increased with the
11 % mesh refinement algorithm until they reach the final tolerances defined
12 % by the user in the initial file.
13
14 end
10.3 DEFAULT SETTINGS OF THE HYBRID STRATEGY
DOTcvp: dotcvp_hybrid_strategy_default.m.m
1 function [data] = dotcvp_hybrid_strategy_default(data)
2
3 switch data.option.HybridStrategy.method
4 case{'stochastic'}
5 % first step [a stochastic solver]: please fill basic settings for
6 % a stochastic solver, otherwise they will be taken from the user
7 % input file
8
9 data.option.HybridStrategy.IVPRelTol = 1e-005; % IVP relative tolerance level
10 data.option.HybridStrategy.IVPAbsTol = 1e-005; % IVP absolute tolerance level
11 data.option.HybridStrategy.NLPTol = 1e-003; % NLP tolerance level
12 data.option.HybridStrategy.NLPSolver = 'DE'; % chose a solver ['FMINCON'|'IPOPT'|'SRES'|'DE'|'ACOMI'|'MISQP'|'MITS']
13 data.option.HybridStrategy.NLPsettings = 'None'; % insert the file name that contains settings for NLP solver, otherwise 'None'
14 data.option.HybridStrategy.MaxIter = 50; % maximum number of iterations
15 data.option.HybridStrategy.MaxCPUTime = 60
*
10; % maximum CPU time of the optimization (60
*
60
*
0.25) = 15 minutes
16 data.option.HybridStrategy.intermediate = 'off'; % ['on'|'off'|'silent'] display of the intermediate results
17
18 case{'deterministic'}
19 % second step [a deterministic solver]: all settings for a
20 % deterministic solver are taken from the user input file, but the
21 % user can introduce some new or special settings, which rewrites
22 % those from the input file. The name of the structure is the same
23 % as the name in the user input file, e.g. data.nlp.RHO, etc.
24
25 end
26 end
10.4 DEFAULT SETTINGS OF THE SIMULATION
DOTcvp: dotcvp_simulation_default.m.m
1 function [data] = dotcvp_simulation_default(data)
2
3 data.options.simulation.IVPsolver = 'ode15s'; % ['ode45'|'ode23'|'ode23t'|'ode23tb'|'ode113'|'ode15s'|'ode23s']
4 data.options.simulation.MaxStep = 1e-1; % ['positive scalar'] step size
5 data.options.simulation.grid = 'yes'; % ['yes'|'no'] display of the grid in the figure(s)
6 data.options.simulation.legend = 'yes'; % ['yes'|'no'] display of the legend in the figure
7 data.options.simulation.semilogx = 'no'; % ['yes'|'no'] if the logarithmic (base 10) scale is used for the X-axis
8 data.options.simulation.output = 'one'; % ['one'|'all'] how many state figures will be depicted
9
10 end
10.5 DEFAULT SETTINGS OF NLP OR MINLP SOLVERS
The following are the default values for the different NLP solvers. The corresponding m-les can be edited
by the user in order to change these defaults if needed.
10.5.1 ACOmi
DOTcvp: dotcvp_acomi_default.m
1 function [data] = dotcvp_acomi_default(data)
2
3 data.options.acomi.report = 0; % create a report file containing all solution information: [1/0] = [Yes/No]
4 data.options.acomi.acc = 10^(-3); % accuracy for both: object-function & constraints
5 data.options.acomi.maxeval = data.nlp.MaxIter; % maximum number of function evaluations
Page 56
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
6 data.options.acomi.maxtime = data.nlp.MaxCPUTime; % maximum CPU time [sec]
7 data.options.acomi.fex = -inf; % stopping criteria: if objective function = fex -> stop
8 data.options.acomi.loc_solver = 1; % use local solver at within ACOMI: [1/0] = [Yes/No]
9 data.options.acomi.loc_type = 'MISQP'; % select a local solver in ACOMI: ['MISQP']
10 data.options.acomi.loc_start = 1; % 10 seconds multistart of the local solver before (!) ACOMI: [1/0] = [Yes/No]
11 %data.options.acomi.oracle = -10^(12); % oracle parameter for penalty function [optional]; with constraints: 10^(12)
12
13 end
10.5.2 DE
DOTcvp: dotcvp_de_default.m
1 function [data] = dotcvp_de_default(data)
2
3 data.options.de.VTR = -Inf; % for minimization "Value To Reach" (stop when objective function < VTR)
4 data.options.de.F = 0.7; % DE-stepsize F from interval [0, 2] (recommended 0.7/0.8)
5 data.options.de.CR = 1.0; % crossover probability constant from interval [0, 1]
6 data.options.de.strategy = 3; % recommended 3 or 8
7 data.options.de.max_time = data.nlp.MaxCPUTime; % maximum CPU time [sec]
8 data.options.de.NLPtol = data.nlp.NLPtol; % NLP tolerance level
9 data.options.de.itermax = data.nlp.MaxIter; % maximum number of iterations (generations)
10 data.options.de.MaxFunEvals = inf; % maximum function evaluation
11 data.options.de.intermediate = data.options.intermediate; % display of the intermediate results
12
13 end
10.5.3 FMINCON
DOTcvp: dotcvp_fmincon_default.m
1 function [data] = dotcvp_fmincon_default(data)
2
3 data.options.fmincon.MaxTime = data.nlp.MaxCPUTime; % maximum CPU time [sec]
4 data.options.fmincon.GradObj = 'on'; % objective function gradients defined by the user
5 data.options.fmincon.GradConstr = 'on'; % constraints gradients defined by the user
6 data.options.fmincon.TolFun = data.nlp.NLPtol; % termination tolerance on the function value
7 data.options.fmincon.TolCon = data.nlp.NLPtol; % termination tolerance on the constraint violation
8 data.options.fmincon.TolX = data.nlp.NLPtol; % termination tolerance on the function value
9 data.options.fmincon.Hessian = 'off'; % hessian information
10 data.options.fmincon.DerivativeCheck = 'off'; % compare user-supplied derivatives to FD derivatives
11 data.options.fmincon.MaxIter = data.nlp.MaxIter; % maximum number of iterations
12 data.options.fmincon.MaxFunEvals = 10
*
data.nlp.MaxIter; % maximum number of function evaluations
13
14 end
10.5.4 IPOPT
DOTcvp: dotcvp_ipopt_default.m
1 function [data] = dotcvp_ipopt_default(data)
2
3 data.options.ipopt.jac_c_constant = 'no'; % indicates whether all equality constraints are linear ['yes','no']
4 data.options.ipopt.hessian_approximation = 'limited-memory'; % indicates what Hessian information is to be used
5 ['exact','limited-memory']
6 data.options.ipopt.mu_strategy = 'adaptive'; % update strategy for barrier parameter ['adaptive','monotone']
7 data.options.ipopt.nlp_scaling_method = 'gradient-based'; % select the technique used for scaling the NLP
8 ['none','user-scaling','gradient-based','equilibration-based']
9 data.options.ipopt.print_options_documentation = 'no'; % switch to print all algorithmic options ['yes','no']
10 %data.options.ipopt.print_level = 5; % [print_level] Output verbosity level [2 <= 5 <= 12 ]
11 data.options.ipopt.acceptable_dual_inf_tol = data.nlp.NLPtol; % "Acceptance" threshold for the dual infeasibility
12 [0 < 1e+10 < +inf]
13 data.options.ipopt.acceptable_constr_viol_tol = data.nlp.NLPtol; % "Acceptance" threshold for the constraint violation
14 [0 < 0.01 < +inf]
15 data.options.ipopt.ma27_pivtol = data.nlp.NLPtol; % pivot tolerance for the linear solvers [0 < 1e-08 < 1]
16 data.options.ipopt.acceptable_tol = data.nlp.NLPtol; % "Acceptable" convergence tolerance (relative)
17 [0 < 1e-06) < +inf]
18 data.options.ipopt.mu_min = data.nlp.NLPtol; % minimum value for barrier parameter [0 < 1e-11 < +inf]
19 data.options.ipopt.bound_push = data.nlp.NLPtol; % desired minimum absolute distance from the initial point
20 to bound [0 < 0.01 < +inf]
21 data.options.ipopt.bound_frac = data.nlp.NLPtol; % desired minimum relative distance from the initial point
22 to bound [0 < 0.01 <= 0.5]
23 data.options.ipopt.tol = data.nlp.NLPtol; % desired convergence tolerance (relative) [0 < 1e-08 < +inf]
24 data.options.ipopt.mu_init = 10^(-8); % initial barrier parameter [0 < 0.1 < +inf]
25 data.options.ipopt.max_iter = data.nlp.MaxIter; % maximal number of iterations allowed (Integer, >=0)
26 data.options.ipopt.derivative_test = 'none'; % enable derivative checker ['none','first-order','second-order']
27 data.options.ipopt.check_derivatives_for_naninf = 'no'; % indicates whether it is desired to check for Nan/Inf in derivative
28 matrices ['no','yes']
29
30 end
10.5.5 MISQP
DOTcvp: dotcvp_misqp_default.m
1 function [data] = dotcvp_misqp_default(data)
2
3 data.options.misqp.NLPtol = data.nlp.NLPtol; % NLP tolerance level
4 data.options.misqp.maxiter = data.nlp.MaxIter; % maximum number of iterations
5
6 end
Page 57
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
10.5.6 MITS
DOTcvp: dotcvp_mits_default.m
1 function [data] = dotcvp_mits_default(data)
2
3 data.options.mits.NLPtol = data.nlp.NLPtol; % NLP tolerance level
4 data.options.mits.max_iter = data.nlp.MaxIter; % maximum number of iterations
5 data.options.mits.MaxTime = data.nlp.MaxCPUTime; % maximum CPU time [sec]
6 data.options.mits.fex = -inf; % stopping criteria: if f = fex --> stop
7 data.options.mits.locstart = 0; % if true: MITS starts with a local solver run from the initial guess
8
9 end
10.5.7 SRES
DOTcvp: dotcvp_sres_default.m
1 function [data] = dotcvp_sres_default(data)
2
3 data.options.sres.mm = 'min'; % ['max'|'min'] (for maximization or minimization)
4 data.options.sres.lambda = 150; % population size (number of offspring) (100 to 200)
5 data.options.sres.G = 100000000; % maximum number of generations
6 data.options.sres.mu = round(data.options.sres.lambda/7); % parent number (mu/lambda usually 1/7), before: roundn(lambda/7,0)
7 data.options.sres.pf = 0.45; % pressure on fitness in [0 0.5] try around 0.45
8 data.options.sres.varphi = 1; % expected rate of convergence (usually 1)
9 data.options.sres.MaxTime = data.nlp.MaxCPUTime; % maximum CPU time [sec]
10 data.options.sres.itermax = data.nlp.MaxIter; % maximum number of iterations
11 data.options.sres.MaxFunEvals = inf; % maximum number of function evaluations
12 data.options.sres.NLPtol = data.nlp.NLPtol; % NLP tolerance level
13 data.options.sres.delta = 0.75; % allowed the time variation for time grid adaptation [0 < 0.75 < 1]
14
15 end
Page 58
Bibliography
[1] E. Balsa-Canto. Algoritmos Ecientes para la optimizacin dinmica de procesos distribuidos. PhD thesis,
University of Vigo, Vigo, Spain, 4 2001.
[2] E. Balsa-Canto, J. R. Banga, A. A. Alonso, and V. S. Vassiliadis. Efcient optimal control of bioprocesses
using second-order information. Industrial and Engineering Chemistry Research, 39(11):42874295, 2000.
[3] E. Balsa-Canto, J. R. Banga, A. A. Alonso, and V. S. Vassiliadis. Restricted second order information for
the solution of optimal control problems using control vector parameterization. Journal of Process Control,
12(2):243255, 2 2002.
[4] E. Balsa-Canto, V. S. Vassiliadis, and J. R. Banga. Dynamic optimization of single- and multi-stage systems
using a hybrid stochastic-deterministic method. Industrial and Engineering Chemistry Research, 44(5):1514
1523, 2005.
[5] J. R. Banga, A. A. Alonso, and R. P. Singh. Stochastic dynamic optimization of batch and semicontinuous
bioprocesses. Biotechnology Progress, 13(3):326335, 1997.
[6] J. R. Banga, E. Balsa-Canto, E. G. Moles, and A. A. Alonso. Dynamic optimization of bioprocesses: Efcient
and robust numerical strategies. Journal of Biotechnology, 117:407419, 2005.
[7] J. R. Banga, R. Irizarry-Rivera, and W. D. Seider. Stochastic optimization for optimal and model-predictive
control. Computers and Chemical Engineering, 22:603612(10), 1998.
[8] J. R. Banga and Warren D. Seider. Global optimization of chemical processes using stochastic algorithms. In
State of the art in global optimization (Princeton, NJ, 1995), volume 7, pages 563583. Kluwer Acad. Publ.,
Dordrecht, 1996.
[9] P. I. Barton, Ch. K. Lee, and M. Yunt. Optimization of hybrid systems. Computers and Chemical Engineering,
30(10-12):15761589, 9 2006.
[10] L. T. Biegler and I. E. Grossmann. Retrospective on optimization. Computers and Chemical Engineering,
28(8):11691192, 7 2004.
[11] B. Bojkov and R. Luus. Optimal control of nonlinear systems with unspecied nal times. Chemical Engi-
neering Science, 51(15):905919, 3 1996.
[12] A. E. Bryson and Y. Ch. Ho. Applied Optimal Control - Optimization, Estimation and Control. Hemisphere
Publishing corporation, Washington, 1975.
[13] E. F. Carrasco and J. R. Banga. Dynamic optimization of batch reactors using adaptive stochastic algorithms.
Industrial and Engineering Chemistry Research, 36:22522261, 1997.
[14] C.-T. Chen and C. Hwang. Optimal control computation for differential-algebraic process systems with
general constraints. Chemical Engineering Communications, 97(1):926, 1 1990.
[15] T. Coleman, M. A. Branch, and A. Grace. Optimization toolbox for use with matlab users guide version 2,
1998.
[16] S. Crescitelli and S. Nicoletti. Near optimal control of batch reactors. Chemical Engineering Science, 28:463
471, 1973.
[17] S. A. Dadebo and K. B. McAuley. Dynamic optimization of constrained chemical engineering problems
using dynamic programming. Computers and Chemical Engineering, 19(5):513525, 1995. 10: Diversen.
[18] O. Exler, L. T. Antelo, J. A. Egea, A. A. Alonso, and J. R. Banga. A tabu search-based algorithm for mixed-
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
integer nonlinear problems and its application to integrated process and control system design. Computers
and Chemical Engineering, 32(8):18771891, 9 2008.
[19] O. Exler and K. Schittkowski. A trust region sqp algorithm for mixed-integer nonlinear programming. Opti-
mization Letters, 1(3):269280, 6 2007.
[20] W. F. Feehery and P. I. Barton. Dynamic optimization with state variable path constraints. Computers and
Chemical Engineering, 22:12411256, 1998.
[21] M. Fikar and M. A. Lati. Users guide for FORTRAN dynamic optimisation code DYNO. Technical Report
mf0201, LSGC CNRS, Nancy, France; SUT Bratislava, Slovak Republic, 2001.
[22] R. Gabasov and F. M. Kirillova. Optimal on-line control with delays. Memoirs on Differential Equations and
Mathematical Physics, 31:3552, 2004.
[23] W. W. Hager. Rates of convergence for discrete approximations to unconstrained control problems. SIAM
Journal on Numerical Analysis, 13(4):449472, 1976.
[24] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, D. E. Shumaker, and C. S. Woodward.
Sundials: Suite of nonlinear and differential/algebraic equation solvers,. ACM Transactions on Mathematical
Software, 31(3):363396, 2005.
[25] D. Jacobson and M. Lele. A transformation technique for optimal control problems with a state variable
inequality constraint. IEEE Transactions on Automatic Control, 5:457464, 1969.
[26] R. Jaczson. Optimal use of mixed catalysts for two successive chemical reactions. Journal of Optimization
Theory and Applications, 2(1):2739, 1968.
[27] S. Kameswaran and L. T. Biegler. Simultaneous dynamic optimization strategies: Recent advances and
challenges. Computers and Chemical Engineering, 30(10-12):15601575, 9 2006.
[28] D. Y. C. Ko and W. F. Stevens. Study of singular solutions in dynamic optimization. AIChE Journal, 17:160
166, 1971.
[29] J. Lee and W. F. Ramirez. Optimal fed-batch control of induced foreign protein production by recombinant
bacteria. AIChE Journal, 40(5):899907, 1994.
[30] R. Luus. Application of dynamic programming to high-dimensional non-linear optimal control problems.
International Journal of Control, 52(1):239250, 1990.
[31] R. Luus. On the application of iterative dynamic programming to singular optimal control problems. IEEE
Transactions on Automatic Control, 37(11):18021806, 1992.
[32] R. Luus. Piecewise linear continuous optimal control by iterative dynamic programming. Industrial and
Engineering Chemistry Research, 32(5):859865, 1993.
[33] R. Luus. Optimal control of batch reactors by iterative dynamic programming. Journal of Process Control,
4(4):218226, 4 1994.
[34] R. Luus. Iterative Dynamic Programming. CRC Press, Inc., Boca Raton, FL, USA, 2000.
[35] W. Mekarapiruk and R. Luus. Optimal control of inequality state constrained systems. Industrial and Engi-
neering Chemistry Research, 36(5):16861694, 1997.
[36] N. Nishida, Y. A. Liu, L. Lapidus, and S. Hiratsuka. An effective computational algorithm for suboptimal
singular and/or bang-bang control i. theoretical developments and applications to linear lumped systems.
AIChE Journal, 22(3):505513, 6 1976.
[37] O. Rosen and R. Luus. Evaluation of gradients for piecewise constant optimal control. Computers and
Chemical Engineering, 15(4):273281, 1991.
[38] T. P. Runarsson and X. Yao. Stochastic ranking for constrained evolutionary optimization. IEEE Transactions
Evolutionary Computation, 4(3):284294, 2000.
[39] P. E. Rutquist and M. M. Edvall. Propt - matlab optimal control software. Technical report, Tomlab Opti-
mization Inc., 1260 SE Bishop Blvd Ste E, Pullman, WA, USA, 5 2008.
[40] M. Schlter, J. A. Egea, and J. R. Banga. Extended ant colony optimization for non-convex mixed integer
nonlinear programming. Computers & Operations Research, 2008.
[41] R. Storn and K. Price. Differential evolution - a simple and efcient heuristic for global optimization over
continuous spaces. Journal of Global Optimization, 11(4):341359, 1997.
[42] P. Tanartkit and L. T. Biegler. Stable decomposition for dynamic optimization. Industrial and Engineering
Chemistry Research, 34:12531266, 1995.
[43] A. Tholudur and W. F. Ramirez. Obtaining smoother singular arc policies using a modied iterative dynamic
programming algorithm. International Journal of Control, 68(5):11151128, 11 1997.
[44] V. S. Vassiliadis. Computational Solution of Dynamic Optimization Problems with General Differential-
Algebraic Constraints. PhD thesis, University of London, London, UK, 1993.
[45] V. S. Vassiliadis, E. Balsa-Canto, and J. R. Banga. Second-order sensitivities of general dynamic systems
Page 60
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
with application to optimal control problems. Chemical Engineering Science, 54:38513860, 1999.
[46] V. S. Vassiliadis, R. W. H. Sargent, and C. C. Pantelides. Solution of a class of multistage dynamic opti-
mization problems. 1. problems without path constraints, 2. problems with path constraints. Industrial and
Engineering Chemistry Research, 33(9):21112122, 21232133, 1994.
[47] M.

Ciniar, M. Fikar, and M. A. Lati. Matlab dynamic optimisation code dynopt. users guide. Technical re-
port, Department of Information Engineering and Process Control, FCFT STU, Bratislava, Slovak Republic,
2006.
[48] A. Wchter and L. T. Biegler. On the implementation of a primal-dual interior point lter line search algorithm
for large-scale nonlinear programming. Mathematical Programming, 106(1):2557, 2006.
Page 61
CHAPTER 11
Appendix
11.1 FINAL DATA STRUCTURE
1 data -> data.name
2 data -> data.compiler
3 data -> data.p
4 data -> version
5 data -> data.gradJ0
6 data -> data.gradJi
7 data -> data.J0
8
9 data -> data.odes
10 data -> data.odes -> data.odes.Def_FORTRAN
11 data -> data.odes -> data.odes.parameters
12 data -> data.odes -> data.odes.Def_MATLAB
13 data -> data.odes -> data.odes.res
14 data -> data.odes -> data.odes.black_box
15 data -> data.odes -> data.odes.ic
16 data -> data.odes -> data.odes.NUMs
17 data -> data.odes -> data.odes.t0
18 data -> data.odes -> data.odes.tf
19 data -> data.odes -> data.odes.NonlinearSolver
20 data -> data.odes -> data.odes.LinearSolver
21 data -> data.odes -> data.odes.LMM
22 data -> data.odes -> data.odes.MaxNumStep
23 data -> data.odes -> data.odes.RelTol
24 data -> data.odes -> data.odes.AbsTol
25
26 data -> data.sens
27 data -> data.sens -> data.sens.SensAbsTol
28 data -> data.sens -> data.sens.SensMethod
29 data -> data.sens -> data.sens.SensErrorControl
30
31 data -> data.nlp
32 data -> data.nlp -> data.nlp.RHO
33 data -> data.nlp -> data.nlp.problem
34 data -> data.nlp -> data.nlp.J0
35 data -> data.nlp -> data.nlp.u0
36 data -> data.nlp -> data.nlp.lb
37 data -> data.nlp -> data.nlp.ub
38 data -> data.nlp -> data.nlp.p0
39 data -> data.nlp -> data.nlp.lbp
40 data -> data.nlp -> data.nlp.ubp
41 data -> data.nlp -> data.nlp.solver
42 data -> data.nlp -> data.nlp.SolverSettings
43 data -> data.nlp -> data.nlp.NLPtol
44 data -> data.nlp -> data.nlp.GradMethod
45 data -> data.nlp -> data.nlp.MaxIter
46 data -> data.nlp -> data.nlp.MaxCPUTime
47 data -> data.nlp -> data.nlp.approximation
48 data -> data.nlp -> data.nlp.FreeTime
49 data -> data.nlp -> data.nlp.t0Time
50 data -> data.nlp -> data.nlp.lbTime
51 data -> data.nlp -> data.nlp.ubTime
52 data -> data.nlp -> data.nlp.NUMc
53 data -> data.nlp -> data.nlp.NUMi
54 data -> data.nlp -> data.nlp.NUMp
55 data -> data.nlp -> data.nlp.eq
56 data -> data.nlp -> data.nlp.eq.status
57 data -> data.nlp -> data.nlp.eq.NEC
58 data -> data.nlp -> data.nlp.eq.eq
59 data -> data.nlp -> data.nlp.eq.time
60 data -> data.nlp -> data.nlp.eq.PenaltyFun
61 data -> data.nlp -> data.nlp.eq.PenaltyCoe
62 data -> data.nlp -> data.nlp.ineq
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
63 data -> data.nlp -> data.nlp.ineq.status
64 data -> data.nlp -> data.nlp.ineq.NEC
65 data -> data.nlp -> data.nlp.ineq.InNUM
66 data -> data.nlp -> data.nlp.ineq.eq
67 data -> data.nlp -> data.nlp.ineq.Tol
68 data -> data.nlp -> data.nlp.ineq.PenaltyFun
69 data -> data.nlp -> data.nlp.ineq.PenaltyCoe
70 data -> data.nlp -> data.nlp.yPointConstraint
71 data -> data.nlp -> data.nlp.uPointConstraint
72
73 data -> data.options
74 data -> data.options -> data.options.intermediate
75 data -> data.options -> data.options.display
76 data -> data.options -> data.options.title
77 data -> data.options -> data.options.state
78 data -> data.options -> data.options.control
79 data -> data.options -> data.options.ConvergCurve
80 data -> data.options -> data.options.Pict_Format
81 data -> data.options -> data.options.report
82 data -> data.options -> data.options.commands
83 data -> data.options -> data.options.trajectories
84 data -> data.options -> data.options.profiler
85 data -> data.options -> data.options.multistart
86 data -> data.options -> data.options.action
87 data -> data.options -> data.options.IVPsimulation
88 data -> data.options -> data.options.cd
89 data -> data.options -> data.options.path
90 data -> data.options -> data.options.ic
91 data -> data.options -> data.options.ic.switchdata
92 data -> data.options -> data.options.ic.rehash
93 data -> data.options -> data.options.ic.ic
94 data -> data.options -> data.options.set
95 data -> data.options -> data.options.set.Constraint
96 data -> data.options -> data.options.fmincon
97 data -> data.options -> data.options.fmincon.MaxTime
98 data -> data.options -> data.options.fmincon.GradObj
99 data -> data.options -> data.options.fmincon.GradConstr
100 data -> data.options -> data.options.fmincon.TolFun
101 data -> data.options -> data.options.fmincon.TolCon
102 data -> data.options -> data.options.fmincon.TolX
103 data -> data.options -> data.options.fmincon.Hessian
104 data -> data.options -> data.options.fmincon.DerivativeCheck
105 data -> data.options -> data.options.fmincon.MaxFunEvals
106
107 data -> data.output
108 data -> data.output -> data.output.iter
109 data -> data.output -> data.output.J0
110 data -> data.output -> data.output.time
111 data -> data.output -> data.output.state
112 data -> data.output -> data.output.control
113 data -> data.output -> data.output.StateVariables
114 data -> data.output -> data.output.CPUtimeStart
115 data -> data.output -> data.output.CPUtime
116 data -> data.output -> data.output.fmincon
117 data -> data.output -> data.output.CPUtimeFINAL
118 data -> data.output -> data.output.RHO
119 data -> data.output -> data.output.ObjFinal
120 data -> data.output -> data.output.DecisionVariables
11.2 SENSITIVITIES AND GRADIENTS DERIVATION
The simple batch reactor given in subsection 7.1 is considered. Firstly, the scenario with xed time intervals
is solved. The problem of the optimization is to nd the optimal control trajectory which minimizes
min
u
i
J
0
= x
2
(t
F
) (11.1)
subject to
x
1
= u
i
x
1
(11.2)
x
2
= u
i
x
1
cu

i
x
2
(11.3)
For simplicity and demonstrative purposes only 3 piecewise constant control variables with xed time were
chosen. The gradients with respect to the control are dened as follows
J
0
u
i
= s
2i
(t
F
), i = 1, 3 (11.4)
To obtain the necessary gradients (11.4) it is needed to integrate sensitivity equations over the whole time
(t
F
). The sensitivity coefcients for i = 1, 3 are dened as
s
1i
=
x
1
u
i
(11.5)
s
2i
=
x
2
u
i
(11.6)
Page 63
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
together with the sensitivity equations
_

_
s
11
=
(u
1
x
1
)
x
1
x
1
u
1
+
(u
1
x
1
)
x
2
x
2
u
1
+
(u
1
x
1
)
u
1
u
1
u
1
= u
1
s
11
x
1
, t [t
0
, t
1
]
s
11
=
(u
2
x
1
)
x
1
x
1
u
1
+
(u
2
x
1
)
x
2
x
2
u
1
+
(u
2
x
1
)
u
2
u
2
u
1
= u
2
s
11
, t [t
1
, t
2
]
s
11
=
(u
3
x
1
)
x
1
x
1
u
1
+
(u
3
x
1
)
x
2
x
2
u
1
+
(u
3
x
1
)
u
3
u
3
u
1
= u
3
s
11
, t [t
2
, t
F
]
s
12
= u
1
s
12
, t [t
0
, t
1
]
s
12
= u
2
s
12
x
1
, t [t
1
, t
2
]
s
12
= u
3
s
12
, t [t
2
, t
F
]
s
13
= u
1
s
13
, t [t
0
, t
1
]
s
13
= u
2
s
13
, t [t
1
, t
2
]
s
13
= u
3
s
13
x
1
, t [t
2
, t
F
]
(11.7)
_

_
s
21
=
_
(u
1
x
1
cu

1
x
2
)
x
1
_
x
1
u
1

_
(u
1
x
1
cu

1
x
2
)
x
2
_
x
2
u
1
+
_
(u
1
x
1
cu

1
x
2
)
u
1
_
u
1
u
1
, t [t
0
, t
1
]
= u
1
s
11
cu

1
s
21
+ x
1
cu
1
1
x
2
s
21
=
_
(u
2
x
1
cu

2
x
2
)
x
1
_
x
1
u
1

_
(u
2
x
1
cu

2
x
2
)
x
2
_
x
2
u
1
+
_
(u
2
x
1
cu

2
x
2
)
u
2
_
u
2
u
1
, t [t
1
, t
2
]
= u
2
s
11
cu

2
s
21
s
21
=
_
(u
3
x
1
cu

3
x
2
)
x
1
_
x
1
u
1

_
(u
3
x
1
cu

3
x
2
)
x
2
_
x
2
u
1
+
_
(u
3
x
1
cu

3
x
2
)
u
3
_
u
3
u
1
, t [t
2
, t
F
]
= u
3
s
11
cu

3
s
21
s
22
= u
1
s
12
cu

1
s
22
, t [t
0
, t
1
]
s
22
= u
2
s
12
cu

2
s
22
+ x
1
cu
1
2
x
2
, t [t
1
, t
2
]
s
22
= u
3
s
12
cu

3
s
22
, t [t
2
, t
F
]
s
23
= u
1
s
13
cu

1
s
23
, t [t
0
, t
1
]
s
23
= u
2
s
13
cu

2
s
23
, t [t
1
, t
2
]
s
23
= u
3
s
13
cu

3
s
23
+ x
1
cu
1
3
x
2
, t [t
2
, t
F
]
(11.8)
or in a more compact form
_
_
_
s
11
= us
11
x
1
R
1
, t [t
0
, t
F
]
s
12
= us
12
x
1
R
2
, t [t
0
, t
F
]
s
13
= us
13
x
1
R
3
, t [t
0
, t
F
]
(11.9)
_
_
_
s
21
= us
11
cu

s
21
+ (x
1
cu
1
x
2
)R
1
, t [t
0
, t
F
]
s
22
= us
12
cu

s
22
+ (x
1
cu
1
x
2
)R
2
, t [t
0
, t
F
]
s
23
= us
13
cu

s
23
+ (x
1
cu
1
x
2
)R
3
, t [t
0
, t
F
]
(11.10)
where R
i
is equal to 1 or 0 depending on the time interval t
i
and relevant control value. Note that not all equations
need to be integrated in each time interval, because the optimized variable in the interval t
i+1
does not affect on
the interval t
i
.
Secondly, is the scenario with the free time intervals considered. In this case it is required to integrate new
sensitivities with respect to time
_
s
14
= us
14
, t [t
0
, t
F
]
s
15
= us
15
, t [t
0
, t
F
]
(11.11)
_
s
24
= us
14
cu

s
24
, t [t
0
, t
F
]
s
25
= us
15
cu

s
25
, t [t
0
, t
F
]
(11.12)
At the end of the time interval it is needed to compute discontinuity of sensitivity equations (11.11), (11.12)
following (3.15)
s
14
(t
+
1
) = s
14
(t

1
) + [f
1
(t, x, u
1
, p) f
1
(t, x, u
2
, p)]
t
1
(11.13)
s
15
(t
+
2
) = s
15
(t

2
) + [f
1
(t, x, u
2
, p) f
1
(t, x, u
3
, p)]
t
2
(11.14)
s
24
(t
+
1
) = s
24
(t

1
) + [f
2
(t, x, u
1
, p) f
2
(t, x, u
2
, p)]
t
1
(11.15)
s
25
(t
+
2
) = s
25
(t

2
) + [f
2
(t, x, u
2
, p) f
2
(t, x, u
3
, p)]
t
2
(11.16)
Page 64
DOTcvp: Dynamic Optimization Toolbox with CVP approach for handling continuous and mixed-integer DO problems
Then the resulting gradients are derived from the equation (3.18)
J
0
t
1
= s
24
(t
F
) (11.17)
J
0
t
2
= s
25
(t
F
) (11.18)
The gradients with respect to nal time are the following (3.18) in this case equal to f
2
. Note that all time
gradients should be modied as is shown in the section 3.3.
Page 65

You might also like