How do i define and extract the MPC constraints?

4 ビュー (過去 30 日間)
Hamza Yusuf
Hamza Yusuf 2023 年 10 月 12 日
コメント済み: Hamza Yusuf 2023 年 10 月 16 日
I have my algorithm I wanna validate against the Matlab constraint generator. There is the function: https://se.mathworks.com/help/mpc/ref/mpc.getconstraint.html
What I want to do i to define my constraints variables i.e., min max and so, and then extract the matrices. The function example extracts the already given matrices (so its redundant i feel???). How do I do the opposite? I have tried to see what changed about the mpcobject before and after the constraints were defined. How do I do this? I have this attempt below which should have worked but does not.
n=4;
p=2;
hp=10;
hu=5;
Sys=ss(eye(n),eye(n,p),eye(n),0);
mpcobj = mpc(Sys,0.1);
mpcobj.PredictionHorizon=hp;
mpcobj.ControlHorizon=hu;
mpcobj.ManipulatedVariables(1).Min = -20;
mpcobj.ManipulatedVariables(2).Min = -20;
mpcobj.ManipulatedVariables(1).Max = 20;
mpcobj.ManipulatedVariables(2).Max = 20;
mpcobj.ManipulatedVariables(1).RateMin = -0.5;
mpcobj.ManipulatedVariables(2).RateMin = -0.5;
mpcobj.ManipulatedVariables(1).RateMax = 0.5;
mpcobj.ManipulatedVariables(2).RateMax = 0.5;
mpcobj.OutputVariables(1).Min = -500;
mpcobj.OutputVariables(2).Min = -500;
mpcobj.OutputVariables(3).Min = -500;
mpcobj.OutputVariables(4).Min = -500;
mpcobj.OutputVariables(1).Max = 500;
mpcobj.OutputVariables(2).Max = 500;
mpcobj.OutputVariables(3).Max = 500;
mpcobj.OutputVariables(4).Max = 500;
%%
[E,F,G] = getconstraint(mpcobj)

回答 (1 件)

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2023 年 10 月 13 日
The getconstraint function is supposed to return mixed input/output constraints. One use case would be that someone creates the MPC object and you want to see what the input/output constraints look like.
The constraints you have defined are simple bounds so they don't fall under this category.
In any case, if you want to display the constraints you have defined, you can simply do
>>mpcobj
and you will see all relevant information about the mpc object.
  1 件のコメント
Hamza Yusuf
Hamza Yusuf 2023 年 10 月 16 日
I am sorry if I wanst clear. I want my constraints in matrix form.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRefinement についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by