text:
LMIs in Control/Click here to continue/Controller synthesis/Apkarian Filter and State Feedback

The System:
The number of LMI constraints needed to check quadratic stability is reduced if all the subsystems in the polytopic model has the same matrix $$B$$. This can be achieved by adding an Apkarian filter in the input of the system.

The Optimization Problem:
Apkarian Filter

Let consider our TS-LIA model. This can be re written in linear form as:

\dot{x} = A(z(t)) x + B(z(t)) u

$$

The filter should be such that the equilibrium of the states are the input values and the dynamics should be fast, so we could assume the dynamics of the filter negligible (i.e. the input of the filter is equivalent to the input of the quadrotor). One possible filter is shown, where $$ A_F$$ = −100$$ I_4$$, $$B_F$$ = 100$$I_4$$ and $$I_4$$ ∈ $$R^{4\times4}$$ is the identity matrix.

 * $$ \dot{x_F} = A_F x_F + B_F u_F; y_f = x_f$$.

When applying the filter, we are imposing that the output of the filter is the new input of the TS-LIA model (i.e. $$u$$ = $$y_F$$ ). Then, the extended model is:

\dot{x_c}= \begin{bmatrix} A(z(t))&B(z(t))\\ 0&A_F\\ \end{bmatrix} x_c + \begin{bmatrix}0\\B_F\end{bmatrix} u_F = A_e(z(t)) x_e + B_e u_f;

x_e = \begin{bmatrix}x\\x_F \end{bmatrix} $$

This prefiltering does not affect the procedure followed to obtain the TS-LIA model, so the premise variables, membership functions and activations functions remains the same.

State Feedback Controller Design

Let consider the state feedback control law for the extended TS-LIA model:$$ \dot{x_e} = \sum_{i=1}^{32} h_i(z(t)) [ A_{ei} x_e + B_{ei} u_F ]$$, where the state feedback control laws are :$$ u_F= \sum_{i=1}^{32} h_i(z(t)) K_i x(t) $$, we get the closed loop system  :$$ \dot{x_e} = \sum_{i=1}^{32} \sum_{j=1}^{32} h_j(z(t)) [ A_{ei} x_e + B_{ei} K_j ]x_e$$

The LMI:
The design of the controller is done by solving an LMI problem involving the quadratic stability constraints. In case we want D- stabilization, the following set of LMI constraints are needed:

 * $$L \otimes P + M \otimes P (A_{ei} + B_e K_i) + MT \otimes (A_ei + B_e K_i)^T P < 0$$ ∀i = 1, . . ., 32.

Conclusion:
The LMI is feasible.

Related LMIs

 * LMI for Natural Frequency in State Feedback. https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Maximum_Natural_Frequency_in_State_Feedback#The_LMI%3A
 * LMI for Minimum Decay Rate in State Feedback. https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Minimum_Decay_Rate_in_State_Feedback#The_LMI%3A


text:
LMIs in Control/Click here to continue/Controller synthesis/Minimum Decay Rate in State Feedback

The System:
The number of LMI constraints needed to check quadratic stability is reduced if all the subsystems in the polytopic model has the same matrix $$B$$. This can be achieved by adding an Apkarian filter in the input of the system.

The Optimization Problem:
Apkarian Filter

Let consider our TS-LIA model. This can be re written in linear form as:

\dot{x} = A(z(t)) x + B(z(t)) u

$$

The filter should be such that the equilibrium of the states are the input values and the dynamics should be fast, so we could assume the dynamics of the filter negligible (i.e. the input of the filter is equivalent to the input of the quadrotor). One possible filter is shown, where $$ A_F$$ = −100$$ I_4$$, $$B_F$$ = 100$$I_4$$ and $$I_4$$ ∈ $$R^{4\times4}$$ is the identity matrix.

 * $$ \dot{x_F} = A_F x_F + B_F u_F; y_f = x_f$$.

When applying the filter, we are imposing that the output of the filter is the new input of the TS-LIA model (i.e. $$u$$ = $$y_F$$ ). Then, the extended model is:

\dot{x_c}= \begin{bmatrix} A(z(t))&B(z(t))\\ 0&A_F\\ \end{bmatrix} x_c + \begin{bmatrix}0\\B_F\end{bmatrix} u_F = A_e(z(t)) x_e + B_e u_f;

x_e = \begin{bmatrix}x\\x_F \end{bmatrix} $$

This prefiltering does not affect the procedure followed to obtain the TS-LIA model, so the premise variables, membership functions and activations functions remains the same.

State Feedback Controller Design

Let consider the state feedback control law for the extended TS-LIA model:$$ \dot{x_e} = \sum_{i=1}^{32} h_i(z(t)) [ A_{ei} x_e + B_{ei} u_F ]$$, where the state feedback control laws are :$$ u_F= \sum_{i=1}^{32} h_i(z(t)) K_i x(t) $$, we get the closed loop system  :$$ \dot{x_e} = \sum_{i=1}^{32} \sum_{j=1}^{32} h_j(z(t)) [ A_{ei} x_e + B_{ei} K_j ]x_e$$

The LMI:
The design of the controller is done by solving an LMI problem involving the quadratic stability constraints. In case we want D- stabilization, the following set of LMI constraints are needed:

 * $$L \otimes P + M \otimes P (A_{ei} + B_e K_i) + MT \otimes (A_ei + B_e K_i)^T P < 0$$ ∀i = 1, . . ., 32.

A pair of conjugate complex poles s of the closed loop system can be written as $$s$$ = − $${\xi} \omega_n \pm j\omega_d $$where $$\xi$$ is the damping ratio,$$\omega_n$$ is the undamped natural frequency and $$\omega_d $$ is the frequency response defined as $$ \omega_d = \omega_n$$ $$ \sqrt{1-\xi^2}$$.Three different LMI regions have been considered, each one related with a performance specification regarding $$ \alpha = \xi \omega_n,\omega_n$$ and $$\xi$$:

Minimum Decay Rate:

If we want to set a minimum decay rate α in the closed loop system response, the poles should be inside the LMI region defined in : $$S_{\alpha}$$ = [s = x + j y | x < − $$ \alpha $$].where $$ \alpha $$ > 0. In this case L$$_\alpha$$ = $$ 2 \alpha $$ and M$$_\alpha$$ = 1.

Applying condition to the closed-loop system, the LMI condition associated to this LMI region is:

 * $$ 2 \alpha P + (A_{ei} + B_e K_i)^T P + P (A_{ei} + B_e K_i) < 0$$ ∀i = 1, . . ., 32.

Conclusion:
The LMI is feasible.

Related LMIs

 * Apkarian Filter and State Feedback. https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Apkarian_Filter-and_State_Feedback
 * Maximum Natural Frequency in State Feedback https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Maximum_Natural_Frequency_in_State_Feedback#The_LMI%3A

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
LMIs in Control/Click here to continue/Controller synthesis/Maximum Natural Frequency in State Feedback

The System:
The number of LMI constraints needed to check quadratic stability is reduced if all the subsystems in the polytopic model has the same matrix $$B$$. This can be achieved by adding an Apkarian filter in the input of the system.

The Optimization Problem:
Apkarian Filter

Let consider our TS-LIA model. This can be re written in linear form as:

\dot{x} = A(z(t)) x + B(z(t)) u

$$

The filter should be such that the equilibrium of the states are the input values and the dynamics should be fast, so we could assume the dynamics of the filter negligible (i.e. the input of the filter is equivalent to the input of the quadrotor). One possible filter is shown, where $$ A_F$$ = −100$$ I_4$$, $$B_F$$ = 100$$I_4$$ and $$I_4$$ ∈ $$R^{4\times4}$$ is the identity matrix.

 * $$ \dot{x_F} = A_F x_F + B_F u_F; y_f = x_f$$.

When applying the filter, we are imposing that the output of the filter is the new input of the TS-LIA model (i.e. $$u$$ = $$y_F$$ ). Then, the extended model is:

\dot{x_c}= \begin{bmatrix} A(z(t))&B(z(t))\\ 0&A_F\\ \end{bmatrix} x_c + \begin{bmatrix}0\\B_F\end{bmatrix} u_F = A_e(z(t)) x_e + B_e u_f;

x_e = \begin{bmatrix}x\\x_F \end{bmatrix} $$

This prefiltering does not affect the procedure followed to obtain the TS-LIA model, so the premise variables, membership functions and activations functions remains the same.

State Feedback Controller Design

Let consider the state feedback control law for the extended TS-LIA model:$$ \dot{x_e} = \sum_{i=1}^{32} h_i(z(t)) [ A_{ei} x_e + B_{ei} u_F ]$$, where the state feedback control laws are :$$ u_F= \sum_{i=1}^{32} h_i(z(t)) K_i x(t) $$, we get the closed loop system  :$$ \dot{x_e} = \sum_{i=1}^{32} \sum_{j=1}^{32} h_j(z(t)) [ A_{ei} x_e + B_{ei} K_j ]x_e$$

The LMI:
The design of the controller is done by solving an LMI problem involving the quadratic stability constraints. In case we want D- stabilization, the following set of LMI constraints are needed:

 * $$L \otimes P + M \otimes P (A_{ei} + B_e K_i) + MT \otimes (A_ei + B_e K_i)^T P < 0$$ ∀i = 1, . . ., 32.

A pair of conjugate complex poles s of the closed loop system can be written as $$s$$ = − $${\xi} \omega_n \pm j\omega_d $$where $$\xi$$ is the damping ratio,$$\omega_n$$ is the undamped natural frequency and $$\omega_d $$ is the frequency response defined as $$ \omega_d = \omega_n$$ $$ \sqrt{1-\xi^2}$$.Three different LMI regions have been considered, each one related with a performance specification regarding $$ \alpha = \xi \omega_n,\omega_n$$ and $$\xi$$:

Maximizing Natural Frequency:

Natural frequency is related with the maximum frequency response in the undamped case ($$ \xi $$ = 0). If we want to set a maximum $$ \omega_n $$ condition, the LMI region associated is $$S_\rho$$ = [s = x + jy | |x + jy| < $$\rho$$], ::$$ L_\rho = \begin{bmatrix}-{\rho}&0\\0&\rho \end{bmatrix}, M_\rho = \begin{bmatrix}0&1\\0&0 \end{bmatrix} $$. Resulting LMI condition is:

\begin{bmatrix} - \rho P&P(A_{ei}+B_{ei} K_i)\\ (A_{ei}+B_{ei} K_i)^T P& - \rho P \end{bmatrix} < 0 $$ ∀i = 1,. . ., 32.

Conclusion:
The LMI is feasible.

Related LMIs

 * Apkarian Filter and State Feedback. https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Apkarian_Filter-and_State_Feedback
 * Minimum Decay Rate in State Feedback. https://en.wikibooks.org/wiki/LMIs_in_Control/pages/Minimum_Decay_Rate_in_State_Feedback#The_LMI%3A


text:
User:Kelti/sandbox/Test2

 * work in progress ***  work in progress  ***  work in progress  ***  work in progress  ***

Exercises

 * ... are available on another page (click here).

title: User:Kelti/sandbox/Test2


text:
User talk:Salil Kumar Mukherjee

Welcome!
Welcome, Salil Kumar Mukherjee!

If you have any questions, you can ask in the assistance reading room or possibly contact me personally. —Atcovi (Talk - Contribs) 16:25, 11 December 2021 (UTC)

title: User talk:Salil Kumar Mukherjee


text:
LMIs in Control/Click here to continue/Observer synthesis

Observer synthesis

 * 1) Continuous Time
 * 2) /FDI Filter Design For Systems With Sensor Faults/
 * 3) /Hurwitz Detectability/
 * 4) /Full-order state Observer/
 * 5) /Full-order Hinf state Observer/
 * 6) /Reduced-Order State Observer/
 * 7) /Switched Systems/
 * 8) Discrete-Time
 * 9) /Discrete-Time Detectability/
 * 10) /Schur Detectability/


text:
LMIs in Control/Click here to continue/Observer synthesis/FDI Filter Design For Systems With Sensor Faults

FDI Filter Design For Systems With Sensor Faults: an LMI

Systems with faulty sensors are a very common type of systems. In many cases, redundancy is added in the form of additional sensors, but in certain cases it could be a costly solution. For general linear system models, the LMI in this section can be utilized to design state estimators which can detect and isolate faulty sensor readings in order to mitigate their effects.

The System

\begin{align} \dot x(t)&=Ax(t)+B_1w(t) + B_2u(t)\\ y(t)&=Cx(t) + v(t) \end{align}$$

where $$ x(t) \in \R^n $$ is the state, $$ u(t) \in \R^m $$ is the control input, $$ w(t) \in \R^r $$ is the process noise, $$ y(t) \in \R^p $$ is the output and $$ v(t) \in \R^q $$ is the measurement noise.

The Data
The state space matrices $$ (A, B_1, B_2, C) $$ are required to be known.

The Optimization LMI
The following LMI is used to design the Fault Detection and Isolation (FDI) filter:

\begin{align} &\text{min}_{\Phi, \Theta, \gamma} \; \gamma, \\ &\text{subj. to: } \Phi > 0, \\ & \quad \quad \begin{bmatrix} A^\top\Phi + \Phi A + C^\top \Theta^\top + \Theta C & \Phi B_1 & \Theta & I \\ *                                       & -\gamma I & 0 & 0 \\ * & * & -\gamma I & 0 \\ * & * & * & -\gamma I \end{bmatrix} <0\\ \end{align}$$

Then the filter is $$ K = \Phi^{-1} \Theta $$.

Conclusion:
The LMI designed in this section is used to design filters that can work on systems that are prone to sensors getting damaged or faulty.

Implementation
To solve the feasibility LMI, YALMIP toolbox is required for setting up the feasibility problem, and SeDuMi is required to solve the problem. The following link showcases an example of the feasibility problem:

https://github.com/smhassaan/LMI-Examples/blob/master/FDI_Filter_example.m

Related LMIs
H-infinity Optimal Filter

H-infinity Optimal Observer


text:
LMIs in Control/Click here to continue/Observer synthesis/Hurwitz Detectability

Hurwitz Detectability
Hurwitz detectability is a dual concept of Hurwitz stabilizability and is defined as the matrix pair $$ (A, C) $$, is said to be Hurwitz detectable if there exists a real matrix $$ L $$ such that $$ A + LC $$ is Hurwitz stable.

The System

\begin{align} \dot x(t)&=Ax(t)+Bu(t),\\ y(t)&=Cx(t)+Du(t)\\ x(0)&=x_0\\ \end{align}$$

where $$x(t)\in \R^n$$, $$y(t)\in \R^m$$, $$u(t)\in \R^q$$, at any $$t\in \R$$.

The Data

 * The matrices $$ A,B,C,D $$ are system matrices of appropriate dimensions and are known.

The Optimization Problem
There exist a symmetric positive definite matrix $$ P $$ and a matrix $$ W $$ satisfying $$ A^TP + PA + W^TC + C^TW < 0 $$ There exists a symmetric positive definite matrix $$ P $$ satisfying $$ N_c^T ( A^TP + PA) N_c < 0 $$ with $$ N_c $$ being the right orthogonal complement of $$ C $$. There exists a symmetric positive definite matrix $$ P $$ such that $$ A^TP + PA < \gamma C^TC $$ for some scalar $$ \gamma > 0 $$

The LMI:
Matrix pair $$(A,C)$$, is Hurwitz detectable if and only if following LMI holds
 * $$ A^TP + PA + W^TC + C^TW < 0. $$
 * $$ N_c^T ( A^TP + PA) N_c < 0 $$
 * $$ A^TP + PA - \gamma C^TC < 0 $$

Conclusion:
Thus by proving the above conditions we prove that the matrix pair $$(A,C)$$ is Hurwitz Detectable.

Implementation
Find the MATLAB implementation at this link below Hurwitz detectability

Related LMIs
Links to other closely-related LMIs LMI for Hurwitz stability LMI for Schur stability Schur Detectability

Return to Main Page:

 * https://en.wikibooks.org/wiki/LMIs_in_Control


text:
LMIs in Control/Click here to continue/Observer synthesis/Full-order state Observer

Full-Order State Observer
The problem of constructing a simple full-order state observer directly follows from the result of Hurwitz detectability LMI's, Which essentially is the dual of Hurwitz stabilizability. If a feasible solution to the first LMI for Hurwitz detectability exist then using the results we can back out a full state observer $$ L $$ such that $$ A + LC $$ is Hurwitz stable.

The System

\begin{align} \dot x(t)&=Ax(t)+Bu(t),\\ y(t)&=Cx(t)+Du(t)\\ x(0)&=x_0\\ \end{align}$$

where $$x(t)\in \R^n$$, $$y(t)\in \R^m$$, $$u(t)\in \R^q$$, at any $$t\in \R$$.

The Data

 * The matrices $$ A,B,C,D $$ are system matrices of appropriate dimensions and are known.

The Optimization Problem
The full-order state observer problem essential is finding a positive definite $$ P $$ such that the following LMI conclusions hold.

The LMI:
1) The full-order state observer problem has a solution if and only if there exist a symmetric positive definite Matrix $$ P $$ and a matrix $$ W $$ that satisfy Then the observer can be obtained as $$ L = P^{-1}W $$ 2) The full-state state observer can be found if and only if there is a symmetric positive definite Matrix $$ P $$ that satisfies the below Matrix inequality In this case the observer can be reconstructed as $$ L = -\frac{1}{2}P^{-1}C^{T} $$. It can be seen that the second relation can be directly obtained by substituting $$ W= -\frac{1}{2}C^{T} $$ in the first condition.
 * $$ A^TP + PA + W^TC + C^TW < 0. $$
 * $$ A^TP + PA - C^TC < 0 $$

Conclusion:
Hence, both the above LMI's result in a full-order observer $$L$$ such that $$ A + LC $$ is Hurwitz stable.


text:
LMIs in Control/Click here to continue/Observer synthesis/Full-order Hinf state Observer

In this section, we design full order H-$$ \infty $$ state observer.

The System
Given a state-space representation of a linear system

\begin{align} \ \dot x(t) = Ax(t) + B_{1}u(t) + B_{2}w(t), x(0) = x_{0} \\ \ y(t) = C_{1}x(t) + D_{1}u(t) + D_{2}w(t) \\ \ z(t) = C_{2}x(t)\\ \end{align}$$

 * $$ x \in \mathbb{R}^{n}, y \in \mathbb{R}^{l}, z in \mathbb{R}^{m} $$ are the state vector, measured output vector and output vectors of interest.
 * $$ w \in \mathbb{R}^{p}, u \in \mathbb{R}^{r}, $$ are the disturbance vector and control vector respectively.

The Data
$$ A,B_{1},B_{2},C_{1},C_{2},D_{1},D_{2}$$ are system matrices

Definition
For the system, a full order state observer of the form of equation (1) is introduced and the estimate of interested output is given by.

The estimate of interested output is

Given the system and a positive scalar $$ \gamma $$, L is found such that

LMI Condition
The $$ H_{\infty}$$ state observers problem has a solution if and only if there exists a symmetric positive definite matrix $$ P $$ and a matrix $$ W $$ satisfying the below LMI

When such a pair of matrics is found, the solution is

Implementation
This implementation requires Yalmip and Mosek.
 * https://github.com/ShenoyVaradaraya/LMI--master/blob/main/hinf_obs.m

Conclusion
Thus, an $$H_{\infty} $$ state observer is designed such that the output vectors of interest are accurately estimated.


text:
LMIs in Control/Click here to continue/Observer synthesis/Reduced-Order State Observer

Reduced Order State Observer
The Reduced Order State Observer design paradigm follows naturally from the design of Full Order State Observer.

The System

\begin{align} \dot x(t)&=Ax(t)+Bu(t),\\ y(t)&=Cx(t)+Du(t)\\ x(0)&=x_0\\ \end{align} $$

where $$x(t)\in \R^n$$, $$y(t)\in \R^m$$, $$u(t)\in \R^q$$, at any $$t\in \R$$.

The Data

 * The matrices $$ A,B,C,D $$ are system matrices of appropriate dimensions and are known.

The Problem Formulation
Given a State-space representation of a system given as above. First an arbitrary matrix $$ R \in \R^{(n-m) x n} $$ is chosen such that the vertical augmented matrix given as

\begin{align} T=\begin{bmatrix} C \\ R \\ \end{bmatrix} \end{align} $$

is nonsingular, then

\begin{align} CT^{-1}=\begin{bmatrix} I_{m} & 0 \end{bmatrix} \end{align} $$

Furthermore, let

\begin{align} TAT^{-1}=\begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22} \\

\end{bmatrix} , A_{11} \in \R^{m x m} \end{align} $$

then the matrix pair $$ (A_{22},A_{12}) $$ is detectable if and only if $$ (A,C) $$ is detectable, then let

\begin{align} Tx=\begin{bmatrix} x_{1} \\ x_{2} \\ \end{bmatrix} , TB=\begin{bmatrix} B_{1} \\ B_{2} \\ \end{bmatrix} \end{align} $$ then a new system of the form given below can be obtained

\begin{align} \begin{bmatrix} \dot x_{1} \\ \dot x_{2} \\ \end{bmatrix} =\begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22} \\ \end{bmatrix} \begin{bmatrix} \dot x_{1} \\ \dot x_{2} \\ \end{bmatrix} + \begin{bmatrix} B_{1} \\ B_{2} \\ \end{bmatrix}u , y=x_{1} \end{align} $$

once an estimate of $$ x_{2} $$ is obtained the the full state estimate can be given as

\begin{align} \hat x= T^{-1}\begin{bmatrix} y \\ \hat x_{2} \\ \end{bmatrix} \end{align} $$ the the reduced order observer can be obtained in the form.

\begin{align} \dot z&=Fz+Gy+Hu,\\ \hat x_{2}&=Mz+Ny\\ \end{align} $$ Such that for arbitrary control and arbitrary initial system values, There holds

\begin{align} lim_{t \to \infty} (x_{2}-\hat x_{2}) = 0 \end{align} $$

The value for $$ F,G,H,M,N $$ can be obtain by solving the following LMI.

The LMI:
The reduced-order observer exists if and only if one of the two conditions holds.

1) There exist a symmetric positive definite Matrix $$ P $$ and a matrix $$ W $$ that satisfy
 * $$ A_{22}^TP + PA_{22} + W^A_{12} + A_{12}^TW < 0. $$

Then $$ L = P^{-1}W $$ 2) There exist a symmetric positive definite Matrix $$ P $$ that satisfies the below Matrix inequality Then $$ L = -\frac{1}{2}P^{-1}A_{12}^{T} $$.
 * $$ A_{22}^TP + PA_{22} - A_{12}^TA_{12} < 0 $$

By using this value of $$ L $$ we can reconstruct the observer state matrices as

\begin{align} F=A_{22}+LA{12}, G=(A_{21}+LA_{11}) - (A_{22}+LA_{12})L, H= B_{2}+LB_{1} , M=I , N=-L, \end{align} $$

Conclusion:
Hence, we are able to form a reduced-order observer using which we can back of full state information as per the equation given at the end of the problem formulation given above.


text:
LMIs in Control/Click here to continue/Observer synthesis/Discrete Time Detectability

Discrete-Time Detectability

A discrete time system operates on a discrete time signal input and produces a discrete time signal output. They are used in digital signal processing, such as digital filters for images or sound. The class of discrete time systems that are both linear and time invariant, known as discrete time LTI systems.

Discrete-Time LTI systems can be made detectable using observer gain L, which can be found using LMI optimization, such that the close loop system is detectable.

The System
Discrete-Time LTI System with state space realization $$(A_d,B_d,C_d,D_d)$$ $$ \begin{align} &A_d \in \bf{R^{n*n}}, &B_d \in \bf{R^{n*m}}, &C_d \in \bf{R^{p*n}}, &D_d \in \bf{R^{p*m}} \;\\ \end{align}$$

The Data
The matrices: System $$ (A_d,B_d,C_d,D_d), P, W $$.

The Optimization Problem
The following feasibility problem should be optimized:

Maximize P while obeying the LMI constraints. Then L is found.

The LMI:
Discrete-Time Detectability

The LMI formulation

$$ \begin{align} P \in {S^{n}}; W \in {R^{m*n}}\;\\ &P>0\\ \begin{bmatrix}P & A_d^TP+C_d^TW\\
 * & P\end{bmatrix}&>0,\\

L = P^{-1}W

\end{align}$$

Conclusion:
The system is detectabe iff there exits a $$P$$, such that $$P>0$$. The matrix $$A_d+LC_d$$ is Schur with $$L = P^{-1}W$$

Implementation
A link to CodeOcean or other online implementation of the LMIMATLAB Code

Related LMIs
- Continuous time Detectability


text:
LMIs in Control/Click here to continue/Observer synthesis/Schur Detectability

Schur Detectability

Schur detectability is a dual concept of Schur stabilizability and is defined as follows, the matrix pair $$ (A, C), $$ is said to be Schur detectable if there exists a real matrix $$ L $$ such that $$ A + LC $$ is Schur stable.

The System
We consider the following system:

$$ \begin{align} x(k+1) = Ax(k) + Bu(k)\\ y(k) = Cx(k) + Du(k)\\ \end{align}$$

where the matrices $$ A \in \mathbb{R}^{n\times n} $$, $$B \in \mathbb{R}^{n \times r} $$, $$ C \in \mathbb{R}^{m\times n} $$,$$ D \in \mathbb{R}^{m\times r} $$$$ x \in \mathbb{R}^{n} $$,$$ y \in \mathbb{R}^{m} $$, and $$ u \in \mathbb{R}^{r} $$ are the state matrix, input matrix, state vector, and the input vector, respectively.

Moreover, $$k$$ represents time in the discrete-time system and $$k+1$$ is the next time step.

The state feedback control law is defined as follows:

$$ \begin{align} u(k) = Kx(k) \end{align}$$

where $$K \in \mathbb{R}^{n\times r} $$ is the controller gain. Thus, the closed-loop system is given by:

$$ \begin{align} x(k+1) = (A + BK)x(k) \end{align}$$

The Data

 * The matrices $$ A,B,C,D $$ are system matrices of appropriate dimensions and are known.

The Optimization Problem
There exist a symmetric matrix $$ P $$ and a matrix W satisfying $$\begin{align} \begin{bmatrix}  -P &  A^TP + C^TW^T    \\ PA + WC  & P \end{bmatrix} < 0\\ \end{align}$$ There exists a symmetric matrix $$ P $$ satisfying $$\begin{align} \begin{bmatrix}  -N_c^TPN_c &  N_c^TA^TP    \\ PAN_c  & -P \end{bmatrix} < 0\\ \end{align}$$ with $$ N_c $$ being the right orthogonal complement of $$ C $$. There exists a symmetric matrix P such that $$\begin{align} \begin{bmatrix}  -P &  PA    \\ A^TP  & -P-\gamma C^TC \end{bmatrix} < 0\\ \end{align}$$ $$ \gamma > 1 $$

The LMI:
The LMI for Schur detectability can be written as minimization of the scalar, $$\gamma$$, in the following constraints:

$$ \begin{align} & \text{min} \quad \gamma\\ & \text{s.t.} \end{align}$$ $$\begin{align} \begin{bmatrix}  -P &  A^TP + C^TW^T    \\ PA + WC  & P \end{bmatrix} < 0\\ \end{align}$$ $$\begin{align} \begin{bmatrix}  -N_c^TPN_c &  N_c^TA^TP    \\ PAN_c  & -P \end{bmatrix} < 0\\ \end{align}$$ $$\begin{align} \begin{bmatrix}  -P &  PA    \\ A^TP  & -P-\gamma C^TC \end{bmatrix} < 0\\ \end{align}$$

