MHE¶

class
do_mpc.estimator.
MHE
(model, p_est_list=[])[source]¶ Moving horizon estimator.
For general information on moving horizon estimation, please read our background article.
The MHE estimator extends the
do_mpc.optimizer.Optimizer
base class (which is also used fordo_mpc.controller.MPC
), as well as theEstimator
base class. Use this class to configure and run the MHE based on a previously configureddo_mpc.model.Model
instance.The class is initiated by passing a list of the parameters that should be estimated. This must be a subset (or all) of the parameters defined in
do_mpc.model.Model
. This allows to define parameters in the model that influence the model externally (e.g. weather predictions), and those that are internal e.g. system parameters and can be estimated. Passing an empty list (default) value, means that no parameters are estimated.Note
Parameters are influencing the model equation at all timesteps but are constant over the entire horizon. Parameters could also be introduced as states without dynamic but this would increase the total number of optimization variables.
Configuration and setup:
Configuring and setting up the MHE involves the following steps:
 Use
set_param()
to configure theMHE
. See docstring for details.  Set the objective of the control problem with
set_default_objective()
or use the lowlevel interfaceset_objective()
.
 Set upper and lower bounds.
 Optionally, set further (nonlinear) constraints with
set_nl_cons()
.  Use
get_p_template()
andset_p_fun()
to set the function for the (not estimated) parameters.  Use
get_tvp_template()
andset_tvp_fun()
to create a method to obtain new timevarying parameters at each iteration.  To finalize the class configuration there are two routes. The default approach is to call
setup()
. For deep customization use the combination ofprepare_nlp()
andcreate_nlp()
. See graph below for an illustration of the process.
Warning
Before running the estimator, make sure to supply a valid initial guess for all estimated variables (states, algebraic states, inputs and parameters). Simply set the intial values of
x0
,z0
,u0
andp_est0
and then callset_initial_guess()
.To take full control over the initial guess, modify the values of
opt_x_num
.During runtime use
make_step()
with the most recent measurement to obtain the estimated states.Parameters:  model (
do_mpc.model.Model
) – A configured and setupdo_mpc.model.Model
 p_est_list (list) – List with names of parameters (
_p
) defined inmodel
Attributes
MHE.bounds
Query and set bounds of the optimization variables. MHE.nlp_cons
Query and modify (symbolically) the NLP constraints. MHE.nlp_cons_lb
Query and modify the lower bounds of the nlp_cons
.MHE.nlp_cons_ub
Query and modify the upper bounds of the nlp_cons
.MHE.nlp_obj
Query and modify (symbolically) the NLP objective function. MHE.opt_p
Full structure of (symbolic) MHE parameters. MHE.opt_p_num
Full MHE parameter vector. MHE.opt_x
Full structure of the (symbolic) MHE optimization variables. MHE.opt_x_num
Full MHE solution and initial guess. MHE.p_est0
Initial value of estimated parameters and current iterate. MHE.scaling
Query and set scaling of the optimization variables. MHE.t0
Current time marker of the class. MHE.u0
Initial input and current iterate. MHE.x0
Initial state and current iterate. MHE.z0
Initial algebraic state and current iterate. Methods
MHE.create_nlp
Create the optimization problem. MHE.get_p_template
Obtain output template for set_p_fun()
.MHE.get_tvp_template
Obtain output template for set_tvp_fun()
.MHE.get_y_template
Obtain output template for set_y_fun()
.MHE.make_step
Main method of the class during runtime. MHE.prepare_nlp
Prepare the optimization problem. MHE.reset_history
Reset the history of the optimizer. MHE.set_default_objective
Configure the suggested default MHE formulation. MHE.set_initial_guess
Initial guess for optimization variables. MHE.set_nl_cons
Introduce new constraint to the class. MHE.set_objective
Set the stage cost \(l(\cdot)\) and arrival cost \(m(\cdot)\) function for the MHE problem: MHE.set_p_fun
Set function which returns parameters.. MHE.set_param
Method to set the parameters of the MHE
class.MHE.set_tvp_fun
Set function which returns timevarying parameters. MHE.set_y_fun
Set the measurement function. MHE.setup
The setup method finalizes the MHE creation. MHE.solve
Solves the optmization problem.  Use
This page is autogenerated. Page source is not available on Github.