All projects

July 2026 – Sept. 2026 · DTU Compute

Stochastic Bilinear MPC with Chance Constraints on District Heating Systems

Taha Berk Koç

Supervisor: Assoc. Prof. Tobias K. S. Ritschel

  • Stochastic MPC
  • Chance Constraints
  • Kalman Filter
  • Monte Carlo

Summary

This report summarizes the work carried out during the internship on the development of Model Predictive Control (MPC) methods for district heating systems under uncertainty. The study progresses from linear time-invariant models to bilinear and stochastic formulations, including chance constraints, state-input analysis, and Kalman filtering. These components are then combined in a stochastic bilinear MPC framework and applied to a single-pipe district heating system. Both open-loop and closed-loop implementations are evaluated using Monte Carlo simulations. The final framework considers uncertainty, state estimation, probabilistic constraints, and nonlinear optimization within a unified control approach.

Acknowledgements

I would like to express my sincere gratitude to Assoc. Prof. Tobias K. S. Ritschel for his guidance, support, and encouragement throughout my research at the Technical University of Denmark. His valuable insights, constructive feedback, and thoughtful discussions have greatly contributed to my understanding of model predictive control and helped me develop as a researcher. I am especially thankful for the opportunity to work under his supervision and for the trust and independence he has given me throughout this work.

1Introduction

District heating systems require effective control strategies to maintain desired temperature levels while dealing with nonlinear dynamics, disturbances, and uncertainty. Model Predictive Control provides a suitable framework for this purpose by predicting future system behavior and optimizing control actions over a finite horizon. The aim of this report was to progressively develop an MPC framework, starting from deterministic linear models and extending it to bilinear and stochastic systems with chance constraints. State estimation using Kalman filtering was also investigated. Finally, the developed methods were applied to a district heating pipe model to study their behavior in a more realistic control problem.

2Linear Time-Invariant Model

2.1LTI System

A discrete-time Linear Time-Invariant (LTI) system can be represented in state-space form as

xk+1=Axk+Buk,yk=Cxk,\begin{align*} x_{k+1} &= A x_k + B u_k, \tag{2.1}\\ y_k &= C x_k, \tag{2.2}\end{align*}

where xk∈Rnx_k \in \mathbb{R}^{n} denotes the state vector, uk∈Rmu_k \in \mathbb{R}^{m} denotes the input vector, and yk∈Rry_k \in \mathbb{R}^{r} denotes the output vector at time step kk. The matrices AA, BB, and CC are the state, input, and output matrices, respectively.

For model predictive control, the future behavior of the system is predicted from the current state x0x_0 and a sequence of future control inputs

u0,u1,…,uN−1,(2.3) u_0,u_1,\ldots,u_{N-1}, \tag{2.3}

where NN denotes the prediction horizon.

2.1.1State and Output Prediction

Starting from the initial state x0x_0, the state after one time step is obtained from Equation (2.1) as

x1=Ax0+Bu0(2.4) x_1 = A x_0 + B u_0 \tag{2.4}

At the next time step,

x2=Ax1+Bu1=A(Ax0+Bu0)+Bu1=A2x0+ABu0+Bu1\begin{align*} x_2 &= A x_1 + B u_1 \tag{2.5}\\ &= A(Ax_0 + Bu_0) + Bu_1 \tag{2.6}\\ &= A^2x_0 + ABu_0 + Bu_1 \tag{2.7}\end{align*}

Similarly, the third predicted state is

x3=Ax2+Bu2=A3x0+A2Bu0+ABu1+Bu2\begin{align*} x_3 &= Ax_2 + Bu_2 \tag{2.8}\\ &= A^3x_0 + A^2Bu_0 + ABu_1 + Bu_2 \tag{2.9}\end{align*}

Following the same recursion, the state at an arbitrary prediction step kk can be written as

xk=Akx0+∑i=0k−1Ak−1−iBui(2.10) x_k = A^k x_0 + \sum_{i=0}^{k-1} A^{k-1-i}B u_i \tag{2.10}

Equation Equation (2.10) separates the future state into two contributions. The first term represents the evolution of the initial state in the absence of future inputs, whereas the summation represents the contribution of the input sequence.

Using the output relation in Equation (2.2), the corresponding output at prediction step kk is

yk=Cxk=C(Akx0+∑i=0k−1Ak−1−iBui),\begin{align*} y_k &= Cx_k \tag{2.11}\\ &= C \left( A^k x_0 + \sum_{i=0}^{k-1} A^{k-1-i}Bu_i \right), \tag{2.12}\end{align*}

which gives

yk=CAkx0+∑i=0k−1CAk−1−iBui(2.13) y_k = CA^k x_0 + \sum_{i=0}^{k-1} CA^{k-1-i}Bu_i \tag{2.13}

Thus, each predicted output is expressed as a function of the current state and all control inputs applied before that prediction step.

2.1.2Stacked Prediction Formulation

For optimization over a prediction horizon NN, the predicted outputs and future inputs can be collected into stacked vectors. The output vector is defined as

Y=[y1y2⋮yN]∈RNr,(2.14) Y = \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_N \end{bmatrix} \in \mathbb{R}^{Nr}, \tag{2.14}

and the corresponding input vector is

U=[u0u1⋮uN−1]∈RNm(2.15) U = \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_{N-1} \end{bmatrix} \in \mathbb{R}^{Nm} \tag{2.15}

The first two predicted outputs can be written explicitly as

y1=CAx0+CBu0,y2=CA2x0+CABu0+CBu1,\begin{align*} y_1 &= CAx_0 + CBu_0, \tag{2.16}\\ y_2 &= CA^2x_0 + CABu_0 + CBu_1, \tag{2.17}\end{align*}

and the final output over the prediction horizon is

yN=CANx0+CAN−1Bu0+CAN−2Bu1+⋯+CBuN−1(2.18) y_N = CA^N x_0 + CA^{N-1}Bu_0 + CA^{N-2}Bu_1 + \cdots + CBu_{N-1} \tag{2.18}

Stacking these equations gives

[y1y2⋮yN]=[CACA2⋮CAN]x0+[CB0⋯0CABCB⋯0⋮⋮⋱⋮CAN−1BCAN−2B⋯CB][u0u1⋮uN−1](2.19) \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_N \end{bmatrix} = \begin{bmatrix} CA \\ CA^2 \\ \vdots \\ CA^N \end{bmatrix} x_0 + \begin{bmatrix} CB & 0 & \cdots & 0 \\ CAB & CB & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ CA^{N-1}B & CA^{N-2}B & \cdots & CB \end{bmatrix} \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_{N-1} \end{bmatrix} \tag{2.19}

Introducing the prediction matrices

Φ=[CACA2⋮CAN]∈RNr×n,(2.20) \Phi = \begin{bmatrix} CA \\ CA^2 \\ \vdots \\ CA^N \end{bmatrix} \in \mathbb{R}^{Nr \times n}, \tag{2.20}

and

Γ=[CB0⋯0CABCB⋯0⋮⋮⋱⋮CAN−1BCAN−2B⋯CB]∈RNr×Nm,(2.21) \Gamma = \begin{bmatrix} CB & 0 & \cdots & 0 \\ CAB & CB & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ CA^{N-1}B & CA^{N-2}B & \cdots & CB \end{bmatrix} \in \mathbb{R}^{Nr \times Nm}, \tag{2.21}

the stacked prediction equation can be written compactly as

Y=Φx0+ΓU(2.22) \boxed{ Y = \Phi x_0 + \Gamma U } \tag{2.22}

The term

Yfree=Φx0(2.23) Y_{\mathrm{free}} = \Phi x_0 \tag{2.23}

describes the free response of the system, i.e. the predicted output evolution due only to the current state. The term

Yforced=ΓU(2.24) Y_{\mathrm{forced}} = \Gamma U \tag{2.24}

describes the forced response resulting from the future input sequence. Consequently,

Y=Yfree+Yforced=Φx0+ΓU(2.25) Y = Y_{\mathrm{free}} + Y_{\mathrm{forced}} = \Phi x_0 + \Gamma U \tag{2.25}

2.2Optimal Control Problem

After deriving the stacked prediction model, the next step is to determine the sequence of control inputs that minimizes a desired performance criterion over the prediction horizon.

For a prediction horizon of length NN, the quadratic cost function is defined as

ϕ=∑k=1N(yk−yˉk)TQk(yk−yˉk)+∑k=0N−1ukTRkuk,(2.26) \phi = \sum_{k=1}^{N} (y_k-\bar{y}_k)^{T} Q_k (y_k-\bar{y}_k) + \sum_{k=0}^{N-1} u_k^{T} R_k u_k, \tag{2.26}

where yˉk\bar{y}_k denotes the desired reference output, while Qk⪰0Q_k \succeq 0 and Rk≻0R_k \succ 0 are weighting matrices penalizing the output tracking error and the control effort, respectively.

Using the stacked output and input vectors, the cost function can be written as

ϕ=(Y−Yˉ)TQ(Y−Yˉ)+UTRU(2.27) \phi = (Y-\bar{Y})^{T} Q (Y-\bar{Y}) + U^{T} R U \tag{2.27}

From the stacked prediction equation

Y=Φx0+ΓU,(2.28) Y = \Phi x_0 + \Gamma U, \tag{2.28}

the cost function becomes

ϕ=(Φx0+ΓU−Yˉ)TQ(Φx0+ΓU−Yˉ)+UTRU(2.29) \phi = (\Phi x_0 + \Gamma U-\bar{Y})^T Q (\Phi x_0 + \Gamma U-\bar{Y}) + U^T R U \tag{2.29}

Defining

e=Φx0−Yˉ,(2.30) e = \Phi x_0-\bar{Y}, \tag{2.30}

the cost function can be written as

ϕ=(e+ΓU)TQ(e+ΓU)+UTRU(2.31) \phi = (e+\Gamma U)^TQ(e+\Gamma U) + U^TRU \tag{2.31}

Expanding the quadratic term gives

ϕ=eTQe+eTQΓU+UTΓTQe+UTΓTQΓU+UTRU\begin{align*} \phi &= e^TQe + e^TQ\Gamma U + U^T\Gamma^TQe \\ &\quad+ U^T\Gamma^TQ\Gamma U + U^TRU \tag{2.32}\end{align*}

Since the cross terms are scalar and Q=QTQ=Q^T,

eTQΓU=UTΓTQe(2.33) e^TQ\Gamma U = U^T\Gamma^TQe \tag{2.33}

Therefore,

ϕ=eTQe+2UTΓTQe+UT(ΓTQΓ+R)U(2.34) \phi = e^TQe + 2U^T\Gamma^TQe + U^T(\Gamma^TQ\Gamma+R)U \tag{2.34}

To obtain the optimal control sequence, the cost function is differentiated with respect to UU:

∂ϕ∂U=2ΓTQe+2(ΓTQΓ+R)U(2.35) \frac{\partial \phi}{\partial U} = 2\Gamma^TQe + 2(\Gamma^TQ\Gamma+R)U \tag{2.35}

At the optimum,

∂ϕ∂U=0(2.36) \frac{\partial \phi}{\partial U}=0 \tag{2.36}

Hence,

ΓTQ(Φx0−Yˉ)+(ΓTQΓ+R)U=0(2.37) \Gamma^TQ(\Phi x_0-\bar{Y}) + (\Gamma^TQ\Gamma+R)U = 0 \tag{2.37}

Solving for UU gives the optimal control sequence

U∗=−(ΓTQΓ+R)−1ΓTQ(Φx0−Yˉ)(2.38) \boxed{ U^\ast = - (\Gamma^TQ\Gamma+R)^{-1} \Gamma^TQ (\Phi x_0-\bar{Y}) } \tag{2.38}

Equivalently,

U∗=(ΓTQΓ+R)−1ΓTQ(Yˉ−Φx0)(2.39) \boxed{ U^\ast = (\Gamma^TQ\Gamma+R)^{-1} \Gamma^TQ (\bar{Y}-\Phi x_0) } \tag{2.39}

2.3Open-Loop Implementation

After deriving the optimal control sequence for the LTI system, the controller was first implemented in an open-loop setting. In this approach, the complete optimal input sequence is computed once using the initial state and the desired reference trajectory. The resulting inputs are then applied sequentially to the system without recalculating the optimization problem using updated state information.

The implementation procedure can be summarized in the following steps.

2.3.1Implementation Procedure

First, the prediction horizon NN, the reference trajectory Yˉ\bar{Y}, the weighting matrices QQ and RR, and the initial state x0x_0 are specified. The weighting matrices satisfy

Q⪰0,R≻0(2.40) Q \succeq 0, \qquad R \succ 0 \tag{2.40}

The stacked prediction matrices Φ\Phi and Γ\Gamma are then constructed according to

Y=Φx0+ΓU,(2.41) Y = \Phi x_0 + \Gamma U, \tag{2.41}

where

Φ=[CACA2⋮CAN],(2.42) \Phi = \begin{bmatrix} CA \\ CA^2 \\ \vdots \\ CA^N \end{bmatrix}, \tag{2.42}

and

Γ=[CB0⋯0CABCB⋯0⋮⋮⋱⋮CAN−1BCAN−2B⋯CB](2.43) \Gamma = \begin{bmatrix} CB & 0 & \cdots & 0 \\ CAB & CB & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ CA^{N-1}B & CA^{N-2}B & \cdots & CB \end{bmatrix} \tag{2.43}

Using these matrices, the quadratic cost function is written as

ϕ(U)=(Φx0+ΓU−Yˉ)TQ(Φx0+ΓU−Yˉ)+UTRU(2.44) \phi(U) = (\Phi x_0+\Gamma U-\bar{Y})^T Q (\Phi x_0+\Gamma U-\bar{Y}) + U^T R U \tag{2.44}

As derived in the previous section, minimizing this cost function with respect to UU gives the optimal input sequence

U∗=−(ΓTQΓ+R)−1ΓTQ(Φx0−Yˉ)(2.45) U^\ast = - \left( \Gamma^TQ\Gamma+R \right)^{-1} \Gamma^TQ \left( \Phi x_0-\bar{Y} \right) \tag{2.45}

In the open-loop implementation, Equation (2.45) is evaluated only once. The resulting control sequence

U∗=[u0∗u1∗⋯uN−1∗]T(2.46) U^\ast = \begin{bmatrix} u_0^\ast & u_1^\ast & \cdots & u_{N-1}^\ast \end{bmatrix}^T \tag{2.46}

is subsequently applied to the system according to

xk+1=Axk+Buk∗,yk=Cxk\begin{align*} x_{k+1} &= Ax_k + Bu_k^\ast, \tag{2.47}\\ y_k &= Cx_k \tag{2.48}\end{align*}

Therefore, no new optimization problem is solved after the simulation begins. This distinguishes the open-loop implementation from a receding-horizon or Model Predictive Control implementation, in which the optimization problem is repeatedly solved using updated state information.

The complete procedure can therefore be summarized as

  1. Select NN, Yˉ\bar{Y}, QQ, RR, and x0x_0.
  2. Construct the prediction matrices Φ\Phi and Γ\Gamma.
  3. Construct the quadratic cost function ϕ(U)\phi(U).
  4. Calculate the optimal input sequence U∗U^\ast.
  5. Apply the components of U∗U^\ast sequentially to the system.
  6. Compare the resulting output trajectory with the reference trajectory.

To quantify the tracking performance, the tracking error is defined as

E=Y−Yref(2.49) E = Y-Y_{\mathrm{ref}} \tag{2.49}

The Root Mean Square Error (RMSE) can additionally be used as a scalar measure of the tracking accuracy. For a system with rr outputs, it is given by

RMSE=1Nr∑k=1N∑j=1r(Yk,j−Yref,k,j)2(2.50) \mathrm{RMSE} = \sqrt{ \frac{1}{Nr} \sum_{k=1}^{N} \sum_{j=1}^{r} \left( Y_{k,j}-Y_{\mathrm{ref},k,j} \right)^2 } \tag{2.50}

2.3.2Results

The open-loop controller was evaluated using the following discrete-time LTI system:

A=[1101],B=[01],C=[10](2.51) A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}, \qquad B = \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \qquad C = \begin{bmatrix} 1 & 0 \end{bmatrix} \tag{2.51}

The desired output reference was changed every ten simulation steps. Three reference levels were considered:

yˉ=[1.03.05.0](2.52) \bar{y} = \begin{bmatrix} 1.0 & 3.0 & 5.0 \end{bmatrix} \tag{2.52}

To investigate the effect of the input penalty on the controller behavior, three different values of RR were tested while keeping the remaining controller parameters unchanged:

R=0.1,R=0.5,R=5(2.53) R = 0.1, \qquad R = 0.5, \qquad R = 5 \tag{2.53}

Case 1: R=0.1R=0.1

LTI Open Loop R0 1

Figure 2.1: Open-loop tracking performance for R=0.1R=0.1, Left-side is when N=5 with the averaged RMSE 0.450392, right-side is the case when N=40 with the averaged RMSE 0.172099

Case 2: R=0.5R=0.5

LTI Open Loop R0 5

Figure 2.2: Open-loop tracking performance for R=0.5R=0.5, Left-side is when N=5 with the averaged RMSE 0.469931, right-side is the case when N=40 with the averaged RMSE 0.220377

Case 3: R=5.0R=5.0

LTI Open Loop R5 0

Figure 2.3: Open-loop tracking performance for R=5.0R=5.0, Left-side is when N=5 with the averaged RMSE 0.571764, right-side is the case when N=40 with the averaged RMSE 0.344596

Comparison

The results demonstrate the trade-off between reference tracking performance and control effort introduced by the weighting matrix RR. As the value of RR increases, the contribution of the term UTRUU^TRU to the objective function becomes more significant. Consequently, the optimizer increasingly penalizes large control inputs and attempts to reduce the magnitude of UU.

