Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: MovingHorizonEstimator support for direct=true #95

Closed
wants to merge 21 commits into from

Conversation

franckgaga
Copy link
Member

No description provided.

@franckgaga franckgaga self-assigned this Aug 23, 2024
@franckgaga
Copy link
Member Author

@franckgaga
Copy link
Member Author

franckgaga commented Aug 24, 2024

I understood an interesting and kinda weird aspect of the MHE in the current form yesterday! I did not found any paper that discuss about that. It seems to be ovelooked in the litterature. I only found http://facta.junis.ni.ac.rs/acar/acar201202/acar20120202.pdf that discuss a little bit more in detailed about the MHE in the current form.

Before the estimation window is filled, the MHE is in fact the full information estimator. The initial covariance at arrival in the objective function is necessarily an a priori estimate $\mathbf{P̂}{-1}(0)$ (since we did not used any measurements yet). But the current form estimates $\mathbf{x̂}_k(k)$, an a posteriori state estimate. Thus, necessarily, at $k=H_e$, the covariance at arrival will switch from the a priori $\mathbf{P̂}{-1}(0)$ estimate to the a posteriori $\mathbf{P̂}_0(0)$ version to match the nature of the state estimate in the arrival cost term. The following time steps will also use the a posteriori estimates $\mathbf{P̂}_1(1)$, $\mathbf{P̂}_2(2)$, and so on.

That's the reason why my notation is now a little bit more complicated, with the introduction of $M_k$ process noises, $N_k$ sensor noises, and the constant $p$.

It is still work in progress, I will notice you when it's ready for you comments!

@franckgaga
Copy link
Member Author

franckgaga commented Aug 29, 2024

Ok, I struggled a lot to rigorously handle the switch in the arrival estimation covariance $\hat{P}$ for the MHE current form.

The main issue is with linear plant model. The whole optimization problem changes a lot at $k=H_e$ if we do not neglect the switch from an a priori $\hat{P_{k-1}}(k)$ to an a posteriori $\hat{P_{k}}(k)$ arrival estimation covariance.

That's mainly because with $k \lt H_e$ the arrival state estimate is inside the measurement window i.e.: the arrival estimate is $\hat{x_{-1}}(0)$ and the first measurement in the window is $y(0)$. At $k = H_e$ and later on, the arrival state estimate is outside this window i.e.: the arrival estimate is $\hat{x_{0}}(0)$ and the first measurement in the window is $y(1)$. The whole optimization problem change so much at this point that it becomes super complicated to handle that rigorously (we would need to change the objective, the linear inequality constraints, etc. at this point in time)

I think I will finally opt for this simple workaround (perhaps less rigorous):

If we assume that the initial estimate provided by the user is in fact $\hat{x_{-1}}(-1)$ and $\hat{P_{-1}}(-1)$ (instead of $\hat{x_{-1}}(0)$ and $\hat{P_{-1}}(0)$ like the prediction form of the MHE and the other Kalman Filter in the package), the optimization problem do not change at $k=H_e$ since the the arrival estimate is always outside the measurement window. I would mention that small inconsistency in the docstring of the MHE. I think that's a good compromise since the initial estimate is always a guess in practice and I do not see any good reason why $\hat{x_{-1}}(-1)$ would be a drastically different guess than $\hat{x_{-1}}(0)$ for the user. Another advantage is the new $M_k$ variable is no longer necessary (only $N_k$, as before).

Note that this only applies for the current form. The prediction form is easier since the arrival estimate is always inside the measurement window.

@franckgaga
Copy link
Member Author

Closing, will merge #96

@franckgaga franckgaga closed this Aug 31, 2024
@franckgaga franckgaga deleted the mhe_direct branch September 4, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant