If you have an issue with
acados and are looking for help here, please mention:
- What interface of
acados are you using (Python)?
- What do you want to achieve?
I have some confusion in looking at the race car code in the acados example, such as
- About cost_z What does the setting of z, such as zl, Zl and so on;
- Is z a slack variable and how does it relate to lsh;
- What dimension should the dimension of z be related to? x？ u？ x+u？ x+u+h
- How to set cost_Zl,cost_Vz,cost_z
I believe you will find the answers from the problem formulation part in the documentation page.
acados/problem_formulation_ocp_mex.pdf at master · acados/acados (github.com)
thanks for your reply！
but i have see it，and i still have no idea about it.
z is the algebraic variable (a variable that is intrinsic to the model equation but that is not time differentiated in the model equation), see Chapter 14 of this script for details.
For each of your questions:
I don’t know what do you mean by
cost_z since I did not find that in the documentation.
It is NOT slack variable and has no relation with
zl, zu, Zl, Zu and
The dimension of
z depends on your problem formulation and is nothing to do with the dimension of
Create an acadosOcp by
ocp = AcadosOcp() and then set
ocp.cost.Zl=. Refer to this example: acados/run_nominal_control.py at master · acados/acados (github.com)
thanks for your reply!
i find an example in race car, and i found the dimension of z is the sum of
nsbx + nsbu + nsg + nsh + nsphi
and when i delete some slack setting, it will mind me reset config:
when i delete:---------------------
# ocp.constraints.lsbx = np.zeros([nsbx])
# ocp.constraints.usbx = np.zeros([nsbx])
# ocp.constraints.idxsbx = np.array(range(nsbx))
then the terminal output:-------------------------
Exception: Inconsistent size for field Zl, with dimension 6,
Detected ns = 5 = nsbx + nsbu + nsg + nsh + nsphi.
With nsbx = 0, nsbu = 0, nsg = 0, nsh = 5, nsphi = 0
so could i think that slack has relation with z?
or the DAE is about Vz，and the slack is about cost.zl/cost.zu
Forgive me for being thoughtless.
waitting for your reply，thank you very much！
I assume you’re talking about this script here: acados/acados_settings_dev.py at master · acados/acados (github.com).
It’s clear that in the race car example, dimension of z is zero from here. There’re 5 nonlinear path constraints (nh=5) and 1 state constraint (nbx=1). They are all slacked so you get
nsh=nh=5, nsbx=nbs=1. Since you do not have other soft constraints, you get
nsbu=nsg=nsphi=0, and then get a total number of
ns=5+1+0+0+0=6 soft constraints. So your statement is incorrect.
I don’t understand why you delete those lines, but the error message you got is just natural. Deleting these two lines wouldn’t make any difference and surely will not lead to error, since they will be set to 0 by default:
ocp.constraints.lsbx = np.zeros([nsbx])
ocp.constraints.usbx = np.zeros([nsbx])
However, by deleting the line
ocp.constraints.idxsbx = np.array(range(nsbx)), you chose not to specify which state constraint you want to slack. Thus all the state constraints are hard constraints by default so you will surely get
nsbx has been decreased from 1 to 0, you should correspondingly reduce the dimension of
Zu, Zl, zu, zl to 5.
Yes, thank you very much for your detailed response!
I am reading this file, and my question is, from your response, it is also the dimension of zl that is related to the number of relaxation variables. So z and zl are different things, z is an algebraic variable, and zl is the cost of relaxation variables?
Yes, I think it’s just a problem of naming.
z is the algebraic variable and
zl, zu, Zl, Zu are the coefficients describing how heavily you penalize the slack variables. Basically they have nothing to do with each other.