Conclusion:
Thus by proving the above conditions we prove that the matrix pair $$(A,C)$$ is Schur Detectable.

Implementation
A link to Matlab codes for this problem in the Github repository: Schur Detectability

Related LMIs
LMI for Hurwitz stability LMI for Schur stability Hurwitz Detectability

Return to Main Page
LMIs in Control/Tools


text:
LMIs in Control/Click here to continue/Robust Controls

Robust Controls

 * 1) Continuous Time
 * 2) /Robust Stabilization of Second-Order Systems/
 * 3) /Robust Stabilization of Hinf Optimal State Feedback Control/
 * 4) /H2-Optimal State Feedback Synthesis/
 * 5) Discrete Time
 * 6) /Robust Hinf state Feedback Control/
 * 7) /Robust Unconstrained Model Predictive Control/
 * 8) /Robust Model Predictive Control with input and output constraints/


text:
LMIs in Control/Click here to continue/Robust Controls/Robust Stabilization of Second-Order Systems

Stabilization is a vastly important concept in controls, and is no less important for second order systems with perturbations. Such a second order system can be conceptualized most simply by the model of a mass-spring-damper, with added perturbations. Velocity and position are of course chosen as the states for this system, and the state space model can be written as it is below. The goal of stabilization in this context is to design a control law that is made up of two controller gain matrices $$ K_{p}$$, and $$ K_{d}$$. These allow the construction of a stabilized closed loop controller.

The System
In this LMI, we have an uncertain second-order linear system, that can be modeled in state space as:

\begin{align} (A_{2}+\Delta A_{2}) \ddot x + (A_{1} + \Delta A_{1})\dot x + (A_{0} + \Delta A_{0})x &= Bu )\\ y_{d} &= C_{d} \dot x\\ y_{p} &= C_{p} x \end{align}$$

where $$ x \in R^{n}$$ and $$ u \in R^{r}$$ are the state vector and the control vector, respectively, $$ y_{d} \in R^{m_{p}}$$ and $$ y_{d} \in R^{m_{p}}$$ are the derivative output vector and the proportional output vector, respectively, and $$ A_{2}, A_{1}, A_{0}, B, C_{d}, C_{p}$$ are the system coefficient matrices of appropriate dimensions.

$$ \Delta A_{2}, \Delta A_{1},$$ and $$ \Delta A_{0}$$ are the perturbations of matrices $$ A_{2}, A_{1},$$ and $$A_{0}$$, respectively, are bounded, and satisfy

\begin{align} \end{align}$$
 * \Delta A_{2}|_{2} \leq \epsilon_{2}, |\Delta A_{1}|_{2} \leq \epsilon_{1}, |\Delta A_{0}|_{2} \leq \epsilon_{0},

or

\begin{align} max\{\|\Delta a_{2ij}\|\} \leq \eta_{2}, max\{\|\Delta a_{1ij}\|\} \leq \eta_{1}, max\{\|\Delta a_{0ij}\|\} \leq \eta_{0}, \end{align}$$

where $$\epsilon_{2}, \epsilon_{1}, \epsilon_{0}$$ and $$\eta_{2}, \eta_{1}, \eta_{0}$$ are two sets of given positive scalars, $$\Delta a_{2ij}, \Delta a_{1ij},$$ and $$\Delta a_{0ij}$$ are the i-th row and j-th collumn elements of matrices $$\Delta A_{2}, \Delta A_{1}, $$ and $$\Delta A_{0}, $$, respectively. Also, the perturbation notations also satisfy the assumption that $$ \Delta A_{2}, \Delta A_{0} \in S^{n} $$ and $$ A_{2} + \Delta A_{2} > 0$$.

To further define: $$x$$ is$$\in R^{n}$$ and is the state vector, $$A_{0} $$ is $$\in R^{n*n}$$ and is the state matrix on $$ x $$, $$A_{1} $$ is $$\in R^{n*n}$$ and is the state matrix on $$ \dot x $$ , $$A_{2} $$ is $$\in R^{n*n}$$ and is the state matrix on $$ \ddot x $$, $$B$$ is $$\in R^{n*r}$$ and is the input matrix, $$u$$ is $$\in R^{r}$$ and is the input, $$C_{d} $$ and $$C_{p} $$ are $$\in R^{m*n}$$ and are the output matrices, $$y_{d}$$ is $$\in R^{m}$$ and is the output from $$C_{d} $$, and $$y_{p}$$ is $$\in R^{m}$$ and is the output from $$C_{p} $$.

The Data
The matrices $$ A_{2}, A_{1}, A_{0}, B, C_d, C_p $$ and perturbations $$ \Delta A_{2}, \Delta A_{1}, \Delta A_{0}, $$ describing the second order system with perturbations.

The Optimization Problem
For the system defined as shown above, we need to design a feedback control law such that the following system is Hurwitz stable. In other words, we need to find the matrices $$ K_{p}$$ and $$ K_{d}$$ in the below system.

\begin{align} (A_{2}+\Delta A_{2}) \ddot x + (A_{1} - BK_{p}C_{p} + \Delta A_{1})\dot x + (A_{0} - BK_{d}C_{d} + \Delta A_{0})x &= 0 \\ \end{align}$$

However, to do proceed with the solution, first we need to present a Lemma. This Lemma comes from Appendix A.6 in "LMI's in Control systems" by Guang-Ren Duan and Hai-Hua Yu. This Lemma states the following: if $$A_{2} > 0, A_{1} + A_{1}^{T} > 0, A_{0} > 0$$, then the following is also true for the system described above:

The system is hurwitz stable if

\begin{align} \lambda_{min}(A_{2}) > |\Delta A_{2}|_{2}, \lambda_{min}(A_{1} + A_{1}^{T}) > |\Delta A_{1}|_{2}, \lambda_{min}(A_{0}) > |\Delta A_{0}|_{2}\end{align}$$,

or

the system is hurwitz stable if

\begin{align}\lambda_{min}(A_{2}) > \sqrt{l_{2}}max\{\|\Delta a_{2ij}\|\}, \lambda_{min}(A_{1} + A_{1}^{T}) > \sqrt{l_{1}}max\{\|\Delta a_{1ij}\|\}, \lambda_{min}(A_{0}) > \sqrt{l_{0}}max\{\|\Delta a_{0ij}\|\}\end{align}$$

, where $$l_{2}, l_{1}, l_{0}$$ are the numbers of nonzero elements in matrices $$ \Delta A_{2}, \Delta A_{1}, \Delta A_{0},$$ respectively.

The LMI: Robust Stabilization of Second Order Systems
This problem is solved by finding matrices $$K_{p} \in R^{r*m_{p}}$$ and $$K_{d} \in R^{r*m_{d}}$$ that satisfy either of the following sets of LMIs.

\begin{align} A_{0} - BK_{d}C_{d} &> \epsilon_{0}I,\\ (A_{1} - BK_{p}C_{p}) + (A_{1} - BK_{p}C_{p})^{T} &> \epsilon_{1}I. \end{align}$$

or

\begin{align} A_{0} - BK_{d}C_{d} &> \eta_{0}\sqrt{l_{0}}I,\\ (A_{1} - BK_{p}C_{p}) + (A_{1} - BK_{p}C_{p})^{T} &> \eta_{1}\sqrt{l_{1}}I. \end{align}$$

Conclusion:
Having solved the above problem, the matrices $$K_{p}$$ and $$K_{d}$$ can be substituted into the input as $$ u = K_{p}C_{p}\dot x + K_{d}C_{d}x $$ to robustly stabilize the second order uncertain system. The new system is stable in closed loop.

Implementation
This implementation requires Yalmip and Sedumi.

https://github.com/rezajamesahmed/LMImatlabcode/blob/master/ROBstab2ndorder.m

Related LMIs
Stabilization of Second-Order Systems


text:
LMIs in Control/Click here to continue/Robust Controls/Robust Stabilization of Hinf Optimal State Feedback Control

Additive uncertainty
Full State Feedback is a control technique which places a given system's closed loop system poles in locations specified by desired performance specifications. One can use $$H_{\infty}$$ methods to turn this into an optimization problem with the goal to minimize the impact of uncertain perturbations in a closed loop system while maintaining system stability. This is done by minimizing the $$ H_{\infty} $$ norm of the uncertain closed loop system, which minimizes the worst case effect of the system disturbance or perturbation. This can be done for single-input single-output (SISO) or multiple-input multiple-output (MIMO) systems. Here we consider the case of a MIMO system with additive uncertainties.

The System
Consider linear system with uncertainty below:
 * $$\begin{bmatrix} \dot{x}\\z \end{bmatrix} = \begin{bmatrix} (A+{\Delta}A) & (B_{1}+{\Delta}B_{1}) & B_{2}\\ C & D_{1} & D_{2} \end{bmatrix} \begin{bmatrix} x\\u\\w \end{bmatrix}

$$ Where $$x(t)\in \R^n$$ is the state, $$z(t)\in \R^m$$ is the output, $$w(t)\in \R^p$$ is the exogenous input or disturbance vector, and $$u(t)\in \R^r$$ is the actuator input or control vector, at any $$t\in \R$$

$$ {\Delta}A $$ and $$ {\Delta}B_{1} $$ are real-valued matrices which represent the time-varying parameter uncertainties in the form:

$$ \begin{bmatrix} {\Delta}A & {\Delta}B_{1} \end{bmatrix} = H F \begin{bmatrix} E_{1} & E_{2} \end{bmatrix} $$

Where

$$ H, E_{1}, E_{2} $$ are known matrices with appropriate dimensions and $$ F $$ is the uncertain parameter matrix which satisfies: $$ F^TF \le I $$

For additive perturbations: $$ {\Delta}A = {\delta}_{1}A_{1}+{\delta}_{2}A_{2}+...+{\delta}_{k}A_{k} $$

Where

$$ A_{i}, i = 1, 2, ... k $$ are the known system matrices and

$$ {\delta}_{i}, i = 1, 2, ... k $$ are the perturbation parameters which satisfy $$ \vert {\delta}_{i} \vert < r_{i}, i = 1, 2, ..., k $$

Thus, $$ {\Delta}A = HFE $$ with

$$ H = \begin{bmatrix} A_{1} & A_{2} & ... & A_{k} \end{bmatrix} $$

$$ E = (\sum_{i=1}^k r_{i}^2)^{1/2} $$

$$ F = (\sum_{i=1}^k r_{i}^2)^{-1/2} \begin{bmatrix} {\delta}_{1}I \\ {\delta}_{2}I \\ \vdots \\ {\delta}_{k}I \end{bmatrix} $$

The Data
$$A$$, $$B_{1}$$, $$B_{2}$$, $$C$$, $$D_{1}$$, $$D_{2}$$, $$E_{1}$$, $$E_{2}$$, $$ {\gamma} $$ are known.

The LMI:Full State Feedback Optimal $$H_{\infty}$$ Control LMI
There exists $$X>0$$ and $$W$$ and scalar $$ {\alpha} $$ such that

 * $$\begin{bmatrix} {\Psi}(X,W) & B_{2} & (CX+D_{1}W)^{T} & (E_{1}X+E_{2}W)^{T} \\ B_{2}^{T} & -{\gamma}I & D_{2}^{T} & 0\\ CX+D_{1}W & D_{2} & -{\gamma}I & 0 \\ E_{1}X+E_{2}W & 0 & 0 & -{\alpha}I \end{bmatrix}<0

$$.

Where $$ {\Psi}(X,W) = (AX+B_{1}W)_{s} + {\alpha}HH^{T} $$

And $$K=WX^{-1}$$.

Conclusion:
Once K is found from the optimization LMI above, it can be substituted into the state feedback control law $$ u(t) = Kx(t) $$ to find the robustly stabilized closed loop system as shown below:

 * $$\begin{bmatrix} \dot{x}\\z \end{bmatrix} = \begin{bmatrix} (A+{\Delta}A)+(B_{1}+{\Delta}B_{1})K & B_{2}\\ (C + D_{1})K & D_{2} \end{bmatrix} \begin{bmatrix} x\\w \end{bmatrix}

$$

where $$x(t)\in \R^n$$ is the state, $$z(t)\in \R^m$$ is the output, $$w(t)\in \R^p$$ is the exogenous input or disturbance vector, and $$u(t)\in \R^r$$ is the actuator input or control vector, at any $$t\in \R$$

Finally, the transfer function of the system is denoted as follows:

$$ G_{zw}(s) = (C+D_{1}K)(sI-[(A+{\Delta}A)+(B_{1}+{\Delta}B_{1})K])^{-1}B_{2}+D_{2} $$

Implementation
This implementation requires Yalmip and Sedumi. https://github.com/rubindan/LMIcontrol/blob/master/HinfFilter.m

Related LMIs
Full State Feedback Optimal H_inf LMI

Return to Main Page:
LMIs in Control: https://en.wikibooks.org/wiki/LMIs_in_Control


text:
LMIs in Control/Click here to continue/Robust Controls/Robust Hinf state Feedback Control

Additive uncertainty
Full State Feedback is a control technique which places a given system's closed loop system poles in locations specified by desired performance specifications. One can use $$H_{\infty}$$ methods to turn this into an optimization problem with the goal to minimize the impact of uncertain perturbations in a closed loop system while maintaining system stability. This is done by minimizing the $$ H_{\infty} $$ norm of the uncertain closed loop system, which minimizes the worst case effect of the system disturbance or perturbation. This can be done for single-input single-output (SISO) or multiple-input multiple-output (MIMO) systems. Here we consider the case of a MIMO system with additive uncertainties.

