quadprog fails because of unrelated code

4 次查看(过去 30 天)
I have a Simulink model that's supposed to simulate a Generalized Prediction Control on a plant. However, the quadprog function fails when I complete the code. When I delete part of the code, it works (but because the code is incomplete, the control as a whole doesn't work).
More specifically, in the attached model, in the "control block" subsystem, in the "controller" MATLAB Function, after line 58, I have this:
coder.extrinsic('quadprog');
U = zeros(size([0; 0; 0; 0]));
U = quadprog(H, b, [], [], [], [], [0; 0; 0; 0], [100; 100; 100; 100]);
f0 = ((F - W)') * (F - W);
u1 = u1m1 + U(1) + f0;
u2 = u2m1 + U(2) + f0;
As it is, it gives me:
An error occurred while running the simulation and the simulation was terminated
Caused by:
The interior-point-convex algorithm requires all objective and constraint values to be finite.
If I comment "+ f0", the simulation works but doesn't do what I'm expecting.
How do I make it work?
I'm using MATLAB R2017a on Debian 9.
Thanks in advance.

采纳的回答

Walter Roberson
Walter Roberson 2017-12-19
Is there feedback from the output of the block to the input? If so then it is possible that at some point the output of becomes infinite, and then that infinite value gets fed back to becoming infinite input that gets complained about. When you comment out the two indicated lines, the output is U(1) and U(2) are not used and so infinite output would not end up as feedback.
  1 个评论
GuiRitter
GuiRitter 2017-12-19
You're right. I ran it for less time and found out the moment it "explodes". Turns out a sign was negated. It's working now, but still needs some work. Thanks!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Model Predictive Control Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by