Adaptive MPC Block Error

조회 수: 21 (최근 30일)
LB_SD
LB_SD 2020년 12월 16일
댓글: Majid Mazouchi 2023년 7월 17일
Question:
How can I correct the error message that shows when I run the model?
  • Error evaluating 'InitFcn' callback of Adaptive MPC block (mask) 'test22/Adaptive MPC Controller'. Callback string is 'ampcblock_InitFcn'
  • Caused by: For compatibility with the adaptive mode, the plant model specified in your controller object must be LTI state-space (OK), have the same sampling time as the controller (Violated), and be delay-free (OK). The "ss", "c2d", "d2d" and "absorbDelay" functions perform the necessary conversions.
What I Have Done:
1) I have tested the model update function independently and it works great.
2) I have tested the dynamic plant using the normal MPC block and it worked well.
Problem
Once I connect the Adaptive MPC block, the error shows up. Please see model and functions used below.
Model Update Function:
function [A,B,C,D,U,Y,X,DX] = fcn(M,x,u)
% Sample time
Ts = 0.02;
% Model parameters
kd=0.015;
R=0.05;
Tg=0.2;
% Continuous-time model
Ac= [0 1 0 0; -(kd/(M*Tg)+1/(R*M*Tg)) -(kd/M+1/Tg) 0 0; 0 0 0 0; 0 0 0 0];
Bc= [0 -1/(M*Tg) 0 0]';
Cc = [1 0 0 0; 0 1 0 0];
Dc = zeros(2,1);
% Generate discrete-time model
nx = size(Ac,1);
nu = size(Bc,2);
Md = expm([[Ac Bc]*Ts; zeros(nu,nx+nu)]);
A = Md(1:nx,1:nx);
B = Md(1:nx,nx+1:nx+nu);
C = Cc;
D = Dc;
% Nominal conditions for discrete-time plant
X = x;
U = u;
Y = C*x + D*u;
DX = A*x+B*u-x;
Dynamic Plant Function:
function xdot = fcn(M,x,u)
% Model parameters
kd=0.015;
R=0.05;
Tg=0.2;
% Continuous-time model
A= [0 1 0 0; -(kd/(M*Tg)+1/(R*M*Tg)) -(kd/M+1/Tg) 0 0; 0 0 0 0; 0 0 0 0];
B= [0 -1/(M*Tg) 0 0]';
C = [1 0 0 0; 0 1 0 0];
D = zeros(2,1);
xdot = A*x + B*u;
MPC Object
MPC object
---------------------------------------------
Sampling time: 0.02 (seconds)
Prediction Horizon: 10
Control Horizon: 1
Plant Model:
--------------
1 manipulated variable(s) -->| 4 states |
| |--> 2 measured output(s)
0 measured disturbance(s) -->| 1 inputs |
| |--> 0 unmeasured output(s)
0 unmeasured disturbance(s) -->| 2 outputs |
--------------
Disturbance and Noise Models:
Output disturbance model: default (type "getoutdist(mpcVSG4by4)" for details)
Measurement noise model: default (unity gain after scaling)
Weights:
ManipulatedVariables: 0
ManipulatedVariablesRate: 0.0595
OutputVariables: [5.9452 0.0595]
ECR: 100000
State Estimation: Default Kalman Filter (type "getEstimator(mpcVSG4by4)" for details)
Constraints:
-22 <= delP <= 22, -10 <= delP/rate <= 10, -311.02 <= State-Space(1) <= 345.58
-1 <= State-Space(2) <= 1
  댓글 수: 1
Mozhgan Sabz
Mozhgan Sabz 2022년 9월 19일
I have the same problem. did you solve your problem?
would you please let me know?

댓글을 달려면 로그인하십시오.

답변 (1개)

dekun wang
dekun wang 2021년 5월 24일
Hi there,
My guess is that you design the mpc controller using a continuous plant model but Adaptive MPC controller requires a discrete plant model.
You can easily transfer the plant model of your mpc controller into discrete in these commands:
cp=mpcobj.Model.Plant;
dp=c2d(cp,Ts);
mpcobj.Model.Plant=dp;
  댓글 수: 1
Majid Mazouchi
Majid Mazouchi 2023년 7월 17일
Thanks! It works!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Refinement에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by