![]() |
Controlpp
|
Calculates the recursive least square for online parameter estimation. More...
#include <controlpp/Estimators.hpp>
Public Member Functions | |
| ReccursiveLeastSquares (const Eigen::Vector< T, NParams > ¶m_hint=Eigen::Vector< T, NParams >().setOne(), T memory=0.99, T cov_regularisation=1e-9, T gain_clamp=10) | |
| Creates a recursive least square object with start parameters/covariance and a memory factor. | |
| void | input (const T &y, const Eigen::Matrix< T, NMeasurements, NParams > &s) |
| Adds a new input output pair that updates the estimate. | |
| const Eigen::Vector< T, NParams > & | estimate () const |
| returns the current best estimate | |
| const Eigen::Matrix< T, NParams, NParams > & | cov () const |
| returns the current covariance | |
| void | set_cov (const Eigen::Matrix< T, NParams, NParams > &cov) |
| void | set_cov_regularisation (const T ®) |
| Set the value for the covariant regularisation. | |
| T | cov_regularisation () const |
| void | set_memory (const T &memory) |
| Sets the memory factor. | |
| const T & | memory () const |
| Returns the memory factor. | |
| void | set_gain_clamp (const T &gain_clamp) |
| Limits the update gain K. | |
| const T & | gain_clamp () |
| Returns the currect gain clamp factor. | |
| const Eigen::Vector< T, NParams > & | gain () const |
| Returns the gain K used in the parameter update. | |
Calculates the recursive least square for online parameter estimation.
Uses the recursive least squares algorithm:
\[ k_j = \frac{P_{j-1} s_j}{q + s_{j}^{T} P_{j-1} s_j} \]
\[ P_j = \left( P_{j-1} - k_{j} s_{j}^{T} P_{j-1}\right) \frac{1}{q} \]
\[ p_j = p_{j-1} + k_{j} \left( y_j - s_{j}^{T} p_{j-1}\right) \]
For a number of outputs greater than one (NOutputs>1) the model uses the 'Multi-Output System with shared parameter vector'. This allows to use multiple sensors observing the same system states and parameters to increase the estimation result.
There is a default regularisation therm (default: 1e-9) added to the diagonal elements of the covariance updata
There is gain clamping (default: [-10, +10]) applied to the parameter update therem K.
|
inline |
Creates a recursive least square object with start parameters/covariance and a memory factor.
Implicitly sets the covariance matrix to a diagonal matrix where each diagonal element has a value of 1000. Large diagonal elements mean that the algorithm is very uncertain about the parameters.
| param_hint | The start value of the parameter vector. If there is no prior knowledge of the values, 0 is often a good choice. |
| cov_hint | The start value of the covariance matrix. The covariance matrix is a measure of the uncertainty of the parameter vector. As a starting point use the square of the standard deviation of the noise if known. If there is no prior knowledge of the uncertainties setting it to a diagonal matrix with elements much greater than 1 is often a good choice |
| memory | The value memory that determines how much the past determines the new estimate. (In literature often called the: forgetting factor) It has to be within the open-closed range: \((0, 1]\). Remembers more of the past with higher memory and forgets more with lower memory
|
| cov_regularisation | Adds a small positive number to the diagonal of the covariance matrix P at every iteration for numerical stability:
|
| gain_clamp | Limits/clamps the elements of the recursive gain vector K = P s / (λ + sᵀ P s) to the range [-gain_clamp, +gain_clamp]. Prevents sudden large scale parameter updates caused by:
|
|
inline |
returns the current covariance
acts as a measure of the uncertainty of the estimate (higher values signal higher uncertainty)
|
inline |
|
inline |
returns the current best estimate
|
inline |
Returns the gain K used in the parameter update.
The gain K can be seen as a measure of uncertainty
|
inline |
Returns the currect gain clamp factor.
|
inline |
Adds a new input output pair that updates the estimate.
| y | The new system measurements/outputs |
| s | The known system inputs |
|
inline |
Returns the memory factor.
The memory factor [0, 1], where:
|
inline |
|
inline |
Set the value for the covariant regularisation.
Often used values: 1e-6 or 1e-9
| reg | The regularisation coefficient that will be added to the diagonal of the covariance matrix |
|
inline |
Limits the update gain K.
Limits the update gain K from -gain_clamp to +gain_clamp. Prevents too fast updates and ill conditioned updates. For example from a lack of excitation variety
default is 10
| gain_clamp | The new gain clamp |
|
inline |
Sets the memory factor.
The memory factor [0, 1], where:
| memory | The new memory factor |