The System
Consider linear system with uncertainty below:
 * $$\begin{bmatrix} \dot{x}\\z \end{bmatrix} = \begin{bmatrix} (A+{\Delta}A) & (B_{1}+{\Delta}B_{1}) & B_{2}\\ C & D_{1} & D_{2} \end{bmatrix} \begin{bmatrix} x\\u\\w \end{bmatrix}

$$ Where $$x(t)\in \R^n$$ is the state, $$z(t)\in \R^m$$ is the output, $$w(t)\in \R^p$$ is the exogenous input or disturbance vector, and $$u(t)\in \R^r$$ is the actuator input or control vector, at any $$t\in \R$$

$$ {\Delta}A $$ and $$ {\Delta}B_{1} $$ are real-valued matrices which represent the time-varying parameter uncertainties in the form:

$$ \begin{bmatrix} {\Delta}A & {\Delta}B_{1} \end{bmatrix} = H F \begin{bmatrix} E_{1} & E_{2} \end{bmatrix} $$

Where

$$ H, E_{1}, E_{2} $$ are known matrices with appropriate dimensions and $$ F $$ is the uncertain parameter matrix which satisfies: $$ F^TF \le I $$

For additive perturbations: $$ {\Delta}A = {\delta}_{1}A_{1}+{\delta}_{2}A_{2}+...+{\delta}_{k}A_{k} $$

Where

$$ A_{i}, i = 1, 2, ... k $$ are the known system matrices and

$$ {\delta}_{i}, i = 1, 2, ... k $$ are the perturbation parameters which satisfy $$ \vert {\delta}_{i} \vert < r_{i}, i = 1, 2, ..., k $$

Thus, $$ {\Delta}A = HFE $$ with

$$ H = \begin{bmatrix} A_{1} & A_{2} & ... & A_{k} \end{bmatrix} $$

$$ E = (\sum_{i=1}^k r_{i}^2)^{1/2} $$

$$ F = (\sum_{i=1}^k r_{i}^2)^{-1/2} \begin{bmatrix} {\delta}_{1}I \\ {\delta}_{2}I \\ \vdots \\ {\delta}_{k}I \end{bmatrix} $$

The Data
$$A$$, $$B_{1}$$, $$B_{2}$$, $$C$$, $$D_{1}$$, $$D_{2}$$, $$E_{1}$$, $$E_{2}$$, $$ {\gamma} $$ are known.

The LMI:Full State Feedback Optimal $$H_{\infty}$$ Control LMI
There exists $$X>0$$ and $$W$$ and scalar $$ {\alpha} $$ such that

 * $$\begin{bmatrix} {\Psi}(X,W) & B_{2} & (CX+D_{1}W)^{T} & (E_{1}X+E_{2}W)^{T} \\ B_{2}^{T} & -{\gamma}I & D_{2}^{T} & 0\\ CX+D_{1}W & D_{2} & -{\gamma}I & 0 \\ E_{1}X+E_{2}W & 0 & 0 & -{\alpha}I \end{bmatrix}<0

$$.

Where $$ {\Psi}(X,W) = (AX+B_{1}W)_{s} + {\alpha}HH^{T} $$

And $$K=WX^{-1}$$.

Conclusion:
Once K is found from the optimization LMI above, it can be substituted into the state feedback control law $$ u(t) = Kx(t) $$ to find the robustly stabilized closed loop system as shown below:

 * $$\begin{bmatrix} \dot{x}\\z \end{bmatrix} = \begin{bmatrix} (A+{\Delta}A)+(B_{1}+{\Delta}B_{1})K & B_{2}\\ (C + D_{1})K & D_{2} \end{bmatrix} \begin{bmatrix} x\\w \end{bmatrix}

$$

where $$x(t)\in \R^n$$ is the state, $$z(t)\in \R^m$$ is the output, $$w(t)\in \R^p$$ is the exogenous input or disturbance vector, and $$u(t)\in \R^r$$ is the actuator input or control vector, at any $$t\in \R$$

Finally, the transfer function of the system is denoted as follows:

$$ G_{zw}(s) = (C+D_{1}K)(sI-[(A+{\Delta}A)+(B_{1}+{\Delta}B_{1})K])^{-1}B_{2}+D_{2} $$

Implementation
This implementation requires Yalmip and Sedumi. https://github.com/rubindan/LMIcontrol/blob/master/HinfFilter.m

Related LMIs
Full State Feedback Optimal H_inf LMI

Return to Main Page:
LMIs in Control: https://en.wikibooks.org/wiki/LMIs_in_Control


text:
LMIs in Control/Click here to continue/Time-Delay Systems

Time-Delay Systems

 * 1) Continuous Time
 * 2) /LMI for Time-Delay system on delay Independent Condition/
 * 3) /LMI for Time-Delay system on delay Dependent Condition/
 * 4) /LMI for Stability of Retarded Differential Equation with Slowly-Varying Delay/
 * 5) /LMI for Robust Stability of Retarded Differential Equation with Norm-Bounded Uncertainty/
 * 6) /Bounded Real Lemma under Slowly-Varying Delay/
 * 7) /LMI for L2-Optimal State-Feedback Control under Time-Varying Input Delay/
 * 8) /LMI for mu-Analysis/
 * 9) Discrete Time
 * 10) /Stability Condition for Discrete-Time TDS/


text:
LMIs in Control/Click here to continue/Time-Delay Systems/LMI for Time-Delay system on delay Independent Condition

The System
The problem is to check the stability of the following linear time-delay system

\begin{align} \begin{cases} \dot x(t)&=Ax(t)+A_dx(t-d)\\ x(t)&=\phi(t), t\in[-d,0], 0 < d \leq \bar{d},\\ \end{cases} \end{align}$$

where

\begin{align} {A, A_d}\in\mathbb{R}^{n\times n}\text{, }{A}\in\mathbb{R}^{n\times r}\text{ are the system coefficient matrices,}\\ \end{align}$$

$$ \phi (t) $$ is the initial condition $$d$$ represents the time-delay $$\bar d$$ is a known upper-bound of $$d$$

The Data
The matrices $$A, A_d$$ are known

The LMI: The Time-Delay systems (Delay Independent Condition)
From the given pieces of information, it is clear that the optimization problem only has a solution if there exists two symmetric matrices $$P,S\in\mathbb{S}^{n}$$ such that

$$P>0$$

\begin{bmatrix} A^TP+PA+S & PA_d \\ A_d^TP & -S \end{bmatrix}$$$$\begin{align}< 0\end{align}$$

This LMI has been derived from the Lyapunov function for the system. By Schur Complement we can see that the above matrix inequality is equivalent to the Riccati inequality $$ A^TP+PA+PA_dS^{-1}A_d^TP+S<0$$

Conclusion:
We can now implement these LMIs to do stability analysis for a Time delay system on the delay independent condition

Implementation
The implementation of the above LMI can be seen here

https://github.com/yashgvd/LMI_wikibooks

Related LMIs
Time Delay systems (Delay Dependent Condition)


text:
LMIs in Control/Click here to continue/Time-Delay Systems/LMI for Time-Delay system on delay Dependent Condition

The System
The problem is to check the stability of the following linear time-delay system on a delay dependent condition

\begin{align} \begin{cases} \dot x(t)&=Ax(t)+A_dx(t-d)\\ x(t)&=\phi(t), t\in[-d,0], 0 < d \leq \bar{d},\\ \end{cases} \end{align}$$

where

\begin{align} {A, A_d}\in\mathbb{R}^{n\times n}, A\in\mathbb{R}^{n\times r}\text{ are the system coefficient matrices,}\\ \end{align}$$

$$ \phi (t) $$ is the initial condition $$d$$ represents the time-delay $$\bar d$$ is a known upper-bound of $$d$$

For the purpose of the delay dependent system we rewrite the system as

\begin{cases} \dot x(t) &= Ax(t)+A_dx(t-d)\\ \dot x(t) &= (A+A_d)x(t)-A_d(x(t)-x(t-d) \end{cases} $$

The Data
The matrices $$A, A_d$$ are known

The LMI: The Time-Delay systems (Delay Dependent Condition)
From the given pieces of information, it is clear that the optimization problem only has a solution if there exists a symmetric positive definite matrix $$X$$ and a scalar $$0< \beta <1$$ such that

\begin{bmatrix} \Phi(X) & \bar dXA^T & \bar dXA_d^T\\ \bar dAX & -d \beta I & 0\\ \bar dA_dX & 0 & -\bar d(1- \beta )I \end{bmatrix}$$$$\begin{align}< 0\end{align}$$

Here $$ \Phi(X) =X)A+A_d)^T + (A+A_d)X+ \bar d A_dA_d^T<0 $$

This LMI has been derived from the Lyapunov function for the system. It follows that the system is asymptotically stable if

$$ P(A+A_d) + (A+A_d)^TP + \bar dPA_dA_d^TP + \frac {\bar d}{\beta}A^TA +\frac {\bar d}{1- \beta} A_d^TA_d<0$$ This is obtained by replacing $$X$$ with $$P^{-1}$$

Conclusion:
We can now implement these LMIs to do stability analysis for a Time delay system on the delay dependent condition

Implementation
The implementation of the above LMI can be seen here

https://github.com/yashgvd/LMI_wikibooks

Related LMIs
Time Delay systems (Delay Independent Condition)


text:
LMIs in Control/Click here to continue/Time-Delay Systems/LMI for Stability of Retarded Differential Equation with Slowly-Varying Delay

This page describes an LMI for stability analysis of a continuous-time system with a time-varying delay. In particular, a delay-independent condition is provided to test uniform asymptotic stability of a retarded differential equation through feasibility of an LMI. The system under consideration pertains a single discrete delay, with the extent of the delay at any time bounded by some known value. Moreover, the delay is assumed to vary only slowly in time, with a temporal derivative bounded by a value less than one. Solving the LMI for a particular value of this bound, uniform asymptotic stability can be shown for any time-delay satisfying this bound.

The System
The system under consideration is one of the form:

\begin{align}

\dot{x}(t) &= Ax(t) + A_1x(t-\tau(t)) & t&\geq t_0, & 0&\leq\tau(t) \leq h, & \dot{\tau}(t)&\leq d<1

\end{align} $$

In this description, $$ A $$ and $$ A_1 $$ are matrices in $$ \mathbb{R}^{n\times n} $$. The variable $$ \tau(t) $$ denotes a delay in the state at time $$ t\geq t_0 $$, assuming a value no greater than some $$ h\in\mathbb{R}_+ $$. Moreover, we assume that the function $$ \tau(t) $$ is differentiable at any time, with the derivative bounded by some value $$ d<1 $$, assuring the delay to be slowly-varying in time.

The Data
To determine stability of the system, the following parameters must be known:

$$ \begin{align} A&\in\mathbb{R}^{n\times n} \\ A_1&\in\mathbb{R}^{n\times n} \\ d&\in [0,1) \end{align} $$

The Optimization Problem
Based on the provided data, uniform asymptotic stability can be determined by testing feasibility of the following LMI:

The LMI: Delay-Independent Uniform Asymptotic Stability for Continuous-Time TDS

\begin{align} &\text{Find}:\\ &\qquad P, Q \in\mathbb{R}^{n\times n}\\ &\text{such that:}\\ &\qquad P>0,\quad Q>0  \\ &\qquad \begin{bmatrix} A^T P+PA+Q & PA_1 \\ A_1^TP & -(1-d)Q \end{bmatrix}<0 \\ \end{align}

$$

Conclusion:
If the presented LMI is feasible, the system will be uniformly asymptotically stable for any delay function $$ \tau(t) $$ satisfying $$ \dot{\tau}(t)\leq d<1 $$. That is, independent of the values of the delays $$ \tau(t) $$ and the starting time $$ t_0\in\mathbb{R} $$:

 * For any real number $$ \epsilon>0 $$, there exists a real number $$ \delta>0 $$ such that:

 * $$ \|x_{t_0}\|_{\mathcal{C}}<\delta \quad \Rightarrow \quad \|x(t)\|<\epsilon \qquad \forall t\geq t_0 $$

 * There exists a real number $$ \delta_a>0 $$ such that for any real number $$ \eta>0 $$, there exists a time $$ T(\delta_a,\eta) $$ such that:

 * $$ \|x_{t_0}\|_{\mathcal{C}}<\delta_a \quad \Rightarrow \quad \|x(t)\|<\eta \qquad \forall t\geq t_0+T(\delta_a,\eta) $$

Here, we let $$ x_{t_0}(\theta)=x(t_0+\theta) $$ for $$ \theta\in[-\tau(t_0),0] $$ denote the delayed state function at time $$ t_0 $$. The norm $$ \|x_{t_0}\|_{\mathcal{C}} $$ of this function is defined as the maximal value of the vector norm assumed by the state over the delayed time interval, given by:

 * $$ \|x_{t_0}\|_{\mathcal{C}}:=\max_{\theta\in[-\tau(t_0),0]} \|x(t_0+\theta)\| $$

Obtaining a feasible point for the LMI, this result can be proven using a Lyapunov-Krasovkii functional:

\begin{align} &V(t,x_t)=x^T(t)Px(t) + \int_{t-\tau(t)}^t x^T(s)Qx(s) ds\\ \end{align} $$

Notably, if matrices $$ P>0,Q>0 $$ prove feasibility of the LMI for the pair $$ (A,A_1) $$, these same matrices will also prove feasibility of the LMI for the pair $$ (A,-A_1) $$. As such, feasibility of this LMI proves uniform asymptotic stability of both systems:

\begin{align}

\dot{x}(t) &= Ax(t) \pm A_1x(t-\tau(t)) & t&\geq t_0, & 0&\leq\tau(t) \leq h & \dot{\tau}(t)&\leq d<1

\end{align} $$

Moreover, since the result is independent of the value of the delay, it will also hold for a delay $$ \tau(t)\equiv 0 $$. Hence, if the LMI is feasible, the matrices $$ A\pm A_1 $$ will be Hurwitz.

