MATLAB中Yalmip工具,yalmip工具箱使用问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

使用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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值