All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.

Related Documents

Share

Description

matlab codding

Transcript

DYNOPT - DYNAMIC OPTIMISATION CODE FORMATLAB
M. ˇ Ciˇzniar
∗
, D. Salhi
†
, M. Fikar
∗
, M.A. Latiﬁ
†∗
Department of Information Engineering and Process Control,FCFT-STU
†
Laboratoire des Sciences du G´enie Chimique,CNRS-ENSIC
AbstractThis paper describes a MATLAB package for dynamic optimisation of processes.The package dynopt searches for proﬁles of decision variables which optimisea given performance index under speciﬁed constraints. The package uses themethod of orthogonal collocations on ﬁnite elements and several case studies aresuccessfully tested. The MATLAB source code is freely available at the packageweb page
http://www.kirp.chtf.stuba.sk/
∼
fikar/research/dynopt/dynopt.htm
.
1 Introduction
The objective of dynamic optimisation is to determine, in open loop control, a set of deci-sion variable time proﬁles (pressure, temperature, ﬂow rate, current, heat duty, ...) for adynamic system that optimise a given performance index (or cost functional or optimisation cri-terion)(cost, time, energy, selectivity, ...) subject to speciﬁed constraints (safety, environmentaland operating constraints). Optimal control refers to the determination of the best time-varyingproﬁles in closed loop control.The numerical methods used to ﬁnd a deterministic solution of dynamic optimisationproblems can be grouped into two categories: indirect and direct methods. In this work onlydirect methods are considered. In this category, there are two strategies: sequential methodand simultaneous method. The sequential strategy, often called control vector parameterisation(CVP), consists in an approximation of the control trajectory by a function of only a fewparameters and leaving the state equations in the form of the original diﬀerential algebraicequation (DAE) system [7]. In the simultaneous strategy, both the control and state variables
are discretised using polynomials (e.g., Lagrange polynomials) of which the coeﬃcients becomethe decision variables in a much larger Nonlinear Programming problem (NLP) [2].
In this paper, the method of orthogonal collocation on ﬁnite elements is developed basedon [2; 9]. It is implemented purely in MATLAB as a collection of M ﬁles without any MEX/DLL
interface. For the solution of NLP, standard Optimisation Toolbox is used. Its aim is to providea simple interface to dynamic optimisation. Is is suitable for typical problems in chemical andbiochemical industries. When compared to lower (compilator based) programming languages, atypical solution time is longer. However, the total time of learning and simplicity makes rapiddevelopment and integration with other packages possible. The source code of the package isavailable free at the web pages of authors.The outline of the paper is as follows. In the next section we sketch a general NLPformulation for optimal control problems using orthogonal collocation on ﬁnite elements method,which is implemented in the dynamic optimisation package (
dynopt
). Section 3 shows how todeﬁne a given control problem with
dynopt
. In section 4, we present some known examples from
literature dealing with chemical reactors which are then solved and discussed in section 5.
2 NLP Formulation Problem
Consider the following general dynamic optimisation problem for
t
∈
[0
,t
f
] which comprises aMeyer-type cost functional, a process dynamic model described by a set of ordinary diﬀerentialequations (ODE), and equality and inequality constraints.
ζ
i
−
1
ζ
i
ζ
i
+1
ζ
i
+2
∆
ζ
ix
i
−
1
,
0
x
i
−
1
,
1
x
i
−
1
,
2
x
i,
0
x
i,
1
x
i,
2
x
i
+1
,
0
x
i
+1
,
1
x
i
+1
,
2
x
i
+2
,
0
u
i
−
1
,
1
u
i
−
1
,
2
u
i,
1
u
i,
2
u
i
+1
,
1
u
i
+1
,
2
Figure 1: Finite-element collocation discretisation for state proﬁles, control proﬁles and elementlengthsmin
u
(
t
)
J
[
x
(
t
f
)] (1)such that
˙
x
(
t
) =
f
[
t,
x
(
t
)
,
u
(
t
)]
,
x
(0) =
x
0
h
[
t,
x
(
t
)
,
u
(
t
)] =
0
g
[
t,
x
(
t
)
u
(
t
)]
≤
0
x
(
t
)
L
≤
x
(
t
)
≤
x
(
t
)
U
u
(
t
)
L
≤
u
(
t
)
≤
u
(
t
)
U
where
J
[
x
(
t
f
)] – objective function evaluated at ﬁnal conditions,
f
– vector of diﬀerential equations,
h
– vector of equality constraints,
g
– vector of inequality constraints,
x
(
t
) – state vector,
u
(
t
) – control vector,
x
0
– process initial conditions,
L
,
U
– lower and upper proﬁle bounds.In order to convert problem (1) into NLP problem, the orthogonal collocation on ﬁniteelements is used (Fig. 1). The optimal control problem (1) is then solved by complete param-
eterisation of both, the control and the state vectors [3; 9; 10]. That means that the control
and state proﬁles on one time interval are approximated by linear combination of some basisfunctions (Lagrange polynomials (2), (3)).
x
K
+1
(
t
) =
K
j
=0
x
ij
φ
j
(
t
);
φ
j
(
t
) =
K
k
=0
,j
(
t
−
t
ik
)(
t
ij
−
t
ik
) (2)in element
i, i
= 1
,...,
NE
u
K
(
t
) =
K
j
=1
u
ij
θ
j
(
t
);
θ
j
(
t
) =
K
k
=1
,j
(
t
−
t
ik
)(
t
ij
−
t
ik
) (3)in element
i, i
= 1
,...,
NE
Here
k
= 0
,j
means that
k
starts from 0 and
k
=
j
, NE is the number of elements. Also
x
K
+1
(
t
)is a (
K
+ 1)th order (deg
< K
+ 1) piecewise polynomial and
u
K
(
t
) is
K
th order (deg
< K
)piecewise polynomial. The diﬀerence in orders is due to the existence of the initial conditionsfor
x
(
t
), for each element
i
. The times
t
ij
are given as roots of the Legendre polynomials oninterval [0
,
1].The problem (1) now becomes:min
x
ij
,
u
ij
,
∆
ζ
i
J
(
x
f
) (4)such that
x
10
−
x
0
=
0
,t
f
−
NE
i
=1
∆
ζ
i
= 0∆
ζ
r
ij
=
˙
x
k
+1
(
t
ij
)
−
∆
ζ
i
f
(
t
ij
,
x
ij
,
u
ij
) =
0
,i
= 1
,...,
NE
j
= 1
,...,K
x
i
0
−
x
i
−
1
K
+1
(
ζ
i
) =
0
, i
= 2
,...,
NE
x
f
−
x
NE K
+1
(
ζ
NE
+1
) =
0
u
Li
≤
u
iK
(
ζ
i
)
≤
u
U i
, i
= 1
,...,
NE
u
Li
≤
u
iK
(
ζ
i
+1
)
≤
u
U i
, i
= 1
,...,
NE∆
ζ
Li
≤
∆
ζ
i
≤
∆
ζ
U i
i
= 1
,...,
NE
h
(
t
ij
,
x
ij
,
u
ij
) =
0
,
g
(
t
ij
,
x
ij
,
u
ij
)
≤
0
x
Lij
≤
x
K
+1
(
t
ij
)
≤
x
U ij
, i
= 1
,...,
NE
, j
= 0
,...,K
u
Lij
≤
u
K
(
t
ij
)
≤
u
U ij
, i
= 1
,...,
NE
, j
= 1
,...,K
where
i
– refers to the element,
j
– refers to the collocation point,∆
ζ
i
– ﬁnite-element lengths,
x
0
=
x
(0) – the value of the state at time
t
= 0,
x
f
=
x
(
t
f
) – the value of the state at the ﬁnal time
t
=
t
f
,
h
– the equality constraint evaluated in time
t
ij
,
g
– the inequality constraint evaluated in time
t
ij
,
x
ij
,
u
ij
– the collocation coeﬃcients for the state and control proﬁles,Problem (4) can be now solved by any standard nonlinear programming solver.To solve this problem within MATLAB, we use the Optimization Toolbox which includesseveral programs for treating optimisation problems. In this case function
fmincon
was choosen.This can minimise/maximise a given objective function subject to nonlinear equality and in-equality constraints. In order to use this function it was neccessary to create and program seriesof additional functions [13]. The resulting code is called
dynopt
. The use of this code is presentedin next section.
3 Tutorial
This section presents a tutorial of to
dynopt
.
3.1 Problem Deﬁnition
Consider the following problem [5; 6; 8]
min
u
(
t
)
J
=
t
f
0
(
x
21
+
x
22
+ 0
.
005
u
2
)d
t
(5)such that˙
x
1
=
x
2
x
1
(0) = 0˙
x
2
=
−
x
2
+
u x
2
(0) =
−
10
≥
x
2
−
8(
t
−
0
.
5)
2
+ 0
.
5
∀
tt
f
= 1where
x
1
(
t
)
, x
2
(
t
) – states,
u
(
t
) – control vector.As the objective function is not in the Meyer form needed by
dynopt
, we deﬁne an additionaldiﬀerential equation˙
x
3
=
x
21
+
x
22
+ 0
.
005
u
2
, x
3
(0) = 0 (6)and rewrite the cost asmin
u
(
t
)
J
=
x
3
(
t
f
) (7)
3.2 User Functions Deﬁnitions
Step1: Process
function sys = process(t,x,flag,u)switch flag,case 0sys = [x(2);-x(2)+u;x(1)^2+x(2)^2+0.005*u^2];case 1sys = [0 0 2*x(1);1 -1 2*x(2);0 0 0];case 2sys = [0 1 0.01*u];case 3sys = [0 0 0];case 4sys = [0;-1;0];otherwiseerror([’unhandled flag = ’,num2str(flag)end
dynopt
optimises a given performance index evaluated at the ﬁnal conditions subject to theconstraints which can be evaluated at the initial conditions or over the full time interval or at

Search

Similar documents

Tags

We Need Your Support

Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks