WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Optimal control problem; sol_h ist leer

 

wishToBeAsWiseAsH.Arendt
Forum-Newbie

Forum-Newbie


Beiträge: 5
Anmeldedatum: 29.03.20
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 02.05.2022, 16:08     Titel: Optimal control problem; sol_h ist leer
  Antworten mit Zitat      
Hallo liebe Forummitglieder,

ich habe ein Problem in meinem OCP.
Ich möchte PMP nutzen und weiß einfach nicht warum im folgenden Code sol_h leer ist.
Vielleicht könnte mir hier jemand bitte helfen?

Code:
% Das ist mein Programm.
clear all

%Initializations and values of constant variables------------------------
C_bat = 28;
R_bat = 0.01;
C_deg = 0.7;
T = 24;
a1 = -33.19;  %polynomial fitting
a2 = 133.84;
a3 = -212.24;
a4 = 165.57;
a5 = -63.67;
a6 = 10.28;
a7 = 0.20;
a8 = 3.44;

% State equations
syms x u p; %u control variable (P_bat) & x = SOC is state variable
Dx = -1/C_bat*(((a1*x^7+a2*x^6+a3*x^5+a4*x^4+a5*x^3+a6*x^2+a7*x+a8)-sqrt((a1*x^7+a2*x^6+a3*x^5+a4*x^4+a5*x^3+a6*x^2+a7*x+a8)^2-4*R_bat*u))/2*R_bat);
% Cost function inside the integral
syms g;
g = C_deg*u;
% Hamiltonian
syms p H;
H = g + p*Dx;
% Costate equations
Dp = -diff(H,x);
% solve for control u
du = diff(H,u);
sol_u = solve(du,u);
% Substitute u to state equations
Dx = subs(Dx,u,sol_u);
% convert symbolic objects to strings for using 'dsolve'
eq1 = strcat('Dx=',char(Dx));
eq2 = strcat('Dp=',char(Dp));
sol_h = dsolve(eq1,eq2);
 


Beste Grüße!
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.448
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 02.05.2022, 16:19     Titel:
  Antworten mit Zitat      
Hallo,

vermutlich ist die DGL einfach zu komplex für eine symbolische Lösung.
Code:
syms x(t) a b c t
dsolve(diff(x) == a*x^2 + b*x + c) % geht noch, aber ist schon kompliziert
dsolve(diff(x) == a*x^3 + b*x^2 + c*x + d) % Warning: Unable to find symbolic solution.

... und deine DGLen sind nochmal deutlich komplizierter.

Ich würde stattdessen eine numerische Lösung, z.B. mit ode45 versuchen. Symbolische Ausdrücke können mit matlabFunction in Function Handles umgewandelt werden.

Ist es übrigens beabsichtigt, dass derzeit in Dp noch u steckt?

Grüße,
Harald
_________________

1.) Ask MATLAB Documentation
2.) Search gomatlab.de, google.de or MATLAB Answers
3.) Ask Technical Support of MathWorks
4.) Go mad, your problem is unsolvable ;)
Private Nachricht senden Benutzer-Profile anzeigen
 
wishToBeAsWiseAsH.Arendt
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 5
Anmeldedatum: 29.03.20
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 03.05.2022, 19:13     Titel:
  Antworten mit Zitat      
Vielen Dank!
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.