# Optimal Control Problem

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a template page to show how a general Optimal Control Problem should be described on this website. In this first paragraph a short description of the problem is given. What is the practical or mathematical context that motivates to solve the problem. What do the free and dependent variables of the optimization problem describe. What kind of model (equality constraints) fix the dependent variables (ODE, RDE, DAE, ...). What is the objective? Also one can cite a paper that introduced or solved this problem just by saying:

Max Mustermann, "This paper doesn't exist!",
Jornal of myths and tails, Eds. Nobody and No-one, -1919, pp. -1-11.


## Model Formulation

In this section the dynamic model, that describes the physical or technical process of interest, should be described. First the differential equation should be written down. Then the states, inputs, and parameters should be declared (Dimension, Type (integer, real, binary, ...)). Finally the parameters that are not free in the optimization and the coefficients should be stated in an extra table or list. All equations and functions are defined over an interval $I \subset \R$. Initial values and free parameters are taken into account later in the Optimal Control Problem.

### Ordinary Differential Equation (ODE)

For a simple scalar ODE model this would look like the following:

$\frac{dx(t)}{dt} = \dot{x}(t)=px(t)+u(t),\; \forall \, t \in I;\; x: I \rightarrow \R,\; u: I \rightarrow \R, \; p \in \R.$

The parameter (coefficient) $p$ could be stated in a table, if it is fixed.

 Name Symbol Value Unit Parameter $p$ 23 [-]

This would result in an right hand side function $f(x,u)$ in this case, because there are no free parameters. Of course one could also specify an implicit DAE system ($F(\dot{x},x,u,p,t)=0$), where it just has to be said which states are differential and which are algebraic. The states and inputs can also be vector valued functions requiring matrix valued coefficients.

### Matrix Differential Equation (MDE)

For an Lyapunov differential equation (with constant coefficient) one could write:

$\dot{X}(t)=AX(t)+X(t)A^T, \forall \, t \in I; \; X: I \rightarrow \R^{n \times n}, A \in \R^{n \times n}.$

Here one also has to specify the matrix $A$ (e.g. in a list - fixing the dimensions of all matrices).

Coefficients of $A$
• $a_{11} = 2, \; a_{12} = 6$
• $a_{21} = 1, \; a_{22} = 0$

### Variational Differential Equation (VDE)

For a VDE with respect to the parameters the equations would be:

$\dot{G}_{p}(t)=f_x(x,p)G_{p}(t)+f_p(x,p), \forall \, t \in I; \; G_{p}: I \rightarrow \R^{n_x \times n_p}, \; x: I \rightarrow \R^{n_x}.$

In this case one has to specify the ODE model as done above, as well as the partial derivatives (which fixes all problem dimensions):

 $-p$ $4x_2$ $0$ $-3x_2^2$

either in a table or as a list:

• $f_{p1} = -x_1$
• $f_{p2} = 1.$

The nominal parameter values can be given as above in the ODE case, if they are fixed.

## Optimal Control Problem

In this section the Optimal Control Problem (OCP) with the dynamic model as equality constraint is specified. In general every OCP has either a Lagrange or Mayer type objective or both. First the general structure of the OCP is given to show the type of objective (linear, quadratic, ...) and constraints (equality and/or inequality, linear or nonlinear) as well as the variables that are free to optimize. All of the above dynamic models can be used, in the following we just write for all:

$\dot{x}(t)=f(x(t),u(t),p,t) \forall \, t \in I.$

Implicit systems would be treated similarly. Then the general OCP is writte as:

$\begin{array}{cl} \displaystyle \min_{x, u, p} & J(x,u,t)\\[1.5ex] \mbox{s.t.} & \dot{x} = f(x,u,p,t), \forall \, t \in I\\ & 0 = g(x(t_o),x(t_f),p) \\ & 0 \ge c(x,u,p), \forall \, t \in I\\ & 0 = h(x,u,p), \forall \, t \in I \\ & x \in \mathcal{X},\,u \in \mathcal{U},\, p \in P. \end{array}$

This is the most general formulation, where the initial value, parameters, and inputs are free. The states and inputs are vectors (or matrices) of functions while the parameters are just a vector of variables. If the initial (or final) state is fixed, one just adds a constraint $x(t_0)=x_0$ and specifies the value(s) of $x_0$ in a list or table. If the parameters are fixed, then one just removes them from the list of optimization variables and states their values in a list (same for point conditions inside of the interval $I$). If the OCP is a parameter estimation problem without inputs, the inputs just dont appear in the problem above at all, neither as optimization variable nor as part of the constraints. In contrast if they are just fixed this is done by the equality constraints. In this setup the above problem is very general and by stating the different objective functions and constraint functions one can cover a wide range of OCPs.

### Objective

To specify the objective the Mayer and/or Lagrange term has to be described. For a parameter estimation problem the objective would be a finite sum over the squared difference between the measurements and the model response:

$J(x,u,t)=\sum_{i=0}^{K}(y_i - h(x(t_i),u(t_i),t_i))^2.$

The output function $h$ has to be specified as above in the model section. An objective with a matrix valued state could look like this:

$J(X)=\int_{I}\det(X(t)^TSX(t)) dt.$

Here the weighting matrix $S$ has to be given. For an tracking type objective with vector valued state and inputs an quadratic objective would be:

$J(x,u,t)=\int_{I}((x(t)-x_{ref})^TQ(x(t)-x_{ref}) + (u(t)-u_{ref})^T R (u(t)-u_{ref}) dt.$

Surely demanding the specification of $Q$ and $R$ in a list or table. Also one can specify a Mayer term:

$J(x,u,t)=x_1^2(t_f)+x_2(t_f)x_3(t_f).$

This all is quite general and has to be adapted to the needs for the special OCP of interest.

### Constraints

The dynamic constraints have to be given in the model section, however the initial (or final) state constraint $g$ has to be specified. It can have a simple form:

$g(x(t_0),x(t_f),p)=x(t_0)-x_0,$

where one hast to state $x_0$. More complicated expressions like periodic constraints:

$g(x(t_0),x(t_f),p)=x(t_0)-x(t_f),$

free initial states (as parameters):

$g(x(t_0),x(t_f),p)=x(t_0)-p,$

and restricting hyperplanes:

$g(x(t_0),x(t_f),p)=g^T x(t_0),$

are also possible. General expressions could also be used. Constraints working on the whole interval $I$ can be also very general or just box constraints.

The set for inputs and states should be used to define the function spaces these functions live in and other set constraints that can not be expressed as nonlinear functions. One could say that the inputs should be piecewise constant or piecewise linear continuous functions and the states should then be $\mathcal{C}^1$ or $\mathcal{C}^2$. The set constraint on the parameters should be used to define all constraints on the parameters, if they are free to the optimization, otherwise it doesn't appear. This could look like:

$P=\{p \in \R^{n_p} | p_{min} \leq p \leq p_{max}\}.$

## Reference Solution

In this section one should provide reference solutions. First the discretization, the initial guess, the solution algorithm and the used hardware should be stated, as well as the solving time. Then the optimal solution should be given, at least as a PNG of the plots for the optimal trajectories. One should provide the optimal objective value.

## Source Code

In this section one can provide the source code of the implementation, that solved the problem and produced the reference solution. This should be done by providing source files.

## Nonlinear Model Predictive Control

If the OCP is solved repeatedly in a Nonlinear Model Predictive Control scheme here one can specify this outer loop configuration (sampling rate, observer, measurement error, measurement funktion, ...). Also reference solutions and code for this can be given to make the context the OCP comes from more clear. Robustness and other control specific matters like real-time requirements or model plant mismatch should also be described.