# set_nl_cons¶

Class method.

do_mpc.estimator.MHE.set_nl_cons(self, expr_name, expr, ub=inf, soft_constraint=False, penalty_term_cons=1, maximum_violation=inf)

Introduce new constraint to the class. Further constraints are optional. Expressions must be formulated with respect to _x, _u, _z, _tvp, _p. They are implemented as:

$m(x,u,z,p_{\text{tv}}, p) \leq m_{\text{ub}}$

Setting the flag soft_constraint=True will introduce slack variables $$\epsilon$$, such that:

$\begin{split}m(x,u,z,p_{\text{tv}}, p)-\epsilon &\leq m_{\text{ub}},\\ 0 &\leq \epsilon \leq \epsilon_{\text{max}},\end{split}$

Slack variables are added to the cost function and multiplied with the supplied penalty term. This formulation makes constraints soft, meaning that a certain violation is tolerated and does not lead to infeasibility. Typically, high values for the penalty are suggested to avoid significant violation of the constraints.

Parameters: expr_name (string) – Arbitrary name for the given expression. Names are used for key word indexing. expr (CasADi SX or MX) – CasADi SX or MX function depending on _x, _u, _z, _tvp, _p. assertion – expr_name must be str assertion – expr must be a casadi SX or MX type Returns the newly created expression. Expression can be used e.g. for the RHS. casadi.SX