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.Optimizerbase class (which is also used fordo_mpc.controller.MPC), as well as theEstimatorbase class. Use this class to configure and run the MHE based on a previously configureddo_mpc.model.Modelinstance.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 low-level interfaceset_objective().
- Set upper and lower bounds.
- Optionally, set further (non-linear) constraints with
set_nl_cons(). - Use
get_p_template()andset_p_fun()to set the function for the parameters. - Finally, call
setup().
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,u0andp_est0and 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.boundsQuery and set bounds of the optimization variables. MHE.opt_p_numFull MHE parameter vector. MHE.opt_x_numFull MHE solution and initial guess. MHE.p_est0Initial value of estimated parameters and current iterate. MHE.scalingQuery and set scaling of the optimization variables. MHE.t0Current time marker of the class. MHE.u0Initial input and current iterate. MHE.x0Initial state and current iterate. MHE.z0Initial algebraic state and current iterate. Methods
MHE.get_p_templateObtain output template for set_p_fun().MHE.get_tvp_templateObtain output template for set_tvp_fun().MHE.get_y_templateObtain output template for set_y_fun().MHE.make_stepMain method of the class during runtime. MHE.reset_historyReset the history of the optimizer. MHE.set_default_objectiveConfigure the suggested default MHE formulation. MHE.set_initial_guessInitial guess for optimization variables. MHE.set_nl_consIntroduce new constraint to the class. MHE.set_objectiveSet the stage cost \(l(\cdot)\) and arrival cost \(m(\cdot)\) function for the MHE problem: MHE.set_p_funSet function which returns parameters.. MHE.set_paramMethod to set the parameters of the MHEclass.MHE.set_tvp_funSet function which returns time-varying parameters. MHE.set_y_funSet the measurement function. MHE.setupThe setup method finalizes the MHE creation. MHE.solveSolves the optmization problem. - Use
This page is auto-generated. Page source is not available on Github.