Implementation
An example of the implementation of this LMI in Matlab is provided on the following site:

 * https://github.com/djagt/LMI_Codes/blob/main/stblty_cTDS_SlowVarying.m

Note that this implementation requires packages for YALMIP with solver mosek, though a different solver can also be implemented.

Related LMIs

 * - Delay-dependent stability LMI for continuous-time TDS

 * - Stability LMI for delayed discrete-time system


text:
LMIs in Control/Click here to continue/Time-Delay Systems/LMI for Robust Stability of Retarded Differential Equation with Norm-Bounded Uncertainty

This page describes an LMI for stability analysis of an uncertain continuous-time system with a time-varying delay. In particular, a delay-independent condition is provided to test uniform asymptotic stability of a retarded differential equation with uncertain matrices through feasibility of an LMI. The system under consideration pertains a single discrete delay, with the extent of the delay at any time bounded by some known value. The matrices describing the system are assumed to be uncertain, with the norm of the uncertainty bounded by a value of one. In addition, the delay is assumed to vary only slowly in time, with a temporal derivative bounded by a value less than one. Solving the LMI for a particular value of this bound, uniform asymptotic stability can be shown for any time-delay satisfying this bound, independent of the value of the uncertainty function.

The System
The system under consideration is one of the form:

\begin{align}

\dot{x}(t) &= (A+H\Delta(t) E)x(t) + (A_1+H\Delta(t) E_1)x(t-\tau(t)) & t&\geq t_0, & 0&\leq\tau(t) \leq h, & \dot{\tau}(t)&\leq d<1

\end{align} $$

In this description, $$ A $$ and $$ A_1 $$ are matrices in $$ \mathbb{R}^{n\times n} $$. The variable $$ \tau(t) $$ denotes a delay in the state at time $$ t\geq t_0 $$, assuming a value no greater than some $$ h\in\mathbb{R}_+ $$. Moreover, we assume that the function $$ \tau(t) $$ is differentiable at any time, with the derivative bounded by some value $$ d<1 $$, assuring the delay to be slowly-varying in time. The uncertainty $$ \Delta(t)\in\mathbb{R}^{r_1\times r_2} $$ is also allowed to vary in time, but at any time $$ t\geq t_0 $$ must satisfy the inequality:

\begin{align}

\Delta^T(t)\Delta(t) &\leq I

\end{align} $$

The uncertainty affects the system through matrices $$ H\in\mathbb{R}^{n\times r_1} $$ and $$ E,E_1\in\mathbb{R}^{r_2\times n} $$, which are constant in time and assumed to be known.

The Data
To determine stability of the system, the following parameters must be known:

$$ \begin{align} A,A_1&\in\mathbb{R}^{n\times n} \\ H&\in\mathbb{R}^{n\times r_1} \\ E,E_1&\in\mathbb{R}^{r_2\times n} \\ d&\in [0,1) \end{align} $$

The Optimization Problem
Based on the provided data, uniform asymptotic stability can be determined by testing feasibility of the following LMI:

The LMI: Delay-Independent Robust Uniform Asymptotic Stability for Continuous-Time TDS

\begin{align} &\text{Find}:\\ &\qquad \epsilon\in\mathbb{R}, \quad P, Q \in\mathbb{R}^{n\times n}\\ &\text{such that:}\\ &\qquad \epsilon>0,\quad P>0,\quad Q>0  \\ &\qquad \begin{bmatrix} A^T P+PA+Q & PA_1 & PH & \epsilon E^T \\ A_1^TP & -(1-d)Q & 0 & \epsilon E_1^T \\ H^T P & 0 & -\epsilon I & 0 \\ \epsilon E & \epsilon E_1 & 0 & -\epsilon I \end{bmatrix}<0 \\ \end{align}

$$

Conclusion:
If the presented LMI is feasible, the system will be uniformly asymptotically stable for any delay function $$ \tau(t) $$ satisfying $$ \dot{\tau}(t)\leq d<1 $$, and any uncertainty $$ \Delta(t) $$ satisfying $$ \Delta^T(t)\Delta(t)\leq I $$. That is, independent of the values of the delays $$ \tau(t) $$, uncertainties $$ \Delta(t) $$, and the starting time $$ t_0\in\mathbb{R} $$:

 * For any real number $$ \epsilon>0 $$, there exists a real number $$ \delta>0 $$ such that:

 * $$ \|x_{t_0}\|_{\mathcal{C}}<\delta \quad \Rightarrow \quad \|x(t)\|<\epsilon \qquad \forall t\geq t_0 $$

 * There exists a real number $$ \delta_a>0 $$ such that for any real number $$ \eta>0 $$, there exists a time $$ T(\delta_a,\eta) $$ such that:

 * $$ \|x_{t_0}\|_{\mathcal{C}}<\delta_a \quad \Rightarrow \quad \|x(t)\|<\eta \qquad \forall t\geq t_0+T(\delta_a,\eta) $$

Here, we let $$ x_{t_0}(\theta)=x(t_0+\theta) $$ for $$ \theta\in[-\tau(t_0),0] $$ denote the delayed state function at time $$ t_0 $$. The norm $$ \|x_{t_0}\|_{\mathcal{C}} $$ of this function is defined as the maximal value of the vector norm assumed by the state over the delayed time interval, given by:

 * $$ \|x_{t_0}\|_{\mathcal{C}}:=\max_{\theta\in[-\tau(t_0),0]} \|x(t_0+\theta)\| $$

The proof of this result relies on the fact that the following inequality holds for any value $$ \epsilon>0 $$ and constant matrices $$ \alpha,\beta $$ of appropriate dimensions:

 * $$ \alpha \Delta(t)\beta + \beta^T \Delta^T(t)\alpha^T \leq \epsilon^{-1} \alpha\alpha^T + \epsilon\beta^T \beta $$

Using this inequality with $$ \alpha^T=\begin{bmatrix} H^TP & 0\end{bmatrix} $$ and $$ \beta = \begin{bmatrix} E & E_1 \end{bmatrix} $$, the described LMI can then be derived from that presented in, corresponding to a situation without uncertainty.

Implementation
An example of the implementation of this LMI in Matlab is provided on the following site:

 * https://github.com/djagt/LMI_Codes/blob/main/Rstblty_cTDS_SlowVarying.m

Note that this implementation requires packages for YALMIP with solver mosek, though a different solver can also be implemented.

Related LMIs

 * - Stability LMI for continuous-time RDE with slowly-varying delay without uncertainty

 * - LMI for quadratic stability of continuous-time system with norm-bounded uncertainty

 * - Stability LMI for delayed discrete-time system


text:
LMIs in Control/Click here to continue/Time-Delay Systems/Bounded Real Lemma under Slowly-Varying Delay

This page describes a bounded real lemma for a continuous-time system with a time-varying delay. In particular, a condition is provided to obtain a bound on the $$ L_2 $$-gain of a retarded differential system through feasibility of an LMI. The system under consideration pertains a single discrete delay, with the extent of the delay at any time bounded by some known value. This delay is only present in the state, with no direct delay in the effects of exogenous inputs on the state. In addition, the delay is assumed to vary only slowly in time, with a temporal derivative bounded by a value less than one, although results can also be attained if no bound is known. Solving the LMI for a particular value of the bound, while minimizing a scalar variable, an upper limit on the $$ L_2 $$-gain of the system can be shown for any time-delay satisfying this bound.

The System
The system under consideration is one of the form:

\begin{align}

\dot{x}(t) &= Ax(t) + A_1x(t-\tau(t)) + B_0 w(t) & t&\geq t_0, & 0&\leq\tau(t) \leq h, & \dot{\tau}(t)&\leq d<1 \\ z(t) &= C_0x(t) + C_{1}x(t-\tau(t))

\end{align} $$

In this description, $$ A $$ and $$ A_1 $$ are constant matrices in $$ \mathbb{R}^{n\times n} $$. In addition, $$ B_0 $$ is a constant matrix in $$ \mathbb{R}^{n\times n_w}$$, and $$ C_0,C_{1} $$ are constant matrices in $$ \mathbb{R}^{n_z\times n}$$ where $$ n_w,n_z\in\mathbb{N} $$ denote the number of exogenous inputs and regulated outputs respectively. The variable $$ \tau(t) $$ denotes a delay in the state at time $$ t\geq t_0 $$, assuming a value no greater than some $$ h\in\mathbb{R}_+ $$. Moreover, we assume that the function $$ \tau(t) $$ is differentiable at any time, with the derivative bounded by some value $$ d<1 $$, assuring the delay to be slowly-varying in time.

The Data
To obtain a bound on the $$ L_2 $$-gain of the system, the following parameters must be known:

$$ \begin{align} A,A_1&\in\mathbb{R}^{n\times n} \\ B_0&\in\mathbb{R}^{n\times n_w} \\ C_0,C_1&\in\mathbb{R}^{n_z\times n} \\ h&\in \mathbb{R}_+ \\ d&\in [0,1) \end{align} $$

The Optimization Problem
Based on the provided data, we can obtain a bound on the $$ L_2$$-gain of the system by testing feasibility of an LMI. In particular, the bounded real lemma states that if the LMI presented below is feasible for some $$ \gamma>0 $$, the $$ L_2 $$-gain of the system is less than or equal to this $$ \gamma $$. To attain a bound that is as small as possible, we minimize the value of $$ \gamma $$ while solving the LMI:

The LMI: L2-gain for TDS with Slowly-Varying Delay

\begin{align} &\text{Solve}:\\ &\qquad\min \gamma \\ &\text{such that there exist}:\\ &\qquad P,P_2,P_3,R,S,S_{12},Q\in\mathbb{R}^{n\times n}\\ &\text{for which}:\\ &\qquad P>0,\quad R>0,\quad S>0,\quad Q>0  \\ &\qquad \begin{bmatrix} \begin{array}{c c c c | c c} \Phi_{11} & \Phi_{12} & S_{12} & R-S_{12}+P_2^T A_1 & P_2^T B_0 & C_0^T \\ \end{array} \end{bmatrix}<0 \\ &\text{where}:\\ &\qquad \Phi_{11} = A^T P_2 + P_2^T A + S + Q -R\\ &\qquad \Phi_{12} = P-P_2^T+A^T P_3 \\ &\qquad \Phi_{22} = -P_3-P_3^T +h^2 R \end{align}
 * & \Phi_{22} & 0 & P_3^T A_1 & P_3^T B_0 & 0\\
 * & * & -S-R & R-S_{12}^T & 0 & 0 \\
 * & * & * & -2R - S_{12} - S_{12}^T - (1-d)Q & 0 & C_1^T \\\hline
 * & * & * & * & -\gamma^2 I & 0 \\
 * & * & * & * & * & -I

$$

In this notation, the symbols $$ * $$ are used to indicate appropriate matrices to assure the overall matrix is symmetric.

Conclusion:
If the presented LMI is feasible for some $$ \gamma $$, the system is internally stable, and will have an $$ L_2$$-gain less than $$ \gamma $$. That is, independent of the values of the delays $$ \tau(t) $$:

 * $$ \|z\|_{L_2} < \gamma \|w\|_{L_2} $$

It should be noted that this result is conservative. That is, even when minimizing the value of $$ \gamma $$, there is no guarantee that the bound obtained on the $$ L_2 $$-gain is sharp.

In a scenario where no bound $$ d $$ on the change in the delay is known, the above LMI can still be used to obtain a bound on the $$ L_2 $$-gain. In particular, setting $$ Q=0 $$ in the above LMI, a bound can be attained independent of the value of the derivative of the delay.

Implementation
An example of the implementation of this LMI in Matlab is provided on the following site:

 * https://github.com/djagt/LMI_Codes/blob/main/L2gain_cTDS.m

Note that this implementation requires packages for YALMIP with solver mosek, though a different solver can also be implemented.

Related LMIs

 * - Bounded real lemma for continuous-time system without delay

 * - Bounded real lemma for discrete-time system without delay

 * - Stability LMI for continuous-time RDE with slowly-varying delay


text:
LMIs in Control/Click here to continue/Time-Delay Systems/LMI for L2-Optimal State-Feedback Control under Time-Varying Input Delay

This page describes a method for constructing a full-state-feedback controller for a continuous-time system with a time-varying input delay. In particular, a condition is provided to obtain a bound on the $$ L_2 $$-gain of closed-loop system under time-varying delay through feasibility of an LMI. The system under consideration pertains a single discrete delay in the actuator input, with the extent of the delay at any time bounded by some known value. Moreover, the delay is assumed to vary only slowly in time, with a temporal derivative bounded by a value less than one, although results may also be attained if no bound is known. Solving the LMI for a particular value of the bound, while minimizing a scalar variable, an upper limit on the $$ L_2 $$-gain of the system can be shown for any time-delay satisfying this bound.

The System
The system under consideration is one of the form:

\begin{align}

\dot{x}(t) &= Ax(t) + B_2u(t-\tau(t)) + B_1 w(t) & t&\geq t_0, & 0&\leq\tau(t) \leq h, & \dot{\tau}(t)&\leq d<1 \\ z(t) &= C_1x(t) + D_{12}u(t-\tau(t))

\end{align} $$

In this description, $$ A $$ and $$ A_1 $$ are constant matrices in $$ \mathbb{R}^{n\times n} $$. In addition, $$ B_1 $$ is a constant matrix in $$ \mathbb{R}^{n\times n_w}$$, and $$ B_2 $$ is a constant matrix in $$ \mathbb{R}^{n\times n_u}$$, where $$ n_w,n_u\in\mathbb{N} $$ denote the number of exogenous and actuator inputs respectively. Finally, $$ C_{1} $$ and $$ D_{12} $$ are constant matrices in $$ \mathbb{R}^{n_z\times n}$$ and $$ \mathbb{R}^{n_z\times n_u}$$ respectively, where $$ n_z\in\mathbb{N} $$ denotes the number of regulated outputs. The variable $$ \tau(t) $$ denotes a delay in the actuator input at time $$ t\geq t_0 $$, assuming a value no greater than some $$ h\in\mathbb{R}_+ $$. Moreover, we assume that the function $$ \tau(t) $$ is differentiable at any time, with the derivative bounded by some value $$ d<1 $$, assuring the delay to be slowly-varying in time.

