Acados + Constraints + multiple shooting

Hi everyone:

I’m using Python interface of Acados to solve an optimization problem for trajectory planning of vehicles. I have encountered some confusion about setting different constraints on each shooting point.

Previously, I constructed and solved the problem through multiple shooting in CasADi. The general procedure was to obtain the state variables (such as px, py, and theta) and control variables (such as v, delta) through a kinematic model. Afterward, by setting the number of shooting points, I obtained the decision variables for the optimization problem. For example, if I set the state variables to be 3-dimensional, control variables to be 2-dimensional, and the number of shooting points to be 100, then the dimensionality of the decision variables for this NLP problem is 500. The kinematic model is shown in the following diagram.

And in CasADi, I need to transcript the OCP problem “manually”. For example, if I set the state variables, control states, number of shooting points like above, the decision variables for this NLP problem will be a vector like \begin{vmatrix} d_0 & d_1 & d_2 & ... & d_{99} \end{vmatrix}^T, each d_i will be like \begin{vmatrix} px(i) & py(i) & theta(i) & v(i) & delta(i) \end{vmatrix}. Then I can get any component of any shooting point and set a constraint on an component. For example, if I set P=\begin{vmatrix} d_0 & d_1 & d_2 & ... & d_{99} \end{vmatrix}^T, then P(0) will be the first component of the first shooting point which is px(0), and P(7) will be the 2nd component of the 2nd shooting point which is theta(1). If I specify that the value of theta(0) belongs to [-1, 1] while the value of theta(1) belongs to [-2, 2], I may set lbx(2) = -1, ubx(2) = 1, lbx(7) = -2, ubx(7) = 2.

Due to slow computation speed, I switched to Acados and utilized SQP for solving the problem. In Acados, it seems like that the solver automatically completed the transcription process. Although the solver also uses multiple shooting method for transcription, I cannot access the vector of 500 dimensions like I can in CasADi. This means that I cannot control a constraint on a specific component of a specific shooting point.

To be more precise, I found that the constraints are described in the form of lg <= Du+Cx <= ug, meaning that these constraints apply to every shooting point? For example, if I set D = 0, C=I, ug = [ … … 1 … …]^T, lg = [ … … -1 … … ]^T, then the same bound [-1 , 1] will be applied to the theta component of each shooting point? I am not sure if I have not found the correct way to use Acados or if Acados does not support assigning independent constraints to each shooting point.

Looking forward to your help, thank you!

Hi,

initially, when you create the solver, you give one value for lbg and ubg which will be enforced on every shooting node.
However, the interfaces allow you to adapt those values between each solve() call.
you can do something like solver.set(i, "lbg", lbg_value).
to set the lbg_value at shooting node i.
The exact syntax is different in Matlab an Python, please look at the examples or documentation for that.

Cheers!

Hi FreyJo,

The problem has been solved now! :grinning: Thank you for the help. The key to the problem is that “the existence of a variable should be declared before changing it”. In this problem, it is necessary to first declare lbx and ubx , and then use solver.constraints_set(i,"ibx",somearray) to assign constraints to a certain shooting point.

Thanks again,
Blood