  To control a dynamical system it is essential to obtain an accurate estimate
of the current system state based on uncertain sensor measurements and existing
system knowledge. An optimization-based moving horizon estimation (MHE)
approach uses a dynamical model of the system, and further allows for
integration of physical constraints on system states and uncertainties, to
obtain a trajectory of state estimates. In this work, we address the problem of
state estimation in the case of constrained linear systems with parametric
uncertainty. The proposed approach makes use of differentiable convex
optimization layers to formulate an MHE state estimator for systems with
uncertain parameters. This formulation allows us to obtain the gradient of a
squared and regularized output error, based on sensor measurements and state
estimates, with respect to the current belief of the unknown system parameters.
The parameters within the MHE problem can then be updated online using
stochastic gradient descent (SGD) to improve the performance of the MHE. In a
numerical example of estimating temperatures of a group of manufacturing
machines, we show the performance of tuning the unknown system parameters and
the benefits of integrating physical state constraints in the MHE formulation.
