8 Optimal Control with Differential-Algebraic Equations
So far we have regarded optimal control problems based on model dynamics in their simplest explicit-ODE form:
This form of model for dynamic systems tend to arise naturally from the first-principle modelling approaches standardly taught and used by engineers. As a result, most continuous dynamic systems are described via explicit ODEs. It is a common but less widespread knowledge that for a large number of applications, building a dynamic model in the form of explicit ODEs can be significantly more involved and yield dramatically more complex model equations than via alternative model forms. Before laying down some theory, let us start with a simple illustrative example that we will use throughout this chapter.
Example 8.1
Consider a mass
Figure 8.1: Illustration of the example considered in this chapter. The system is described via the cartesian position of the mass
The rod maintains the mass at a distance
where DAE).
Following up on this example, we will now provide a more formal view on the concept of Differential-Algebraic Equations.
8.1 What are DAEs ?
Let us consider a differential equation in a very generic form:
Such a differential equation is labelled implicit as the state derivative
The Implicit Function Theorem guarantees that
Formally, Differential-Algebraic Equations are equations in the form
Definition DAE
It is admittedly not straightforward to relate Definition above to the earlier example
Example 8.2
Let us consider the following implicit differential equation, having the form
then the Jacobian of
and is rank-deficient, entailing that
Alternatively, one can also simply observe that
In order to gain some further intuition in this example, consider solving the first equation in
Upon inserting the expression for
We observe here that the second equation is in fact purely algebraic, such that the model can be written as a mixture of an explicit differential equation and of an algebraic equation. This form of DAE is actually the most commonly used in practice. It is referred to as a semi-explicit DAE.
The above example can mislead one to believe that DAEs are fairly simple objects. To dispel that impression, let us provide a simple example of a DAE that possess fairly exotic properties.
Example 8.3
Let us consider the following differential equation
having the Jacobian
which is rank-deficient for
our equation is a DAE and its solution obeys:
otherwise it is an ODE. The fact that some differential equation can switch between being DAEs and ODEs betrays the fact that DAEs are not necessarily simple to handle and analyse. However, in the context of numerical optimal control, simple DAEs are typically favoured.
About DAE
As observed before, DAEs often simply arise from the fact that some states in the state vector
A DAE in the form
is always rank deficient. The differential equation
As mentioned in example 8.2, a common form of DAE often used in practice is the so-called semi-explicit form. It consists in explicitly splitting the DAE between an explicit differential equation and an implicit algebraic one. It reads as:
The semi-explicit form is the most commonly used form of DAEs in optimal control. We turn next to a very important notion in the world of Differential-Algebraic Equations, both in theory and in practice.
8.2 Differential Index of DAEs
Before introducing the notion of differential index for DAE, it will be useful to take a brief and early tour into the problem of solving DAEs. Consider the semi-explicit DAE:
and suppose that one can construct (possibly via a numerical algorithm such as a Newton iteration) a function
That is, function
One can observe that
It is then natural to ask when such an elimination is possible. The Implicit Function Theorem (IFT) provides here a straightforward answer, namely the function
is full rank along the trajectories
converges locally to the solution
These notions easily extend to fully-implicit DAEs in the distinct form
Then one can rewrite
Similarly to
is full rank, then functions
Let us consider two examples to illustrate these notions.
Example 8.4
Consider again the fully-implicit DAE of Example 8.2, i.e.:
We observe that
is full rank whenever
solve
This simple example needs to be pitted against a more problematic one.
Example 8.5
Consider the fully-implicit DAE:
We observe that:
is always rank-deficient, such that the differential state
differential index
The topic of this section is the notion of differential index of DAEs. As we will see next, the loose idea of "easy" DAEs presented above is directly related to it. Let us introduce now the notion of differential index for DAEs.
Definition: differential index of a DAE
The differential index of a DAE is the number of times it must be time-differentiated before an explicit ODE is obtained.
For the specific case of a semi-explicit DAE, the above definition also reads as follows.
Definition: differential index of the semi-explicit DAE
The differential index of the semi-explicit DAE
In order to clarify these definitions, let us make a simple example.
Example 8.5
Let us calculate the differential index of the DAE proposed in Example 8.2, i.e.:
We then consider the time derivative of
For the sake of clarity, we label
The Jacobian
is then full rank, such that
Let us contrast this example with a DAE having a higher differential index.
Example 8.6
Let us calculate the differential index of our illustrative example
one can easily verify that the DAE
We observe that for a given
One can then use
As
index DAE
Now we ought to relate the notion of "easy" DAEs to the notion of differential index. More specifically, we shall see next that index-1 DAEs are "easy" DAEs in the sense detailed previously. This observation can be formally described in the following Lemma.
Lemma
For any fully-implicit index-
there exists implicit functions
Proof: We observe that if
yields a pure ODE. For the sake of clarity, we label
By assumption,
holds on the DAE trajectories. The IFT then guarantees the existence of the implicit functions
A similar result can clearly be established for any index-
The crucial practical consequence of these observations is that index-
A non-trivial but important point needs to be stressed here. DAEs of index higher than
Example 8.7
In this example, we are interested to observe the result of "naively" deploying a classical implicit integration scheme on a high-index DAE. We consider again the fully-implicit DAE of Example 8.5, i.e.
The reader can easily verify that
We are interested now in naively deploying an implicit Euler scheme of step length
where
for some
For DAE
such that the integration error is of order
This simple example reveals that, even though a classic implicit integration scheme deployed on high-index DAEs
Because index-
8.3 Index reduction
As detailed in the previous Section, index-
Example 8.8
We consider again the semi-explicit DAE
which is in a semi-explicit form. Similarly to the index evaluation presented in Example 8.6, i.e. we consider the time-derivatives of the algebraic equation (8.16c)
One can then easily verify that the new DAE:
is of index
which shows unambiguously that the state derivatives
Index-reduction procedures can be fairly intricate to deploy on very complex models. For the sake of completeness, let us report here a recipe for performing the index-reduction on any semi-explicit DAE:
- Check if the DAE system is index
(i.e. full rank). If yes, stop. - Identify a subset of algebraic equations that can be solved for a subset of algebraic variables.
- Perform a time-differentiation on the remaining algebraic equations that contain (some of) the differential variables
. Terms will appear in these differentiated equations. - Substitute the
with their corresponding symbolic expressions . This generates new algebraic equations. - With this new DAE system, go to step 1.
Our discussion on index reduction would not complete if we omit the question of consistency conditions. To understand this issue, consider the indexreduced DAE developed in Example 8.8, which takes the form:
One needs to observe here that while a solution to the original DAE
is obviously also a solution for the index-reduced DAE (8.19), the converse is not necessarily true, i.e. a solution of the index-reduced DAE
holds. This trajectory clearly satisfies
ensures that the trajectories of the index-reduced DAE are solution of the original one. More generally, enforcing
at any time
In the context of optimal control based on an index-reduced DAE, consistency conditions are crucial when the trajectories of the differential states of system do not have (fully) prescribed initial or terminal values. In such a case, the consistency conditions must be adequately enforced within the optimal control problem. E.g. an optimal control problem involving our index-reduced DAE
for any
It ought to be underlined here that imposing some constraints on the initial and/or terminal state trajectories in conjunction with imposing the consistency conditions must be done with great care in order to avoid generating a redundant set of constraints in the OCP. As a trivial example of this difficulty, imposing e.g. the initial states in
The consistency conditions can in principle be enforced at any time
ensure mathematically that
holds at any time
Conversely, if the OCP implements a Moving Horizon Estimation (MHE) scheme, then the differential state obtained at the very end of the time span covered by the OCP delivers a state estimation to e.g. an NMPC scheme. In such a case, the accuracy is most important at the very end of the time interval, such that the consistency conditions are best imposed at
8.4 Direct Methods with Differential-Algebraic Equations
We will now turn to discussing the deployment of direct optimal control methods on OCPs involving DAEs. For the reasons detailed previously, we will focus on OCPs involving index-
8.4.1 Numerical Solution of Differential-Algebraic Equations
In this Section, we will briefly discuss the numerical solution of DAEs. As hinted above, index-
Though low-order methods generally offer a poor ratio between accuracy and computational complexity and higher-order integrators should be preferred, let use nonetheless start here with a simple
the
Algorithm 8.13 (Implicit Euler integrator). Input: initial value
for
A similar approach can be deployed using any implicit integration method, such as an IRK4 integrator.
A fairly efficient and useful type of implicit integrator already introduced in Section 7.3 is the orthogonal collocation approach. Let us consider the building of the collocation equations for DAEs in a generic implicit form
on a time interval
- the polynomial interpolation meets the initial value, i.e.:
- the DAE is satisfied in the collocation times
for , i.e.:
We can gather these requirements in the compact implicit equation:
The same observations as for the semi-explicit case hold for the general case.
One ought to observe that the discretized algebraic states
For the sake of completeness, let us provide the algorithm for a collocation-based integrator for index-
Algorithm 8.14 (Collocation-based integrator). Input: initial value
for
It is interesting to observe here that while the algorithm ought to receive an initial guess for the discrete algebraic states
Sensitivities of the integrators
The computation of the sensitivities of an implicit integrator such as
The sensitivities are then provided at the solution
It is important to note here that a factorization of the Jacobian matrix
Algorithm 8.15 (Collocation-based integrator with Sensitivities). Input: initial value
for
Output:
We can now turn to the deployment of Multiple-Shooting on DAE-based optimal control problems.
8.4.2 Direct Multiple-Shooting with Differential-Algebraic Equations
Figure 8.4.1: The diagram
In the context of Multiple-Shooting for DAE-based optimal control problems, the implicit numerical integration schemes detailed above are interacting with the NLP solver tackling the NLP resulting from the Multiple-Shooting discretization. We illustrate this interaction in Figure above. The NLP solver is then responsible for closing the shooting gaps, i.e. enforcing the continuity conditions:
for
One ought to observe here that the algebraic state dynamics can in principle be totally "hidden" inside the integrator scheme, and not reported at all to the NLP solver. In that sense, implicit integrators in general perform an elimination of the algebraic variables present in the dynamics, and hide their existence to the NLP solver.
Another crucial observation to make here is that no continuity condition nor initial condition is enforced on the algebraic state trajectories
As mentioned previously, the integrator can hide the algebraic variables from the NLP solvers and keep them as purely internal. However, one may want to use these variables in the cost function of the OCP, or impose some inequality constraints on them. In such a case, the algebraic states ought to be reported to the NLP solver, where they are regarded as functions of the decision variables
As illustrated in Figure 8.4.1, Multiple-Shooting with implicit integrators can be viewed as a two-level Newton scheme, where algebraic conditions are solved at two different levels. A natural alternative to this setup is then clearly to introduce the algebraic conditions underlying the numerical integrators into the NLP, and leave them to be solved by the NLP solver. Doing so leads us back to the Direct Collocation scheme, which we revisit next in the context of DAE-based optimal control problems.
8.4.3 Direct Collocation with Differential-Algebraic Equations
We will focus now on the deployment of the Direct Collocation method on such DAE-based optimal control problems. The principle here is extremely similar to those detailed in Section 7.3. However, there are a few important additional specific details arising from the presence of algebraic states and equations that need to be properly covered here. Let us briefly recall here the core principles of the direct collocation method. As detailed earlier in Section 7.3 and briefly recalled in Section 8.4.1 above, the differential state trajectories are approximated on each time intervals
- the continuity conditions of the differential states at the times
for
- the state dynamics at the times
for and
Additional conditions are typically added as boundary conditions, e.g.
The extension of the collocation equations for a semi-explicit DAE
follow the exact same philosophy, namely the collocation equations enforce:
- the continuity conditions of the differential states via
at the times . - the state dynamics at the times
for and via
The collocation equations for a semi-implicit DAE therefore read as:
for
A few details ought to be properly stressed here.
- similarly to the observations made in Section 8.4.2, no continuity condition is enforced on the algebraic states, hence
applies to the differential state trajectories alone. - one ought to observe that the discretized algebraic states
appear only for the indices in the collocation equations, i.e. the discrete algebraic states have one DoF less that the discrete differential states which appear with the indices in the collocation equations. The extra DoF granted to the differential state is actually required in order to be able to impose the continuity of the differential state trajectories, while the algebraic state trajectories are not required to be continuous. When building the NLP arising from a discretization of a DAE-based OCP using direct collocation, one ought to make sure that the adequate number of discrete algebraic states and discrete differential states are declared to the NLP solver. Indeed, e.g. introducing by mistake the unnecessary extra variables can create numerical difficulties in the solver, as these variables would be "free" in the NLP and their values not clearly fixed by the problem.
Building the collocation equations for DAEs in a generic implicit form
is a natural generalization of the constraints used in the case of a semi-explicit DAE. In the general case, the collocation equations simply read as:
for