I have a communication problem in my NMPC controller.

조회 수: 2 (최근 30일)
Sebastian
Sebastian 2023년 7월 13일
------------------------------------------------------
Start of Error Report
------------------------------------------------------
Unable to perform assignment because the left and right sides have a different number of elements.
gfx(ix) = gfx(ix) + Ck'*wtYerr;
[fs, gfX, gfU, gfE] = quadraticObjective(coredata, runtimedata, handles, X, U, e, computeJacobian);
CostFcn = @(z) znlmpc_objfun(z(:), coredata, runtimedata, userdata, handles);
Error in fmincon (line 577)
[initVals.f,initVals.g] = feval(funfcn{3},X,varargin{:});
[z, cost, ExitFlag, Out] = fmincon(CostFcn, z0, A, B, [], [], zLB, zUB, ConFcn, fminconOpt);
[mv, ~, Info] = nlmpcmove(nlobj, x, lastmv, ref, md, Options);
sim(mdl)
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
------------------------------------------------------
End of Error Report
------------------------------------------------------
Error occurred when calling NLP solver "fmincon". See the error report displayed above.
Error in nmpcblock_interface.m (line 165)
throw(ME)
Error in PEMFC_1_NMPC_Workspace.mlx (line 85)
Taht is my code:
addpath('C:\Users\grums\OneDrive\Dokumente\MATLAB\PEMFC\Bachelor\PEMFC');
mdl = "PEMFC_1_NMPC_Controller";
open_system(mdl)
% NMPC Objekt mit 2 Zustands-, 2 Ausgangs-, 2 Stellgröße und
% 0 Störgröße (werden in meiner Simulation nicht berücksichtigt)
nlobj=nlmpc(4,4,'MV',[1 2 3 4 ]);
% Abtastzeit und Horizontlängen
PredictionHorizon=10; % Regelhorizont
ControlHorizon=3; % Steuerhorizont
Ts=0.1;
nlobj.Ts=Ts;
nlobj.PredictionHorizon=PredictionHorizon;
nlobj.ControlHorizon=ControlHorizon;
% Definition Prädiktionsgleichungen und Namen der
%Zustandsgrößen
nlobj.Model.StateFcn ='PEMFCStateFcn';
nlobj.States(1).Name='FuelFr_state';
nlobj.States(2).Name='AirFr_state';
nlobj.States(3).Name='Ifc_state';
nlobj.States(4).Name='Tfc_state';
%nlobj.States(3).Name='Current';
nlobj.States(1).Min= 51; % Anfangswert für den ersten Zustand
nlobj.States(2).Min= 51; % Anfangswert für den zweiten Zustand
nlobj.States(1).Max= 1460; % Endswert für den ersten Zustand
nlobj.States(2).Max= 7350; % Endwert für den zweiten Zustand
%Definition Ausgangsgleichung, Name der Regelgröße,
nlobj.Model.OutputFcn='OutputFcn';
nlobj.OutputVariables(1).Name='FuelFr_out';
nlobj.OutputVariables(2).Name='AirFr_out';
nlobj.OutputVariables(3).Name='T_out';
nlobj.OutputVariables(4).Name='Pfuel_out';
%nlobj.OutputVariables(5).Name='Pair_out';
%MV
nlobj.MV(1).Name='u1';
nlobj.MV(2).Name='u2';
nlobj.MV(3).Name='u3';
nlobj.MV(4).Name='u4';
%nlobj.MV(5).Name='u5';
%nlobj.MV(1).Min = 50; % Minimum Volumenstrom H2 [l/m]
%nlobj.MV(1).Max = 1460; % Maximum Volumenstrom H2 [l/m]
%nlobj.MV(2).Min = 1000; % Minimum Volumenstrom O2 [l/m]
%nlobj.MV(2).Max = 7350; % Maximum Volumenstrom O2 [l/m]
%nlobj.MV(3).Min = 330; % Minimum Volumenstrom H2 [l/m]
%nlobj.MV(3).Max = 345; % Maximum Volumenstrom H2 [l/m]
%nlobj.MV(4).Min = 1; % Minimum Volumenstrom O2 [l/m]
%nlobj.MV(4).Max = 2; % Maximum Volumenstrom O2 [l/m]
%nlobj.MV(5).Min = 0.1; % Minimum Volumenstrom H2 [l/m]
%nlobj.MV(5).Max = 2; % Maximum Volumenstrom H2 [l/m]
sim(mdl)
  댓글 수: 1
Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2023년 7월 17일
Are you using a custom cost function or the default quadratic one? That's where the error seems to originate from

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

답변 (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