For a small value such as R=0.1R=0.1, the controller is willing to use relatively large control actions in order to achieve accurate reference tracking. As RR is increased to 0.50.5 and subsequently to 55, the control actions become less aggressive. The system therefore has increasing difficulty following changes in the reference trajectory, resulting in larger tracking errors.

Hence, increasing RR improves the economy of the control action at the expense of tracking performance. The selection of RR therefore represents a compromise between minimizing the control effort and maintaining accurate reference tracking.

2.4Closed-Loop Implementation

The open-loop implementation computes the optimal control sequence only once from the initial state and applies the complete sequence without further optimization. In contrast, the closed-loop implementation repeatedly solves the optimal control problem using the most recent state information.

This approach follows the receding-horizon principle. At each time step, a new optimal input sequence is calculated, but only its first control action is applied to the system. At the following time step, the state is updated and the optimization problem is solved again.

2.4.1Implementation Procedure

The prediction horizon NN, control horizon NcN_c, total simulation length NendN_{\mathrm{end}}, reference trajectory, weighting matrices QQ and RR, and initial state x0x_0 are first specified.

The prediction and control horizons satisfy

Nc≤N(2.54) N_c \leq N \tag{2.54}

The stacked prediction model derived previously is

Y=Φxk+ΓUfull,(2.55) Y = \Phi x_k + \Gamma U_{\mathrm{full}}, \tag{2.55}

where

Φ=[CACA2⋮CAN](2.56) \Phi = \begin{bmatrix} CA \\ CA^2 \\ \vdots \\ CA^N \end{bmatrix} \tag{2.56}

and

Γ=[CB0⋯0CABCB⋯0⋮⋮⋱⋮CAN−1BCAN−2B⋯CB](2.57) \Gamma = \begin{bmatrix} CB & 0 & \cdots & 0 \\ CAB & CB & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ CA^{N-1}B & CA^{N-2}B & \cdots & CB \end{bmatrix} \tag{2.57}

When a control horizon NcN_c shorter than the prediction horizon is used, the independent control variables are collected in

Uc=[u0u1⋮uNc−1](2.58) U_c = \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_{N_c-1} \end{bmatrix} \tag{2.58}

The complete input sequence over the prediction horizon is then generated as

Ufull=TUc,(2.59) U_{\mathrm{full}} = T U_c, \tag{2.59}

where TT is a control-horizon mapping matrix. This matrix maps the NcN_c independent control variables to the full prediction horizon.

Substituting Equation (2.59) into the prediction model gives

Y=Φxk+ΓTUc(2.60) Y = \Phi x_k + \Gamma T U_c \tag{2.60}

At each time step kk, the reference trajectory corresponding to the current prediction window is denoted by Yˉk\bar{Y}_k. The quadratic cost function is therefore written as

ϕ(Uc)=(Φxk+ΓTUc−Yˉk)TQ(Φxk+ΓTUc−Yˉk)+UcTRUc(2.61) \phi(U_c) = \left( \Phi x_k + \Gamma T U_c - \bar{Y}_k \right)^T Q \left( \Phi x_k + \Gamma T U_c - \bar{Y}_k \right) + U_c^T R U_c \tag{2.61}

The optimization problem is solved again at every sampling instant. Following the same derivation as in the previous section, the optimal control sequence becomes

Uc∗=−[(ΓT)TQ(ΓT)+R]−1(ΓT)TQ(Φxk−Yˉk)(2.62) U_c^\ast = - \left[ (\Gamma T)^T Q (\Gamma T) + R \right]^{-1} (\Gamma T)^T Q \left( \Phi x_k-\bar{Y}_k \right) \tag{2.62}

Unlike the open-loop implementation, the complete optimal sequence is not applied to the system. Instead, only the first control input is selected.

A selection matrix Π\Pi can be defined such that

uk=ΠUc∗(2.63) u_k = \Pi U_c^\ast \tag{2.63}

For a scalar-input system,

Π=[10⋯0](2.64) \Pi = \begin{bmatrix} 1 & 0 & \cdots & 0 \end{bmatrix} \tag{2.64}

The selected input is then applied to the system:

xk+1=Axk+Buk,yk=Cxk\begin{align*} x_{k+1} &= Ax_k + Bu_k, \tag{2.65}\\ y_k &= Cx_k \tag{2.66}\end{align*}

After obtaining the new state xk+1x_{k+1}, the prediction window is shifted forward by one time step. The reference trajectory is updated accordingly, and the optimization problem is solved again.

This procedure is repeated until

k=Nend−1(2.67) k = N_{\mathrm{end}}-1 \tag{2.67}

Therefore, the closed-loop algorithm can be summarized as follows:

  1. Select NN, NcN_c, NendN_{\mathrm{end}}, QQ, RR, the reference trajectory, and x0x_0.
  2. Construct the prediction matrices Φ\Phi and Γ\Gamma, together with the control-horizon mapping matrix TT.
  3. At time step kk, construct the reference vector Yˉk\bar{Y}_k over the current prediction horizon.
  4. Compute the optimal control sequence Uc∗U_c^\ast.
  5. Apply only the first control action,

    uk=ΠUc∗ u_k = \Pi U_c^\ast
  6. Update the system state and output.
  7. Shift the prediction horizon and repeat the optimization for k+1k+1.

2.4.2Results

The closed-loop controller was evaluated using the same LTI system considered in the open-loop implementation:

A=[1101],B=[01],C=[10](2.68) A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}, \qquad B = \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \qquad C = \begin{bmatrix} 1 & 0 \end{bmatrix} \tag{2.68}

The reference output was chosen as

yˉ=[1.03.05.0],(2.69) \bar{y} = \begin{bmatrix} 1.0 & 3.0 & 5.0 \end{bmatrix}, \tag{2.69}

where the reference value changes every 10 simulation steps.

For this experiment, the control-input weighting was selected as

R=0.1(2.70) R = 0.1 \tag{2.70}

Also, in our example, the prediction horizon is chosen to be the same as the control horizon. So,

T=I,Ufull=Uc(2.71) T = I,\quad U_{full}=U_c \tag{2.71}

LTI Closed Loop R0 1

Figure 2.4: Closed-loop tracking performance for R=5.0R=5.0, Left-side is when N=2 with the averaged RMSE 0.238485, right-side is the case when N=5 with the averaged RMSE 0.242733

3Bilinear Model

3.1Bilinear System

In the bilinear formulation considered in this work, the system matrices depend on a time-varying variable vkv_k. The discrete-time state-space model is written as

xk+1=A(vk)xk+B(vk)ukyk=Cxk\begin{align*} x_{k+1} &= A(v_k)x_k + B(v_k)u_k \tag{3.1}\\ y_k &= Cx_k \tag{3.2}\end{align*}

For compactness, the time-varying system matrices are denoted by

Ak=A(vk),Bk=B(vk)(3.3) A_k = A(v_k), \qquad B_k = B(v_k) \tag{3.3}

The state equation can therefore be written as

xk+1=Akxk+Bkuk(3.4) x_{k+1} = A_k x_k + B_k u_k \tag{3.4}

Unlike the LTI case, where AA and BB remain constant over the prediction horizon, the matrices AkA_k and BkB_k may change at every prediction step according to the corresponding value of vkv_k.

3.1.1State and Output Prediction

Starting from the initial state x0x_0, the first predicted state is

x1=A0x0+B0u0(3.5) x_1 = A_0x_0 + B_0u_0 \tag{3.5}

The corresponding output is

y1=Cx1=CA0x0+CB0u0(3.6) y_1 = Cx_1 = CA_0x_0 + CB_0u_0 \tag{3.6}

At the second prediction step,

x2=A1x1+B1u1=A1(A0x0+B0u0)+B1u1=A1A0x0+A1B0u0+B1u1\begin{align*} x_2 &= A_1x_1+B_1u_1 \tag{3.7}\\ &= A_1(A_0x_0+B_0u_0)+B_1u_1 \tag{3.8}\\ &= A_1A_0x_0+A_1B_0u_0+B_1u_1 \tag{3.9}\end{align*}

Therefore,

y2=Cx2=CA1A0x0+CA1B0u0+CB1u1\begin{align*} y_2 &= Cx_2 \tag{3.10}\\ &= CA_1A_0x_0 +CA_1B_0u_0 +CB_1u_1 \tag{3.11}\end{align*}

Similarly, the third predicted state is

x3=A2x2+B2u2=A2A1A0x0+A2A1B0u0+A2B1u1+B2u2\begin{align*} x_3 &= A_2x_2+B_2u_2 \tag{3.12}\\ &= A_2A_1A_0x_0 +A_2A_1B_0u_0 +A_2B_1u_1 +B_2u_2 \tag{3.13}\end{align*}

and hence

y3=CA2A1A0x0+CA2A1B0u0+CA2B1u1+CB2u2\begin{align*} y_3 &= CA_2A_1A_0x_0 +CA_2A_1B_0u_0 \\ &\quad +CA_2B_1u_1 +CB_2u_2 \tag{3.14}\end{align*}

Following the same recursive structure, the state at prediction step kk can be expressed as

xk=(∏j=0k−1Aj)x0+∑i=0k−1(∏j=i+1k−1Aj)Biui(3.15) x_k = \left( \prod_{j=0}^{k-1} A_j \right)x_0 + \sum_{i=0}^{k-1} \left( \prod_{j=i+1}^{k-1} A_j \right) B_i u_i \tag{3.15}

where the matrix products are ordered such that

∏j=0k−1Aj=Ak−1Ak−2⋯A0(3.16) \prod_{j=0}^{k-1}A_j = A_{k-1}A_{k-2}\cdots A_0 \tag{3.16}

For i=k−1i=k-1, the product multiplying Bk−1uk−1B_{k-1}u_{k-1} is interpreted as the identity matrix.

Using yk=Cxky_k=Cx_k, the corresponding predicted output becomes

yk=C(∏j=0k−1Aj)x0+∑i=0k−1C(∏j=i+1k−1Aj)Biui(3.17) y_k = C \left( \prod_{j=0}^{k-1} A_j \right)x_0 + \sum_{i=0}^{k-1} C \left( \prod_{j=i+1}^{k-1} A_j \right) B_i u_i \tag{3.17}

3.1.2Stacked Prediction Formulation

As in the LTI case, the future outputs and control inputs over a prediction horizon NN are collected into stacked vectors:

Y=[y1y2⋮yN],U=[u0u1⋮uN−1](3.18) Y = \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_N \end{bmatrix}, \qquad U = \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_{N-1} \end{bmatrix} \tag{3.18}

Using the previously derived output equations, the stacked prediction can be written as

Y=Φ(V)x0+Γ(V)U,(3.19) Y = \Phi(V)x_0 + \Gamma(V)U, \tag{3.19}

where

V=[v0v1⋯vN−1]T(3.20) V = \begin{bmatrix} v_0 & v_1 & \cdots & v_{N-1} \end{bmatrix}^{T} \tag{3.20}

contains the values determining the system matrices over the prediction horizon.

The state-dependent prediction matrix is

Φ(V)=[CA0CA1A0CA2A1A0⋮CAN−1AN−2⋯A0](3.21) \Phi(V) = \begin{bmatrix} CA_0 \\ CA_1A_0 \\ CA_2A_1A_0 \\ \vdots \\ CA_{N-1}A_{N-2}\cdots A_0 \end{bmatrix} \tag{3.21}

The input prediction matrix is

Γ(V)=[CB000⋯0CA1B0CB10⋯0CA2A1B0CA2B1CB2⋯0⋮⋮⋮⋱⋮CAN−1⋯A1B0CAN−1⋯A2B1CAN−1⋯A3B2⋯CBN−1](3.22) \Gamma(V) = \begin{bmatrix} CB_0 & 0 & 0 & \cdots & 0 \\[2mm] CA_1B_0 & CB_1 & 0 & \cdots & 0 \\[2mm] CA_2A_1B_0 & CA_2B_1 & CB_2 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\[2mm] CA_{N-1}\cdots A_1B_0 & CA_{N-1}\cdots A_2B_1 & CA_{N-1}\cdots A_3B_2 & \cdots & CB_{N-1} \end{bmatrix} \tag{3.22}

Consequently, the compact prediction equation is

Y=Φ(V)x0+Γ(V)U(3.23) \boxed{ Y = \Phi(V)x_0+\Gamma(V)U } \tag{3.23}

3.2Optimal Control Problem

For the bilinear system, both the control sequence UU and the scheduling-variable sequence VV are treated as optimization variables. The decision vector is therefore defined as

z=[UV](3.24) z = \begin{bmatrix} U \\ V \end{bmatrix} \tag{3.24}

Using the bilinear stacked prediction model,

Ypred=Φ(V)x0+Γ(V)U(3.25) Y_{\mathrm{pred}} = \Phi(V)x_0 + \Gamma(V)U \tag{3.25}

the tracking error is defined as

e=Ypred−Yˉ(3.26) e = Y_{\mathrm{pred}} - \bar{Y} \tag{3.26}

The quadratic objective function is then written as

ϕ(z)=eTQe+UTRUU+VTRVV,(3.27) \phi(z) = e^TQe + U^TR_UU + V^TR_VV, \tag{3.27}

where Q⪰0Q \succeq 0 penalizes the output tracking error, while RU≻0R_U \succ 0 and RV≻0R_V \succ 0 penalize the magnitudes of the control and scheduling-variable sequences, respectively.

Substituting the prediction model into the cost function gives

ϕ(U,V)=(Φ(V)x0+Γ(V)U−Yˉ)TQ(Φ(V)x0+Γ(V)U−Yˉ)+UTRUU+VTRVV\begin{align*} \phi(U,V) &= \left( \Phi(V)x_0 + \Gamma(V)U - \bar{Y} \right)^T Q \left( \Phi(V)x_0 + \Gamma(V)U - \bar{Y} \right) \\ &\quad + U^TR_UU + V^TR_VV \tag{3.28}\end{align*}

The optimal control and scheduling sequences are therefore obtained from

(U∗,V∗)=arg⁡min⁡U,Vϕ(U,V)(3.29) \boxed{ (U^\ast,V^\ast) = \arg\min_{U,V} \phi(U,V) } \tag{3.29}

In the LTI case, the prediction matrices Φ\Phi and Γ\Gamma are constant. As a result, the cost function is quadratic in UU, and the optimal solution can be obtained analytically by setting the gradient equal to zero.

For the bilinear system, however, both Φ(V)\Phi(V) and Γ(V)\Gamma(V) depend on the optimization variable VV. Consequently, the predicted output depends nonlinearly on the joint decision vector z=[UT  VT]Tz=[U^T \; V^T]^T. The resulting optimization problem is therefore generally nonlinear and does not admit the same closed-form solution used for the LTI system.

3.2.1Numerical Solution Using SLSQP

The nonlinear optimization problem in Equation (3.29) is solved numerically using Sequential Least Squares Programming (SLSQP).

SLSQP is a gradient-based constrained optimization method that solves a sequence of local quadratic approximations of the original nonlinear problem. At each iteration, the algorithm updates the decision variables while attempting to reduce the objective function and satisfy the imposed constraints.

The optimization variable is

z=[UV](3.30) z = \begin{bmatrix} U \\ V \end{bmatrix} \tag{3.30}

with an initial guess

z(0)=[U(0)V(0)](3.31) z^{(0)} = \begin{bmatrix} U^{(0)} \\ V^{(0)} \end{bmatrix} \tag{3.31}

At each SLSQP iteration, the current sequence VV is used to construct the time-varying matrices

Ak=A(vk),Bk=B(vk)(3.32) A_k=A(v_k), \qquad B_k=B(v_k) \tag{3.32}

and consequently the prediction matrices

Φ(V),Γ(V)(3.33) \Phi(V), \qquad \Gamma(V) \tag{3.33}

The predicted output is then evaluated as

Ypred=Φ(V)x0+Γ(V)U(3.34) Y_{\mathrm{pred}} = \Phi(V)x_0 + \Gamma(V)U \tag{3.34}

and the objective function ϕ(U,V)\phi(U,V) is computed.

The optimizer repeatedly updates UU and VV until a convergence criterion is satisfied, resulting in the numerical solution

z∗=[U∗V∗](3.35) z^\ast = \begin{bmatrix} U^\ast \\ V^\ast \end{bmatrix} \tag{3.35}

3.3Open-Loop Implementation

The open-loop implementation of the bilinear controller follows the same general structure as the open-loop implementation introduced for the LTI system. However, the optimal control problem is solved numerically for both UU and VV, rather than analytically for UU alone.

The implementation procedure can therefore be summarized as follows:

  1. Select the prediction horizon NN, reference trajectory Yˉ\bar{Y}, weighting matrices QQ, RUR_U, RVR_V, and the initial state x0x_0.
  2. Define the bounds and initial guesses for the optimization variables UU and VV.
  3. For a candidate sequence VV, construct the time-varying matrices

    Ak=A(vk),Bk=B(vk) A_k=A(v_k), \qquad B_k=B(v_k)
  4. Construct the prediction matrices Φ(V)\Phi(V) and Γ(V)\Gamma(V).
  5. Construct the nonlinear objective function ϕ(U,V)\phi(U,V).
  6. Solve the optimization problem numerically using SLSQP to obtain U∗U^\ast and V∗V^\ast.
  7. Apply the components of U∗U^\ast and V∗V^\ast sequentially to the bilinear system.
  8. Compare the resulting output trajectory with the reference trajectory.

At each simulation step, the optimized values are applied according to

xk+1=A(vk∗)xk+B(vk∗)uk∗yk=Cxk\begin{align*} x_{k+1} &= A(v_k^\ast)x_k + B(v_k^\ast)u_k^\ast \tag{3.36}\\ y_k &= Cx_k \tag{3.37}\end{align*}

Since the controller operates in open loop, the optimization is not updated after the simulation begins. Therefore, the sequences U∗U^\ast and V∗V^\ast are determined entirely from the initial state and the prescribed reference trajectory.

