Binary checks in cost


Quick question, in Casadi you can formulate binary checks as part of your functions e.g. by using > and < operators. I have added such cost terms in my Acados NMPC and it seems to work but it is a little hard to validate. So I just wanted to ask here directly, is this supported?

Thanks for all your hard work creating this amazing framework!!


Hi @martiabr

acados provides SQP-type methods to solve OCPs.
These methods are based on linearizations and quadratic approximations of the model functions.
Functions with binary checks, are in general non-differentiable and not even continuous.
Thus, the convergence results of SQP do not hold for such problems and I do not recommend using such functions with acados.


Thanks for your response Jonathan, that makes sense!

I will experiment with using a differentiable on/off function like the logistic function instead then.