Ricatti: applying control signal forward in time

2 Ansichten (letzte 30 Tage)
Chris Dizon
Chris Dizon am 28 Mär. 2020
Hey all,
In an optimization class where we are learning about tracking to a desired output.
System
The system is a dc electric motor attached to a rotational load, with the s.s. described by:
x = [x1;x2;x3] = ang pos, vel, current || dx = [dx1;dx2;dx3] || A = [0 1 0; 0 0 4.438; 0 -12 -24] || B= [0;0;20]
There is a performance index, which I won't write, but R=0.01 and Q=[10 0 0;0 0 0;0 0 0]
output y is ang pos, tracking desired y_d(t) = 1
_________________________________________________________________________________________________________________
I was just auditing the class last term and am working through some HW's and have been stuck on applying the control signal forward in time.
I am NOT using the lqr function here; that yieds the steady state answers when T=infinity in the performance index. Here T=10, so the ricatti coefficients and co-state equations are solved first backwards in time, then applied to the control signal forward in time.
Here's what I've done (i.e. ^(T)=transpose):
  • Matlab I solved for the P matrix (defined as dP = PBR^(-1)B^(T)P - PA - A^(T)P - Q || P(T) = 0 )
  • Matlab I solved for the co state matrix (defined as db = -(A - BR^(-1)B^(T)P)^(T)*b + Q*x_d || b(T) = 0 )
  • I made a Simulink model which used gains/sums/integrators/froms/goto blocks to find p1,p2,...p6 and b1,b2,b3 from the above matrices
  • These succesfully gave me the steady state values (when looking at last of data set) of P from using [K,P,sig]=lqr(A,B,Q,R)
  • I also got the correct values for the co-state eq when using the Leibniz formula
  • Basically ^^^^ P and b are verified as correct!
What we know about u:
The optimal control at least, in a tracking problem, is defined as u*(t) = -R^(-1)B^(T)P(t)x(t) - R^(-1)B^(T)b(t)
You can see that the control signal changes in time due to P and b depending on time
In Matlab I managed to get a symbolic array of u*(t) with variables of x1,x2,x3 (since p1...p6 and b1..b3 are already known at each time step).
Problem:
Usually, I would go about this the same way as solving a s.s.
Using the s.s. equation I defined above, use gains/sums/integrators/froms/goto blocks and be fine. But that was when the control signal was constant because p1...p6 were constants.
Here they are changing with time.
I at first used a Matlab function block, where the function is simply y=u_opt_final (this contains the array of changing optimal control signals with time)
However it is not working:
Caused by:
  • Error in default port dimensions function of S-function 'a_control_out/MATLAB Function'. This function does not fully set the dimensions of output port 2
Additionally, Simulink wouldn't know how to step through an array for each time step in its simulation, anyway...
As you can see, I'm sort of stuck :/
I'm attaching my code and the model...if anyone would like to take an in-depth look at it.
OR, if anyone has better advice on how to go about this, I'm all ears. This is my first crack, there is no solution, and I haven't really seen anything online for the past week I have been working on it. At least, what I've seen is the steady state values, but again, that is not what I'm trying to do.
Thanks! That was a lot of info, and I hope any of it made sense, I am happy to clarify.
a_coefficients is parta of HW, where p1..p6 and b1..b3 are solved
a_control_out is where I am currently in a pickle
c_control_out is partc where T=inifinty, and the control signal is known b/c everything is constants. This is just to compare of a system that works
HW3.m is the main file
Chris

Antworten (0)

Kategorien

Mehr zu Simulink Design Optimization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by