add_constr

Class method.

add_constr(self, cons_type, *args)

Add linear or nonlinear constraints to the OCP.

Nonlinear inequality constraints are of the form

\[g(t,x,u) \geq 0 \quad \text{or} \quad g(x,u) \geq 0.\]

Nonlinear equality constraints are of the form

\[h(t,x,u) = 0 \quad \text{or} \quad h(x,u) = 0.\]

Linear inequality constraints are of the form

\[Ex + Fu \geq h.\]

Linear equality constraints are of the form

\[Ex + Fu = h.\]

For the form of terminal constrains see add_terminalconstr().

Parameters:
  • cons_type (str) – String that defines the type of the constraints. Possible values are eq, ineq, terminal_eq and terminal_ineq.

  • *args (callable or arrays) – Function defining the (nonlinear) constraints or arrays defining the linear constraints. In the letter case the order of arguments are E, F, h and if h is undefined this array is set to zero.

For example

>>> constraints.add_constr('ineq', E, F, h)

will add a linear inequality constraint to linear_constr while

>>> constraints.add_constr('terminal_eq',h_end)

will add a nonlinear equality terminal constraint to nonlinear_constr.