该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
使用yalmip自带的yalmipdemo函数进行测试,但是优化的结果经常会出现NaN,如下例所示,(最后是运行结果,出现了NaN)哪位大神知道这是为什么啊?
%*********************************************************
%
% Model predictive control example
%
%*********************************************************
%
% In this example, we solve quadratic problems using
% semidefinite programming, second order cone programming
% and quadratic programming.
% MPC settings
N = 5;
pause % Strike any key to continue.
% Create numerics for a discretized double integrator
A = [2 -1;1 0];
B = [1;0];
C = [0.5 0.5];
[H,S] = create_CHS(A,B,C,N)
H =
1.5000 -0.5000
2.5000 -1.5000
3.5000 -2.5000
4.5000 -3.5000
5.5000 -4.5000
S =
0.5000 0 0 0 0
1.5000 0.5000 0 0 0
2.5000 1.5000 0.5000 0 0
3.5000 2.5000 1.5000 0.5000 0
4.5000 3.5000 2.5000 1.5000 0.5000
pause % Strike any key to continue.
% Initial state
x = [2;0];
% Define free variables
t = sdpvar(1,1);
U = sdpvar(N,1);
pause % Strike any key to continue.
% Define the prediction vector
Y = H*x+S*U;
pause % Strike any key to continue.
% Control constraints
F = set(-1 < U < 1);
% Terminal constraint
F = F+set(-1 < Y(N) < 1);
pause % Strike any key to continue.
% Our goal is to minimize the quadratic function Y'*Y+U'*U
%
% Performance constraint written as an SDP using Schur complement
% (very inefficient way to solve a QP...)
F = F+set([t Y' U';Y eye(N) zeros(N,N);U zeros(N,N) eye(N)]>0)
+++++++++++++++++++++++++++++++++++++++++++++++++++
| ID| Constraint| Type|
+++++++++++++++++++++++++++++++++++++++++++++++++++
| #1| Numeric value| Element-wise 10x1|
| #2| Numeric value| Element-wise 2x1|
| #3| Numeric value| Matrix inequality 11x11|
+++++++++++++++++++++++++++++++++++++++++++++++++++
pause % Strike any key to continue.
% Solve
sol = solvesdp(F,t);
pause % Strike any key to continue.
% Look at solution
double(U)
ans =
NaN
NaN
NaN
NaN
NaN
double(Y(N))
ans =
NaN
pause % Strike any key to continue.