CPC L10 LQR
CPC L10 LQR
Eduardo F. Camacho
Outline
◼ LQR formulation
◼ Dynamic programing
◼ LQR solution
◼ Steady-state
◼ Infinite horizon
◼ C
2
LQR formulation
Objective function
4
Multiobjective and Pareto front
for i=1:10000
x=rand(1);
y=rand(1)
J1(i)=x*x+3*(y-1)*(y-1);
J2(i)=4*(x-2)*x+y*y;
end
6
Dynamic Programming
Dynamic Programming
8
Dynamic Programming: shortest path
2, 6,
A D
7,E
4, 3, 10,H (I)
A D
6,F
2, 7,
A D
10
LQR solved by dynamic programming
11
12
LQR solved by dynamic programming III
13
LQR algorithm
14
LQR algorithm matlab
for t=N:-1:1
P=Q+A'*Pt1*A-A'*Pt1*B*inv(R+B'*Pt1*B)*B'*Pt1*A;
c1(:,t)=Pt1(:,1);
c2(:,t)=Pt1(:,2);
K(:,t)=-inv(R+B'*Pt1*B)*B'*Pt1*A;
Pt1=P;
end
% Simulación
for t=2:N
x(:,t)=A*x(:,t-1)+B*K(:,t-1)'*x(:,t-1);
end
15
A= Kt
0.7094 0.2760
0.7547 0.6797
B=
0.6551
0.1626
Qf=100*eye(2);
Q=50*eye(2);
R=20;
16
16
LQR algorithm matlab example
A= Kt
0.7094 0.2760
0.7547 0.6797
B=
0.6551
0.1626
Qf=100*eye(2);
Q=50*eye(2);
R=20;
17
17
A= xt
0.7094 0.2760
0.7547 0.6797
B=
0.6551
0.1626
Qf=100*eye(2);
Q=50*eye(2);
R=20;
x0=[5;2]
18
18
Limits of P and K
(infinite horizon)
19
for t=N:-1:1
P=Q+A'*Pt1*A-A'*Pt1*B*inv(R+B'*Pt1*B)*B'*Pt1*A;
c1(:,t)=Pt1(:,1);
c2(:,t)=Pt1(:,2);
K(:,t)=-inv(R+B'*Pt1*B)*B'*Pt1*A;
Pt1=P;
end
% Simulación
for t=2:N
% x(:,t)=A*x(:,t-1)+B*K(:,t-1)'*x(:,t-1);
xc(:,t)=A*x(:,t-1)+B*K(:,1)'*x(:,t-1);
end
20
LQR algorithm matlab example
A= x con Kcte
0.7094 0.2760
0.7547 0.6797
B=
0.6551
0.1626
Qf=100*eye(2);
Q=50*eye(2);
R=20;
x0=[5;2]
21
21