Possible bug in Python interface slack dimensions?

Hi :wave:

I am fairly new to acados, so maybe it is a stupid question. In that case I would be happy to get help in better understanding the definition of slack varibales for the nonlinear OCP.

I am currently setting up a nonlinear MPC problem using the python interface. I have a nonlinear constraint function h(x,u,p)<=0 which is slacked. I want to add slack weights for initial, stage, and terminal cost.
When running my script to create the ocp and sim solver, the following error occurs:

Exception: Inconsistent size for fields Zl_0, with dimension 7, 
        Detected ns_0 = 14 = nsbu + nsg + nsh_0 + nsphi_0.
        With nsbu = 0, nsg = 0, nsh_0 = 7, nsphi_0 = 0

When looking at acados_ocp.py, I believe there may be a bug, because nsh_0 is added twice to ns_0 in acados_ocp.py?

# Note: at stage 0 bounds on x are not slacked!
        ns_0 = nsbu + nsg + nsh_0 + nsphi_0 + nsh_0  # NOTE: nsbx not supported at stage 0

Shouldn’t it be the following?

# Note: at stage 0 bounds on x are not slacked!
        ns_0 = nsbu + nsg + nsh_0 + nsphi_0  # NOTE: nsbx not supported at stage 0

Again, maybe I don’t understand something about a possible separation of slack weights into upper and lower bounds at stage 0? Or is it really a bug?

Thank you all in advance and for your amazing work on this OS project!

Hi,

thanks for reporting this!
It is indeed a bug.
I just separated the nonlinear constraints at the initial and path stage a week ago, and unfortunately introduced it then, see Separate nonlinear constraints into path and initial stage constraints by FreyJo · Pull Request #994 · acados/acados · GitHub
I pushed a fix and will merge it soon here: Fix bugs with slack dimensions Python interface by FreyJo · Pull Request #1001 · acados/acados · GitHub

1 Like