# Control Systems/Controllability and Observability

## System Interaction

In the world of control engineering, there are a slew of systems
available that need to be controlled. The task of a control engineer is
to design controller and compensator units to interact with these
pre-existing systems. However, some systems simply cannot be controlled
(or, more often, cannot be controlled in specific ways). The concept of
**controllability** refers to the ability of a controller to arbitrarily
alter the functionality of the system plant.

The state-variable of a system, *x*, represents the internal workings of
the system that can be separate from the regular input-output
relationship of the system. This also needs to be measured, or
*observed*. The term **observability** describes whether the internal
state variables of the system can be externally measured.

## Controllability

Complete state controllability (or simply controllability if no other
context is given) describes the ability of an external input to move the
internal state of a system from any initial state to any other final
state in a finite time interval

We will start off with the definitions of the term **controllability**,
and the related terms **reachability** and **stabilizability**.

We can also write out the definition of reachability more precisely:

Similarly, we can more precisely define the concept of controllability:

### Controllability Matrix

For LTI (linear time-invariant) systems, a system is reachable if and
only if its **controllability matrix**, ζ, has a full row rank of *p*,
where *p* is the dimension of the matrix A, and *p* × *q* is the
dimension of matrix B.

$$\zeta = \begin{bmatrix}B & AB & A^2B & \cdots & A^{p-1}B\end{bmatrix} \in R^{p \times pq}$$

A system is controllable or \"Controllable to the origin\" when any
state x~1~ can be driven to the zero state *x = 0* in a finite number of
steps.

A system is controllable when the rank of the system matrix A is *p*,
and the rank of the controllability matrix is equal to:

$$Rank(\zeta) = Rank(A^{-1}\zeta) = p$$

If the second equation is not satisfied, the system is not .

MATLAB allows one to easily create the controllability matrix with the
**ctrb** command. To create the controllability matrix $\zeta$ simply
type

$$\zeta=ctrb(A,B)$$

where A and B are mentioned above. Then in order to determine if the
system is controllable or not one can use the rank command to determine
if it has full rank.

If

$$Rank(A) < p$$

Then controllability does not imply reachability.

-   Reachability always implies controllability.
-   Controllability only implies reachability when the state transition
    matrix is nonsingular.

### Determining Reachability

There are four methods that can be used to determine if a system is
reachable or not:

1.  If the *p* rows of $\phi(t, \tau)B(t)$ are linearly independent over
    the field of complex numbers. That is, if the rank of the product of
    those two matrices is equal to *p* for all values of *t* and *τ*
2.  If the rank of the controllability matrix is the same as the rank of
    the system matrix A.
3.  If the rank of $\operatorname{rank}[\lambda I - A, B] = p$ for all
    eigenvalues λ of the matrix A.
4.  If the rank of the **reachability gramian** (described below) is
    equal to the rank of the system matrix A.

Each one of these conditions is both necessary and sufficient. If any
one test fails, all the tests will fail, and the system is not
reachable. If any test is positive, then all the tests will be positive,
and the system is reachable.

### Gramians

**Gramians** are complicated mathematical functions that can be used to
determine specific things about a system. For instance, we can use
gramians to determine whether a system is controllable or reachable.
Gramians, because they are more complicated than other methods, are
typically only used when other methods of analyzing a system fail (or
are too difficult).

All the gramians presented on this page are all matrices with dimension
*p* × *p* (the same size as the system matrix A).

All the gramians presented here will be described using the general case
of Linear time-variant systems. To change these into LTI (time-invariant
equations), the following substitutions can be used:

$$\phi(t, \tau) \to e^{A(t-\tau)}$$

$$\phi'(t, \tau) \to e^{A'(t-\tau)}$$

Where we are using the notation X\' to denote the transpose of a matrix
X (as opposed to the traditional notation X^T^).

### Reachability Gramian

We can define the **reachability gramian** as the following integral:


$$W_r(t_0, t_1) = \int_{t_0}^{t_1}\phi(t_1, \tau)B(\tau)B'(\tau)\phi'(t_1, \tau)d\tau$$

The system is reachable if the rank of the reachability gramian is the
same as the rank of the system matrix:

$$\operatorname{rank}(W_r) = p$$ `<chemistry>`{=html}/control{range}

### Controllability Gramian

We can define the **controllability gramian** of a system (A, B) as:


$$W_c(t_0, t_1) = \int_{t_0}^{t_1}\phi(t_0, \tau)B(\tau)B'(\tau)\phi'(t_0, \tau)d\tau$$