3.3.1Results

The bilinear open-loop controller was evaluated using the system

xk+1=A(vk)xk+B(vk)uk,yk=Cxk(3.38) x_{k+1} = A(v_k)x_k + B(v_k)u_k, \qquad y_k=Cx_k \tag{3.38}

with

A(v)=[0.9v0.00.5](3.39) A(v) = \begin{bmatrix} 0.9 & v \\ 0.0 & 0.5 \end{bmatrix} \tag{3.39}
B(v)=[01],C=[1.00.0](3.40) B(v) = \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \qquad C= \begin{bmatrix} 1.0 & 0.0 \end{bmatrix} \tag{3.40}

The initial state was selected as

x0=[1.00.0](3.41) x_0 = \begin{bmatrix} 1.0 \\ 0.0 \end{bmatrix} \tag{3.41}

The optimization bounds were chosen as

−5.0≤uk≤5.0−10.0≤vk≤10.0\begin{align*} -5.0 &\leq u_k \leq 5.0 \tag{3.42}\\ -10.0 &\leq v_k \leq 10.0 \tag{3.43}\end{align*}

The control penalties were selected as

RU=0.1,RV=0.1(3.44) R_U = 0.1, \qquad R_V = 0.1 \tag{3.44}

Bilinear Open Loop

Figure 3.1: Open-loop output tracking performance of the bilinear system, left-side is the case when N=5, and right-side is the case when N=10

3.4Closed-Loop Implementation

The closed-loop implementation of the bilinear controller follows the same receding-horizon principle introduced for the LTI system. However, in the bilinear case, both the control sequence UU and the scheduling-variable sequence VV are optimized at every sampling instant.

At time step kk, the current state xkx_k is used together with the reference trajectory over the prediction horizon. The nonlinear optimization problem is then solved numerically using SLSQP. Only the first elements of the optimal sequences are applied to the system. At the next time step, the state is updated and the complete optimization problem is solved again.

Only the first control values are applied to the system. Using the selection matrix Π\Pi,

uk=ΠUc∗vk=ΠVc∗\begin{align*} u_k &= \Pi U_c^\ast \tag{3.45}\\ v_k &= \Pi V_c^\ast \tag{3.46}\end{align*}

After the state is updated, the prediction horizon is shifted forward by one step and the optimization problem is solved again using the new state xk+1x_{k+1}.

The closed-loop bilinear control procedure can therefore be summarized as follows:

  1. Select NN, NcN_c, NendN_{\mathrm{end}}, QQ, RUR_U, RVR_V, the reference trajectory, and x0x_0.
  2. Define the bounds and initial guesses for the optimization variables UcU_c and VcV_c, and construct the control-horizon mapping matrix TT.
  3. At time step kk, construct the reference vector Yˉk\bar{Y}_k over the current prediction horizon.
  4. For the current candidate sequence VcV_c, construct Vfull=TVc V_{\mathrm{full}} = TV_c and the corresponding time-varying system matrices Ai=A(vi),Bi=B(vi). A_i=A(v_i), \quad B_i=B(v_i).
  5. Construct the prediction matrices Φ(Vfull)andΓ(Vfull). \Phi(V_{\mathrm{full}}) \quad \text{and} \quad \Gamma(V_{\mathrm{full}}).
  6. Solve the nonlinear optimization problem using SLSQP to obtain Uc∗andVc∗. U_c^\ast \quad \text{and} \quad V_c^\ast.
  7. Apply only the first elements of the optimal sequences: uk=ΠUc∗,vk=ΠVc∗. u_k = \Pi U_c^\ast, \quad v_k = \Pi V_c^\ast.
  8. Update the system state and output: xk+1=A(vk)xk+B(vk)uk,yk=Cxk. x_{k+1} = A(v_k)x_k + B(v_k)u_k, \quad y_k=Cx_k.
  9. Shift the prediction horizon and repeat the optimization for k+1k+1 until k=Nend−1k=N_{\mathrm{end}}-1.

3.4.1Results

The closed-loop bilinear controller was evaluated using the same system and parameter settings as in the open-loop implementation.

However, the sequences U∗U^\ast and V∗V^\ast are not computed only once. Instead, a new nonlinear optimization problem is solved at every sampling instant using the current state of the system.

Bilinear Closed Loop

Figure 3.2: Closed-loop output tracking performance of the bilinear system, left-side is the case when N=2, and right-side is the case when N=10

4Stochastic Model

4.1Stochastic System

A stochastic discrete-time linear system can be written as

xk+1=Axk+Buk+wkyk=Cxk+vk\begin{align*} x_{k+1} &= Ax_k + Bu_k + w_k \tag{4.1}\\ y_k &= Cx_k + v_k \tag{4.2}\end{align*}

where wkw_k represents the process noise and vkv_k represents the measurement noise. The noise terms are assumed to be zero-mean Gaussian random variables,

wk∼N(0,Rw)vk∼N(0,Rv)\begin{align*} w_k &\sim \mathcal{N}(0,R_w)\tag{4.3}\\ v_k &\sim \mathcal{N}(0,R_v) \tag{4.4}\end{align*}

and the initial state is assumed to be Gaussian distributed as

x0∼N(μ0,P0)(4.5) x_0 \sim \mathcal{N}(\mu_0,P_0) \tag{4.5}

Under these assumptions, the state distribution at time step kk is characterized by its mean and covariance:

xk∼N(μk,Pk)(4.6) x_k \sim \mathcal{N}(\mu_k,P_k) \tag{4.6}

4.1.1State Mean

The mean of the state is defined as

μk=E[xk](4.7) \mu_k = \mathbb{E}[x_k] \tag{4.7}

Taking the expectation of the state equation gives

μk+1=E[xk+1]=E[Axk+Buk+wk]\begin{align*} \mu_{k+1} &= \mathbb{E}[x_{k+1}] \tag{4.8}\\ &= \mathbb{E}[Ax_k+Bu_k+w_k] \tag{4.9}\end{align*}

Using the linearity of expectation,

μk+1=AE[xk]+BE[uk]+E[wk](4.10) \mu_{k+1} = A\mathbb{E}[x_k] + B\mathbb{E}[u_k] + \mathbb{E}[w_k] \tag{4.10}

Assuming that the control input uku_k is deterministic and using

E[wk]=0(4.11) \mathbb{E}[w_k]=0 \tag{4.11}

the state mean evolves according to

μk+1=Aμk+Buk(4.12) \boxed{ \mu_{k+1} = A\mu_k + Bu_k } \tag{4.12}

Therefore, the control input shifts the mean of the state distribution.

4.1.2State Covariance

The state covariance is defined as

Pk=E[(xk−μk)(xk−μk)T](4.13) P_k = \mathbb{E} \left[ (x_k-\mu_k) (x_k-\mu_k)^T \right] \tag{4.13}

From Equation (4.1) and Equation (4.12),

xk+1−μk+1=Axk+Buk+wk−(Aμk+Buk)=A(xk−μk)+wk\begin{align*} x_{k+1}-\mu_{k+1} &= Ax_k+Bu_k+w_k - \left( A\mu_k+Bu_k \right) \tag{4.14}\\ &= A(x_k-\mu_k)+w_k \tag{4.15}\end{align*}

Hence,

Pk+1=E[(xk+1−μk+1)(xk+1−μk+1)T]=E[(A(xk−μk)+wk)(A(xk−μk)+wk)T]\begin{align*} P_{k+1} &= \mathbb{E} \left[ (x_{k+1}-\mu_{k+1}) (x_{k+1}-\mu_{k+1})^T \right] \tag{4.16}\\ &= \mathbb{E} \left[ \left( A(x_k-\mu_k)+w_k \right) \left( A(x_k-\mu_k)+w_k \right)^T \right] \tag{4.17}\end{align*}

Expanding the product gives

Pk+1=AE[(xk−μk)(xk−μk)T]AT+E[wkwkT]+AE[(xk−μk)wkT]+E[wk(xk−μk)T]AT\begin{align*} P_{k+1} &= A \mathbb{E} \left[ (x_k-\mu_k) (x_k-\mu_k)^T \right] A^T \\ &\quad+ \mathbb{E}[w_kw_k^T] \\ &\quad+ A \mathbb{E} \left[ (x_k-\mu_k)w_k^T \right] \\ &\quad+ \mathbb{E} \left[ w_k(x_k-\mu_k)^T \right] A^T \tag{4.18}\end{align*}

Assuming that the process noise wkw_k is independent of the state deviation xk−μkx_k-\mu_k, the cross terms are zero. Since

E[wkwkT]=Rw(4.19) \mathbb{E}[w_kw_k^T]=R_w \tag{4.19}

the covariance recursion becomes

Pk+1=APkAT+Rw(4.20) \boxed{ P_{k+1} = AP_kA^T+R_w } \tag{4.20}

Thus, the state uncertainty propagates through the system dynamics and increases due to the process noise.

4.1.3Output Mean

The stochastic output equation is

yk=Cxk+vk(4.21) y_k=Cx_k+v_k \tag{4.21}

The mean of the output is therefore

μy,k=E[yk]=E[Cxk+vk]\begin{align*} \mu_{y,k} &= \mathbb{E}[y_k] \tag{4.22}\\ &= \mathbb{E}[Cx_k+v_k] \tag{4.23}\end{align*}

Using the linearity of expectation and

E[vk]=0(4.24) \mathbb{E}[v_k]=0 \tag{4.24}

we obtain

μy,k=Cμk(4.25) \boxed{ \mu_{y,k} = C\mu_k } \tag{4.25}

4.1.4Output Covariance

The output covariance is defined as

Py,k=E[(yk−μy,k)(yk−μy,k)T](4.26) P_{y,k} = \mathbb{E} \left[ (y_k-\mu_{y,k}) (y_k-\mu_{y,k})^T \right] \tag{4.26}

Using

xk=μk+ek(4.27) x_k=\mu_k+e_k \tag{4.27}

where

ek=xk−μkE[ek]=0(4.28) e_k=x_k-\mu_k \qquad \mathbb{E}[e_k]=0 \tag{4.28}

the output can be expressed as

yk=C(μk+ek)+vk=Cμk+Cek+vk\begin{align*} y_k &= C(\mu_k+e_k)+v_k \tag{4.29}\\ &= C\mu_k+Ce_k+v_k \tag{4.30}\end{align*}

Since

μy,k=Cμk(4.31) \mu_{y,k}=C\mu_k \tag{4.31}

the output deviation from its mean is

yk−μy,k=Cek+vk(4.32) y_k-\mu_{y,k} = Ce_k+v_k \tag{4.32}

Therefore,

Py,k=E[(Cek+vk)(Cek+vk)T]\begin{align*} P_{y,k} &= \mathbb{E} \left[ (Ce_k+v_k) (Ce_k+v_k)^T \right] \tag{4.33}\end{align*}

Expanding the expression gives

Py,k=CE[ekekT]CT+E[vkvkT]+CE[ekvkT]+E[vkekT]CT\begin{align*} P_{y,k} &= C \mathbb{E}[e_ke_k^T] C^T + \mathbb{E}[v_kv_k^T] \\ &\quad+ C\mathbb{E}[e_kv_k^T] + \mathbb{E}[v_ke_k^T]C^T \tag{4.34}\end{align*}

Assuming that the measurement noise vkv_k is independent of the state error eke_k, the cross terms vanish. Since

E[ekekT]=Pk(4.35) \mathbb{E}[e_ke_k^T]=P_k \tag{4.35}

and

E[vkvkT]=Rv,(4.36) \mathbb{E}[v_kv_k^T]=R_v, \tag{4.36}

the output covariance becomes

Py,k=CPkCT+Rv(4.37) \boxed{ P_{y,k} = CP_kC^T+R_v } \tag{4.37}

Therefore, the stochastic state and output distributions are completely characterized by the following recursive equations:

μk+1=Aμk+Buk,Pk+1=APkAT+Rw,μy,k=Cμk,Py,k=CPkCT+Rv\begin{align*} \mu_{k+1} &= A\mu_k+Bu_k,\tag{4.38}\\ P_{k+1} &= AP_kA^T+R_w,\tag{4.39}\\ \mu_{y,k} &= C\mu_k,\tag{4.40}\\ P_{y,k} &= CP_kC^T+R_v \tag{4.41}\end{align*}

Hence,

xk∼N(μk,Pk)(4.42) x_k \sim \mathcal{N}(\mu_k,P_k) \tag{4.42}

while the corresponding output distribution is

yk∼N(μy,k,Py,k)(4.43) y_k \sim \mathcal{N} \left( \mu_{y,k}, P_{y,k} \right) \tag{4.43}

4.2Model with Chance Constraints

In stochastic systems, the output cannot in general be guaranteed to remain inside deterministic bounds at every time step because of the presence of uncertainty. Instead, the constraints can be imposed probabilistically using chance constraints.

For each prediction step kk, the output is required to satisfy

P(ymin⁡≤yk≤ymax⁡)≥1−α,k=1,…,N(4.44) \mathbb{P} \left( y_{\min} \leq y_k \leq y_{\max} \right) \geq 1-\alpha, \qquad k=1,\ldots,N \tag{4.44}

where α\alpha denotes the allowed probability of constraint violation.

The total violation probability is divided between the upper and lower bounds according to

αupper+αlower=α(4.45) \alpha_{\mathrm{upper}} + \alpha_{\mathrm{lower}} = \alpha \tag{4.45}

The two-sided chance constraint can therefore be handled through separate upper and lower probabilistic constraints.

Upper Chance Constraint

The upper output constraint is

P(yk≤ymax⁡)≥1−αupper(4.46) \mathbb{P} \left( y_k \leq y_{\max} \right) \geq 1-\alpha_{\mathrm{upper}} \tag{4.46}

Since

yk∼N(μy,k,σy,k2)(4.47) y_k \sim \mathcal{N} \left( \mu_{y,k}, \sigma_{y,k}^2 \right) \tag{4.47}

the output can be standardized as

Z=yk−μy,kσy,k,Z∼N(0,1)(4.48) Z = \frac{ y_k-\mu_{y,k} }{ \sigma_{y,k} }, \qquad Z\sim\mathcal{N}(0,1) \tag{4.48}

Therefore,

P(yk≤ymax⁡)=P(Z≤ymax⁡−μy,kσy,k)\begin{align*} \mathbb{P} \left( y_k\leq y_{\max} \right) &= \mathbb{P} \left( Z \leq \frac{ y_{\max}-\mu_{y,k} }{ \sigma_{y,k} } \right) \tag{4.49}\end{align*}

Using the cumulative distribution function Φ(⋅)\Phi(\cdot) of the standard normal distribution,

Φ(ymax⁡−μy,kσy,k)≥1−αupper(4.50) \Phi \left( \frac{ y_{\max}-\mu_{y,k} }{ \sigma_{y,k} } \right) \geq 1-\alpha_{\mathrm{upper}} \tag{4.50}

Applying the inverse standard normal cumulative distribution function yields

ymax⁡−μy,kσy,k≥Φ−1(1−αupper)(4.51) \frac{ y_{\max}-\mu_{y,k} }{ \sigma_{y,k} } \geq \Phi^{-1} \left( 1-\alpha_{\mathrm{upper}} \right) \tag{4.51}

Rearranging gives

μy,k≤ymax⁡−Φ−1(1−αupper)σy,k(4.52) \mu_{y,k} \leq y_{\max} - \Phi^{-1} \left( 1-\alpha_{\mathrm{upper}} \right) \sigma_{y,k} \tag{4.52}

Lower Chance Constraint

Similarly, the lower output constraint is

P(yk≥ymin⁡)≥1−αlower(4.53) \mathbb{P} \left( y_k \geq y_{\min} \right) \geq 1-\alpha_{\mathrm{lower}} \tag{4.53}

Following the same standardization procedure gives

μy,k≥ymin⁡+Φ−1(1−αlower)σy,k(4.54) \mu_{y,k} \geq y_{\min} + \Phi^{-1} \left( 1-\alpha_{\mathrm{lower}} \right) \sigma_{y,k} \tag{4.54}

Reformulation

From the stochastic output model,

μy,k=Cμk(4.55) \mu_{y,k} = C\mu_k \tag{4.55}

and

Py,k=CPkCT+Rv(4.56) P_{y,k} = CP_kC^T+R_v \tag{4.56}

For a scalar output, the standard deviation is therefore

σy,k=CPkCT+Rv(4.57) \sigma_{y,k} = \sqrt{ CP_kC^T+R_v } \tag{4.57}

Substituting these expressions into the deterministic chance constraints gives

Cμk≤ymax⁡−Φ−1(1−αupper)CPkCT+Rv(4.58) C\mu_k \leq y_{\max} - \Phi^{-1} \left( 1-\alpha_{\mathrm{upper}} \right) \sqrt{ CP_kC^T+R_v } \tag{4.58}

and

Cμk≥ymin⁡+Φ−1(1−αlower)CPkCT+Rv(4.59) C\mu_k \geq y_{\min} + \Phi^{-1} \left( 1-\alpha_{\mathrm{lower}} \right) \sqrt{ CP_kC^T+R_v } \tag{4.59}

The resulting deterministic limits are referred to as the tight bounds. They are defined as

y~min⁡,k=ymin⁡+Φ−1(1−αlower)σy,k(4.60) \boxed{ \tilde{y}_{\min,k} = y_{\min} + \Phi^{-1} \left( 1-\alpha_{\mathrm{lower}} \right) \sigma_{y,k} } \tag{4.60}

and

y~max⁡,k=ymax⁡−Φ−1(1−αupper)σy,k(4.61) \boxed{ \tilde{y}_{\max,k} = y_{\max} - \Phi^{-1} \left( 1-\alpha_{\mathrm{upper}} \right) \sigma_{y,k} } \tag{4.61}

