# Adaptive Control using Multiple Models

This post has been adapted from a university project to understand and simulate the findings of [1]

## Preamble

The evolution of a dynamical system is mathematically modeled as differential equations. Properties of the system like position and velocity at any given moment are the State of the system. Differential equations capture how these states change and influence each other over time.

The mathematical models imply that a given system (or Plant) would follow a deterministic trajectory for a given initial state. For example, an airplane would remain at rest if it is parked on level ground. It would glide down if it is released at 1000 feet above in the air with a particular initial velocity and orientation.

But we often want to do more with systems than to let them follow their natural trajectories. And we cannot always precisely set or measure initial conditions. We want more Control.

Thus we influence some properties of the dynamical system by applying a control input. For example applying torque to the wheels of your car, or by propelling the motors of an airplane to create thrust that pushes it forward. This control input directly or indirectly alters the state of our system.

A control designer’s job is to ensure that the system follows a trajectory of our choice, which is often represented as a Reference Model; and to ensure stability of the overall system, i.e. it does not behave erratically on small deviations.

## PID Controller

For simple single-order plants, an often effective strategy is to change the control input in proportion to the difference (or error) between the plant state and reference state.

The error term is often integrated over time to capture the past, and differentiated to capture the instantaneous future of the error. The three terms (Proportional, Integral, Derivative) are used together in different proportions to design a control input, resulting in a PID Controller.

The performance of simple PID controllers isn’t always good enough, and the control law is not designed to the specification of plant dynamics and parameters, but only to its output.

Especially for complex multi-order plants, a lot of information is lost if we use only the plant output to control it and not the known information about its internal dynamics.

Many times the parameters of the dynamical system are not completely known, or they are changing as the system evolves. In such scenarios, we need to adaptively change the control law itself with time.

Adaptive control primarily focuses on system identification (i.e. estimating the parameters of the system) to design the control input; and using Lyapunov analysis to ensure stability of the system.

### Plant Model

Let’s start with the simple case of a multi-order linear plant. Its dynamics can be described in state-space form as:

Where $x_p$ is the n-dimensional state space vector, $A_p$ are the parameters as a $n \times n$ companion matrix. $u$ is the control input, and $b = [0, \cdots, 0, 1]^T$

Side Note: More details on how to represent an nth order d.e. in state-space form with companion matrices is given here

The last row of the companion matrix $A_p$ is the parameter vector $\theta_p$, which can also be represented as:

### Reference Model

A reference model that this plant should track can be described via a similar set of equations:

Where $x_m$ and $A_m$ are described similarly, and $r$ is a known reference signal.

### Identification Model

Before we proceed to designing our control law, we need to estimate the plant parameters $\theta_p$, as they are unknown to us.

To achieve that we set up an identification model as follows:

Where $A_I$ is a matrix in companion form with its last row as the plant parameter estimate $\theta_I$. The identification error $e_I$ is defined as:

Let $P$ be the positive definite matrix solution to the lyapunov equation for the reference model:

Where our Lyapunov function candidate is defined as:

#### Theorem 1

If we define our parameter adaptive law as:

we end up with a stable system under Lyapunov criteria:

### Control Law

Using the Lyapunov stability analysis, we can define our control input as:

Where $k(t) = \theta_I(t) - \theta_m$. From Barbalat’s lemma it follows that the tracking error $e_c$ approaches 0 $\lim_{t \rightarrow \infty} e_c(t) = 0$, or in other words that $x_p$ tracks $x_m$.

#### Simulation 1

For a second order plant, with parameters $\theta_p = [-7, -2]^T$ tracking a reference model with $\theta_m = [-5, -6]^T$. We initialize our identification model with $\theta_i = [-8, -4]^T$. The tracking signal is $r(t) = 5\sin(0.2\pi t)$.

(d/l multidim_singlemodel.slx)

The tracking error $e_c$ dies down slowly. This is because the parameter estimates $\theta_i$ converge to the plant values $\theta_p$ very slowly (as seen in the following figure).

## Multiple Identification Models

### Level 1

Let us use $N = n + 1$ identification models, defined similarly as before, with same initial state as $x_p$, but different initial values for the parameter estimate $\theta_i$:

Despite having $N$ models, we can still only have a single control input. We achieve that by taking a convex combination of the parameter estimates as:

Where $\sum_{i=1}^N \alpha_i = 1$. We can restate this in matrix-vector notation, with $\theta_i$ as columns of $\Theta_I$, and $\alpha = [\alpha_1, \alpha_2, \cdots, \alpha_N]^T$:

#### Theorem 2

If $N$ adaptive identification models are initialized as $\theta_i(t_0)$ such that $x_i(t_0) = x_p(t_0)$, and plant parameter vector $\theta_p$ lies in the convex hull of $\theta_i(t_0)$, then $\theta_p$ continues to lie in the convex hull of $\theta_i(t), t > t_0$.

#### Simulation 2

For a second order plant, with parameters $\theta_p = [-2, 9]^T$ tracking same reference model as before $\theta_m = [-5, -6]^T$. We initialize our identification model with $\alpha = [0.7, 0.1, 0.2]^T$ and

(d/l multidim_multimodel.slx)

Tracking error $e_c$ still dies down slowly in the later phase. Despite having multiple models, we’re still estimating only one value in the convex hull of the multiple models. And the individual parameter errors of the models are still converging slowly to the actual value.

### Level 2

Level 1 leads to an equivalent performing system as before, albeit using multiple models. The key insight is to adaptively estimate $\alpha$ itself, along with each model’s parameters.

The conclusion of theorem 2 can be restated as:

Subtracting $\theta_p$ from both sides:

The previous equation can be simplified down using:

Substituting $\bar{\alpha} = [\alpha_1, \alpha_2, \cdots, \alpha_{N-1}]^T$ leads to:

#### Estimate $\bar{\alpha}$

We can now use a standard estimation process for $\bar{\alpha}$ like we did for parameters before. Let $\hat{\bar{\alpha}}(t)$ be its estimation, then the adaptive law is given by:

#### Theorem 3

Using analysis similar to Theorem 1, we can show that the second level of adaptation also leads to an overall stable system. And when convergence is slow in first level (i.e. large parametric errors), convergence of $\hat{\bar{\alpha}}$ to $\bar{\alpha}$ is rapid. (and vice versa)

#### Simulation 3

For the same second order plant as in Simulation 2. That is $\theta_p = [-7, -2]^T$, $\theta_m = [-5, -6]^T$. This time we initialize our identification model with $\hat{\bar{\alpha}}(t_0) = [0.7, 0.1, 0.2]^T$ estimating it on the fly along with plant parameters with

(d/l multidim_multimodel_lvl2.slx)

The tracking error is converging to 0 rapidly.

The individual parameter estimates are still converging to the plant values very slowly. But due to fast second level estimation of $\alpha$ (as seen in next fig.), the system as a whole is converging down rapidly.

## Result

Through qualitative analysis and simulations we have demonstrated the effectiveness of using multiple models for adaptive control, as introduced by the original paper [1].

## References

[1] Z. Han and K. S. Narendra, “New Concepts in Adaptive Control Using Multiple Models,” in IEEE Transactions on Automatic Control, vol. 57, no. 1, pp. 78-89, Jan. 2012. doi: 10.1109/TAC.2011.2152470