Using Matlab (fmincon, ode) to solve an optimal control problem

  Рет қаралды 9,866

Ahmad Hably

Ahmad Hably

Күн бұрын

Пікірлер: 48
@mukhtarsani9871
@mukhtarsani9871 4 жыл бұрын
Nice video.
@rachmawatiw.8753
@rachmawatiw.8753 6 ай бұрын
Thx you very much for the video.
@rachmawatiw.8753
@rachmawatiw.8753 6 ай бұрын
My research is also in the area of optimal control, mostly in Industrial Engineering; and love MATLAB so much. May I contact you someday to discuss?
@ahmadhably80
@ahmadhably80 6 ай бұрын
Of course
@40NoNameFound-100-years-ago
@40NoNameFound-100-years-ago Жыл бұрын
Hello Sir, thank you for such a great video. Is there any way you can share the code? On a google drive for example?
@rushabhdalal6072
@rushabhdalal6072 3 жыл бұрын
How to find parameters a and b such that the sum of quadratic errors e=sum_i((ym_i-y(tm_i))^2) between measurements ym and model output y is minimal using optimizers such as fminunc and ODE. The model reads xt=[0 1; a b]*x; y=x; tm ym 0 1.0000 0.5000 0.6482 1.0000 -0.1047 1.5000 -0.6897
@priyaverma3247
@priyaverma3247 3 жыл бұрын
How to solve optimal control problem with two control parameters, by matlab 2018.. Could you hwlp me?
@UsmanKhan-dg8kn
@UsmanKhan-dg8kn 2 жыл бұрын
Sir can you help me in making graph on MATLAB. Actually I have done my all part or numerical but still facing problem in MATLAB coding of optimal control strategies for infectious disease
@santanubhattacharya316
@santanubhattacharya316 2 жыл бұрын
Thank you Sir. I have one question. What type of control is this? Like bang bang or singular or anything else?
@ahmadhably80
@ahmadhably80 2 жыл бұрын
optimal control type
@arthurmoreno145
@arthurmoreno145 2 жыл бұрын
Hello Ahmad, Can you help me with problem ? I didn't understand why you didn't use the final state in the code even though you declared x1 as a global variable.
@ahmadhably80
@ahmadhably80 2 жыл бұрын
what do you mean by the final state?
@maryyamirfan8620
@maryyamirfan8620 2 жыл бұрын
Hi sir.. My MATLAB code show alot of errors then i clear all ...but still my code bot running .. can you please help in making my code???
@ahmadhably80
@ahmadhably80 2 жыл бұрын
Please share it
@maryyamirfan8620
@maryyamirfan8620 2 жыл бұрын
@@ahmadhably80 in comments???
@ahmadhably80
@ahmadhably80 2 жыл бұрын
By email
@ihebkharab
@ihebkharab 2 жыл бұрын
Hi sir, thank you for this helpful video, I have an issue with coding the same principle but, I have a two variable function in an SI model and I want to minimize the infections by adding the travel restriction function u , and can be treated as a signal or so as you did in the video, could you please help me? I have errors on the coding part that I do not know how to fix. Thank you in advance
@ahmadhably80
@ahmadhably80 2 жыл бұрын
what is the type of your input?
@Sinanmmd
@Sinanmmd 3 жыл бұрын
Sir, can you please the same for SIR model? I need this code for optimal control in Mathematical Biology
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Can you give your model
@lidia1653
@lidia1653 3 жыл бұрын
Thank you for sharing your knowledge! Could you please help me understand your "way of a contraction of U"? I used your example to find the optimal control for a simple SIR model with a control variable from 0 to 1. And I expected to obtain the graphic for U from 0 to some optimal value U. However, in the results, I got that the initial point of the control was not equal to zero but greater to zero. Could you please help understand why the control is not equal to zero at the initial point?
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Could you share your code ?
@lidia1653
@lidia1653 3 жыл бұрын
@@ahmadhably80 Thank you for your reply! I did it. Graph U already has the correct results. The graph is not very smooth, but the values are correct. I will attach the code below if you are still interested in it. How do you think is it possible to transform this problem into a multi-objective problem? Ex. to minimize the cost integral (objective function for the integral of the control), and simultaneously to maximize the second objective function, say, to maximize the number of recovered. global T N I0 np S0 R0 Y0 x0 T=30; N=10; I0=1; np=169; S0=np-I0; R0=0; Y0=0; x0=[S0;I0;R0;Y0]; lesu_init=zeros(1,N); u_out = fmincon(@cost3, lesu_init, [],[],[],[],zeros(1,N),ones(1,N),@nonlcon); [t,x]=ode45(@my_ode2, [0 T], x0, [], u_out); figure (1) umin2=[u_out u_out(:,end)]; t2=(0:T/N:T); ui=smooth(t2,umin2) ; stairs(0:T/N:T, umin2,'r'); hold on plot(t2, ui,'b'); xlabel('temps') legend('u optimal'); hold off figure (2) plot(t,x(:,1:3)); xlabel('temps') legend('x1','x2','x3'); figure (3) plot(t,x(:,4)); xlabel('temps') legend('x4'); function xdot=my_ode2(t,x,lesu) lamda = 0.005; gamma = 0.04; q=1.5; u=udet2(t, lesu); xdot=zeros(4,1); xdot(1)=- lamda *x(1)*x(2); %S xdot(2)=lamda * x(1)*x(2) - gamma *x(2)-u*x(2); xdot(3)=gamma * x(2)+u*x(2); xdot(4)=q*u*u; end % U function vector=udet2(t, lesu) global T N a=N*t/T; if a==0 vector=lesu(:,1); else vector=lesu(:, abs(ceil(a))); end end %Cost function we want to minimize x(2)+int(q*u^2)dt function J2=cost3(lesu) global T x0 u_out [t,x]=ode45(@my_ode2,[0,T],x0,[],lesu); J21=(x(end,2)); J22=(x(end,4)); J2=J21+J22; end function [c,ceq]=nonlcon(lesu) global T x0 [t,x]=ode45(@my_ode2,[0,T],x0,[],lesu); c=[]; ceq=[]; end
@لياحبلي
@لياحبلي Жыл бұрын
انا ليا يا عمو ❤
@marieaimeineza2224
@marieaimeineza2224 3 жыл бұрын
Thx for this video, it really helpfully but i tried to run these codes in MATLAB 2018a unfortunately they are not working. they keep giving errors like not enough inputs argument. need your help!!!!!!!!
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Send them by email please. They are working on my desktop
@tareqahmad4484
@tareqahmad4484 3 жыл бұрын
hi sir, how i can make matlab for discrete cost function ?
@ahmadhably80
@ahmadhably80 3 жыл бұрын
What do you mean? Sum instead of integral?
@melikagolgoon9628
@melikagolgoon9628 Жыл бұрын
@@ahmadhably80 Yes. My objective function is the derivative of the Lyapunov function and I want to find the optimal u that minimizes Vdot. I don't have an integral in my objective function in this case. Should I add an integral with some time span? Because, after all, I want to see how the optimal u changes as the state goes through that time span.
@ahmadhably80
@ahmadhably80 Жыл бұрын
What is the type of your system. If it is linear try to use lqr. To minimize a riccati equation.
@啸宇周
@啸宇周 3 жыл бұрын
Thank you sir! Can you please show another example about solving the optimal control problem with the final time tf free which is also called the linear quadratic minimum-time problem?
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Please send me the formulation of it?
@righteousnasheed7131
@righteousnasheed7131 3 жыл бұрын
@@ahmadhably80 Hi Ahmed, how to assign x(0)=x(tf) in fmincon along with other bound and constraints such as xmin
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Please see trajectory optimization
@righteousnasheed7131
@righteousnasheed7131 3 жыл бұрын
@@ahmadhably80 where? could you please help me with a problem?
@aymenbalti5963
@aymenbalti5963 4 жыл бұрын
great
@ravikhandelwal2996
@ravikhandelwal2996 4 жыл бұрын
Sir please make videos on State space analysis simulation...in simulink... your content is awesome
@ahmadhably80
@ahmadhably80 4 жыл бұрын
Visit my channel there are a complete course on the subject
@منوعاتثقافيةتعليمية
@منوعاتثقافيةتعليمية 3 жыл бұрын
can you provide me the code please?
@zeynabjoorsara1457
@zeynabjoorsara1457 2 жыл бұрын
that's great. Can you share the code with me?
@ahmadhably80
@ahmadhably80 2 жыл бұрын
no I cannot :-)
@UsmanKhan-dg8kn
@UsmanKhan-dg8kn 2 жыл бұрын
Any body here can help me about optimal control stratigies for infectious diseases graphing on MATLAB coding?
@ahmadhably80
@ahmadhably80 2 жыл бұрын
What do you mean by graphing?
@priyaverma3247
@priyaverma3247 3 жыл бұрын
Thank you sir, But this command is not work in matlab 2018 version
@ahmadhably80
@ahmadhably80 3 жыл бұрын
Thank you for this comment. Would you explain in which sense it does not work?
@nhanNguyen-wo8fy
@nhanNguyen-wo8fy 3 жыл бұрын
@@ahmadhably80 Professor I laugh so hard at your answer. Your answer made my day. That answer is very coder. =)))) You know, like this guy in Vietnam control engineering student think about Matlab much like an App not a programming language. I also thought "What the hell why this guy think this may not work on Matlab2018a". Just like you. But I quickly understand why.
@أزهارعباسخضر
@أزهارعباسخضر 3 жыл бұрын
@@ahmadhably80 great Can you healp Me about obtiml control of Nonlinear Systems
@أزهارعباسخضر
@أزهارعباسخضر 3 жыл бұрын
And about robust control of linear descriptor system
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Everything You Need to Know About Control Theory
16:08
MATLAB
Рет қаралды 602 М.
Effortless modeling of optimal control problems with rockit
20:43
MECO Research Team, KU Leuven
Рет қаралды 1,2 М.
MATLAB Nonlinear Optimization with fmincon
14:26
APMonitor.com
Рет қаралды 243 М.
Constrained Optimization Problems with MATLAB
13:00
Dr. Harish Garg
Рет қаралды 16 М.
Model Predictive Control
12:13
Steve Brunton
Рет қаралды 278 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН