LQR controllers come with infinite horizon
$$J = \sum_{k=0}^{\infty}(x^TQx + u^TRu)$$
and finite horizon
$$J = \sum_{k=0}^{N}(x^TQx + u^TRu)$$
But Generalized Predictive Control solves the optimization problem with least squares:
$$u = (\Gamma^T \Gamma + \rho I)^{-1}\Gamma^T (R- \Phi x_0)$$
or
$$ u = \Gamma^{\dagger}(R- \Phi x_0)$$
Where $\Phi$ is the extended observability matrix and $\Gamma \in \Re^{NxN}$ is the lower triangular toeplitz matrix of observability matrix times B. $R$ is our reference vector and $x_0$ is the initial state vector. The number $\rho$ is a very small number so the inverse won't fail. The $\Gamma^{\dagger}$ is the pseudo inverse of $\Gamma$ solved with Singular value decomposition method. More numerical stable, but requires more code and work to get it done.
Generalized Predictive Control can easily be computed if you have a state space model representation and this MATLAB/Octave-code.
My question is:
What's the difference between finding the inputs $u$ from: $$J = \sum_{k=0}^{N}(x^TQx + u^TRu)$$ $$u = -Lu(k)$$
and from:
$$u = (\Gamma^T \Gamma + \rho I)^{-1}\Gamma^T (R- \Phi x_0)$$
Assuming of we compute the new control law $L$ for every sampling.
function u = gpc(A, B, C, N, x, r)
PHI = phiMat(A, C, N);
GAMMA = gammaMat(A, B, C, N);
R = repmat(r, N, 1);
u = inv(GAMMA'*GAMMA)*GAMMA'*(R-PHI*x);
u = u(1);
end
function PHI = phiMat(A, C, N)
## Create the special Observabillity matrix
PHI = [];
for i = 1:N
PHI = vertcat(PHI, C*A^i);
end
end
function GAMMA = gammaMat(A, B, C, N)
## Create the lower triangular toeplitz matrix
GAMMA = [];
for i = 1:N
GAMMA = horzcat(GAMMA, vertcat(zeros((i-1)*size(C*A*B, 1), size(C*A*B, 2)),cabMat(A, B, C, N-i+1)));
end
end
function CAB = cabMat(A, B, C, N)
## Create the column for the GAMMA matrix
CAB = [];
for i = 0:N-1
CAB = vertcat(CAB, C*A^i*B);
end
end
The reason why I'm asking this question is because I tried a system identified state space model from data and Generalized Predictive Control and the results become like this below. A total mess because the input vector $u$ gave not smooth values, compared to infinite horizon LQR. Saturation was absolutely necessary for GPC. Else it will be very unstable:
And infinite horzion LQR with the same model. Much better. So I assume that solving a control law is much better than solve a least square problem?