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 for do_mpc.controller.MPC), as well as the Estimator base class. Use this class to configure and run the MHE based on a previously configured do_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.


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:

  1. Use set_param() to configure the MHE. See docstring for details.
  2. Set the objective of the control problem with set_default_objective() or use the low-level interface set_objective().
  1. Set upper and lower bounds.
  2. Optionally, set further (non-linear) constraints with set_nl_cons().
  3. Use get_p_template() and set_p_fun() to set the function for the parameters.
  4. Finally, call setup().


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 and p_est0 and then call set_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.



MHE.bounds Query and set bounds of the optimization variables.
MHE.opt_p_num Full MHE parameter vector.
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.


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.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 time-varying parameters.
MHE.set_y_fun Set the measurement function.
MHE.setup The setup method finalizes the MHE creation.
MHE.solve Solves the optmization problem.

This page is auto-generated. Page source is not available on Github.