Adaptive MPC Block Error

25 views (last 30 days)
LB_SD
LB_SD on 16 Dec 2020
Commented: Majid Mazouchi on 17 Jul 2023
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 Comment
Mozhgan Sabz
Mozhgan Sabz on 19 Sep 2022
I have the same problem. did you solve your problem?
would you please let me know?

Sign in to comment.

Answers (1)

dekun wang
dekun wang on 24 May 2021
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;

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!