Observers¶
- class hilo_mpc.MovingHorizonEstimator(model, id=None, name=None, plot_backend=None, time=0)[source]¶
Moving Horizon Estimator (MHE) class for state and parameter estimation.
- Parameters:
model (HILO-MPC Model) – HILO-MPC model object that will be used in the estimator.
id (str, optional) – id name
name (str, optional) – The name of the MHE. By default the MHE has no name.
plot_backend (str, optional) – Plot package. Can be ‘bokeh’ (recommended) or ‘matplotlib’ (default: matplotlib).
time (float or int, optional) – Initial time. Useful for time-varying systems (default: 0 ).
mhe_opts: options list
Opts
Description
arrival_cost_update
Can be smoothing or filtering
- add_measurements(y_meas, u_meas=None)[source]¶
This adds measurements that will appended to the measurements history. At the moment it is assumed that measurements are available ata constant time interval.
- Parameters:
y_meas –
u_meas –
- Returns:
- estimate(x_arrival=None, p_arrival=None, v0=None, runs=0, **kwargs)[source]¶
Compute MHE
- Parameters:
x_arrival –
p_arrival –
v0 – initial guess of the optimal vector
runs – number of optimizations to run. If different than zero will run very optimization will perturb the initial guess v0 randomly. ACHTUNG: this could cause problems with the integrators or give something outside constraints. The output will be the solution with the minimum objective function (default 0)
kwargs –
- Returns:
u_opt: first piece of optimal control sequence
- plot_mhe_estimation(save_plot=False, plot_dir=None, name_file='mhe_estimation.html', show_plot=True, extras=None, extras_names=None, title=None, format_figure=None)[source]¶
- Parameters:
save_plot – if True plot will be saved under ‘plot_dir/name_file.html’ if they are declared, otherwise in current directory
plot_dir – path to the folder where plots are saved (default = None)
name_file – name of the file where plot will be saved (default = mpc_prediction.html)
show_plot – if True, shows plots (default = False)
extras – dictionary with values that will be plotted over the predictions if keys are equal to predicted states/inputs
extras_names – tags that will be attached to the extras in the legend
title – title of the plots
format_figure – python function that modifies the format of the figure
- Returns:
- set_aux_nonlinear_constraints(aux_nl_const=None, ub=None, lb=None)[source]¶
- Parameters:
aux_nl_const –
ub –
lb –
- Returns:
- set_box_constraints(x_ub=None, x_lb=None, w_ub=None, w_lb=None, p_lb=None, p_ub=None, z_ub=None, z_lb=None)[source]¶
- Parameters:
x_ub –
x_lb –
w_ub –
w_lb –
p_lb –
p_ub –
z_ub –
z_lb –
- Returns:
- set_initial_guess(x_guess=None, w_guess=None, p_guess=None, z_guess=None)[source]¶
Sets initial guess for the optimizer when no other information of the states or inputs are available.
- Parameters:
x_guess – list of optimal dynamical state guess
w_guess – list of optimal input guess
p_guess – list of optimal parameter guess
z_guess – list of optimal algebraic state guess
- Returns:
- set_nlp_options(*args, **kwargs)[source]¶
Sets the options that modify how the mpc problem is set
- Parameters:
args –
kwargs –
- Returns:
- set_scaling(x_scaling=None, w_scaling=None, p_scaling=None, u_scaling=None)[source]¶
Scales the states and input. This is important for systems with large difference of order of magnitude in states and inputs.
- Parameters:
x_scaling – list of scaling factors
w_scaling – list of scaling factors
p_scaling – list of scaling factors
u_scaling – list of scaling factors
- Returns:
- set_time_varying_parameters(time_varying_parameters=None)[source]¶
Sets the time-varying parameters for the estimator. The estimator will expect these as an input at every iteration
- Parameters:
time_varying_parameters – list of strings with time varying parameter names
- Returns:
- property has_state_noise¶
- Returns:
- class hilo_mpc.KalmanFilter(model, id=None, name=None, plot_backend=None, square_root_form=True)[source]¶
Kalman filter (KF) class for state estimation (parameter estimation will follow soon)
- Parameters:
model –
id – The identifier of the KF object. If no identifier is given, a random one will be generated.
name – The name of the KF object. By default the KF object has no name.
plot_backend – Plotting library that is used to visualize estimated data. At the moment only Matplotlib and Bokeh are supported. By default no plotting library is selected, i.e. no plots can be generated.
square_root_form – Not used at the moment (will be implemented in the future)
- hilo_mpc.KF¶
alias of
KalmanFilter
- class hilo_mpc.ExtendedKalmanFilter(model, id=None, name=None, plot_backend=None, square_root_form=True)[source]¶
Extended Kalman filter (EKF) class for state estimation (parameter estimation will follow soon)
- Parameters:
model –
id – The identifier of the EKF object. If no identifier is given, a random one will be generated.
name – The name of the EKF object. By default the EKF object has no name.
plot_backend –
Plotting library that is used to visualize estimated data. At the moment only Matplotlib and Bokeh are supported. By default no plotting library is selected, i.e. no plots can be generated.
square_root_form – Not used at the moment (will be implemented in the future)
- Note:
The same methods and properties as for the
Kalman filter
apply
- hilo_mpc.EKF¶
alias of
ExtendedKalmanFilter
- class hilo_mpc.UnscentedKalmanFilter(model, id=None, name=None, alpha=None, beta=None, kappa=None, plot_backend=None, square_root_form=True)[source]¶
Unscented Kalman filter (UKF) class for state estimation (parameter estimation will follow soon)
- Parameters:
model –
id – The identifier of the UKF object. If no identifier is given, a random one will be generated.
name – The name of the UKF object. By default the UKF object has no name.
alpha –
beta –
kappa –
plot_backend –
Plotting library that is used to visualize estimated data. At the moment only Matplotlib and Bokeh are supported. By default no plotting library is selected, i.e. no plots can be generated.
square_root_form – Not used at the moment (will be implemented in the future)
- property alpha¶
- Returns:
- property beta¶
- Returns:
- property kappa¶
- Returns:
- hilo_mpc.UKF¶
alias of
UnscentedKalmanFilter
- class hilo_mpc.ParticleFilter(model, id=None, name=None, plot_backend=None, variant=None, roughening=False, prior_editing=False, **kwargs)[source]¶
Particle filter (PF) class for state estimation
- Parameters:
model –
id – The identifier of the PF object. If no identifier is given, a random one will be generated.
name – The name of the PF object. By default the PF object has no name.
plot_backend –
Plotting library that is used to visualize estimated data. At the moment only Matplotlib and Bokeh are supported. By default no plotting library is selected, i.e. no plots can be generated.
variant –
roughening –
prior_editing –
kwargs –
- property n_samples¶
- Returns:
- property pdf¶
- Returns:
- property probability_density_function¶
- Returns:
- property sample_size¶
- Returns:
- property variant¶
- Returns:
- hilo_mpc.PF¶
alias of
ParticleFilter