I have a communication problem in my NMPC controller.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
------------------------------------------------------
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);
[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.
throw(ME)
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 commentaire
Emmanouil Tzorakoleftherakis
le 17 Juil 2023
Are you using a custom cost function or the default quadratic one? That's where the error seems to originate from
Réponses (0)
Voir également
Catégories
En savoir plus sur Model Predictive Control Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!