Hence, the original probabilistic constraint can be enforced through the deterministic condition

y~min⁡,k≤Cμk≤y~max⁡,k(4.62) \boxed{ \tilde{y}_{\min,k} \leq C\mu_k \leq \tilde{y}_{\max,k} } \tag{4.62}

The tight bounds shrink the original feasible output interval in order to account for stochastic uncertainty. The amount of tightening depends on the output standard deviation σy,k\sigma_{y,k} and on the selected violation probabilities.

A larger uncertainty results in a larger distance between the original bounds and the tight bounds. Similarly, selecting a smaller violation probability increases that difference.

4.3Stacked Forms Derivation

For optimization over a finite prediction horizon, the state means, output means, and control inputs are collected into stacked vectors. This allows the stochastic control problem to be expressed in a compact matrix form.

4.3.1Stacked Prediction Matrices

The mean-state dynamics are given by

μk+1=Aμk+Buk(4.63) \mu_{k+1} = A\mu_k+Bu_k \tag{4.63}

Starting from the initial mean μ0\mu_0, the first predicted mean is

μ1=Aμ0+Bu0(4.64) \mu_1 = A\mu_0+Bu_0 \tag{4.64}

The second predicted mean is

μ2=Aμ1+Bu1=A(Aμ0+Bu0)+Bu1=A2μ0+ABu0+Bu1\begin{align*} \mu_2 &= A\mu_1+Bu_1 \tag{4.65}\\ &= A(A\mu_0+Bu_0)+Bu_1 \tag{4.66}\\ &= A^2\mu_0+ABu_0+Bu_1 \tag{4.67}\end{align*}

Similarly,

μ3=A3μ0+A2Bu0+ABu1+Bu2(4.68) \mu_3 = A^3\mu_0 + A^2Bu_0 + ABu_1 + Bu_2 \tag{4.68}

The state means over a prediction horizon NN are stacked as

M=[μ1μ2⋮μN](4.69) M = \begin{bmatrix} \mu_1 \\ \mu_2 \\ \vdots \\ \mu_N \end{bmatrix} \tag{4.69}

while the control inputs are collected in

U=[u0u1⋮uN−1](4.70) U = \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_{N-1} \end{bmatrix} \tag{4.70}

The stacked mean-state prediction can therefore be written as

M=Aμ0+BU(4.71) \boxed{ M = \mathcal{A}\mu_0 + \mathcal{B}U } \tag{4.71}

where

A=[AA2⋮AN](4.72) \mathcal{A} = \begin{bmatrix} A \\ A^2 \\ \vdots \\ A^N \end{bmatrix} \tag{4.72}

and

B=[B0⋯0ABB⋯0A2BAB⋯0⋮⋮⋱⋮AN−1BAN−2B⋯B](4.73) \mathcal{B} = \begin{bmatrix} B & 0 & \cdots & 0 \\ AB & B & \cdots & 0 \\ A^2B & AB & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ A^{N-1}B & A^{N-2}B & \cdots & B \end{bmatrix} \tag{4.73}

The output mean at each prediction step is

μy,k=Cμk(4.74) \mu_{y,k}=C\mu_k \tag{4.74}

The stacked output-mean vector is therefore defined as

My=[μy,1μy,2⋮μy,N](4.75) M_y = \begin{bmatrix} \mu_{y,1} \\ \mu_{y,2} \\ \vdots \\ \mu_{y,N} \end{bmatrix} \tag{4.75}

Defining the block-diagonal output matrix

C=IN⊗C(4.76) \mathcal{C} = I_N\otimes C \tag{4.76}

the stacked output means satisfy

My=CM(4.77) M_y = \mathcal{C}M \tag{4.77}

Substituting Equation (4.71) gives

My=CAμ0+CBU(4.78) M_y = \mathcal{C}\mathcal{A}\mu_0 + \mathcal{C}\mathcal{B}U \tag{4.78}

Introducing

F=CA,G=CB(4.79) F = \mathcal{C}\mathcal{A}, \qquad G = \mathcal{C}\mathcal{B} \tag{4.79}

the stacked output-mean prediction becomes

My=Fμ0+GU(4.80) \boxed{ M_y = F\mu_0+GU } \tag{4.80}

4.3.2Stacked Cost Function

For a stochastic output,

yk=μy,k+ey,k(4.81) y_k = \mu_{y,k} + e_{y,k} \tag{4.81}

where

E[ey,k]=0(4.82) \mathbb{E}[e_{y,k}]=0 \tag{4.82}

The expected quadratic tracking cost at one prediction step is

E[(yk−yˉk)TQ(yk−yˉk)](4.83) \mathbb{E} \left[ (y_k-\bar{y}_k)^T Q (y_k-\bar{y}_k) \right] \tag{4.83}

Substituting

yk=μy,k+ey,k(4.84) y_k=\mu_{y,k}+e_{y,k} \tag{4.84}

gives

E[(yk−yˉk)TQ(yk−yˉk)]=(μy,k−yˉk)TQ(μy,k−yˉk)+E[ey,kTQey,k]\begin{align*} &\mathbb{E} \left[ (y_k-\bar{y}_k)^T Q (y_k-\bar{y}_k) \right] \\ &= (\mu_{y,k}-\bar{y}_k)^T Q (\mu_{y,k}-\bar{y}_k) + \mathbb{E} \left[ e_{y,k}^T Qe_{y,k} \right] \tag{4.85}\end{align*}

Using the trace identity

xTQx=tr⁡(QxxT)(4.86) x^TQx = \operatorname{tr} \left( Qxx^T \right) \tag{4.86}

the second term can be written as

E[ey,kTQey,k]=tr⁡(QE[ey,key,kT])=tr⁡(QPy,k)\begin{align*} \mathbb{E} \left[ e_{y,k}^TQe_{y,k} \right] &= \operatorname{tr} \left( Q \mathbb{E} [e_{y,k}e_{y,k}^T] \right) \tag{4.87}\\ &= \operatorname{tr} \left( QP_{y,k} \right) \tag{4.88}\end{align*}

Since

Py,k=CPkCT+Rv(4.89) P_{y,k} = CP_kC^T+R_v \tag{4.89}

the expected tracking cost becomes

E[(yk−yˉk)TQ(yk−yˉk)]=(μy,k−yˉk)TQ(μy,k−yˉk)+tr⁡[Q(CPkCT+Rv)]\begin{align*} &\mathbb{E} \left[ (y_k-\bar{y}_k)^T Q (y_k-\bar{y}_k) \right] \\ &= (\mu_{y,k}-\bar{y}_k)^T Q (\mu_{y,k}-\bar{y}_k) + \operatorname{tr} \left[ Q(CP_kC^T+R_v) \right] \tag{4.90}\end{align*}

For the additive-noise stochastic system considered here, the covariance recursion

Pk+1=APkAT+Rw(4.91) P_{k+1} = AP_kA^T+R_w \tag{4.91}

does not depend on the deterministic control input uku_k. Therefore,

tr⁡[Q(CPkCT+Rv)](4.92) \operatorname{tr} \left[ Q(CP_kC^T+R_v) \right] \tag{4.92}

is constant with respect to the optimization variable UU and can be omitted when determining the optimal control sequence.

The resulting optimization objective is therefore

ϕopt=12∑k=0N−1[(Cμk+1−yˉk+1)TQ(Cμk+1−yˉk+1)+ukTRuk](4.93) \phi_{\mathrm{opt}} = \frac{1}{2} \sum_{k=0}^{N-1} \left[ (C\mu_{k+1}-\bar{y}_{k+1})^T Q (C\mu_{k+1}-\bar{y}_{k+1}) + u_k^TRu_k \right] \tag{4.93}

Define the stacked reference vector as

Yˉref=[yˉ1yˉ2⋮yˉN](4.94) \bar{Y}_{\mathrm{ref}} = \begin{bmatrix} \bar{y}_1 \\ \bar{y}_2 \\ \vdots \\ \bar{y}_N \end{bmatrix} \tag{4.94}

and let the stacked weighting matrices be

Qˉ=blkdiag⁡(Q,…,Q)Rˉ=blkdiag⁡(R,…,R)\begin{align*} \bar{Q} &= \operatorname{blkdiag} \left( Q,\ldots,Q \right)\tag{4.95}\\ \bar{R} &= \operatorname{blkdiag} \left( R,\ldots,R \right) \tag{4.96}\end{align*}

Using

My=Fμ0+GU(4.97) M_y=F\mu_0+GU \tag{4.97}

the stacked cost function becomes

ϕ=12[(Fμ0+GU−Yˉref)TQˉ(Fμ0+GU−Yˉref)+UTRˉU](4.98) \phi = \frac{1}{2} \left[ (F\mu_0+GU-\bar{Y}_{\mathrm{ref}})^T \bar{Q} (F\mu_0+GU-\bar{Y}_{\mathrm{ref}}) + U^T\bar{R}U \right] \tag{4.98}

Expanding Equation (4.98) gives

ϕ=12UT(GTQˉG+Rˉ)U+(Fμ0−Yˉref)TQˉG U+const\begin{align*} \phi &= \frac{1}{2} U^T \left( G^T\bar{Q}G+\bar{R} \right) U \\ &\quad+ (F\mu_0-\bar{Y}_{\mathrm{ref}})^T \bar{Q}G\,U + \text{const} \tag{4.99}\end{align*}

Define

H=GTQˉG+Rˉ(4.100) H = G^T\bar{Q}G+\bar{R} \tag{4.100}

and

f=GTQˉ(Fμ0−Yˉref)(4.101) f = G^T \bar{Q} \left( F\mu_0-\bar{Y}_{\mathrm{ref}} \right) \tag{4.101}

The cost function can then be written in standard quadratic-programming form as

ϕ(U)=12UTHU+fTU(4.102) \boxed{ \phi(U) = \frac{1}{2}U^THU + f^TU } \tag{4.102}

For the unconstrained problem, the stationary condition is

∂ϕ∂U=HU+f=0(4.103) \frac{\partial\phi}{\partial U} = HU+f = 0 \tag{4.103}

and therefore

U∗=−H−1f(4.104) U^\ast = -H^{-1}f \tag{4.104}

4.3.3Stacked Chance Constraints

From the chance-constraint derivation, the deterministic tight bounds at each prediction step are

y~min⁡,k≤μy,k≤y~max⁡,k(4.105) \tilde{y}_{\min,k} \leq \mu_{y,k} \leq \tilde{y}_{\max,k} \tag{4.105}

The tight lower and upper bounds are stacked as

Y~min⁡=[y~min⁡,1y~min⁡,2⋮y~min⁡,N](4.106) \tilde{Y}_{\min} = \begin{bmatrix} \tilde{y}_{\min,1} \\ \tilde{y}_{\min,2} \\ \vdots \\ \tilde{y}_{\min,N} \end{bmatrix} \tag{4.106}

and

Y~max⁡=[y~max⁡,1y~max⁡,2⋮y~max⁡,N](4.107) \tilde{Y}_{\max} = \begin{bmatrix} \tilde{y}_{\max,1} \\ \tilde{y}_{\max,2} \\ \vdots \\ \tilde{y}_{\max,N} \end{bmatrix} \tag{4.107}

Therefore, the stacked deterministic chance constraint becomes

Y~min⁡≤My≤Y~max⁡(4.108) \boxed{ \tilde{Y}_{\min} \leq M_y \leq \tilde{Y}_{\max} } \tag{4.108}

Using

My=Fμ0+GU(4.109) M_y = F\mu_0+GU \tag{4.109}

this becomes

Y~min⁡≤Fμ0+GU≤Y~max⁡(4.110) \tilde{Y}_{\min} \leq F\mu_0+GU \leq \tilde{Y}_{\max} \tag{4.110}

Rearranging with respect to the optimization variable UU gives

Y~min⁡−Fμ0≤GU≤Y~max⁡−Fμ0(4.111) \boxed{ \tilde{Y}_{\min}-F\mu_0 \leq GU \leq \tilde{Y}_{\max}-F\mu_0 } \tag{4.111}

Overview

Combining the stacked cost function and the tight chance constraints, the stochastic optimal control problem can be written as

min⁡U12UTHU+fTUsubject toY~min⁡−Fμ0≤GU≤Y~max⁡−Fμ0(4.112) \boxed{ \begin{aligned} \min_U \quad & \frac{1}{2}U^THU+f^TU \\[1mm] \text{subject to} \quad & \tilde{Y}_{\min}-F\mu_0 \leq GU \leq \tilde{Y}_{\max}-F\mu_0 \end{aligned} } \tag{4.112}

4.4Open-Loop Implementation

The open-loop implementation follows the same general structure as the deterministic LTI open-loop case. The optimal input sequence is computed once at the beginning of the simulation and is not updated afterwards.

For the stochastic system, however, the resulting controller performance is evaluated using Monte Carlo simulation. A single optimal control sequence U∗U^\ast is first obtained from the stochastic optimization problem. The same sequence is then applied to a large number of independently generated monte carlo trajectories.

The optimization problem is

min⁡U12UTHU+fTUsubject toY~min⁡−Fμ0≤GU≤Y~max⁡−Fμ0(4.113) \begin{aligned} \min_U \quad & \frac{1}{2}U^THU+f^TU \\ \text{subject to} \quad & \tilde{Y}_{\min}-F\mu_0 \leq GU \leq \tilde{Y}_{\max}-F\mu_0 \end{aligned} \tag{4.113}

Solving this problem yields the optimal open-loop input sequence

U∗=[u0∗u1∗⋮uN−1∗](4.114) U^\ast = \begin{bmatrix} u_0^\ast \\ u_1^\ast \\ \vdots \\ u_{N-1}^\ast \end{bmatrix} \tag{4.114}

This sequence is calculated only once using the initial mean and covariance, the reference trajectory, and the tight output bounds.

The stochastic open-loop procedure can therefore be summarized as follows:

  1. Select NN, μ0\mu_0, P0P_0, QQ, RR, RwR_w, RvR_v, the reference trajectory, and the chance-constraint parameters.
  2. Propagate the state covariance and construct the corresponding tight bounds

    Y~min⁡,Y~max⁡ \tilde{Y}_{\min}, \qquad \tilde{Y}_{\max}
  3. Construct the stacked prediction matrices and the quadratic-programming matrices HH and ff.
  4. Solve the stochastic open-loop optimization problem once to obtain

    U∗ U^\ast
  5. Generate nMCn_{\mathrm{MC}} independent Monte Carlo realizations of the initial state and stochastic noise.
  6. Apply the same optimal sequence U∗U^\ast to every Monte Carlo trajectory.
  7. Simulate all trajectories using the stochastic state and output equations.
  8. Evaluate the resulting tracking performance and the empirical constraint-satisfaction probability.

4.4.1Results

The stochastic open-loop controller was evaluated using a two-state linear system over a prediction horizon of

N=30(4.115) N = 30 \tag{4.115}

The system matrices were selected as

A=[0.901.000.000.50],B=[0.01.0](4.116) A = \begin{bmatrix} 0.90 & 1.00 \\ 0.00 & 0.50 \end{bmatrix}, \qquad B = \begin{bmatrix} 0.0 \\ 1.0 \end{bmatrix} \tag{4.116}

with both states directly observed at the output:

C=[1001](4.117) C = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \tag{4.117}

The state and input weighting matrices were chosen as

Q=I2,R=0.1(4.118) Q = I_2, \qquad R = 0.1 \tag{4.118}

The process and measurement noise covariance matrices were defined as

Rw=[0.005000.005](4.119) R_w = \begin{bmatrix} 0.005 & 0 \\ 0 & 0.005 \end{bmatrix} \tag{4.119}

and

Rv=[0.005000.005](4.120) R_v = \begin{bmatrix} 0.005 & 0 \\ 0 & 0.005 \end{bmatrix} \tag{4.120}

The initial state distribution was specified by

μ0=[00](4.121) \mu_0 = \begin{bmatrix} 0 \\ 0 \end{bmatrix} \tag{4.121}

and

P0=[0.01000.01](4.122) P_0 = \begin{bmatrix} 0.01 & 0 \\ 0 & 0.01 \end{bmatrix} \tag{4.122}

The output constraints were imposed equally on both outputs as

ymin⁡=[−1.7−1.7]ymax⁡=[3.53.5](4.123) y_{\min} = \begin{bmatrix} -1.7 \\ -1.7 \end{bmatrix} \qquad y_{\max} = \begin{bmatrix} 3.5 \\ 3.5 \end{bmatrix} \tag{4.123}

The upper and lower risk allocations were selected as

αlower=0.01,αupper=0.01(4.124) \alpha_{\mathrm{lower}} = 0.01, \qquad \alpha_{\mathrm{upper}} = 0.01 \tag{4.124}

These values were used to compute the corresponding tight bounds at each prediction step according to the propagated output covariance.

The reference trajectory was divided into two operating periods. During the first 15 steps, the desired output was

yˉ(1)=[3.1−1.3](4.125) \bar{y}^{(1)} = \begin{bmatrix} 3.1 \\ -1.3 \end{bmatrix} \tag{4.125}

while during the second 15 steps the reference was changed to

yˉ(2)=[−1.33.1](4.126) \bar{y}^{(2)} = \begin{bmatrix} -1.3 \\ 3.1 \end{bmatrix} \tag{4.126}

Thus, the reference schedule is

