set_expression¶
Class method.
-
do_mpc.model.Model.
set_expression
(self, expr_name, expr)¶ Introduce new expression to the model class. Expressions are not required but can be used to extract further information from the model. Expressions must be formulated with respect to
_x
,_u
,_z
,_tvp
,_p
.Example:
Maybe you are interested in monitoring the product of two states?
Introduce two scalar states: x_1 = model.set_variable('_x', 'x_1') x_2 = model.set_variable('_x', 'x_2') # Introduce expression: model.set_expression('x1x2', x_1*x_2)
This new expression
x1x2
is then available in all do-mpc modules utilizing this model instance. It can be set, e.g. as the cost function indo-mpc.controller.MPC
or simply used in a graphical representation of the simulated / controlled system.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
.
Raises: - assertion – expr_name must be str
- assertion – expr must be a casadi SX or MX type
- assertion – Cannot call after
setup()
.
Returns: Returns the newly created expression. Expression can be used e.g. for the RHS.
Return type: casadi.SX
This page is auto-generated. Page source is not available on Github.