The Data
To construct an $$ L_2 $$-optimal controller of the system, the following parameters must be known:

$$ \begin{align} A&\in\mathbb{R}^{n\times n} \\ B_1&\in\mathbb{R}^{n\times n_w} \\ B_2&\in\mathbb{R}^{n\times n_u} \\ C_1&\in\mathbb{R}^{n_z\times n} \\ D_{12}&\in\mathbb{R}^{n_z\times n_u} \\ h&\in \mathbb{R}_+ \\ d&\in [0,1) \end{align} $$

In addition to these parameters, a tuning scalar $$ \epsilon>0 $$ is also implemented in the LMI.

The Optimization Problem
Based on the provided data, we can construct an $$ L_2$$-optimal full-state-feedback controller of the system by testing feasibility of an LMI. In particular, we note that if the LMI presented below is feasible for some $$ \gamma>0 $$ and matrices $$ \bar{P}_2^{-1}>0 $$ and $$ Y $$, implementing the state-feedback $$ u(t)=Kx(t) $$ with $$ K=Y\bar{P}_2^{-1} $$, the $$ L_2 $$-gain of the closed-loop system will be less than or equal to $$ \gamma $$. To attain a bound that is as small as possible, we minimize the value of $$ \gamma $$ while solving the LMI:

The LMI: L2-Optimal Full-State-Feedback for TDS with Slowly-Varying Input Delay

\begin{align} &\text{Solve}:\\ &\qquad\min \gamma \\ &\text{such that there exist}:\\ &\qquad \bar{P},\bar{P}_2,\bar{R},\bar{S},\bar{S}_{12},\bar{Q}\in\mathbb{R}^{n\times n}, \quad Y\in\mathbb{R}^{n_u\times n}\\ &\text{for which}:\\ &\qquad \bar{P}>0,\quad \bar{P}_2>0,\quad \bar{R}>0,\quad \bar{S}>0  \\ &\qquad \begin{bmatrix} \begin{array}{c c c c | c c} \bar{\Phi}_{11} & \bar{\Phi}_{12} & \bar{S}_{12} & B_2Y+\bar{R}-\bar{S}_{12} & B_1 & \bar{P}_2^T C_1^T \\ \end{array} \end{bmatrix}<0 \\ &\text{where}:\\ &\qquad \Phi_{11} = A \bar{P}_2 + \bar{P}_2^T A^T + \bar{S} + \bar{Q} -\bar{R}\\ &\qquad \Phi_{12} = \bar{P}-\bar{P}_2+\epsilon \bar{P}_2^T A^T \\ &\qquad \Phi_{22} = -\epsilon \bar{P}_2-\epsilon\bar{P}_2^T + h^2 R \end{align}
 * & \bar{\Phi}_{22} & 0 & \epsilon B_2Y & \epsilon B_1 & 0\\
 * & * & -\bar{S}-\bar{R} & \bar{R}-\bar{S}_{12}^T & 0 & 0 \\
 * & * & * & -(1-d)\bar{Q}-2\bar{R}+\bar{S}_{12}+\bar{S}_{12}^T & 0 & Y^T D_{12}^T \\\hline
 * & * & * & * & -\gamma^2 I & 0 \\
 * & * & * & * & * & -I

$$

In this notation, the symbols $$ * $$ are used to indicate appropriate matrices to assure the overall matrix is symmetric.

Conclusion:
If the presented LMI is feasible for some $$ \gamma,Y,\bar{P}_2 x(t) $$, implementing the full-state-feedback controller $$ u(t)=Kx(t)=Y\bar{P}_2^{-1} $$, the closed-loop system will be asymptotically stable, and will have an $$ L_2$$-gain less than $$ \gamma $$. That is, independent of the values of the delays $$ \tau(t) $$, the system:

\begin{align} \dot{x}(t)&=Ax(t)+B_2Kx(t-\tau(t))+B_1 w(t) \\ z(t) &= C_1x(t)+D_{12}Kx(t-\tau(t)) \end{align} $$

with:

 * $$ \|z\|_{L_2} < \gamma \|w\|_{L_2}

\begin{align} K=Y\bar{P}_2^{-1} \end{align} $$

will satisfy:

 * $$ \|z\|_{L_2} < \gamma \|w\|_{L_2} $$

Here we note that $$ \bar{P}_2^{-1}x(t) $$ is guaranteed to exist as $$ P_2 $$ is positive definite, and thus nonsingular.

It should be noted that the obtained result is conservative. That is, even when minimizing the value of $$ \gamma $$, there is no guarantee that the bound obtained on the $$ L_2 $$-gain is sharp, meaning that the actual $$ L_2 $$-gain of the closed-loop can be (significantly) smaller than $$ \gamma $$.

In a scenario where no bound $$ d $$ on the change in the delay is known, or this bound is greater than one, the above LMI may still be used to construct a controller. In particular, if the presented LMI is feasible with $$ \bar{Q}=0 $$, the closed-loop system imposing $$ u(t)=Kx(t)=Y\bar{P}_2^{-1} $$ will be internally exponentially stable with an $$ L_2 $$-gain less than $$ \gamma $$ independent of the value of $$ \dot{\tau}(t) $$.

Implementation
An example of the implementation of this LMI in Matlab is provided on the following site:

 * https://github.com/djagt/LMI_Codes/blob/main/L2_OptStateFdbck_cTDS.m

Note that this implementation requires packages for YALMIP with solver mosek, though a different solver can also be implemented.

Related LMIs

 * - Bounded real lemma for continuous-time system with slowly-varying delay

 * - LMI for Hinf-optimal full-state-feedback control in a non-delayed continuous-time system

 * - LMI for Hinf-optimal output-feedback control in a non-delayed continuous-time system


text:
LMIs in Control/Click here to continue/Time-Delay Systems/Stability Condition for Discrete-Time TDS

This page describes an LMI for stability analysis of a discrete-time system with a time-varying delay. In particular, a delay-dependent condition is provided to test asymptotic stability of a discrete-delay system through feasibility of an LMI. The system under consideration pertains a single discrete delay, with the extent of the delay at any time bounded by some known value. Solving the LMI for different values of this bound, a limit on the delay can be attained for which the system remains asymptotically stable.

The System
The system under consideration is one of the form:

\begin{align}

x(k+1) &= Ax(k) + A_1x(k-\tau_k) & k&\in\mathbb{Z}_+, & \tau_k &\in\mathbb{N}, & 0&\leq\tau_k \leq h

\end{align} $$

In this description, $$ A $$ and $$ A_1 $$ are matrices in $$ \mathbb{R}^{n\times n} $$. The variable $$ \tau_k $$ denotes a delay in the state at discrete time $$ k $$, assuming a value no greater than some $$ h\in\mathbb{Z}_+ $$.

The Data
To determine stability of the system, the following parameters must be known:

$$ \begin{align} A&\in\mathbb{R}^{n\times n} \\ A_1&\in\mathbb{R}^{n\times n} \\ h&\in\mathbb{Z}_+ \end{align} $$

The Optimization Problem
Based on the provided data, asymptotic stability can be determined by testing feasibility of the following LMI:

The LMI: Asymptotic Stability for Discrete-Time TDS

\begin{align} &\text{Find}:\\ &\qquad P, S, R, S_{12}, P_2, P_3 \in\mathbb{R}^{n\times n}\\ &\text{such that:}\\ &\qquad P>0,\quad S>0,\quad R>0,  \\ &\qquad \begin{bmatrix} \Phi_{11} & \Phi_{12} & S_{12} & R-S_{12}+P_2^T A_1 \\ * & \Phi_{22} & 0 & P_3^T A_1\\ * & * & -(S+R) & R-S_{12}^T \\ * & * & * & -2R + S_{12} + S_{12}^T \end{bmatrix}<0 \\ &\text{where:}\\ &\qquad \Phi_{11} = (A^T-I)P_2 + P_2^T(A-I) + S-R\\ &\qquad \Phi_{12} = P-P_2^T+(A^T-I)P_3 \\ &\qquad \Phi_{22} = -P_3-P_3^T + P+h^2 R \end{align}

$$

In this notation, the symbols $$ * $$ are used to indicate appropriate matrices to assure the overall matrix is symmetric.

Conclusion:
If the presented LMI is feasible, the system will be asymptotically stable for any sequence $$ \tau_k $$ of delays within the interval $$ [0,h] $$. That is, independent of the values of the delays $$ \tau_k\in[0,h] $$ at any time:

 * For any real number $$ \epsilon>0 $$, there exists a real number $$ \delta>0 $$ such that:

 * $$ \|x(0)\|<\delta \quad \Rightarrow \quad \|x(k)\|<\epsilon \qquad \forall k\in\mathbb{N} $$

 * $$ \lim_{k\rightarrow\infty} x(k)=0 $$

Obtaining a feasible point for the LMI, this result can be proven using a Lyapunov-Krasovkii functional:

\begin{align} &V(x_k)=V_P(k)+V_S(k)+V_R(k)\\ \end{align} $$

where:

\begin{align} &V_P(k)=x^T(k)Px(k),  \\ &V_S(k)=\sum_{j=k-h}^{k-1} x^T(j)Sx(j), \\ &V_R(k)=h\sum_{m=-h}^{-1}\sum_{j=k+m}^{k-1}[x(j+1)-x(j)]^T R[x(j+1)-x(j)] \\ \end{align}

$$

Implementation
An example of the implementation of this LMI in Matlab is provided on the following site:

 * https://github.com/djagt/LMI_Codes/blob/main/D_TDS_DC.m

Note that this implementation requires packages for YALMIP with solver mosek, though a different solver can also be implemented.

Related LMIs

 * TDSDC – Delay-dependent stability LMI for continuous-time TDS

 * LMI for Stability of Retarded Differential Equation with Slowly-Varying Delay – Delay-independent stability LMI for continuous-time TDS

 * Discrete Time Lyapunov Stability – Stability LMI for non-delayed discrete-time system


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems

Applications of Non Linear systems

 * 1) /Lyapunov Stability of a System With Polynomial Dynamics/
 * 2) /Global Minimum of Polynomial via SOS Method/
 * 3) /Local Minimum of Polynomial via SOS Method/
 * 4) /Global Lyapunov Function Search for System with Polynomial Dynamics/
 * 5) /Stability of Switching Systems - Arbitrary Switching/
 * 6) /Chebyshev Polynomials/
 * 7) /Control of Rational Systems using Linear-fractional Representations and Linear Matrix Inequalities*/


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Lyapunov Stability of a System With Polynomial Dynamics

[UNDER CONSTRUCTION] - CME

Find the local Lyapunov function for a system with known polynomial dynamics.

Required Data
The system dynamics to be tested in the form $$ \dot x = f(x) $$ where $$ f(x) $$ is a polynomial function of the states $$ x $$.

A function or functions representing the local domain over which stability is to be determined, $$ X := \{x : p_i(x) \geq 0, i = 1,...,k\} $$. Commonly this is a ball of specified radius such that $$p(x) = R^2 - x^Tx $$. [Is this assuming P-Compactness of the set?]

Find the Lyapunov Function
Suppose there exists Lyapunov function $$V(x)$$, a scalar $$\epsilon > 0$$, and $$s_0, s_i, t_0, t_i \in \Sigma_s$$ (where $$ \Sigma_s $$ is the set of Sum-of-Squares polynomials, all of which are positive) such that:

$$ V(x) = s_0(x) + \sum \limits_i s_i(x)p_i(x) + \epsilon x^T x $$

$$ -\dot V(x) = -\nabla V(x)^T f(x) = t_0(x) + \sum \limits_i t_i(x)p_i(x) + \epsilon x^T x $$

The Lyaponov function, if it exists, will be positive and always decreasing over the desired set $$ X $$

Example
Code example in SOStools probably worthwhile!

Reference
SOS tools manual is a good one

Tie in the reference from SOS tools? The Khalil?

Related LMIs
Add things here about SOS methods

Global Lyapunov Search


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Global Minimum of Polynomial via SOS Method

[UNDER CONSTRUCTION] - CME

The global minimum of a certain polynomial functions $$f(x)$$ can be found using Sum-of-Squares (SOS) methods. This is a useful starting point to the more-useful but less straightforward issue of local minimums.

Required Data
A polynomial function $$f(x)$$ whose minimum is desired.

The Problem
To find the minimum value of $$f(x)$$, we suppose that there exists a scalar $$ p $$ such that

$$ f(x) - p \geq 0 $$

This is equivalent to determining if $$(f(x)-p)$$ has a SOS representation, since a SOS polynomial is never negative. This becomes an optimization problem by attempting to find the largest possible $$ p $$ such that a representation exists. In other words, the optimization problem becomes

$$ \min_p -p $$ subject to $$ f(x)-p \geq 0 $$

Example
Code example in SOStools probably worthwhile!

Reference
SOS tools manual is a good one

Related LMIs
SOS Basics

Local Minimum is a solid follow-up


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Local Minimum of Polynomial via SOS Method

[UNDER CONSTRUCTION] - CME

The local minimum of a certain polynomial functions f(x) can be found using Sum-of-Squares (SOS) methods. Here we assume the local set has a P-Compact representation, and that this representation is used.

Required Data
A polynomial function f(x) whose minimum is desired.

A P-Compact representation of the set.

First Steps
Touch up on the Putinar Positivstellensatz and what it means for us.

Why does it work
Based in S-Procedure, with the Positivstellensatz all about the right representation.