yˉk={[ 3.1    −1.3 ]T,k=1,…,15[ −1.3    3.1 ]T,k=16,…,30(4.127) \bar{y}_k = \begin{cases} [\,3.1 \;\; -1.3\,]^T, & k=1,\ldots,15\\[1mm] [\,-1.3 \;\; 3.1\,]^T, & k=16,\ldots,30 \end{cases} \tag{4.127}

The control input was constrained by

−5.0≤uk≤5.0(4.128) -5.0 \leq u_k \leq 5.0 \tag{4.128}

A single optimal open-loop input sequence U∗U^\ast was obtained by solving the stacked stochastic optimization problem. This same sequence was then applied to all Monte Carlo trajectories.

stochastic open loop

Figure 4.1: Monte Carlo output trajectories for the stochastic open-loop implementation together with the reference trajectory, original output constraints, and tight bounds

4.5Closed-Loop Implementation

The closed-loop stochastic implementation follows the same receding-horizon structure used in the LTI closed-loop Case. The main difference is that the controller is evaluated using Monte Carlo simulation, and each stochastic realization solves its own optimization problem using its own current state.

For each Monte Carlo trajectory jj, the initial state is sampled independently as

x0(j)∼N(μ0,P0)(4.129) x_0^{(j)} \sim \mathcal{N}(\mu_0,P_0) \tag{4.129}

Since the realizations start from different initial conditions and are affected by independent process and measurement noise, the state of each trajectory evolves differently.

At every time step kk, each trajectory therefore constructs and solves its own model predictive control problem.

The stochastic closed-loop implementation can therefore be summarized as follows:

  1. Select NN, NcN_c, NendN_{\mathrm{end}}, QQ, RR, RwR_w, RvR_v, the reference trajectory, and the chance-constraint parameters.
  2. Generate nMCn_{\mathrm{MC}} independent initial states

    x0(j)∼N(μ0,P0) x_0^{(j)} \sim \mathcal{N}(\mu_0,P_0)
  3. For each Monte Carlo trajectory jj, use its current state xk(j)x_k^{(j)} as the initial condition of the MPC prediction.
  4. Construct the reference vector Yˉk\bar{Y}_k over the current prediction horizon.
  5. Construct the corresponding tight bounds

    Y~min⁡,k,Y~max⁡,k \tilde{Y}_{\min,k}, \qquad \tilde{Y}_{\max,k}
  6. Solve a separate constrained MPC problem for each Monte Carlo realization to obtain

    Uk∗,(j) U_k^{\ast,(j)}
  7. Apply only the first control action

    uk(j)=uk∣k∗,(j) u_k^{(j)} = u_{k|k}^{\ast,(j)}
  8. Sample the process and measurement noise and update each stochastic trajectory independently.
  9. Shift the prediction horizon and repeat the optimization for every realization at the next time step.
  10. Continue until k=Nend−1k=N_{\mathrm{end}}-1.

4.5.1Results

The closed-loop stochastic controller was evaluated using the same system, noise levels, output constraints, reference trajectory, and weighting matrices used in the open-loop experiment.

stochastic closed loop

Figure 4.2: Monte Carlo output trajectories for the stochastic closed-loop implementation together with the reference trajectory, original output constraints, and tight bounds

5Stochastic Bilinear Model with Chance Constraints

5.1Stochastic Bilinear System

A stochastic bilinear system is considered in the form

xk+1=A(vk)xk+B(vk)uk+wkyk=Cxk+ηk\begin{align*} x_{k+1} &= A(v_k)x_k + B(v_k)u_k + w_k \tag{5.1}\\ y_k &= Cx_k+\eta_k \tag{5.2}\end{align*}

where uku_k denotes the control input and vkv_k is the bilinear scheduling variable. The stochastic disturbances are assumed to be zero-mean Gaussian,

wk∼N(0,Rw)ηk∼N(0,Rη)\begin{align*} w_k &\sim \mathcal{N}(0,R_w)\tag{5.3}\\ \eta_k &\sim \mathcal{N}(0,R_\eta) \tag{5.4}\end{align*}

and the initial state is distributed according to

x0∼N(μ0,P0)(5.5) x_0 \sim \mathcal{N}(\mu_0,P_0) \tag{5.5}

For compactness, the time-varying system matrices are denoted by

Ak=A(vk),Bk=B(vk)(5.6) A_k=A(v_k), \qquad B_k=B(v_k) \tag{5.6}

5.1.1System Matrices

The state distribution at time step kk is characterized by its mean and covariance,

xk∼N(μk,Pk)(5.7) x_k \sim \mathcal{N}(\mu_k,P_k) \tag{5.7}

The state mean is defined as

μk=E[xk](5.8) \mu_k=\mathbb{E}[x_k] \tag{5.8}

Taking the expectation of Equation (5.1) gives

μk+1=E[Akxk+Bkuk+wk]=AkE[xk]+Bkuk+E[wk]\begin{align*} \mu_{k+1} &= \mathbb{E} \left[ A_kx_k+B_ku_k+w_k \right] \tag{5.9}\\ &= A_k\mathbb{E}[x_k] + B_ku_k + \mathbb{E}[w_k] \tag{5.10}\end{align*}

Since the process noise is zero mean,

μk+1=Akμk+Bkuk(5.11) \boxed{ \mu_{k+1} = A_k\mu_k+B_ku_k } \tag{5.11}

To derive the covariance, the state is decomposed as

xk=μk+ek,(5.12) x_k=\mu_k+e_k, \tag{5.12}

where

ek=xk−μk,E[ek]=0(5.13) e_k=x_k-\mu_k, \qquad \mathbb{E}[e_k]=0 \tag{5.13}

Using the state and mean equations,

xk+1=Akμk+Bkuk+Akek+wkμk+1=Akμk+Bkuk\begin{align*} x_{k+1} &= A_k\mu_k+B_ku_k+A_ke_k+w_k\tag{5.14}\\ \mu_{k+1} &= A_k\mu_k+B_ku_k \tag{5.15}\end{align*}

and therefore

ek+1=Akek+wk(5.16) e_{k+1} = A_ke_k+w_k \tag{5.16}

The state covariance is

Pk+1=E[ek+1ek+1T](5.17) P_{k+1} = \mathbb{E} \left[ e_{k+1}e_{k+1}^T \right] \tag{5.17}

Substituting the error dynamics gives

Pk+1=E[(Akek+wk)(Akek+wk)T]=AkPkAkT+AkE[ekwkT]+E[wkekT]AkT+Rw\begin{align*} P_{k+1} &= \mathbb{E} \left[ (A_ke_k+w_k) (A_ke_k+w_k)^T \right]\tag{5.18}\\ &= A_kP_kA_k^T + A_k\mathbb{E}[e_kw_k^T] + \mathbb{E}[w_ke_k^T]A_k^T + R_w \tag{5.19}\end{align*}

Assuming that the process noise is independent of the state error, the cross terms vanish, giving

Pk+1=AkPkAkT+Rw(5.20) \boxed{ P_{k+1} = A_kP_kA_k^T+R_w } \tag{5.20}

Since Ak=A(vk)A_k=A(v_k), the propagated covariance depends on the sequence VV. Hence,

Pk=Pk(V)(5.21) P_k=P_k(V) \tag{5.21}

The output mean follows from

yk=Cxk+ηk(5.22) y_k=Cx_k+\eta_k \tag{5.22}

Taking the expectation gives

μy,k=E[yk]=Cμk(5.23) \boxed{ \mu_{y,k} = \mathbb{E}[y_k] = C\mu_k } \tag{5.23}

The corresponding output covariance is

Py,k=CPkCT+Rη(5.24) \boxed{ P_{y,k} = CP_kC^T+R_\eta } \tag{5.24}

Since Pk=Pk(V)P_k=P_k(V),

Py,k=Py,k(V)(5.25) P_{y,k}=P_{y,k}(V) \tag{5.25}

5.1.2Stacked Matrix Derivations

The first predicted state mean is

μ1=A0μ0+B0u0.(5.26) \mu_1=A_0\mu_0+B_0u_0. \tag{5.26}

The second predicted mean becomes

μ2=A1μ1+B1u1=A1A0μ0+A1B0u0+B1u1\begin{align*} \mu_2 &= A_1\mu_1+B_1u_1\tag{5.27}\\ &= A_1A_0\mu_0 + A_1B_0u_0 + B_1u_1 \tag{5.28}\end{align*}

Similarly,

μ3=A2A1A0μ0+A2A1B0u0+A2B1u1+B2u2(5.29) \mu_3 = A_2A_1A_0\mu_0 + A_2A_1B_0u_0 + A_2B_1u_1 + B_2u_2 \tag{5.29}

In general,

μk=Ak−1⋯A0μ0+∑j=0k−1Ak−1⋯Aj+1Bjuj(5.30) \mu_k = A_{k-1}\cdots A_0\mu_0 + \sum_{j=0}^{k-1} A_{k-1}\cdots A_{j+1}B_ju_j \tag{5.30}

where an empty matrix product is interpreted as the identity matrix.

Define the stacked vectors

M=[μ1μ2⋮μN],U=[u0u1⋮uN−1],V=[v0v1⋮vN−1](5.31) M= \begin{bmatrix} \mu_1\\ \mu_2\\ \vdots\\ \mu_N \end{bmatrix}, \qquad U= \begin{bmatrix} u_0\\ u_1\\ \vdots\\ u_{N-1} \end{bmatrix}, \qquad V= \begin{bmatrix} v_0\\ v_1\\ \vdots\\ v_{N-1} \end{bmatrix} \tag{5.31}

The stacked state-mean prediction becomes

M=A(V)μ0+B(V)U(5.32) \boxed{ M = \mathcal{A}(V)\mu_0 + \mathcal{B}(V)U } \tag{5.32}

The matrix A(V)\mathcal{A}(V) is

A(V)=[A0A1A0A2A1A0⋮AN−1AN−2⋯A0](5.33) \mathcal{A}(V) = \begin{bmatrix} A_0\\ A_1A_0\\ A_2A_1A_0\\ \vdots\\ A_{N-1}A_{N-2}\cdots A_0 \end{bmatrix} \tag{5.33}

while

B(V)=[B00⋯0A1B0B1⋯0A2A1B0A2B1⋯0⋮⋮⋱⋮AN−1⋯A1B0AN−1⋯A2B1⋯BN−1](5.34) \mathcal{B}(V) = \begin{bmatrix} B_0 & 0 & \cdots & 0\\ A_1B_0 & B_1 & \cdots & 0\\ A_2A_1B_0 & A_2B_1 & \cdots & 0\\ \vdots & \vdots & \ddots & \vdots\\ A_{N-1}\cdots A_1B_0 & A_{N-1}\cdots A_2B_1 & \cdots & B_{N-1} \end{bmatrix} \tag{5.34}

For the outputs, define

C=IN⊗C.(5.35) \mathcal{C}=I_N\otimes C. \tag{5.35}

The stacked output-mean vector is

My=[μy,1μy,2⋮μy,N]=CM(5.36) M_y = \begin{bmatrix} \mu_{y,1}\\ \mu_{y,2}\\ \vdots\\ \mu_{y,N} \end{bmatrix} = \mathcal{C}M \tag{5.36}

Therefore,

My=CA(V)μ0+CB(V)U(5.37) M_y = \mathcal{C}\mathcal{A}(V)\mu_0 + \mathcal{C}\mathcal{B}(V)U \tag{5.37}

Defining

Φ(V)=CA(V),Γ(V)=CB(V)(5.38) \Phi(V) = \mathcal{C}\mathcal{A}(V), \qquad \Gamma(V) = \mathcal{C}\mathcal{B}(V) \tag{5.38}

gives

My=Φ(V)μ0+Γ(V)U(5.39) \boxed{ M_y = \Phi(V)\mu_0 + \Gamma(V)U } \tag{5.39}

5.2Model with Chance Constraints

The probabilistic output constraint is

P(ymin⁡≤yk≤ymax⁡)≥1−α(5.40) \mathbb{P} \left( y_{\min} \leq y_k \leq y_{\max} \right) \geq 1-\alpha \tag{5.40}

The violation probability is divided as

αlower+αupper=α(5.41) \alpha_{\mathrm{lower}} + \alpha_{\mathrm{upper}} = \alpha \tag{5.41}

For the stochastic bilinear system,

μy,k=Cμk(U,V)(5.42) \mu_{y,k} = C\mu_k(U,V) \tag{5.42}

while

Py,k(V)=CPk(V)CT+Rη(5.43) P_{y,k}(V) = CP_k(V)C^T+R_\eta \tag{5.43}

For a scalar output, the corresponding standard deviation is

σy,k(V)=CPk(V)CT+Rη(5.44) \sigma_{y,k}(V) = \sqrt{ CP_k(V)C^T+R_\eta } \tag{5.44}

The upper chance constraint becomes

Cμk(U,V)≤ymax⁡−ΦN−1(1−αupper)σy,k(V)(5.45) C\mu_k(U,V) \leq y_{\max} - \Phi_{\mathcal{N}}^{-1} \left( 1-\alpha_{\mathrm{upper}} \right) \sigma_{y,k}(V) \tag{5.45}

while the lower constraint becomes

Cμk(U,V)≥ymin⁡+ΦN−1(1−αlower)σy,k(V)(5.46) C\mu_k(U,V) \geq y_{\min} + \Phi_{\mathcal{N}}^{-1} \left( 1-\alpha_{\mathrm{lower}} \right) \sigma_{y,k}(V) \tag{5.46}

where ΦN−1\Phi_{\mathcal{N}}^{-1} denotes the inverse CDF of the standard normal distribution.

The tight bounds are therefore defined as

y~min⁡,k(V)=ymin⁡+ΦN−1(1−αlower)σy,k(V)(5.47) \boxed{ \tilde{y}_{\min,k}(V) = y_{\min} + \Phi_{\mathcal{N}}^{-1} (1-\alpha_{\mathrm{lower}}) \sigma_{y,k}(V) } \tag{5.47}

and

y~max⁡,k(V)=ymax⁡−ΦN−1(1−αupper)σy,k(V)(5.48) \boxed{ \tilde{y}_{\max,k}(V) = y_{\max} - \Phi_{\mathcal{N}}^{-1} (1-\alpha_{\mathrm{upper}}) \sigma_{y,k}(V) } \tag{5.48}

Hence,

y~min⁡,k(V)≤Cμk(U,V)≤y~max⁡,k(V)(5.49) \boxed{ \tilde{y}_{\min,k}(V) \leq C\mu_k(U,V) \leq \tilde{y}_{\max,k}(V) } \tag{5.49}

Define

Y~min⁡(V)=[y~min⁡,1(V)⋮y~min⁡,N(V)](5.50) \tilde{Y}_{\min}(V) = \begin{bmatrix} \tilde{y}_{\min,1}(V)\\ \vdots\\ \tilde{y}_{\min,N}(V) \end{bmatrix} \tag{5.50}

and

Y~max⁡(V)=[y~max⁡,1(V)⋮y~max⁡,N(V)](5.51) \tilde{Y}_{\max}(V) = \begin{bmatrix} \tilde{y}_{\max,1}(V)\\ \vdots\\ \tilde{y}_{\max,N}(V) \end{bmatrix} \tag{5.51}

Using the stacked output-mean prediction,

Y~min⁡(V)≤Φ(V)μ0+Γ(V)U≤Y~max⁡(V)(5.52) \boxed{ \tilde{Y}_{\min}(V) \leq \Phi(V)\mu_0+\Gamma(V)U \leq \tilde{Y}_{\max}(V) } \tag{5.52}

5.3Cost Function Derivation

The expected stochastic objective is defined as

ϕ=12E[(Y−Yˉref)TQ(Y−Yˉref)+UTRUU+VTRVV](5.53) \phi = \frac{1}{2} \mathbb{E} \left[ (Y-\bar{Y}_{\mathrm{ref}})^T Q (Y-\bar{Y}_{\mathrm{ref}}) + U^TR_UU + V^TR_VV \right] \tag{5.53}

Since UU and VV are deterministic optimization variables,

ϕ=12E[(Y−Yˉref)TQ(Y−Yˉref)]+12UTRUU+12VTRVV\begin{align*} \phi &= \frac{1}{2} \mathbb{E} \left[ (Y-\bar{Y}_{\mathrm{ref}})^T Q (Y-\bar{Y}_{\mathrm{ref}}) \right] \\ &\quad+ \frac{1}{2}U^TR_UU + \frac{1}{2}V^TR_VV \tag{5.54}\end{align*}

The stochastic output is decomposed as

Y=My+Ey(5.55) Y=M_y+E_y \tag{5.55}

where

E[Ey]=0(5.56) \mathbb{E}[E_y]=0 \tag{5.56}

Substitution gives

E[(Y−Yˉref)TQ(Y−Yˉref)]=(My−Yˉref)TQ(My−Yˉref)+E[EyTQEy]\begin{align*} &\mathbb{E} \left[ (Y-\bar{Y}_{\mathrm{ref}})^T Q (Y-\bar{Y}_{\mathrm{ref}}) \right] \tag{5.57}\\ &= (M_y-\bar{Y}_{\mathrm{ref}})^T Q (M_y-\bar{Y}_{\mathrm{ref}}) + \mathbb{E}[E_y^TQE_y] \tag{5.58}\end{align*}

Using the trace identity,

E[EyTQEy]=tr⁡(QPY)(5.59) \mathbb{E}[E_y^TQE_y] = \operatorname{tr} \left( QP_Y \right) \tag{5.59}

Therefore,

ϕ=12[(My−Yˉref)TQ(My−Yˉref)+tr⁡(QPY)+UTRUU+VTRVV](5.60) \phi = \frac{1}{2} \left[ (M_y-\bar{Y}_{\mathrm{ref}})^T Q (M_y-\bar{Y}_{\mathrm{ref}}) + \operatorname{tr}(QP_Y) + U^TR_UU + V^TR_VV \right] \tag{5.60}

For the stochastic bilinear model,

My=Φ(V)μ0+Γ(V)U(5.61) M_y = \Phi(V)\mu_0+\Gamma(V)U \tag{5.61}

and the output covariance also depends on VV. Hence,

ϕ(U,V)=12[(Φ(V)μ0+Γ(V)U−Yˉref)TQ(Φ(V)μ0+Γ(V)U−Yˉref)+UTRUU+VTRVV+tr⁡(QPY(V))](5.62) \boxed{ \begin{aligned} \phi(U,V) = \frac{1}{2} \Big[ & \left( \Phi(V)\mu_0 + \Gamma(V)U - \bar{Y}_{\mathrm{ref}} \right)^T Q \left( \Phi(V)\mu_0 + \Gamma(V)U - \bar{Y}_{\mathrm{ref}} \right) \\ &+ U^TR_UU + V^TR_VV + \operatorname{tr} \left( QP_Y(V) \right) \Big] \end{aligned} } \tag{5.62}

5.4Problem Overview

Combining the stochastic bilinear cost function and the chance constraints gives the complete optimization problem

min⁡U,Vϕ(U,V)subject toY~min⁡(V)≤Φ(V)μ0+Γ(V)U≤Y~max⁡(V),Umin⁡≤U≤Umax⁡,Vmin⁡≤V≤Vmax⁡(5.63) \boxed{ \begin{aligned} \min_{U,V} \quad & \phi(U,V) \\[1mm] \text{subject to} \quad & \tilde{Y}_{\min}(V) \leq \Phi(V)\mu_0+\Gamma(V)U \leq \tilde{Y}_{\max}(V), \\ & U_{\min} \leq U \leq U_{\max}, \\ & V_{\min} \leq V \leq V_{\max} \end{aligned} } \tag{5.63}

The decision vector can equivalently be written as

z=[UV](5.64) z= \begin{bmatrix} U\\ V \end{bmatrix} \tag{5.64}

5.5Open-Loop Implementation

The stochastic bilinear open-loop implementation is evaluated using Monte Carlo simulation. A single pair of optimal sequences U∗U^\ast and V∗V^\ast is first obtained by solving the nonlinear optimization problem using SLSQP.

The optimization is performed only once:

(U∗,V∗)=arg⁡min⁡U,Vϕ(U,V)(5.65) (U^\ast,V^\ast) = \arg\min_{U,V}\phi(U,V) \tag{5.65}

subject to the chance constraints and the bounds on UU and VV.

After the optimal sequences have been obtained, the same U∗U^\ast and V∗V^\ast are applied to every Monte Carlo realization.

For realization jj,

x0(j)∼N(μ0,P0)(5.66) x_0^{(j)} \sim \mathcal{N}(\mu_0,P_0) \tag{5.66}

and independent stochastic disturbances are sampled as

wk(j)∼N(0,Rw)ηk(j)∼N(0,Rη)\begin{align*} w_k^{(j)} &\sim \mathcal{N}(0,R_w)\tag{5.67}\\ \eta_k^{(j)} &\sim \mathcal{N}(0,R_\eta) \tag{5.68}\end{align*}

All trajectories use

uk(j)=uk∗,vk(j)=vk∗(5.69) u_k^{(j)}=u_k^\ast, \qquad v_k^{(j)}=v_k^\ast \tag{5.69}

The stochastic dynamics are then simulated according to

xk+1(j)=A(vk∗)xk(j)+B(vk∗)uk∗+wk(j)(5.70) x_{k+1}^{(j)} = A(v_k^\ast)x_k^{(j)} + B(v_k^\ast)u_k^\ast + w_k^{(j)} \tag{5.70}

and

yk(j)=Cxk(j)+ηk(j)(5.71) y_k^{(j)} = Cx_k^{(j)} + \eta_k^{(j)} \tag{5.71}

Thus, the optimizer determines one common open-loop pair (U∗,V∗)(U^\ast,V^\ast), while the Monte Carlo trajectories differ because of their independently sampled initial conditions and stochastic disturbances.

  1. Define NN, μ0\mu_0, P0P_0, QQ, RUR_U, RVR_V, RwR_w, RηR_\eta, the reference trajectory, chance-constraint parameters, and bounds on UU and VV.
  2. Initialize candidate sequences UU and VV.
  3. For each candidate VV, construct AkA_k, BkB_k, Φ(V)\Phi(V), Γ(V)\Gamma(V), and propagate Pk(V)P_k(V).
  4. Construct the VV-dependent tight bounds.
  5. Evaluate the cost function ϕ(U,V)\phi(U,V).
  6. Solve the constrained nonlinear problem using SLSQP to obtain U∗U^\ast and V∗V^\ast.
  7. Generate the Monte Carlo realizations.
  8. Apply the same U∗U^\ast and V∗V^\ast to every realization.
  9. Evaluate the output trajectories and empirical constraint satisfaction.

5.5.1Results

The stochastic bilinear open-loop controller was evaluated over a horizon

N=30.(5.72) N=30. \tag{5.72}

The bilinear state-transition matrix was defined as

A(v)=Abase+vAv(5.73) A(v) = A_{\mathrm{base}} + vA_v \tag{5.73}

where

Abase=[0.90000.50],Av=[0100](5.74) A_{\mathrm{base}} = \begin{bmatrix} 0.90 & 0\\ 0 & 0.50 \end{bmatrix}, \qquad A_v = \begin{bmatrix} 0 & 1\\ 0 & 0 \end{bmatrix} \tag{5.74}

Hence,

A(v)=[0.90v00.50](5.75) A(v) = \begin{bmatrix} 0.90 & v\\ 0 & 0.50 \end{bmatrix} \tag{5.75}

The input matrix was

B(v)=[01](5.76) B(v) = \begin{bmatrix} 0\\ 1 \end{bmatrix} \tag{5.76}

and both states were directly observed,

C=I2(5.77) C=I_2 \tag{5.77}

The weighting matrices were

Q=I2,RU=0.1,RV=0.1(5.78) Q=I_2, \qquad R_U=0.1, \qquad R_V=0.1 \tag{5.78}

The process and measurement noise covariance matrices were

Rw=Rη=[0.005000.005](5.79) R_w = R_\eta = \begin{bmatrix} 0.005 & 0\\ 0 & 0.005 \end{bmatrix} \tag{5.79}

The initial state distribution was

μ0=[00],P0=[0.01000.01](5.80) \mu_0= \begin{bmatrix} 0\\ 0 \end{bmatrix}, \qquad P_0= \begin{bmatrix} 0.01 & 0\\ 0 & 0.01 \end{bmatrix} \tag{5.80}

The output bounds were

ymin⁡=[−1.7−1.7],ymax⁡=[3.53.5](5.81) y_{\min} = \begin{bmatrix} -1.7\\ -1.7 \end{bmatrix}, \qquad y_{\max} = \begin{bmatrix} 3.5\\ 3.5 \end{bmatrix} \tag{5.81}

with

αlower=αupper=0.01(5.82) \alpha_{\mathrm{lower}} = \alpha_{\mathrm{upper}} = 0.01 \tag{5.82}

The reference trajectory was

yˉk={[ 3.1    −1.3 ]T,k=1,…,15,[ −1.3    3.1 ]T,k=16,…,30(5.83) \bar{y}_k = \begin{cases} [\,3.1\;\;-1.3\,]^T, & k=1,\ldots,15,\\[1mm] [\,-1.3\;\;3.1\,]^T, & k=16,\ldots,30 \end{cases} \tag{5.83}

The optimization variables were bounded by

−5≤uk≤5,−5≤vk≤5\begin{align*} -5 &\leq u_k \leq 5,\tag{5.84}\\ -5 &\leq v_k \leq 5 \tag{5.85}\end{align*}

Stochastic Bilinear Open Loop n 500

Figure 5.1: Monte Carlo output trajectories for the stochastic bilinear open-loop implementation together with the reference trajectory, original constraints, and tight bounds

5.6Closed-Loop Implementation

The stochastic bilinear closed-loop controller is implemented using a receding-horizon Monte Carlo structure similar to the stochastic closed-loop model. But this time for finding optimal U* V* SLSQP solver used.

  1. Generate independent initial conditions for all Monte Carlo realizations.
  2. At time kk, use the current state of each realization as the initial condition for its prediction problem.
  3. Construct the current reference trajectory over the prediction horizon.
  4. For each candidate VV, propagate the bilinear covariance and construct the corresponding tight bounds.
  5. Solve the nonlinear constrained optimization problem using SLSQP independently for each realization.
  6. Obtain Uk∗,(j)U_k^{\ast,(j)} and Vk∗,(j)V_k^{\ast,(j)}.
  7. Apply only the first pair

    uk(j)=uk∣k∗,(j),vk(j)=vk∣k∗,(j) u_k^{(j)}=u_{k|k}^{\ast,(j)}, \qquad v_k^{(j)}=v_{k|k}^{\ast,(j)}
  8. Sample the stochastic disturbances and update the system.
  9. Shift the horizon and repeat the optimization at k+1k+1.

5.6.1Results

The closed-loop experiment used the same stochastic bilinear system with the open-loop case.

Stochastic Bilinear Closed Loop n 500

Figure 5.2: Monte Carlo output trajectories for the stochastic bilinear closed-loop implementation

6State Input Analysis

6.1Analysing Objective

The purpose of the state-input analysis is to investigate how the optimal decision variables change as a function of the system state.

For a two-state system, the initial state is written as

x0=[x1x2](6.1) x_0 = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \tag{6.1}

A rectangular grid is constructed over the (x1,x2)(x_1,x_2) state plane. At each grid point, the corresponding optimization problem is solved using that state as the initial condition.

For the linear case, the analysis records the first optimal control input,

u0∗=f(x1,x2)(6.2) u_0^\ast = f(x_1,x_2) \tag{6.2}

For the bilinear case, both the first optimal control input and the first optimal bilinear parameter are recorded,

u0∗=f(x1,x2)v0∗=g(x1,x2)\begin{align*} u_0^\ast &= f(x_1,x_2)\tag{6.3}\\ v_0^\ast &= g(x_1,x_2) \tag{6.4}\end{align*}

Only the first optimized values are considered because they represent the immediate control decision associated with a particular state.

The state space is sampled over predefined intervals,

x1∈[x1,min⁡,x1,max⁡],x2∈[x2,min⁡,x2,max⁡](6.5) x_1 \in [x_{1,\min},x_{1,\max}], \qquad x_2 \in [x_{2,\min},x_{2,\max}] \tag{6.5}

and the optimization problem is solved independently for every point in this grid.

The resulting values form surfaces over the state plane:

(x1,x2)⟶u0∗(6.6) (x_1,x_2) \longrightarrow u_0^\ast \tag{6.6}

and, for the bilinear system,

(x1,x2)⟶v0∗(6.7) (x_1,x_2) \longrightarrow v_0^\ast \tag{6.7}

These mappings provide a direct visualization of how the optimal decision changes depending on the location of the system in the state space.

The surfaces are represented using both three-dimensional surface plots and two-dimensional contour plots. The main objective of this analysis is therefore not to study a particular trajectory, but to characterize the state-dependent structure of the optimization problem. In particular, the plots make it possible to identify regions in the state space where the optimal input changes gradually, changes rapidly, approaches its bounds, or exhibits nonlinear behavior.

For the bilinear system, separate plots are produced for u0∗u_0^\ast and v0∗v_0^\ast. This allows the influence of the state on the two optimization variables to be examined independently.

6.2Results

The state-input relation was evaluated using the stochastic bilinear system

A(v)=Abase+vAv(6.8) A(v) = A_{\mathrm{base}} + vA_v \tag{6.8}

with

Abase=[0.90000.50](6.9) A_{\mathrm{base}} = \begin{bmatrix} 0.90 & 0 \\ 0 & 0.50 \end{bmatrix} \tag{6.9}

and

Av=[0100](6.10) A_v = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \tag{6.10}

Therefore,

A(v)=[0.90v00.50](6.11) A(v) = \begin{bmatrix} 0.90 & v \\ 0 & 0.50 \end{bmatrix} \tag{6.11}

The input and output matrices were

B=[01],C=[10](6.12) B = \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \qquad C = \begin{bmatrix} 1 & 0 \end{bmatrix} \tag{6.12}

The prediction horizon was selected as

N=15(6.13) N=15 \tag{6.13}

with weighting matrices

Q=1,RU=0.1,RV=0.1(6.14) Q=1, \qquad R_U=0.1, \qquad R_V=0.1 \tag{6.14}

The state-input relation was evaluated over

−10≤x1≤10,−10≤x2≤10(6.15) -10 \leq x_1 \leq 10, \qquad -10 \leq x_2 \leq 10 \tag{6.15}

using a 50×5050\times50 grid.

6.2.1Optimal Control Input Relation

For every point in the (x1,x2)(x_1,x_2) grid, the nonlinear optimization problem was solved and the first optimal control input u0∗u_0^\ast was recorded.

The resulting surface represents

u0∗=f(x1,x2)(6.16) u_0^\ast=f(x_1,x_2) \tag{6.16}

state input u surface

Figure 6.1: First optimal control input u0∗u_0^\ast as a function of the initial state (x1,x2)(x_1,x_2)

state input u contour

Figure 6.2: Contour representation of u0∗u_0^\ast over the initial-state plane

The same relation is shown as a contour plot in Figure 6.2. The contour representation provides a two-dimensional view of regions in the state space associated with similar optimal control actions.

6.2.2Optimal Bilinear Parameter Relation

The same state-space sweep was also used to evaluate the first optimal bilinear parameter. For each initial state, the optimization therefore provides

v0∗=g(x1,x2)(6.17) v_0^\ast=g(x_1,x_2) \tag{6.17}

state input v surface

Figure 6.3: First optimal bilinear parameter v0∗v_0^\ast as a function of the initial state (x1,x2)(x_1,x_2)

state input v contour

Figure 6.4: Contour representation of v0∗v_0^\ast over the initial-state plane

The u0∗u_0^\ast surface shows how the immediate control action selected by the optimizer depends on the initial values of x1x_1 and x2x_2. Similarly, the v0∗v_0^\ast surface illustrates how the bilinear parameter is adjusted depending on the state.

7Kalman Filtering

7.1Theory Derivation

The Kalman filter is used to estimate the internal state of a stochastic system from noisy measurements. The system considered in this work is

xt+1=Axt+But+wtyt=Cxt+vt\begin{align*} x_{t+1} &= Ax_t + Bu_t + w_t \tag{7.1}\\ y_t &= Cx_t + v_t \tag{7.2}\end{align*}

where

wt∼N(0,Rw),vt∼N(0,Rv)(7.3) w_t \sim \mathcal{N}(0,R_w), \qquad v_t \sim \mathcal{N}(0,R_v) \tag{7.3}

Let

Yt={y0,…,yt}(7.4) Y_t = \{y_0,\ldots,y_t\} \tag{7.4}

denote all measurements available up to time tt. Before receiving the measurement yty_t, the state distribution conditioned on the previous measurements is represented by

xt∣Yt−1∼N(x^t∣t−1,Pt∣t−1)(7.5) x_t \mid Y_{t-1} \sim \mathcal{N} \left( \hat{x}_{t|t-1}, P_{t|t-1} \right) \tag{7.5}

Thus, before yty_t is observed, the best available state estimate is x^t∣t−1\hat{x}_{t|t-1}, with uncertainty represented by Pt∣t−1P_{t|t-1}.

To incorporate the new measurement, the joint distribution of the state and measurement is considered. Since the system and noise distributions are Gaussian, the variables xtx_t and yty_t, conditioned on the previous measurements, are jointly Gaussian.

The required moments are first derived. The conditional mean of the state is

E[xt∣Yt−1]=x^t∣t−1(7.6) E[x_t \mid Y_{t-1}] = \hat{x}_{t|t-1} \tag{7.6}

The conditional mean of the measurement becomes

E[yt∣Yt−1]=E[Cxt+vt∣Yt−1]=CE[xt∣Yt−1]=Cx^t∣t−1\begin{align*} E[y_t \mid Y_{t-1}] &= E[Cx_t+v_t \mid Y_{t-1}] \tag{7.7}\\ &= C E[x_t \mid Y_{t-1}] \tag{7.8}\\ &= C\hat{x}_{t|t-1} \tag{7.9}\end{align*}

The covariance between the measurement and the state is

Cov⁡(yt,xt∣Yt−1)=Cov⁡(Cxt+vt,xt∣Yt−1)=CCov⁡(xt,xt∣Yt−1)=CPt∣t−1\begin{align*} \operatorname{Cov} (y_t,x_t \mid Y_{t-1}) &= \operatorname{Cov} (Cx_t+v_t,x_t \mid Y_{t-1}) \tag{7.10}\\ &= C\operatorname{Cov} (x_t,x_t \mid Y_{t-1}) \tag{7.11}\\ &= CP_{t|t-1} \tag{7.12}\end{align*}

Similarly,

Pxy=PyxT=Pt∣t−1CT(7.13) P_{xy} = P_{yx}^{T} = P_{t|t-1}C^T \tag{7.13}

The measurement covariance is

Cov⁡(yt∣Yt−1)=Cov⁡(Cxt+vt,Cxt+vt∣Yt−1)=CPt∣t−1CT+Rv\begin{align*} \operatorname{Cov} (y_t \mid Y_{t-1}) &= \operatorname{Cov} (Cx_t+v_t,Cx_t+v_t \mid Y_{t-1}) \tag{7.14}\\ &= CP_{t|t-1}C^T+R_v \tag{7.15}\end{align*}

Therefore,

[xtyt]∣Yt−1∼N([x^t∣t−1Cx^t∣t−1],[Pt∣t−1Pt∣t−1CTCPt∣t−1CPt∣t−1CT+Rv])(7.16) \begin{bmatrix} x_t \\ y_t \end{bmatrix} \Bigg| Y_{t-1} \sim \mathcal{N} \left( \begin{bmatrix} \hat{x}_{t|t-1} \\ C\hat{x}_{t|t-1} \end{bmatrix}, \begin{bmatrix} P_{t|t-1} & P_{t|t-1}C^T \\ CP_{t|t-1} & CP_{t|t-1}C^T+R_v \end{bmatrix} \right) \tag{7.16}

The measurement update can then be obtained using the projection theorem.

For two jointly Gaussian variables,

Z=[XY]∼N([mxmy],[PxPxyPxyTPy])(7.17) Z= \begin{bmatrix} X \\ Y \end{bmatrix} \sim \mathcal{N} \left( \begin{bmatrix} m_x \\ m_y \end{bmatrix}, \begin{bmatrix} P_x & P_{xy} \\ P_{xy}^T & P_y \end{bmatrix} \right) \tag{7.17}

the conditional distribution is

X∣Y∼N(mx+PxyPy−1(y−my),  Px−PxyPy−1PxyT)(7.18) X|Y \sim \mathcal{N} \left( m_x + P_{xy}P_y^{-1}(y-m_y), \; P_x - P_{xy}P_y^{-1}P_{xy}^T \right) \tag{7.18}

The projection theorem therefore provides the conditional mean and covariance of the state after the measurement has been observed. Applying it to the joint distribution of xtx_t and yty_t gives the measurement-update equations

x^t∣t=x^t∣t−1+Pt∣t−1CT(CPt∣t−1CT+Rv)−1(yt−Cx^t∣t−1)(7.19) \boxed{ \hat{x}_{t|t} = \hat{x}_{t|t-1} + P_{t|t-1}C^T \left( CP_{t|t-1}C^T+R_v \right)^{-1} \left( y_t-C\hat{x}_{t|t-1} \right) } \tag{7.19}

and

Pt∣t=Pt∣t−1−Pt∣t−1CT(CPt∣t−1CT+Rv)−1CPt∣t−1(7.20) \boxed{ P_{t|t} = P_{t|t-1} - P_{t|t-1}C^T \left( CP_{t|t-1}C^T+R_v \right)^{-1} CP_{t|t-1} } \tag{7.20}

After the measurement update, the state estimate is propagated to the next time step. From the system dynamics,

xt+1=Axt+But+wt,(7.21) x_{t+1} = Ax_t+Bu_t+w_t, \tag{7.21}

the predicted state estimate becomes

x^t+1∣t=Ax^t∣t+But(7.22) \boxed{ \hat{x}_{t+1|t} = A\hat{x}_{t|t}+Bu_t } \tag{7.22}

The corresponding covariance is

Pt+1∣t=Cov⁡(Axt+But+wt∣Yt),(7.23) P_{t+1|t} = \operatorname{Cov} (Ax_t+Bu_t+w_t \mid Y_t), \tag{7.23}

which gives

Pt+1∣t=APt∣tAT+Rw(7.24) \boxed{ P_{t+1|t} = AP_{t|t}A^T+R_w } \tag{7.24}

The predicted quantities at time t+1t+1 then become the prior quantities for the next iteration, and the procedure is repeated when the next measurement is received.

7.1.1Overview

The Kalman filter therefore consists of two main stages: the measurement update and the time update.

Starting with the prior state estimate

x^k∣k−1,Pk∣k−1(7.25) \hat{x}_{k|k-1}, \qquad P_{k|k-1} \tag{7.25}

the current measurement yky_k is first used to obtain the posterior state estimate

x^k∣k=x^k∣k−1+Pk∣k−1CT(CPk∣k−1CT+Rv)−1(yk−Cx^k∣k−1)(7.26) \hat{x}_{k|k} = \hat{x}_{k|k-1} + P_{k|k-1}C^T \left( CP_{k|k-1}C^T+R_v \right)^{-1} \left( y_k-C\hat{x}_{k|k-1} \right) \tag{7.26}

with covariance

Pk∣k=Pk∣k−1−Pk∣k−1CT(CPk∣k−1CT+Rv)−1CPk∣k−1(7.27) P_{k|k} = P_{k|k-1} - P_{k|k-1}C^T \left( CP_{k|k-1}C^T+R_v \right)^{-1} CP_{k|k-1} \tag{7.27}

This corresponds to the measurement update.

The resulting posterior state estimate is then propagated forward through the system model according to

x^k+1∣k=Ax^k∣k+Buk(7.28) \hat{x}_{k+1|k} = A\hat{x}_{k|k} + Bu_k \tag{7.28}

and

Pk+1∣k=APk∣kAT+Rw(7.29) P_{k+1|k} = AP_{k|k}A^T+R_w \tag{7.29}

This corresponds to the time update. The predicted state x^k+1∣k\hat{x}_{k+1|k} then becomes the prior estimate for the next measurement step x^k∣k−1\hat{x}_{k|k-1}, and the same procedure is repeated.

7.2Results

The Kalman filter was evaluated using the stochastic bilinear system employed in the previous chapter. The system matrices were

A(v)=[0.90v0.000.50],B(v)=[01](7.30) A(v) = \begin{bmatrix} 0.90 & v \\ 0.00 & 0.50 \end{bmatrix}, \qquad B(v) = \begin{bmatrix} 0 \\ 1 \end{bmatrix} \tag{7.30}

with

C=[10](7.31) C= \begin{bmatrix} 1 & 0 \end{bmatrix} \tag{7.31}

The process and measurement noise covariance matrices were selected as

Rw=[0.05000.05],Rv=[0.005](7.32) R_w= \begin{bmatrix} 0.05 & 0 \\ 0 & 0.05 \end{bmatrix}, \qquad R_v= \begin{bmatrix} 0.005 \end{bmatrix} \tag{7.32}

The initial state distribution was defined using

μ0=[00],P0=[0.01000.01](7.33) \mu_0= \begin{bmatrix} 0 \\ 0 \end{bmatrix}, \qquad P_0= \begin{bmatrix} 0.01 & 0 \\ 0 & 0.01 \end{bmatrix} \tag{7.33}

The controller weighting matrices were selected as

Q=1,RU=0.1,RV=0.1(7.34) Q=1, \qquad R_U=0.1, \qquad R_V=0.1 \tag{7.34}

and the optimization variables were constrained by

−5≤uk≤5,−5≤vk≤5(7.35) -5\leq u_k\leq5, \qquad -5\leq v_k\leq5 \tag{7.35}

The reference levels were 3.13.1 and −1.3-1.3, with the reference changing after 15 time steps.

7.2.1Open-Loop

For the open-loop evaluation, the stochastic bilinear system was simulated over a horizon of 30 steps using 100 Monte Carlo realizations. The same optimized UU and VV sequences were used for all Monte Carlo realizations. The Kalman filter was then applied to the resulting noisy measurements.

7.2.1.1Single Trajectory

A single Monte Carlo realization was first selected to illustrate the estimation behavior of the Kalman filter. The estimated states were compared directly with the corresponding true states.

The uncertainty associated with the state estimate is also shown using the ±2σ\pm2\sigma interval obtained from the posterior covariance matrix. This provides a visual indication of the uncertainty represented by the filter.

kalman open single

Figure 7.1: Kalman-filter state estimate for a single stochastic bilinear open-loop trajectory

7.2.1.2Monte Carlo Result

The Kalman filter was then applied to all Monte Carlo trajectories. The true state trajectories and their corresponding Kalman-filter estimates are shown together in order to examine the estimation behavior over repeated stochastic realizations.

The empirical mean of the true trajectories and the empirical mean of the estimated trajectories are also displayed. In addition, the corresponding ±2σ\pm2\sigma regions show the spread of the Monte Carlo trajectories.

kalman open multiple

Figure 7.2: Monte Carlo true-state trajectories and Kalman-filter estimates for the stochastic bilinear open-loop simulation

7.2.1.3Performance Evaluation

The performance of the Kalman filter was further evaluated by examining the difference between the estimated and true states over all Monte Carlo realizations.

The mean estimation error is shown together with the empirical ±2σ\pm2\sigma spread of the estimation error. This is compared with the uncertainty predicted by the Kalman covariance matrix.

This comparison provides an indication of whether the covariance calculated by the Kalman filter appropriately represents the observed estimation uncertainty over the Monte Carlo simulations.

kalman open performance

Figure 7.3: Mean estimation error and comparison between the empirical and Kalman-filter uncertainty for the stochastic bilinear open-loop simulation

7.2.2Closed-Loop

The Kalman filter was also evaluated using the stochastic bilinear closed-loop simulations. The same system and stochastic parameters were used.

In this case, the input sequences UU and VV can differ between Monte Carlo realizations. Consequently, the corresponding time-varying system matrices used in the Kalman-filter prediction step also depend on the individual realization.

7.2.2.1Single Trajectory

A single closed-loop Monte Carlo realization was first selected. The Kalman-filter estimate was obtained using the UU and VV sequences corresponding to that particular trajectory.

The true states, estimated states, and the corresponding ±2σ\pm2\sigma uncertainty interval are shown in Figure 7.4.

kalman closed single

Figure 7.4: Kalman-filter state estimate for a single stochastic bilinear closed-loop trajectory

7.2.2.2Monte Carlo Result

The filter was subsequently applied to every closed-loop Monte Carlo trajectory. Since the optimized VV-sequence can differ between realizations, the corresponding covariance propagation is also evaluated separately for each trajectory.

The true and estimated state trajectories are shown together with their empirical means and spreads.

kalman closed multiple

Figure 7.5: Monte Carlo true-state trajectories and Kalman-filter estimates for the stochastic bilinear closed-loop simulation

7.2.2.3Performance Evaluation

Finally, the estimation errors from all closed-loop Monte Carlo trajectories were analyzed.

The mean estimation error and its empirical spread are compared with the uncertainty obtained from the Kalman covariance matrices. Since each trajectory may have a different VV-sequence, the covariance evolution can also differ between simulations.

The comparison therefore provides a statistical evaluation of the state estimator under the stochastic bilinear closed-loop simulations.

kalman closed performance

Figure 7.6: Mean estimation error and comparison between the empirical and Kalman-filter uncertainty for the stochastic bilinear closed-loop simulation

8District Heating System

8.1Derivation of T˙i\dot{T}_i Equation

The district heating pipes are assumed to transport incompressible water with constant specific heat capacity. The flow velocity is assumed to be constant throughout each pipe, and only temperature variations in the axial direction are considered.

For a pipe with axial coordinate zz, the energy balance is written as

∂tu(t,z)=−∂zNh(t,z)+q(t,z),z∈[z0,zf](8.1) \partial_t u(t,z) = - \partial_z \mathcal{N}_h(t,z) + q(t,z), \qquad z \in [z_0,z_f] \tag{8.1}

where u(t,z)u(t,z) denotes the internal energy per unit volume, Nh(t,z)\mathcal{N}_h(t,z) denotes the enthalpy flux, and q(t,z)q(t,z) represents the heat loss per unit volume.

The enthalpy flux is expressed as

Nh(t,z)=H(T(t,z),p,N(t))(8.2) \mathcal{N}_h(t,z) = H \left( T(t,z),p,\mathcal{N}(t) \right) \tag{8.2}

where T(t,z)T(t,z) is the water temperature, pp is the pressure, and N(t)\mathcal{N}(t) is the molar flux. The molar flux is given by

N(t)=ρv(t)(8.3) \mathcal{N}(t) = \rho v(t) \tag{8.3}

where ρ\rho denotes the constant density and v(t)v(t) denotes the flow velocity.

The heat loss to the surroundings is modeled as

q(t,z)=−k(T(t,z)−Ta(t))(8.4) q(t,z) = - k \left( T(t,z)-T_a(t) \right) \tag{8.4}

where kk is the conductance and Ta(t)T_a(t) is the ambient temperature.

Applying the chain rule to the enthalpy flux gives

∂TH(T(t,z),p,N(t))∂zT(t,z)=∂zNh(t,z)(8.5) \partial_T H \left( T(t,z),p,\mathcal{N}(t) \right) \partial_z T(t,z) = \partial_z \mathcal{N}_h(t,z) \tag{8.5}

Using the specific heat capacity cpc_p, this becomes

N(t)cp∂zT(t,z)=∂zNh(t,z)(8.6) \mathcal{N}(t)c_p \partial_z T(t,z) = \partial_z \mathcal{N}_h(t,z) \tag{8.6}

The pipe is then segmented into MM finite volumes. For the ii-th segment,

Ωi=[zi,zi+1](8.7) \Omega_i = [z_i,z_{i+1}] \tag{8.7}

and the energy balance is integrated over the segment:

∂t∫Ωiu(t,z) dz=−∫Ωi∂zNh(t,z) dz+∫Ωiq(t,z) dz(8.8) \partial_t \int_{\Omega_i} u(t,z)\,dz = - \int_{\Omega_i} \partial_z \mathcal{N}_h(t,z)\,dz + \int_{\Omega_i} q(t,z)\,dz \tag{8.8}

Multiplying by the cross-sectional area AA, the energy balance of the segment can be written as

U˙i(t)=−AN(t)cp∫zizi+1∂zT(t,z) dz+Qi(t)(8.9) \dot{U}_i(t) = - A\mathcal{N}(t)c_p \int_{z_i}^{z_{i+1}} \partial_z T(t,z)\,dz + Q_i(t) \tag{8.9}

where Ui(t)U_i(t) denotes the internal energy of the segment and Qi(t)Q_i(t) denotes the corresponding heat loss.

Evaluating the integral gives

U˙i(t)=−AN(t)cp(T(t,zi+1)−T(t,zi))+Qi(t)(8.10) \dot{U}_i(t) = - A\mathcal{N}(t)c_p \left( T(t,z_{i+1}) - T(t,z_i) \right) + Q_i(t) \tag{8.10}

Using the average temperature of each finite volume, this is approximated as

U˙i(t)=−AN(t)cp(Tˉi+1(t)−Tˉi(t))+Qi(t)(8.11) \dot{U}_i(t) = - A\mathcal{N}(t)c_p \left( \bar{T}_{i+1}(t) - \bar{T}_i(t) \right) + Q_i(t) \tag{8.11}

The internal energy of the ii-th segment is written as

Ui(t)=ncpTˉi(t)(8.12) U_i(t) = n c_p \bar{T}_i(t) \tag{8.12}

where

n=AΔzρ,Δz=zi+1−zi(8.13) n = A\Delta z \rho, \qquad \Delta z = z_{i+1}-z_i \tag{8.13}

The heat loss of the segment is approximated by

Qi(t)≈−AΔzk(Tˉi(t)−Ta(t))(8.14) Q_i(t) \approx - A\Delta z k \left( \bar{T}_i(t)-T_a(t) \right) \tag{8.14}

Substituting the internal-energy and heat-loss expressions into the energy balance gives

cpAΔzρ Tˉ˙i(t)=−AN(t)cp(Tˉi+1(t)−Tˉi(t))−AΔzk(Tˉi(t)−Ta(t))\begin{align*} c_p A\Delta z \rho \, \dot{\bar{T}}_i(t) &= - A\mathcal{N}(t)c_p \left( \bar{T}_{i+1}(t) - \bar{T}_i(t) \right) \\ &\quad - A\Delta z k \left( \bar{T}_i(t)-T_a(t) \right) \tag{8.15}\end{align*}

Since

N(t)=ρv(t)(8.16) \mathcal{N}(t) = \rho v(t) \tag{8.16}

the equation can be divided by AΔzρcpA\Delta z\rho c_p, resulting in

Tˉ˙i(t)=−v(t)Δz(Tˉi+1(t)−Tˉi(t))−kρcp(Tˉi(t)−Ta(t))(8.17) \boxed{ \dot{\bar{T}}_i(t) = - \frac{v(t)}{\Delta z} \left( \bar{T}_{i+1}(t) - \bar{T}_i(t) \right) - \frac{k}{\rho c_p} \left( \bar{T}_i(t) - T_a(t) \right) } \tag{8.17}

The resulting pipe model can subsequently be expressed in continuous state-space form as

x˙(t)=Acx(t)+Bcu(t)+Ecd(t)y(t)=Ccx(t)+e(tk)\begin{align*} \dot{x}(t) &= A_c x(t) + B_c u(t) + E_c d(t)\tag{8.18}\\ y(t) &= C_c x(t) + e(t_k) \tag{8.19}\end{align*}

where the states x(t)x(t) correspond to the average temperatures Tˉi(t)\bar{T}_i(t), u(t)u(t) represents the supply temperature TsT_s, d(t)d(t) represents the ambient temperature TaT_a, and y(t)y(t) contains the temperatures measured at the selected pipe nodes.

8.2Change of Variable

From the temperature equation derived in the previous section,

T˙i=−vΔz(Ti−Ti−1)−kρcp(Ti−Ta)(8.20) \dot{T}_i = - \frac{v}{\Delta z} \left( T_i-T_{i-1} \right) - \frac{k}{\rho c_p} \left( T_i-T_a \right) \tag{8.20}

To simplify the notation, define

α(v)=vΔz(8.21) \alpha(v) = \frac{v}{\Delta z} \tag{8.21}

and

β=kρcp(8.22) \beta = \frac{k}{\rho c_p} \tag{8.22}

The temperature dynamics can then be written as

T˙i=−α(v)(Ti−Ti−1)−β(Ti−Ta)(8.23) \dot{T}_i = - \alpha(v) \left( T_i-T_{i-1} \right) - \beta \left( T_i-T_a \right) \tag{8.23}

A change of variables is introduced by defining the state relative to the ambient temperature as

xi=Ti−Ta(8.24) x_i = T_i-T_a \tag{8.24}

Similarly, the input is defined as the supply temperature relative to the ambient temperature,

u=Ts−Ta(8.25) u = T_s-T_a \tag{8.25}

Therefore,

Ti=xi+Ta(8.26) T_i = x_i+T_a \tag{8.26}

and

Ts=u+Ta(8.27) T_s = u+T_a \tag{8.27}

Differentiating Equation (8.24) gives

x˙i=T˙i−T˙a(8.28) \dot{x}_i = \dot{T}_i-\dot{T}_a \tag{8.28}

Substituting

Ti=xi+Ta,Ti−1=xi−1+Ta(8.29) T_i=x_i+T_a, \qquad T_{i-1}=x_{i-1}+T_a \tag{8.29}

into Equation (8.23) gives

x˙i+T˙a=−α[(xi+Ta)−(xi−1+Ta)]−βxi(8.30) \dot{x}_i+\dot{T}_a = - \alpha \left[ (x_i+T_a) - (x_{i-1}+T_a) \right] - \beta x_i \tag{8.30}

After simplifying,

x˙i=−(α+β)xi+αxi−1−T˙a(8.31) \boxed{ \dot{x}_i = - (\alpha+\beta)x_i + \alpha x_{i-1} - \dot{T}_a } \tag{8.31}

For the first pipe segment, the upstream temperature is the supply temperature TsT_s. Since

u=Ts−Ta(8.32) u=T_s-T_a \tag{8.32}

the first state equation becomes

x˙0=−(α+β)x0+αu−T˙a(8.33) \boxed{ \dot{x}_0 = - (\alpha+\beta)x_0 + \alpha u - \dot{T}_a } \tag{8.33}

Collecting all pipe-segment temperatures into the state vector gives the continuous-time system

x˙=Ac(v)x+Bc(v)u+EcT˙a(8.34) \boxed{ \dot{x} = A_c(v)x + B_c(v)u + E_c\dot{T}_a } \tag{8.34}

The system matrix is

Ac(v)=[−(α+β)00⋯0α−(α+β)0⋯00α−(α+β)⋱⋮⋮⋱⋱⋱00⋯0α−(α+β)](8.35) A_c(v) = \begin{bmatrix} -(\alpha+\beta) & 0 & 0 & \cdots & 0 \\ \alpha & -(\alpha+\beta) & 0 & \cdots & 0 \\ 0 & \alpha & -(\alpha+\beta) & \ddots & \vdots \\ \vdots & \ddots & \ddots & \ddots & 0 \\ 0 & \cdots & 0 & \alpha & -(\alpha+\beta) \end{bmatrix} \tag{8.35}

where

α=α(v)=vΔz(8.36) \alpha=\alpha(v)=\frac{v}{\Delta z} \tag{8.36}

The input matrix is

Bc(v)=[α0⋮0](8.37) B_c(v) = \begin{bmatrix} \alpha \\ 0 \\ \vdots \\ 0 \end{bmatrix} \tag{8.37}

and the disturbance matrix associated with the change in ambient temperature is

Ec=[−1−1⋮−1](8.38) E_c = \begin{bmatrix} -1 \\ -1 \\ \vdots \\ -1 \end{bmatrix} \tag{8.38}

8.3Controller and Hidden Plant Approach

After introducing the change of variable

xi=Ti−Ta(8.39) x_i = T_i-T_a \tag{8.39}

the continuous-time district heating model was obtained as

x˙=Ac(v)x+Bc(v)u+EcT˙a(8.40) \dot{x} = A_c(v)x + B_c(v)u + E_c\dot{T}_a \tag{8.40}

The change of variable therefore introduces the derivative of the ambient temperature into the state dynamics. In the implementation, the model used by the controller and the model used to simulate the physical plant are treated separately.

8.3.1Controller Approach

On the controller side, the ambient temperature is assumed to remain constant within each sampling interval. Thus,

Ta(t)=Ta,k,t∈[tk,tk+1)(8.41) T_a(t) = T_{a,k}, \qquad t\in[t_k,t_{k+1}) \tag{8.41}

and consequently

T˙a(t)=0,t∈(tk,tk+1)(8.42) \dot{T}_a(t) = 0, \qquad t\in(t_k,t_{k+1}) \tag{8.42}

Therefore,

EcT˙a=0(8.43) E_c\dot{T}_a=0 \tag{8.43}

and the continuous-time model used by the controller reduces to

x˙=Ac(v)x+Bc(v)u(8.44) \boxed{ \dot{x} = A_c(v)x + B_c(v)u } \tag{8.44}

This model is discretized using a Zero-Order Hold assumption. During each sampling interval, the matrices and the input are kept constant. The resulting state at the end of the sampling interval is

x(tk+1−)=eAc,kΔtxk+∫0ΔteAc,k(Δt−τ)Bc,kuk dτ(8.45) x(t_{k+1}^{-}) = e^{A_{c,k}\Delta t}x_k + \int_{0}^{\Delta t} e^{A_{c,k}(\Delta t-\tau)} B_{c,k}u_k \,d\tau \tag{8.45}

The discrete-time matrices are obtained from

exp⁡([AcBc00]Δt)=[AkBk0I](8.46) \exp \left( \begin{bmatrix} A_c & B_c \\ 0 & 0 \end{bmatrix} \Delta t \right) = \begin{bmatrix} A_k & B_k \\ 0 & I \end{bmatrix} \tag{8.46}

Thus, the controller uses the discrete-time model generated from the continuous dynamics under the assumption that the ambient temperature does not change inside the sampling interval.

8.3.2Hidden Plant Approach

The hidden plant represents the system used to generate the simulated measurements. In contrast to the controller model, the hidden plant is affected by the actual ambient-temperature values.

Because the transformed state is defined relative to the ambient temperature, a change in TaT_a between two sampling instants changes the state coordinates. After the continuous evolution over one sampling interval,

xk+1=xk+1−+(Ta,k−Ta,k+1)1(8.47) x_{k+1} = x_{k+1}^{-} + \left( T_{a,k}-T_{a,k+1} \right)\mathbf{1} \tag{8.47}

The ambient-temperature contribution is therefore defined as

dk=(Ta,k−Ta,k+1)1(8.48) d_k = \left( T_{a,k}-T_{a,k+1} \right)\mathbf{1} \tag{8.48}

The hidden plant simulation consequently uses

xk+1=Akxk+Bkuk+dk+wk(8.49) \boxed{ x_{k+1} = A_kx_k + B_ku_k + d_k + w_k } \tag{8.49}

where

wk∼N(0,Rw)(8.50) w_k \sim \mathcal{N}(0,R_w) \tag{8.50}

The output represents the outlet temperature relative to the current ambient temperature,

yk=Tout,k−Ta,k(8.51) y_k = T_{\mathrm{out},k} - T_{a,k} \tag{8.51}

The measured output is modeled as

yk=Cxk+νk(8.52) \boxed{ y_k = Cx_k+\nu_k } \tag{8.52}

with

νk∼N(0,Rv)(8.53) \nu_k \sim \mathcal{N}(0,R_v) \tag{8.53}

The hidden plant is used only to simulate the underlying system behavior. Its internal state is not assumed to be directly available to the controller. Instead, the controller receives the noisy output measurements, and the Kalman filter is applied to these measurements in order to estimate the internal state.

Therefore, the controller performs its prediction using the model in which the ambient temperature is assumed constant over each sampling interval, whereas the hidden plant evolves according to the actual ambient-temperature sequence through the additional term dkd_k. This separation allows the effect of changing ambient conditions to be included in the simulation while maintaining the controller formulation based on the ZOH-discretized model.

8.3.3Change on Kalman Filter

The change of variable

xi=Ti−Ta(8.54) x_i=T_i-T_a \tag{8.54}

also introduces a modification to the Kalman-filter procedure. Since the state is defined relative to the ambient temperature, a change in the ambient temperature between two consecutive sampling instants changes the state coordinates.

As derived previously,

xk+1=xk+1−+(Ta,k−Ta,k+1)1(8.55) x_{k+1} = x_{k+1}^{-} + \left( T_{a,k}-T_{a,k+1} \right)\mathbf{1} \tag{8.55}

Defining

dk=(Ta,k−Ta,k+1)1(8.56) d_k = \left( T_{a,k}-T_{a,k+1} \right)\mathbf{1} \tag{8.56}

the same correction must also be applied to the predicted state estimate of the Kalman filter.

The measurement-update equations remain unchanged. Starting from the prior estimate x^k∣k−1\hat{x}_{k|k-1}, the measurement yky_k is used to obtain

x^k∣k=x^k∣k−1+Pk∣k−1CT(CPk∣k−1CT+Rv)−1(yk−Cx^k∣k−1)(8.57) \hat{x}_{k|k} = \hat{x}_{k|k-1} + P_{k|k-1}C^T \left( CP_{k|k-1}C^T+R_v \right)^{-1} \left( y_k-C\hat{x}_{k|k-1} \right) \tag{8.57}

and

Pk∣k=Pk∣k−1−Pk∣k−1CT(CPk∣k−1CT+Rv)−1CPk∣k−1(8.58) P_{k|k} = P_{k|k-1} - P_{k|k-1}C^T \left( CP_{k|k-1}C^T+R_v \right)^{-1} CP_{k|k-1} \tag{8.58}

The time update is then first performed using the controller model,

x^k+1∣k−=Akx^k∣k+Bkuk(8.59) \hat{x}_{k+1|k}^{-} = A_k\hat{x}_{k|k} + B_ku_k \tag{8.59}

At this stage, the predicted state is based on the assumption used by the controller that the ambient temperature remains constant over the sampling interval.

When the next ambient-temperature value Ta,k+1T_{a,k+1} becomes available, the change in ambient temperature is calculated through

dk=(Ta,k−Ta,k+1)1(8.60) d_k = \left( T_{a,k}-T_{a,k+1} \right)\mathbf{1} \tag{8.60}

The predicted state estimate is then corrected as

x^k+1∣k=x^k+1∣k−+dk(8.61) \boxed{ \hat{x}_{k+1|k} = \hat{x}_{k+1|k}^{-} + d_k } \tag{8.61}

Therefore, the complete prediction step can be written as

x^k+1∣k=Akx^k∣k+Bkuk+dk(8.62) \boxed{ \hat{x}_{k+1|k} = A_k\hat{x}_{k|k} + B_ku_k + d_k } \tag{8.62}

After this correction, the time index is advanced,

k←k+1(8.63) k \leftarrow k+1 \tag{8.63}

and the corrected prediction becomes the prior estimate used in the next measurement update.

Thus, the main modification to the Kalman-filter structure is the additional state correction introduced when the new ambient-temperature value becomes available. This allows the state estimate to remain consistent with the definition xi=Ti−Tax_i=T_i-T_a while the actual ambient temperature changes over time.

8.4Updates on Implementation

Two modifications were introduced in the implementation of the optimization problem. First, the changes in the control input UU and flow velocity VV were included in the cost function. Second, the numerical optimization method was changed from SLSQP to IPOPT due to the increase in computational time.

8.4.1Penalizing Changes in UU and VV

Previously, the objective function penalized the tracking error together with the magnitudes of the control input UU and the flow velocity VV. However, minimizing only these quantities does not explicitly discourage large changes between consecutive control actions.

Therefore, additional terms were introduced to penalize the changes in UU and VV. For consecutive prediction steps, these changes are defined as

Δuk=uk−uk−1(8.64) \Delta u_k = u_k-u_{k-1} \tag{8.64}

and

Δvk=vk−vk−1(8.65) \Delta v_k = v_k-v_{k-1} \tag{8.65}

The corresponding penalties are

ΔukTRΔUΔuk(8.66) \Delta u_k^T R_{\Delta U}\Delta u_k \tag{8.66}

and

ΔvkTRΔVΔvk(8.67) \Delta v_k^T R_{\Delta V}\Delta v_k \tag{8.67}

The updated objective function therefore becomes

ϕ(U,V)=12∑k=0N−1[(μy,k−yˉk)TQ(μy,k−yˉk)+ukTRUuk+vkTRVvk+tr⁡(QPy,k)+ΔukTRΔUΔuk+ΔvkTRΔVΔvk]\begin{align*} \phi(U,V) = \frac{1}{2} \sum_{k=0}^{N-1} \Big[ & (\mu_{y,k}-\bar{y}_k)^T Q (\mu_{y,k}-\bar{y}_k) + u_k^T R_U u_k + v_k^T R_V v_k \\ & + \operatorname{tr}(Q P_{y,k}) + \Delta u_k^T R_{\Delta U} \Delta u_k + \Delta v_k^T R_{\Delta V} \Delta v_k \Big] \tag{8.68}\end{align*}

Thus, RR and SS penalize the magnitude of the control variables, whereas QchangeQ_{\mathrm{change}} and SchangeS_{\mathrm{change}} penalize how rapidly these variables change from one time step to the next.

For k>0k>0,

Δuk=uk−uk−1,Δvk=vk−vk−1\begin{align*} \Delta u_k &= u_k-u_{k-1},\tag{8.69}\\ \Delta v_k &= v_k-v_{k-1} \tag{8.70}\end{align*}

In the receding-horizon implementation, the first elements of the newly optimized sequences are compared with the values that were actually applied at the previous sampling instant. Therefore,

Δu0=u0−uprev,Δv0=v0−vprev\begin{align*} \Delta u_0 &= u_0-u_{\mathrm{prev}},\tag{8.71}\\ \Delta v_0 &= v_0-v_{\mathrm{prev}} \tag{8.72}\end{align*}

When no previous control value exists, such as at the beginning of the simulation, this first change term is not penalized.

Including these additional terms encourages smoother control-input and flow-velocity sequences and avoids unnecessarily large changes between consecutive optimization steps.

8.4.2Numerical Solver Change

The numerical solver used for the nonlinear optimization problem was also changed during the implementation.

The earlier stochastic bilinear models were solved using Sequential Least Squares Programming (SLSQP). As the district heating model was extended, the optimization problem became more computationally demanding. In particular, the larger state dimension, propagation of the stochastic covariance, chance constraints, bilinear dependence on VV, and the additional penalties on the changes in UU and VV increased the computation time.

For this reason, the implementation was changed from SLSQP to IPOPT. The optimization problem is constructed using CasADi.

8.5Results

The developed controller was evaluated on the single-pipe district heating example. The pipe was divided into M=6M=6 finite volumes over a total length of 6 km6\,\mathrm{km}, and the sampling time was selected as Δt=0.5 h\Delta t=0.5\,\mathrm{h}. The heat-loss coefficient was

β=7.66×10−3 h−1(8.73) \beta = 7.66\times10^{-3}\,\mathrm{h}^{-1} \tag{8.73}

Two temperatures were considered as measured outputs: the temperature at the pipe outlet and the temperature at the third finite volume. The initial temperature of the pipe was 65∘C65^\circ\mathrm{C}, while the initial ambient temperature was 0∘C0^\circ\mathrm{C}.

The physical output constraints were selected as

65∘C≤Tout≤90∘C(8.74) 65^\circ\mathrm{C} \leq T_{\mathrm{out}} \leq 90^\circ\mathrm{C} \tag{8.74}

for both measured locations. The supply-temperature and flow-velocity bounds were

50∘C≤Ts≤110∘C(8.75) 50^\circ\mathrm{C} \leq T_s \leq 110^\circ\mathrm{C} \tag{8.75}

and

0.05≤v≤7.0km/h(8.76) 0.05 \leq v \leq 7.0 \quad \mathrm{km/h} \tag{8.76}

The reference temperatures were changed during the simulation according to

Tˉ1=[7070]T,Tˉ2=[7087]T,Tˉ3=[8770]T(8.77) \bar{T}_1 = \begin{bmatrix} 70 & 70 \end{bmatrix}^{T}, \qquad \bar{T}_2 = \begin{bmatrix} 70 & 87 \end{bmatrix}^{T}, \qquad \bar{T}_3 = \begin{bmatrix} 87 & 70 \end{bmatrix}^{T} \tag{8.77}

Each reference level was held for 4848 sampling instants, corresponding to 24 h24\,\mathrm{h}. The ambient temperature was initially 0∘C0^\circ\mathrm{C} and was changed to 10∘C10^\circ\mathrm{C} at t=36 ht=36\,\mathrm{h}.

The weighting matrices used in the optimization were

Q=1011I,RU=0,RV=0(8.78) Q=10^{11}I, \qquad R_U=0, \qquad R_V=0 \tag{8.78}

together with the move-suppression weights

RΔU=10,RΔV=20(8.79) R_{\Delta U}=10, \qquad R_{\Delta V}=20 \tag{8.79}

The stochastic behavior was evaluated using 200200 Monte Carlo realizations.

8.5.1Open-Loop

In the open-loop simulation, the optimization problem was solved once over the complete simulation horizon. The complete future ambient-temperature profile was provided to the controller before the optimization. Therefore, the calculated sequences U∗U^\ast and V∗V^\ast already account for the scheduled change in ambient temperature.

The same optimized input and velocity sequences were subsequently applied to all Monte Carlo realizations.

8.5.2Closed-Loop

For the closed-loop simulation, a prediction horizon of

N=12(8.80) N=12 \tag{8.80}

was used, corresponding to 6 h6\,\mathrm{h}. In contrast to the open-loop case, the controller does not receive the future ambient-temperature trajectory. At each sampling instant, only the currently available ambient temperature is used and is assumed to remain constant over the prediction horizon.

A separate MPC optimization is performed for every Monte Carlo realization. Consequently, each trajectory obtains its own optimal U∗U^\ast and V∗V^\ast sequences according to its current state estimate. Only the first elements of these sequences are applied, after which a new measurement is received and the optimization is repeated.

When a new ambient-temperature value becomes available, the Kalman-filter state prediction is corrected using the ambient-temperature re-basing term. The corrected state estimate is then used by the subsequent MPC problem. This allows the controller to respond to the actual ambient-temperature change without assuming its future value beforehand.

9Conclusion

During this internship, a complete MPC framework was developed step by step from linear deterministic systems to stochastic bilinear systems with chance constraints. The work also incorporated state-input analysis and Kalman filtering for state estimation under noisy measurements. The resulting controller was applied to a district heating system and evaluated in both open-loop and closed-loop settings using Monte Carlo simulations. The final implementation combines nonlinear optimization, uncertainty handling, probabilistic constraints, and state estimation, providing a basis for further development of stochastic MPC methods for district heating applications

10An Appendix

Codes used in this report can be found on: