Types¶
Contrax uses small eqx.Module result bundles for solver, simulation-adjacent,
and estimator outputs. These types are part of the public API.
Use them as named return values rather than unpacking by position:
LQRResultfordare(),care(),lqr(), andlqi()KalmanGainResultforkalman_gain()KalmanResultforkalman()andekf()UKFResultforukf()RTSResultforrts()anduks()MHEResultformhe()PHSStructureDiagnosticsforphs_diagnostics()InnovationDiagnosticsandLikelihoodDiagnosticsfor filter-health helpersSmootherDiagnosticsfor RTS/UKS covariance-reduction health checks
Why Result Bundles Exist¶
The result types are not decorative wrappers. They are part of the numerical workflow design:
- they make multi-output solver contracts explicit
- they keep field names stable across tutorials, examples, and compiled code
- they remain pytrees, so downstream JAX code can return or differentiate
through fields such as
LQRResult.Kwithout conversion to ad hoc dicts
Important Fields¶
Some fields are especially worth knowing about:
LQRResult.residual_norm: a JAX scalar Riccati residual diagnosticKalmanResult.innovations: the measurement residual sequenceUKFResult.log_likelihood_terms: per-step innovation-form Gaussian log-likelihood termsKalmanGainResult.K: the steady-state measurement-update gainMHEResult.x_hat: the terminal state estimate from the optimized windowPHSStructureDiagnostics.power_balance_residual: the local port-Hamiltonian power-balance residualInnovationDiagnostics.mean_nis: the mean normalized innovation squared summarySmootherDiagnostics.min_covariance_reduction: the worst-case smoother covariance-reduction health flag; negative means the smoother increased variance in some direction
Related Pages¶
- Control for
LQRResult - Estimation for the Kalman-family and MHE result bundles
- Systems for the structured-system diagnostics surface
contrax.types
¶
Public result-bundle types.
InnovationDiagnostics
¶
Bases: Module
Diagnostics derived from an innovation sequence and covariance model.
Source code in contrax/types.py
KalmanGainResult
¶
Bases: Module
Result bundle for steady-state Kalman estimator design.
Attributes:
| Name | Type | Description |
|---|---|---|
K |
Array
|
Steady-state measurement-update gain. Shape: |
P |
Array
|
Steady-state predicted covariance. Shape: |
poles |
Array
|
Estimator error-dynamics eigenvalues. Shape: |
Source code in contrax/types.py
KalmanResult
¶
Bases: Module
Result bundle for Kalman filter and EKF passes.
Attributes:
| Name | Type | Description |
|---|---|---|
x_hat |
Array
|
Filtered state estimates over time. Shape: |
P |
Array
|
Filtered covariance matrices over time. Shape: |
innovations |
Array
|
Measurement residual sequence. Shape: |
Source code in contrax/types.py
LQRResult
¶
Bases: Module
Result bundle for LQR, DARE, and CARE computations.
Attributes:
| Name | Type | Description |
|---|---|---|
K |
Array
|
Optimal state-feedback gain. Shape: |
S |
Array
|
Riccati solution matrix. Shape: |
poles |
Array
|
Closed-loop eigenvalues of the designed system. Shape: |
residual_norm |
Array
|
Maximum absolute Riccati residual. Shape: scalar. |
Source code in contrax/types.py
LikelihoodDiagnostics
¶
Bases: Module
Summary diagnostics for innovation-form log-likelihood terms.
Source code in contrax/types.py
MHEResult
¶
Bases: Module
Result bundle for a fixed-window moving-horizon-estimation solve.
Attributes:
| Name | Type | Description |
|---|---|---|
xs |
Array
|
Estimated state trajectory over the window. Shape: |
x_hat |
Array
|
Terminal state estimate, equal to |
final_cost |
Array
|
Final MHE objective value. Shape: scalar. |
solver_converged |
Array
|
Whether the underlying optimizer reported convergence.
Shape: scalar bool. Note: LBFGS may report |
Source code in contrax/types.py
PHSStructureDiagnostics
¶
Bases: Module
Structure-oriented diagnostics for a port-Hamiltonian state.
Attributes:
| Name | Type | Description |
|---|---|---|
skew_symmetry_error |
Array
|
Maximum absolute residual in |
dissipation_symmetry_error |
Array
|
Maximum absolute residual in |
min_dissipation_eigenvalue |
Array
|
Smallest eigenvalue of the symmetrized dissipation matrix. Shape: scalar. |
storage_rate |
Array
|
Instantaneous Hamiltonian rate |
dissipation_power |
Array
|
Dissipated power |
supplied_power |
Array
|
Port power |
power_balance_residual |
Array
|
Residual in the standard PHS energy balance
|
Source code in contrax/types.py
RTSResult
¶
Bases: Module
Result bundle for Rauch-Tung-Striebel smoothing.
Attributes:
| Name | Type | Description |
|---|---|---|
x_smooth |
Array
|
Smoothed state estimates over time. Shape: |
P_smooth |
Array
|
Smoothed covariance matrices over time. Shape: |
Source code in contrax/types.py
SmootherDiagnostics
¶
Bases: Module
Health diagnostics for RTS/UKS smoother output.
A well-behaved smoother strictly reduces uncertainty: P_smooth ≤ P_filtered
in the positive-semidefinite sense. These diagnostics surface numerical
breakdown before it affects downstream analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
covariance_reduction |
Array
|
Per-step minimum eigenvalue of
|
min_covariance_reduction |
Array
|
Scalar minimum over time. The primary health flag: negative means the smoother violated its own uncertainty-reduction guarantee. |
state_corrections |
Array
|
Per-step L2 norm of |
max_state_correction |
Array
|
Scalar maximum correction over time. |
smoothed_min_eigenvalue |
Array
|
Per-step minimum eigenvalue of |
nonfinite |
Array
|
True if any smoothed mean or covariance contains NaN/Inf. |
Source code in contrax/types.py
UKFResult
¶
Bases: Module
Result bundle for unscented Kalman filtering.
Attributes:
| Name | Type | Description |
|---|---|---|
x_hat |
Array
|
Filtered state estimates over time. Shape: |
P |
Array
|
Filtered covariance matrices over time. Shape: |
innovations |
Array
|
Measurement residual sequence. Shape: |
predicted_measurements |
Array
|
Predicted measurement means before each update.
Shape: |
innovation_covariances |
Array
|
Innovation covariance matrices for each update.
Shape: |
log_likelihood_terms |
Array
|
Per-step Gaussian innovation log-likelihood
terms. Shape: |
predicted_state_means |
Array
|
One-step predicted state means after each
update. Shape: |
predicted_state_covariances |
Array
|
One-step predicted state covariances after
each update. Shape: |
transition_cross_covariances |
Array
|
Cross-covariances between filtered
states and one-step predictions. Shape: |