Example
Code example in SOStools probably worthwhile!

Reference
SOS tools manual is a good one

Related LMIs
SOS Basics

Global Minimum


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Global Lyapunov Function Search for System with Polynomial Dynamics

[UNDER CONSTRUCTION] - CME

Find the global Lyapunov function for a system with known polynomial dynamics.

Required Data
The system dynamics to be tested in the form $$ \dot x = f(x) $$ where $$ f(x) $$ is a polynomial function of the states $$ x $$.

Find the Lyapunov Function
Find a polynomial (our Lyapunov function) $$V(x)$$, supposing there exists scalar $$\epsilon > 0$$ such that:

$$ V(x) -\epsilon x^Tx \geq 0 $$

$$ -\dot V(x) = -\nabla V(x)^T f(x) \geq 0 $$

Example
Code example in SOStools probably worthwhile!

Reference
SOS tools manual is a good one

Tie in the reference from SOS tools? The Khalil one seems correct.

Related LMIs
Add things here about SOS methods

Local Lyapunov Search


text:
User:EthanGaming7640/sig

Ethan Gaming  7640

title: User:EthanGaming7640/sig


text:
LMIs in Control/Click here to continue/Robust Controls/H2-Optimal State Feedback Synthesis

Robust H2-Optimal State Feedback Synthesis
For systems with uncertain state parameters, a robust controller is needed. H2-optimal control is desirable in minimum-energy applications.

The System
The static formulation of the system is given as follows:

$$ \begin{align} \dot{x}(t) = A(\delta)x(t) + B(\delta)u(t) \\ y(t) = C(\delta)x(t) + D(\delta)u(t) \end{align} $$

Where $$x(t)\in \R^n$$ is the state and $$u(t)\in \R^m$$ is the input at any $$t\in \R$$

$$ A(\delta) $$, $$ B(\delta) $$, $$ C(\delta) $$, and $$ D(\delta) $$ are rational matrices with variance $$ \delta \in \Delta $$.

The Data
The state matrices are defined as:

$$A(\delta) = A(\delta)$$, $$B(\delta) = \begin{bmatrix}B_1(\delta) & B_2(\delta) \end{bmatrix}$$

$$C(\delta) = \begin{bmatrix}C_1(\delta) \\ C_2(\delta) \end{bmatrix}$$

$$D(\delta) = \begin{bmatrix}D_{11}(\delta) & D_{12}(\delta) \\ D_{21}(\delta) & D_{22}(\delta) \end{bmatrix}$$

The LMI:H2-Optimal State Feedback Synthesis
Suppose $$ \hat{P}(s,\delta) = C(\delta)(sI-A(\delta))^-$$$$^1B(\delta) $$. Then the following are equivalent:

1. $$ \left\vert \left\vert S(K(\delta),P(\delta)) \right\vert \right\vert $$$H_2$ $$ < \gamma $$ for all $$ \delta \in \Delta $$.

2. $$ K(\delta) = Z(\delta)X(\delta)^-$$$$^1$$ for some $$Z(\delta)$$ and $$X(\delta)$$ such that $$X(\delta) > 0$$ for all $$\delta \in \Delta $$and

$$ \begin{align} \begin{bmatrix} A(\delta) & B_{2}(\delta) \end{bmatrix} \begin{bmatrix} X(\delta)\\ Z(\delta) \end{bmatrix} + \begin{bmatrix} X(\delta) & Z(\delta)^T \end{bmatrix} \begin{bmatrix} A(\delta)^T\\ B(\delta)_2^T \end{bmatrix} + B_1(\delta)B_1(\delta)^T < 0 \end{align} $$

$$ \begin{align} \begin{bmatrix} X(\delta) & (C_1(\delta)X(\delta)+D_{12}(\delta)Z(\delta))^T \\ C_1(\delta)X(\delta)+D_{12}(\delta)Z(\delta) & W(\delta) \end{bmatrix} > 0 \end{align} $$

$$ Trace(W(\delta)) < \gamma^2 $$

for all $$ \delta \in \Delta $$

Conclusion:
The method above can be used to find an H2-optimal robust state feedback controller for a system with uncertain parameters.

Implementation
This implementation requires Yalmip and Sedumi.

H2-Optimal State Feedback Synthesis

Related LMIs
Full State Feedback Optimal H_inf LMI

Return to Main Page:
LMIs in Control: https://en.wikibooks.org/wiki/LMIs_in_Control


text:
Programming in LOLGraphics 3.4/Variables & Input

LOLGraphics Memory
In LOLGraphics, the interpreter gives you access to 4 segments which can be used to store data. Each segment has 65536 cells. In the one byte segment, each cell is a signed 1 byte integer. In the two byte segment, each cell is signed 2 byte integer. In the four byte segment each cell is a signed 4 byte integer, and in the 8 byte segment each cell is a signed 8 byte integer.

The cells in each segment are numbered 0-65535. At the beginning of the program each cell is set to a random number. You can print the value of each cell using. That command will print the value in the cell with index 100 (the 101st cell!) and not the number 100 (!). If you want to print 100 regardless of the value of a variable, simply type. can also change the value of each cell. Running  will set the value on index 100 in the one-byte segment to 27.

Declaring a variable
Writing cell addresses will make your code hard to read if you use many values. That’s why you have the ability to label those cells. If you type the line, you label the first unlabeled cell in the four byte segment “X”. You can also run, and.

The following code will print the same number twice but each time a different one.

HAI 3.4 0 100 IM IN UR CODE EXECUTIN UR KOMANDZ I HAS A FOUR BYTE DAT IZ CALLED X PLZ PRINT FOUR BYTE X PLZ PRINT FOUR BYTE 0 IM OUTTA UR CODE

Variable names
Readers familiar with programming languages will definitely recall that practically all languages have rules regarding to which characters can be used in the name of a variable (usually just letters, numbers, and underscores with the first character being a letter always). The esoteric programming language TMMLPTEALPAITAFNFAL (The Multi-Million Language Project To End All Language Projects And Isn't That A Fine Name For A Language) has really weird rules that rotate every day so one day it can require the symbol [ to appear at least 15 days or something like that.

LOLGraphics doesn’t have any restrictions regarding the variable name. You can name a variable by a number but this probably isn’t a very smart decision since it will always go the cell with that index and not that variable.

Also you can give different variables the same name. If they are in different segments then there isn’t any reason the code won’t work as you have to specify the size of the variable anyways. However, if they are in the same segment the code will still work but when the variable name is specified, it will always operate using the first instance of it.

Where to declare variables
Many programming languages like java and rust have scopes and variables declared in a scope can’t be used outside of it. LOLGraphics doesn’t have such stuff so if you declare a variable it’s forever. The only important thing is that the command which declares the variable was run before the commands that use it are run. In order to avoid having multiple variables with the same name, it’s recommended to declare the variables either at the very beginning of the code or if you think it makes the code messy, in a subprogram that is called only at the beginning of the code.

Also, it’s important to remember that despite the fact that this books says “and address or a variable” that a variable in LOLGraphics is just a label that points towards an address.

Random numbers
To generate a random number, all you need to do is type the command. There is also the command. Despite what the name suggests, it doesn’t set all the cells in all the segments to 0, and neither does it set them to their initial values. Instead it sets all the values in all the segments to random numbers.

Input
There are 2 ways to ask the user for input. The first one, which is preferable for cli apps is using the command  this command will stop the program, activate the input button, wait for the user to type a number, then after he presses the button, it will save the value typed by the user in the specified address or variable.

The second way which is preferable in some situations is using the command. It doesn’t wait for the user to press on the input button, and doesn’t even activate it, instead it just takes whatever is there, and puts in the specified variable or address. If the input field is empty, the command will do nothing. This is the method used in the “8462 demo” which is like a WASD demo only using the numpad. You will also learn how to write such a program later in the book.

Halting the program
The above section is useful if you want to wait for the user to type a number and then press on the input button. But what if you want to just halt the program and wait for the user to press on the input button? Luckily there is a command just for that! It’s. It will be annoying for production applications if you plan on writing any in LOLGraphics, however it will be useful for debugging purposes.


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Stability of Switching Systems - Arbitrary Switching

Stability of Switching Systems - Quadratic Stability Under Arbitrary Switching
For gain scheduled systems, stability of each subsystem {A1,A2} does not guarantee stability under arbitrary switching. Additionally, smart switching can stabilize two unstable systems.

The System
The state space formulation of each subsystem is given as follows:

$$ \begin{align} \dot{x}(t) = A_i(t) + B_iu(t) \\ y(t) = C_ix(t) + D_iu(t) \end{align} $$

Where i = 1,2,...,n for each of the subsystems in the switching system.

The Data
For a switching system with multiple subsystems, the A matrix for each is defined by

$$ A_i = A_1, A_2, ... A_n $$

The LMI:Quadratic Stability Under Arbitrary Switching
The switched system $$ \dot{x}(t) \in {A_1x(t),A_2x(t)} $$ is stable under arbitrary switching if there exists some P > 0 such that

$$ A_1^TP+PA_1<0 $$ and

$$ A_2^TP+PA_2<0 $$

Conclusion:
This implies that both A1 and A2 are Hurwitz.

There is not necessarily a common quadratic Lyapunov function for both A1 and A2.

This quadratic stability condition under arbitrary switching is a useful condition to use when designing controllers for switching systems. This LMI does not provide information on how the controller is designed, but is to be used as an additional condition to stabilize a switching system.

Implementation
This implementation requires Yalmip and Sedumi.

Quadratic Stability Under Arbitrary Switching

Related LMIs
Lyapunov Stability of a System with Polynomial Dynamics/

Global Minimum of Polynomial via SOS Method/

Local Minimum of Polynomial via SOS Method/

Global Lyapunov Function Search for System with Polynomial Dynamics/

Return to Main Page:
LMIs in Control: https://en.wikibooks.org/wiki/LMIs_in_Control


text:
Programming in LOLGraphics 3.4/Authors & Contributors

This list is updated automatically by AuthorsAndContributorsBot. Please do not update it manually.


text:
Programming in LOLGraphics 3.4/External links

Simply click on the link you want to enter, or if you are reading a printed version, type it in your browser of choice:

 * 1) https://bloody-wall-software.itch.io/lolgraphics - link to download from itch.io
 * 2) https://esolangs.org/wiki/LOLGraphics - entry in esolangs.org
 * 3) https://pwwe47.wixsite.com/bloodywallsoftware/lolgraphics - entry in the website of Bloody Wall Software


text:
LMIs in Control/Click here to continue/Fundamentals of Matrix and LMIs/Submatrix Determinants and Imaginary and Real Parts

Required data
Consider $$A\in \mathbb{S}^{n}$$, Let$$A_k \in\mathbb{S}^{k}$$ be a submatrix of A consisting of its first $$ k $$rows and columns, where $$k \leq n$$.

Matrix inequality
The matrix inequality $$ A>0 $$ is satisfied if and only if

$$det(A_k) > 0, k =1, ....., n$$.

Required data
Consider $$Q_R \in \mathbb{S}^{n}$$, $$Q_I \in \mathbb{R}^{n \times n}$$, $$ Q = Q^H = Q_R + j Q_I \in \mathbb{C}^{n \times n} $$,

Matrix inequality
The matrix inequality, $$Q>0$$ is equivalent to the matrix inequality given by

$$ \begin{bmatrix} Q_R & Q_I \\ -Q_I & Q_R \end{bmatrix}> 0$$.


text:
LMIs in Control/Click here to continue/Applications of Non-Linear Systems/Chebyshev Polynomials

Required data
A univariate Polynomial whose SOSINEQ range specification is desired

The Problem
Let $$p_n (x)$$ be a univariate polynomial of degree $$n, with \gamma$$ being the coefficient of $$x^n$$.

$$ \max_\gamma \gamma $$, subject to: $$|p_n(x)|\leq 1, \forall x \in [-1,1]$$.

Formulation
The absolute value constraint can be easily rewritten using two inequalities, namely: $$ \begin{align} 1+p_n(x) \geq 0 \\ 1-p_n(x) \geq 0, \\ \forall x \in [-1,1] \end{align} $$.

Solution
The optimal solution is $$\gamma^* = 2 ^{n-1}$$, with $$p^*_n (x) = arccos(cos nx)$$ being the n-th Chebyshev polynomial of the first kind.

Example
Code example in SOStools probably worthwhile!

Reference
SOS tools manual: https://sums-of-squares.github.io/sos/

Related LMIs
SOS Basics


text:
LMIs in Control/Click here to continue/Fundamentals of Matrix and LMIs/Minimizing Norm by Scaling

Minimizing Norm by Scaling
There are many cases in which a norm should be minimized, such as in applications of the $$ H_2 $$ or $$ H_{\infty} $$ norm optimal control.

The System
$$ M $$ is a matrix $$M \in \mathbb{C}^{nxn}$$. $$ D $$ is some diagonal, nonsingular $$ D $$.

The Data
The optimal diagonally scaled norm of a matrix $$M \in \mathbb{C}^{nxn}$$ is defined as $$ \nu(M) \overset{\underset{\mathrm{def}}{}}{=} inf \left \lbrace \lVert DMD^{-1} \rVert \quad | D \in \mathbb{C}^{n \times n} \right \rbrace $$,  where $$ D $$ is diagonal and nonsingular.

The LMI:Minimizing Norm by Scaling
Therefore, $$ \nu(M) $$ is the optimal value of the generalized eigenvalue problem

minimize $$ \quad \gamma $$

subject to $$ \quad P>0 $$ and diagonal, $$ \quad M^TPM-\gamma^2P<0 $$

Conclusion:
This result can be extended in many ways, such as in applications of $$ H_2 $$ or $$ H_{\infty} $$ optimal control.

Implementation
This implementation requires Yalmip and Sedumi.

Minimizing Norm by Scaling

