Q and R selection problem in LQI design

1k Views Asked by At

I have the following continuous system:

\begin{align*} A&= \begin{bmatrix} 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 7.969 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 7.969 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 80.0568\\ 0 & 0 & 0 & 0 & 0 & 0 & -9.0909 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -9.0909 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -9.0909 \end{bmatrix}\\[20pt] B&= \begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 37.8338\\ 327.2727 & 0 & 0\\ 0 & 327.2727 & 0\\ 0 & 0 & 327.2727 \end{bmatrix}\\[20pt] C&= \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \end{bmatrix}\\[20pt] D&= 0 \end{align*}

The system is linearized about the point $x_0=[0,0,0,0,0,0,0,0,0]$.

Using MATLAB, I'm trying to find linear quadratic regulator gains (with integral part): Ki= lqi(sys, Q, R, 0), where sys= ss(A,B,C,D).

The problem is that I have very few values Q and R which are not throw an exception during solving ARE e.g. Q= 1000000*eye(15),R= 1*eye(3). With the most of the values I have an error:

Error using ss/lqi (line 112)
Cannot compute a stabilizing LQR gain (the Riccati solution S and gain matrix K are infinite). 
This could be because: 
  * A has unstable modes that are not controllable through B, 
  * Q,R,N values are too large, 
  * [Q N;N' R] is indefinite, 
  * The E matrix in the state equation is singular.

The resulting gain is stabilizing but closed loop has very slow response.

As I understand Q and R those can be almost any values defining the relative cost of overshoot or using some control input. But I have no idea on how to choose the values other than picking randomly.

Any clues on how to deal with it?

Thanks!

Possible sol'n:

I wrote a function to iterate over some range of multipliers and now I have a list of possible multipliers for Q=blkdiag(Qx,Qz) and R:

vals= [];
for i = 1:10
    for ii = 1:10
        for iii = 1:10
            Mqix= i;
            Mqiz= ii;
            Mri= iii;
            Qix= diag(Mqix * [ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]);
            Qiz= diag(Mqiz * [ 1, 1, 1, 1, 1, 1 ]);
            Qi= blkdiag(Qix,Qiz);
            Ri= diag(Mri * [ 1, 1, 1 ]);
            Ni= zeros(15,3);
            try
                Kcheck= lqi(sys, Qi, Ri, Ni);
            catch ME
            end
            if exist('Kcheck') == 1
                vals= [vals; i ii iii];
                clear Kcheck;
            end
        end
    end
end

The diagram of the controller: The diagram of the controller

1

There are 1 best solutions below

6
On BEST ANSWER

The problem that you observe can be shown by a much simpler example. Consider a mass that is moved by a force:

$$ \ddot{p} = \frac{f}{m} $$

There you have position $p$, force $f$ and mass $m$. Use $x_1 = p, x_2 = \dot{p}, u =f$:

$$ \dot{x} = Ax+Bu = \begin{pmatrix}0&1\\0&0 \end{pmatrix}x+\begin{pmatrix}0\\\frac{1}{m}\end{pmatrix}u $$

Now assume that you can measure position $p = x_1$ and speed $\dot{p} = x_2$. Then the output is:

$$ y=Cx=\begin{pmatrix}1&0\\0&1\end{pmatrix}x $$

Now we try to apply LQI (Linear-Quadratic-Integral) control. The augmented system is:

$$ \begin{align} \dot{x}_a &= A_a x_a + B_a w= \begin{pmatrix}A&0\\-C&0\end{pmatrix}\begin{pmatrix}x\\x_i\end{pmatrix}+\begin{pmatrix}B\\0\end{pmatrix}w \\ y&=C_ax_a = \begin{pmatrix} C&0 \end{pmatrix}\begin{pmatrix}x\\x_i\end{pmatrix} \end{align} $$

The $x_i$ are the integrator states and $w$ is your setpoint. LQI means that $y\rightarrow w$ for $t \rightarrow \infty$ and constant $w$.

Now build the observability matrix of the augmented system:

$$ C_o = \begin{pmatrix}B_a&A_a B_a&A_a^2 B_a&A_a^3B_a\end{pmatrix} = \frac{1}{m}\begin{pmatrix}0&1&0&0\\1&0&0&0\\0&0&-1&0\\0&-1&0&0\end{pmatrix} $$

You can see that $C_o$ has rank equal $3$ which is smaller than the order of the augmented system (which is $4$). So this system suffers from the same problem like your example: LQI cannot be used like this because the augmented system is not controllable.

However: If we think about this a bit it makes sense. As I said, the goal of LQI is to match $y$ and $w$ eventually. But you can't have both, match an arbitrary position and an arbitrary speed because if you set your setpoint for speed to a non-zero value, the position has to change. So trying to solve the above LQI problem doesn't make sense: its an ill-posed problem.

Solution: You can solve this by using a different output. This means you have to make a decision: do you want to control position or speed at steady state? This decision depends on what ultimate goal you are trying to achieve and only you (knowing your original system and your goal) can decide which is appropriate.

For example, say you want control position. Then the output becomes:

$$ y=\begin{pmatrix}1&0\end{pmatrix}x $$

And you get the controllability matrix:

$$ C_o = \begin{pmatrix}B_a&A_a B_a&A_a^2 B_a\end{pmatrix}=\frac{1}{m}\begin{pmatrix}0&1&0\\1&0&0\\0&0&-1\end{pmatrix} $$

which has still rank $3$ but now matches the rank of the augmented system which is now also of rank $3$ because you have one integrator less. So the augmented system is now fully controllable and you can use LQI.

Note that this doesn't mean you throw away the information from the second sensor because you still use $x_2$ for feedback. You just don't use it for the integral action.


Your system has the same problem, just with some more states.

So why do some values for $Q$ and $R$ seem to work? For example the loop from your comment suggests that LQI can be used with Q = eye(15) and R = 9*eye(3). For example the following code runs without any problems:

A = [0 0 0 0.5 0 0 0 0 0;0 0 0 0 0.5 0 0 0 0;0 0 0 0 0 0.5 0 0 0;0 0 0 0 0 0 7.969 0 0;0 0 0 0 0 0 0 7.969 0;0 0 0 0 0 0 0 0 80.0568;0 0 0 0 0 0 -9.0909 0 0;0 0 0 0 0 0 0 -9.0909 0;0 0 0 0 0 0 0 0 -9.0909]; 
B = [0 0 0;0 0 0;0 0 0;0 0 0;0 0 0;0 0 37.8338;327.2727 0 0;0 327.2727 0;0 0 327.2727]; 
C = [1 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0;0 0 0 0 1 0 0 0 0;0 0 0 0 0 1 0 0 0];

nx = size(A, 1);
nu = size(B, 2);
ny = size(C, 1);

D = zeros(ny, nu);

Aa = [A, zeros(nx, ny); -C, zeros(ny, ny)];
Ba = [B ; -D];
Ca = [C, zeros(ny, ny)];

Q = eye(nx + ny);
R = 9*eye(nu);

sys = ss(A, B, C, D);

K = lqi(sys, Q, R);
Ac = Aa - Ba*K;

However, if we look at the eigenvalues of the closed loop system (the maximum real part) we get:

>> max(real(eig(Ac)))

ans =

   9.6409e-15

This is practically (up to numerics) zero, so the closed loop system is not Hurwitz and so the computed gain is not stabilizing. I suspect that it is just numeric inaccuracy that lqi does not produce an error message in this case because the system is not controllable.

[~,~,~,~,k] = ctrbf(Aa, Ba, Ca);
n_uc = size(Aa,1) - sum(k) % Number of uncontrollable states

This code prints:

n_uc =

     3

So the number of uncontrollable states is $n_{uc} = 3$, as we expected and so your augmented system is not controllable. The solution is to reduce your outputs used for integral action.