Constraint on the input rate

183 views
Skip to first unread message

Alex

unread,
Dec 6, 2018, 7:34:50 AM12/6/18
to CasADi
Hi,

I would like to constrain the input rate for an NMPC problem using a direct collocation method. 

My NLP control variable is defined as:

Uk = MX.sym(['U_' num2str(k)]);
w = {w{:}, Uk};
lbw = [lbw; -0.5];
ubw = [ubw;  0.5];
w0 = [w0;  0];

I figured that I could define another control variable 'Uk1' vector that stores the control inputs one step ahead such that:
Uk =
U_0
U_1
U_2
   |
   |
U_19


and
Uk1 =
U_1
U_2
   |
   |
U_20

for N = 20

and then implement a constraint:

g = {g{:}, Uk1 - Uk};
lbg = [lbg; -1];
ubg = [ubg; 1];

But this results in the following error:

Error using main (line 6)
    .../casadi/core/nlpsol.cpp:120: Cannot create 'solver' since [U_1, U_2, U_3, U_4, U_5, U_6, U_7,
    U_8, U_9, U_10, U_11, U_12, U_13, U_14, U_15, U_16, U_17, U_18, U_19, U_20] are free.

Is there another way of constraining the rate of input?

Alex

unread,
Dec 7, 2018, 7:24:41 AM12/7/18
to CasADi
I got to define the one step ahead Uk1 vector. However it still seems to violate any constraint I put on U[k+1] - U[k]. I can however put a constraint on just U[k+1] or U[k].

I looked into this thread as well: https://groups.google.com/forum/#!topic/casadi-users/LF8IPOaO-1U and try to obtain the Legendre-Chebyshev differentiation matrix: udot = D*u. For this I would need to have the control input at each time interval u_k (for k = 1:20) and it will give me the corresponding derivative. I can't figure out how you would implement this in the cost function as that is defined before the NLP variables are defined. So I can't access any control inputs of specific time steps k in the cost function.

For reference: I started out with this example: https://web.casadi.org/blog/mpc-simulink/ and changed the MS approach to a direct collocation method.

Any help will be greatly appreciated!

Thanks in advance!
Reply all
Reply to author
Forward
0 new messages