Return to Main Page:
LMIs in Control: https://en.wikibooks.org/wiki/LMIs_in_Control


text:
User talk:Contributer1234

Welcome to Wikibooks
Just wanted to say hello and welcome you aboard. Don't hesitate to message me if you need help with anything. —  ⚞ ℛogueScholar 🐈 ₨🗩 ⚟   $My recent mischief$  23:24, 11 December 2021 (UTC)

title: User talk:Contributer1234


text: Category:Book:Programming in LOLGraphics 3.4


text: Programming in LOLGraphics 3.4/Printable version


text: Tibetan/Printable version

title: Tibetan/Printable version


text: Czech/Printable version

title: Czech/Printable version


text: Ethics for IT Professionals/Printable version


text: Cherokee/Printable version

title: Cherokee/Printable version


text: Category:Book:Acing the SQE

title: Category:Book:Acing the SQE


text: Systems Theory/Printable version

title: Systems Theory/Printable version


text: Category:Book:Teochew

title: Category:Book:Teochew


text: Paper Mario/Printable version

title: Paper Mario/Printable version


text: Agile Software Engineering Cheatsheets/Printable version


text: Ethnomedicine/Printable version

title: Ethnomedicine/Printable version


text: Computer Programming Principles/Printable version


text: Category:Book:Raku Pottery

title: Category:Book:Raku Pottery


text: Juggling/Printable version

title: Juggling/Printable version


text: Tennis/Printable version

title: Tennis/Printable version


text: Table Tennis/Printable version

title: Table Tennis/Printable version


text: Swimming Manual/Printable version

title: Swimming Manual/Printable version


text: World of Dinosaurs/Printable version

title: World of Dinosaurs/Printable version


text:
Programming in LOLGraphics 3.4/Conditions & Loops

Introduction
What we have learned so far is very good, but in order to write anything useful in a programming language, it’s a must to have conditions and loops or at least a way to make “pseudo-loops” using conditions and labels. Luckily, LOLGraphics has all 3 and in this chapter we will be learning all of them! 🎊

If else statements in other programming languages
In python for example, an if else statement looks the following:

Different programming languages may have different syntaxes, but the overall idea stays the same. For example in java you must put the conditions in brackets, write else if instead of elif, and if the block is more than one line wrap it with curly brackets {}.

However, in LOLGraphics it looks entirely different.

If else statements in LOLGraphics
In LOLGraphics there is a single flag that can be updated using commands and is used in conditions and loops. It’s default value is false, and to update it type. The condition can be comparing between 2 numbers, addresses, or variables, or a combination of two.

The command  will check is the value in the one byte variable X is equal to 8. You can use two byte variables ( X ), four byte variables ( [X] ), and eight byte variables ( [[X]] ).

So we know how to set the flag, but what to do with it. Luckily for use, ceiling cat is very generous and will keep nodding while the flag is true. Simply type. If you want to run a subprogram when the flag is false, type. Note that unlike other programming languages, those are two separate commands that come independently from each other which means that you can have any “else” without an “if” in LOLGraphics.

Also, you can manually set the flag to true and false by using the commands  and

Finite Recursion & Roman Numerals
In the previous chapter, you have learned how to make infinite recursions. Using the if/else statement, you can make a finite recursion. Using this you can write a program that coverts numbers to Roman Numerals. Here’s the source code that is not included as an example program in the editor:

HAI 3.4 0 10 IM IN UR CODE EXECUTIN UR KOMANDZ I HAS A TWO BYTE DAT IZ CALLED X DIS IZ MY LABEL! IT IZ KALLED START PLZ ASK TEH USR 2 GIMME A TWO BYTE X PLZ PRINT TWO BYTE X PLZ ASK CEILIN KAT 2 CHEK IZ X >999 IF CEILIN KAT IZ NODDING PLZ RUN M PLZ ASK CEILIN KAT 2 CHEK IZ X >899 IF CEILIN KAT IZ NODDING PLZ RUN CM PLZ ASK CEILIN KAT 2 CHEK IZ X >499 IF CEILIN KAT IZ NODDING PLZ RUN D PLZ ASK CEILIN KAT 2 CHEK IZ X >399 IF CEILIN KAT IZ NODDING PLZ RUN CD PLZ ASK CEILIN KAT 2 CHEK IZ X >99 IF CEILIN KAT IZ NODDING PLZ RUN C PLZ ASK CEILIN KAT 2 CHEK IZ X >89 IF CEILIN KAT IZ NODDING PLZ RUN XC PLZ ASK CEILIN KAT 2 CHEK IZ X >49 IF CEILIN KAT IZ NODDING PLZ RUN L PLZ ASK CEILIN KAT 2 CHEK IZ X >39 IF CEILIN KAT IZ NODDING PLZ RUN XL PLZ ASK CEILIN KAT 2 CHEK IZ X >9 IF CEILIN KAT IZ NODDING PLZ RUN X PLZ ASK CEILIN KAT 2 CHEK IZ X >8 IF CEILIN KAT IZ NODDING PLZ RUN IX PLZ ASK CEILIN KAT 2 CHEK IZ X >4 IF CEILIN KAT IZ NODDING PLZ RUN V PLZ ASK CEILIN KAT 2 CHEK IZ X >3 IF CEILIN KAT IZ NODDING PLZ RUN IV PLZ ASK CEILIN KAT 2 CHEK IZ X >0 IF CEILIN KAT IZ NODDING PLZ RUN I PLZ PRINT TEXT PLZ PRINT TEXT====================== PLZ GOTO LABEL START IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED M PLZ TYPE TEXT M PLZ SET TWO BYTE X X-1000 PLZ ASK CEILIN KAT 2 CHEK IZ X >999 IF CEILIN KAT IZ NODDING PLZ RUN M IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CM PLZ TYPE TEXT CM PLZ SET TWO BYTE X X-900 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED D PLZ TYPE TEXT D PLZ SET TWO BYTE X X-500 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CD PLZ TYPE TEXT CD PLZ SET TWO BYTE X X-400 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED C PLZ TYPE TEXT C PLZ SET TWO BYTE X X-100 PLZ ASK CEILIN KAT 2 CHEK IZ X >99 IF CEILIN KAT IZ NODDING PLZ RUN C IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED XC PLZ TYPE TEXT XC PLZ SET TWO BYTE X X-90 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED L PLZ TYPE TEXT L PLZ SET TWO BYTE X X-50 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED XL PLZ TYPE TEXT XL PLZ SET TWO BYTE X X-40 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED X PLZ TYPE TEXT X PLZ SET TWO BYTE X X-10 PLZ ASK CEILIN KAT 2 CHEK IZ X >9 IF CEILIN KAT IZ NODDING PLZ RUN X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED IX PLZ TYPE TEXT IX PLZ SET TWO BYTE X X-9 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED V PLZ TYPE TEXT V PLZ SET TWO BYTE X X-5 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED IV PLZ TYPE TEXT IV PLZ SET TWO BYTE X X-4 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED I PLZ TYPE TEXT I PLZ SET TWO BYTE X X-1 PLZ ASK CEILIN KAT 2 CHEK IZ X >0 IF CEILIN KAT IZ NODDING PLZ RUN I IM OUTTA UR SUBPROGRAM Notice how some of the digits are checked recursively, while others like L for 50, XL for 40, and IV for 4 can appear only once and therefore are only printed once.

“8462 demo” part 1
Remember previously, the “8462 demo” was mentioned? It’s like a WASD demo only using the numpad. Let’s implement part of it here. Note that this is only part of the code, so don’t expect to copy it to the editor and have it working. Also don’t worry too much about what exactly the subprograms do, we will cover that in the chapter about graphics. Concentrate on the conditions. Assume that the variable graphics was given by the user previously in the code.

PLZ ASK CEILIN KAT 2 CHEK IZ [BUTTON]==8 IF CEILIN KAT IZ NODDING PLZ RUN UP PLZ ASK CEILIN KAT 2 CHEK IZ [BUTTON]==2 IF CEILIN KAT IZ NODDING PLZ RUN DOWN PLZ ASK CEILIN KAT 2 CHEK IZ [BUTTON]==4 IF CEILIN KAT IZ NODDING PLZ RUN LEFT PLZ ASK CEILIN KAT 2 CHEK IZ [BUTTON]==6 IF CEILIN KAT IZ NODDING PLZ RUN RIGHT

As you can see the code is neither attractive nor efficient. Later this chapter we will learn how to write a better version of this code. Also, the code above contains 8 lines of code since empty lines and comments are not sent to the interpreter.

Switch case
Luckily, there is a way to make the code in the previous section more efficient & more attractive, using the switch case commands. The LOLGraphics Interpreter stores a single 8 byte variable (it’s the largest size possible in LOLGraphics in order that you will be able to put in it also smaller sizes). It can be updated using the SWITCH command, and checked using the CASE command. Let’s use a more efficient version of the code in the previous section as an example:

SWITCH [BUTTON] CASE 8 UP CASE 2 DOWN CASE 4 LEFT CASE 6 RIGHT CASE 86,68,9 UP_RIGHT CASE 48,84,7 UP_LEFT CASE 42,24,1 DOWN_LEFT CASE 62,26,3 DOWN_RIGHT

The first line takes whatever is in the one byte variable BUTTON and puts it in the switch/case variable (the default value is 0). The second line of code checks is the variable equal to 8, and if it is goes to the subprogram called UP (again, don’t worry to much about what it does, we will learn more about that in the chapter about graphics).

The third, fourth, and fifth do more or less the same, so let’s skip them and explain the sixth line of code. This line has multiple numbers separated by commas without spaces. This is the way it must be done. If you don’t type commas or do type a space between values, your code won’t work! If the value of the switch/case variable is equal to 86, 68, or 9, subprogram UP_RIGHT will run. If you check the numpad, it will make sense.

The code above consists of 9 lines of code, just one more than the code in the previous section however accomplished much more since it allows also to move by diagonals. If you wanted to make it only up/down/left/right, it would be 5 lines of code.

If statements or switch/case?
As you have seen the code using switch case is both cleaner and more efficient. So why on earth would you want to use if/else? In this specific program, using switch/case is preferable, however you should know that it’s less flexible since it can only be used to check is a variable equal to a constant number. If you want to check is a variable equal to another variable or use more less operations, then you must use if else. Also sometimes you want to compare a variable to a variable, and also in this case switch/case won’t be very useful for you.

Infinite loops
To create an infinite loop, write. Now let’s rewrite the infinite loop code from “Interface, hello world program, subprograms, & labels”, only with actual loops:

HAI 3.4 0 100 IM IN UR CODE EXECUTIN UR KOMANDZ FOREVER RUN PRINT IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED PRINT PLZ PRINT TEXT I CAN HAS A CHEEZBURGER? IM OUTTA UR SUBPROGRAM

Finite loops
Loops work sort of like if statements in that that you can’t write the condition itself in the same line. The loop checks is ceiling cat nodding and while it is, runs a subprogram. The command looks as following:. If you want it to work as an actual while loop, update the flag before this line and at the end of the subprogram.

Factorial
The following code prints the factorial of a number the user enters. It is not available as an example code in the LOLGraphics Editor.

HAI 3.4 0 100 IM IN UR CODE EXECUTIN UR KOMANDZ I HAS A EIGHT BYTE DAT IZ CALLED X I HAS A EIGHT BYTE DAT IZ CALLED I PLZ ASK TEH USR 2 GIMME A EIGHT BYTE X PLZ SET EIGHT BYTE I X-1 PLZ ASK CEILIN KAT 2 CHEK IZ [[I]] >1 WHILE CEILIN CAT IZ NODDIN PLZ RUN MULTIPLY PLZ PRINT EIGHT BYTE X IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED MULTIPLY PLZ SET EIGHT BYTE X X*I PLZ SET EIGHT BYTE I I-1 PLZ ASK CEILIN KAT 2 CHEK IZ [[I]] >1 IM OUTTA UR SUBPROGRAM

Fibonacci sequence
The following code prints numbers from Fibonacci sequence. It is available in the LOLGraphics Editor as one of the example codes.

HAI 3.4 0 100 IM IN UR CODE EXECUTIN UR KOMANDZ I HAS A ONE BYTE DAT IZ CALLED MAX PLZ TYPE TEXT HOW MANY NUMBERS DO  YOU WANT ME TO PRINT? PLZ ASK TEH USR 2 GIMME A ONE BYTE MAX PLZ PRINT ONE BYTE MAX PLZ PRINT TEXT ====================== I HAS A ONE BYTE DAT IZ CALLED I I HAS A EIGHT BYTE DAT IZ CALLED A I HAS A EIGHT BYTE DAT IZ CALLED B I HAS A EIGHT BYTE DAT IZ CALLED C PLZ SET ONE BYTE I 2 PLZ SET EIGHT BYTE A 0 PLZ SET EIGHT BYTE B 1 PLZ ASK CEILIN KAT 2 CHEK IZ [MAX]>0 IF CEILIN KAT IZ NODDING PLZ RUN PRINT_A PLZ ASK CEILIN KAT 2 CHEK IZ [MAX]>1 IF CEILIN KAT IZ NODDING PLZ RUN PRINT_B PLZ ASK CEILIN KAT 2 CHEK IZ [I]<[MAX] WHILE CEILIN CAT IZ NODDIN PLZ RUN COUNT IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED COUNT PLZ SET ONE BYTE I I+1 PLZ SET EIGHT BYTE C A PLZ SET EIGHT BYTE A B PLZ SET EIGHT BYTE B C+A PLZ PRINT EIGHT BYTE B PLZ ASK CEILIN KAT 2 CHEK IZ [I]<[MAX] IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED PRINT_A PLZ PRINT EIGHT BYTE A IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED PRINT_B PLZ PRINT EIGHT BYTE B IM OUTTA UR SUBPROGRAM