Hello i need help with this error i am working in LQR control by LMI

조회 수: 8 (최근 30일)
mahdi
mahdi 2024년 6월 26일
답변: Abhinaya Kennedy 2024년 6월 27일
A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp('Matrix P calculated using manual method:');
%disp(P)
%disp('Matrix K calculated using manual method:');
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)' + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)' -P];
H13 = trace((Q^0.5)*P*(Q^0.5)') + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)' + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)' + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)' -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)' + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)' + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)' -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)' + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)' + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)' -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)' + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+...
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]...
;
ops = sdpsettings('solver','sedumi');
% ops = sdpsettings('solver','gurobi');
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible);

답변 (1개)

Abhinaya Kennedy
Abhinaya Kennedy 2024년 6월 27일
It looks like an issue where the matrix "Pfeasible" contains "NaN" or "Inf" values. This happens due to numerical issues or infeasibility in the constraints you've set up in your optimization problem.
  1. Check for Feasibility by using "opt_info"
  2. Ensure Initial Values: Verify that A1, A2, A3, A4, B, Q, and R are correctly defined and contain no "NaN" or "Inf".
  3. Adding a small regularization term to the constraints can help with numerical stability
E = 1e-6 * eye(2); % Small regularization term
4. Check each constraint individually to see which one might be causing the issue.
5.Try using a different solver:
ops = sdpsettings('solver', 'gurobi');
[opt_info] = optimize(F, [], ops);
You can also check out this conversation on the YALMIP Google group for more information: You have NaNs in your constraints! (google.com)

카테고리

Help CenterFile Exchange에서 Linear Matrix Inequalities에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by