# LMIs in Control/pages/Discrete-Time HInf-Optimal Observer

LMIs in Control/pages/Discrete-Time HInf-Optimal Observer
In many applications, perhaps even most, the state of the system cannot be directly known. In this case, you will need to strategically to measure key system outputs that will make the system states indirectly observable. Observers need to converge much faster than the system dynamics in order for their estimations to be accurate. Optimal observer synthesis is therefore advantageous. In this LMI, we seek to optimize the H-infinity norm, which conceptually is minimizing the maximum magnitude of error in the observer.

## The System

The system needed for this LMI is a discrete-time LTI plant $G$, which has the state space realization:
    ${\begin{aligned}x_{k+1}&=A_{d}x_{k}+B_{d1}w_{k},\\y_{k}&=C_{d2}x_{k}+D_{d21}w_{k}\\\end{aligned}}$
where $x\in R^{n}$ and is the state vector, $A\in R^{n*n}$ and is the state matrix, $B\in R^{n*r}$ and is the input matrix, $w\in R^{r}$ and is the exogenous input, $C\in R^{m*n}$ and is the output matrix, $D\in R^{m*r}$ and is the feedthrough matrix, $y\in R^{m}$ and is the output, and it is assumed that $(A_{d},C_{d2})$ is detectable.

## The Data

The matrices $A_{d},B_{d1},C_{d2},D_{d21},D_{d11}$.

## The Optimization Problem

An observer of the form:
    ${\begin{aligned}{\hat {x}}_{k+1}&=A_{d}{\hat {x}}_{k}+L_{d}(y_{k}-{\hat {y}}_{k}),\\{\hat {y}}_{k}&=C_{d2}{\hat {x}}_{k}\\\end{aligned}}$
is to be designed, where $L_{d}\in R^{n_{x}*n_{y}}$ is the observer gain.
Defining the error state $e_{k}=x_{k}-{\hat {x}}_{k}$, the error dynamics are found to be
$e_{k+1}=(A_{d}-L_{d}C_{d2})e_{k}+(B_{d1}-L_{d}D_{d21})w_{k}$,
and the performance output is defined as
$z_{k}=C_{d1}e_{k}+D_{d11}w_{k}$.
The observer gain $L_{d}$ is to be designed such that the $H_{inf}$ of the transfer matrix from $w_{k}$ to $z_{k}$, given by
${\begin{aligned}T(z)&=C_{d1}(z1-(A_{d}-L_{d}C_{d2}))^{-1}(B_{d1}-L_{d}D_{d21})+D_{d11},\\\end{aligned}}$
is minimized.

## The LMI: Discrete-Time Hinf-Optimal Observer

The discrete-time $H_{inf}$-optimal observer gain is synthesized by solving for $P\in S^{n_{x}}$, $G_{d}\in R^{n_{x}*n_{y}}$, and $\gamma \in R_{>0}$ that minimize J$(\gamma )=\gamma$ subject to $P>0$, and
       ${\begin{aligned}{\begin{bmatrix}P&PA_{d}-G_{d}C_{d2}&PB_{d1}-G_{d}D_{d21}&0\\*&P&0&C_{d1}^{T}\\*&*&\gamma *1&D_{d11}^{T}\\*&*&*&\gamma *1\end{bmatrix}}&>0.\\\end{aligned}}$

## Conclusion:

The $H_{inf}$-optimal observer gain is recovered by $L_{d}=P^{-1}G_{d}$ and the $H_{inf}$ norm of $T(z)$ is $\gamma$. This matrix of observer gains can then be used to form the optimal observer formulated by:
    ${\begin{aligned}{\hat {x}}_{k+1}&=A_{d}{\hat {x}}_{k}+L_{d}(y_{k}-{\hat {y}}_{k}),\\{\hat {y}}_{k}&=C_{d2}{\hat {x}}_{k}\\\end{aligned}}$

## Implementation

This implementation requires Yalmip and Sedumi.
https://github.com/rezajamesahmed/LMImatlabcode/blob/master/Hinfobsdiscretetime.m

## Related LMIs

Mixed H2-Hinfinity discrete time observer
Discrete-Time_H2-Optimal_Observer

## External Links

This LMI comes from Ryan Caverly's text on LMI's (Section 5.2.2):
* LMI Properties and Applications in Systems, Stability, and Control Theory - A List of LMIs by Ryan Caverly and James Forbes.
Other resources:
* LMI Methods in Optimal and Robust Control - A course on LMIs in Control by Matthew Peet.
* LMIs in Systems and Control Theory - A downloadable book on LMIs by Stephen Boyd.