The system is controllable if the rank of the controllability gramian is
the same as the rank of the system matrix:

$$\operatorname{rank}(W_c) = p$$

If the system is time-invariant, there are two important points to be
made. First, the reachability gramian and the controllability gramian
reduce to be the same equation. Therefore, for LTI systems, if we have
found one gramian, then we automatically know both gramians. Second, the
controllability gramian can also be found as the solution to the
following Lyapunov equation:

$$AW_c + W_cA' = -BB'$$

Many software packages, notably MATLAB, have functions to solve the
Lyapunov equation. By using this last relation, we can also solve for
the controllability gramian using these existing functions.

## Observability

The state-variables of a system might not be able to be measured for any
of the following reasons:

1.  The location of the particular state variable might not be
    physically accessible (a capacitor or a spring, for instance).
2.  There are no appropriate instruments to measure the state variable,
    or the state-variable might be measured in units for which there
    does not exist any measurement device.
3.  The state-variable is a derived \"dummy\" variable that has no
    physical meaning.

If things cannot be directly observed, for any of the reasons above, it
can be necessary to calculate or **estimate** the values of the internal
state variables, using only the input/output relation of the system, and
the output history of the system from the starting time. In other words,
we must ask whether or not it is possible to determine what the inside
of the system (the internal system states) is like, by only observing
the outside performance of the system (input and output)? We can provide
the following formal definition of mathematical observability:

A system state x~i~ is unobservable at a given time t~i~ if the
zero-input response of the system is zero for all time t. If a system is
observable, then the only state that produces a zero output for all time
is the zero state. We can use this concept to define the term
**state-observability**.

### Constructability

A state *x* is **unconstructable** at a time t~1~ if for every finite
time t \< t~1~ the zero input response of the system is zero for all
time t.

A system is completely **state constructable** at time t~1~ if the only
state *x* that is unconstructable at t~0~ is *x* = 0.

If a system is observable at an initial time t~0~, then it is
constructable at some time t \> t~0~, if it is constructable at t~1~.

### Observability Matrix

The observability of the system is dependent only on the system states
and the system output, so we can simplify our state equations to remove
the input terms: 

$$x'(t) = Ax(t)$$

$$y(t) = Cx(t)$$

Therefore, we can show that the observability of the system is dependent
only on the coefficient matrices A and C. We can show precisely how to
determine whether a system is observable, using only these two matrices.
If we have the **observability matrix** Q:

$$Q = \begin{bmatrix}C\\CA\\CA^2\\\vdots\\CA^{p-1}\end{bmatrix}$$

we can show that the system is observable if and only if the Q matrix
has a rank of *p*. Notice that the Q matrix has the dimensions *pr* ×
*p*.

MATLAB allows one to easily create the observability matrix with the
**obsv** command. To create the observability matrix $Q$ simply type

:   Q=obsv(A,C)

where A and C are mentioned above. Then in order to determine if the
system is observable or not one can use the rank command to determine if
it has full rank.

### Observability Gramian

We can define an **observability gramian** as:

$$W_o(t_0, t_1) = \int_{t_0}^{t_1} \phi'(\tau, t_0)C'(\tau)C(\tau)\phi(\tau, t_0)d\tau$$

A system is completely state observable at time t~0~ \< t \< t~1~ if and
only if the rank of the observability gramian is equal to the size *p*
of the system matrix A.

If the system (A, B, C, D) is time-invariant, we can construct the
observability gramian as the solution to the Lyapunov equation:

$$A'W_o + W_oA = -C'C$$

### Constructability Gramian

We can define a **constructability gramian** as:

$$W_{cn}(t_0, t_1) = \int_{t_0}^{t_1} \phi'(\tau, t_1)C'(\tau)C(\tau)\phi(\tau, t_1)d\tau$$

A system is completely state observable at an initial time t~0~ if and
only if there exists a finite t~1~ such that:

$$\operatorname{rank} (W_0) = \operatorname{rank} (W_{cn}) = p$$

Notice that the constructability and observability gramians are very
similar, and typically they can both be calculated at the same time,
only substituting in different values into the state-transition matrix.

## Duality Principle

The concepts of controllability and observability are very similar. In
fact, there is a concrete relationship between the two. We can say that
a system (A, B) is controllable if and only if the system (A\', C, B\',
D) is observable. This fact can be proven by plugging A\' in for A, and
B\' in for C into the observability Gramian. The resulting equation will
exactly mirror the formula for the controllability gramian, implying
that the two results are the same.

