nonlinear MPC with if_else constraints

165 views
Skip to first unread message

kevin

unread,
May 19, 2020, 4:52:40 PM5/19/20
to CasADi
Hello,

I am solving a nonlinear MPC problem with CasADi. I use opti stack to formulate the problem. Part of the script is presented below. There is a "if_else" constraints in the problem, which determines whether the constraint exist or not. I use a "flag" variable to apply it.  However, when I run the code, it shows the 'Infeasible_Problem_Detected'. If I remove the constraints, the rest part of the code works and give the solution. I am not sure whether the constraint is implemented correctly of not. Could someone give some suggestion?  Thank you very much.

------------------------
from casadi import * 
opti = casadi.Opti()
X = opti.variable(2, 4)
for i in range(4):
    flag = if_else(X[0, i] >= 15, 1, 0)
    opti.subject_to(X[1, i] * flag ->= 2.5 * flag)

Bruno M L

unread,
Jun 10, 2020, 4:43:49 PM6/10/20
to CasADi
Hi!

why do you have 'flag' multiplying both sides of the equation? Makes no sense.
Reply all
Reply to author
Forward
0 new messages