contrax 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- contrax-0.1.0/LICENSE +21 -0
- contrax-0.1.0/PKG-INFO +172 -0
- contrax-0.1.0/README.md +133 -0
- contrax-0.1.0/contrax/__init__.py +197 -0
- contrax-0.1.0/contrax/_ekf.py +269 -0
- contrax-0.1.0/contrax/_estimation_diagnostics.py +155 -0
- contrax-0.1.0/contrax/_kalman.py +322 -0
- contrax-0.1.0/contrax/_mhe.py +242 -0
- contrax-0.1.0/contrax/_place.py +392 -0
- contrax-0.1.0/contrax/_precision.py +16 -0
- contrax-0.1.0/contrax/_riccati.py +389 -0
- contrax-0.1.0/contrax/_ukf.py +285 -0
- contrax-0.1.0/contrax/analysis.py +422 -0
- contrax-0.1.0/contrax/compat/__init__.py +7 -0
- contrax-0.1.0/contrax/compat/python_control.py +142 -0
- contrax-0.1.0/contrax/control.py +238 -0
- contrax-0.1.0/contrax/core.py +401 -0
- contrax-0.1.0/contrax/estimation.py +54 -0
- contrax-0.1.0/contrax/interconnect.py +113 -0
- contrax-0.1.0/contrax/nonlinear.py +148 -0
- contrax-0.1.0/contrax/parameterization.py +88 -0
- contrax-0.1.0/contrax/phs.py +397 -0
- contrax-0.1.0/contrax/sim.py +639 -0
- contrax-0.1.0/contrax/simulation.py +25 -0
- contrax-0.1.0/contrax/systems.py +48 -0
- contrax-0.1.0/contrax/types.py +209 -0
- contrax-0.1.0/contrax.egg-info/PKG-INFO +172 -0
- contrax-0.1.0/contrax.egg-info/SOURCES.txt +40 -0
- contrax-0.1.0/contrax.egg-info/dependency_links.txt +1 -0
- contrax-0.1.0/contrax.egg-info/requires.txt +16 -0
- contrax-0.1.0/contrax.egg-info/top_level.txt +1 -0
- contrax-0.1.0/pyproject.toml +85 -0
- contrax-0.1.0/setup.cfg +4 -0
- contrax-0.1.0/tests/test_analysis.py +328 -0
- contrax-0.1.0/tests/test_control.py +556 -0
- contrax-0.1.0/tests/test_core.py +263 -0
- contrax-0.1.0/tests/test_estimation.py +1204 -0
- contrax-0.1.0/tests/test_examples.py +94 -0
- contrax-0.1.0/tests/test_interconnect.py +213 -0
- contrax-0.1.0/tests/test_linearize.py +232 -0
- contrax-0.1.0/tests/test_public_modules.py +59 -0
- contrax-0.1.0/tests/test_sim.py +660 -0
contrax-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Givani Boekestijn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
contrax-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: contrax
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: JAX-native control theory library
|
|
5
|
+
Author-email: Givani Boekestijn <givaniboek@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/givani30/Contrax
|
|
8
|
+
Project-URL: Repository, https://github.com/givani30/Contrax
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/givani30/Contrax/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: diffrax>=0.7.2
|
|
24
|
+
Requires-Dist: equinox>=0.13.6
|
|
25
|
+
Requires-Dist: jax>=0.9.2
|
|
26
|
+
Requires-Dist: lineax>=0.0.8
|
|
27
|
+
Requires-Dist: optimistix>=0.1.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: build>=1.2.2; extra == "dev"
|
|
30
|
+
Requires-Dist: matplotlib>=3.10.8; extra == "dev"
|
|
31
|
+
Requires-Dist: mkdocstrings-python>=2.0.3; extra == "dev"
|
|
32
|
+
Requires-Dist: pillow>=12.2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pre-commit>=4.0.1; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest>=9.0.3; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-xdist>=3.8.0; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.11.13; extra == "dev"
|
|
37
|
+
Requires-Dist: zensical>=0.0.32; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# Contrax
|
|
41
|
+
|
|
42
|
+
**Differentiable control theory primitives for JAX.**
|
|
43
|
+
|
|
44
|
+
[](https://github.com/givani30/Contrax/actions/workflows/ci.yml)
|
|
45
|
+
[](https://givani30.github.io/Contrax/)
|
|
46
|
+
[](https://pypi.org/project/contrax/)
|
|
47
|
+
[](https://pypi.org/project/contrax/)
|
|
48
|
+
[](LICENSE)
|
|
49
|
+
|
|
50
|
+
Contrax is a JAX-native systems, estimation, and control toolbox.
|
|
51
|
+
MATLAB-familiar names at the API surface — `ss`, `lqr`, `kalman`, `place` —
|
|
52
|
+
with `jit`, `vmap`, and `grad` behavior underneath.
|
|
53
|
+
|
|
54
|
+
**[Documentation](https://givani30.github.io/Contrax/)** · [Getting started](https://givani30.github.io/Contrax/getting-started/) · [API reference](https://givani30.github.io/Contrax/api/systems/)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install contrax
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Requires Python 3.11+ and JAX 0.4+. For GPU support, install JAX separately
|
|
65
|
+
per the [JAX installation guide](https://jax.readthedocs.io/en/latest/installation.html)
|
|
66
|
+
before installing Contrax.
|
|
67
|
+
|
|
68
|
+
## Why Contrax
|
|
69
|
+
|
|
70
|
+
A controller design step can sit inside an ordinary differentiable objective
|
|
71
|
+
instead of being a separate offline calculation:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import jax
|
|
75
|
+
jax.config.update("jax_enable_x64", True)
|
|
76
|
+
|
|
77
|
+
import jax.numpy as jnp
|
|
78
|
+
import contrax as cx
|
|
79
|
+
|
|
80
|
+
A = jnp.array([[1.0, 0.05], [0.0, 1.0]])
|
|
81
|
+
B = jnp.array([[0.0], [0.05]])
|
|
82
|
+
SYS = cx.dss(A, B, jnp.eye(2), jnp.zeros((2, 1)), dt=0.05)
|
|
83
|
+
X0 = jnp.array([1.0, 0.0])
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def closed_loop_cost(log_q_diag, log_r):
|
|
87
|
+
K = cx.lqr(SYS, jnp.diag(jnp.exp(log_q_diag)), jnp.exp(log_r)[None, None]).K
|
|
88
|
+
_, xs, _ = cx.simulate(SYS, X0, lambda t, x: -K @ x, num_steps=80)
|
|
89
|
+
return jnp.sum(xs**2) + 1e-2 * jnp.sum((xs[:-1] @ K.T) ** 2)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
cost, (dq, dr) = jax.jit(jax.value_and_grad(closed_loop_cost, argnums=(0, 1)))(
|
|
93
|
+
jnp.zeros(2), jnp.array(0.0)
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This is the central Contrax idea: control primitives that behave like normal
|
|
98
|
+
JAX building blocks.
|
|
99
|
+
|
|
100
|
+
## Scope
|
|
101
|
+
|
|
102
|
+
**Systems**
|
|
103
|
+
`ss`, `dss`, `c2d`, `nonlinear_system`, `phs_system`, `canonical_J`,
|
|
104
|
+
`schedule_phs`, `linearize`, `linearize_ss`, `phs_to_ss`, `series`, `parallel`
|
|
105
|
+
|
|
106
|
+
**Simulation**
|
|
107
|
+
`lsim`, `simulate`, `rollout`, `step_response`, `impulse_response`,
|
|
108
|
+
`initial_response`, `sample_system`, `foh_inputs`
|
|
109
|
+
|
|
110
|
+
**Control**
|
|
111
|
+
`lqr`, `lqi`, `dare`, `care`, `place`, `feedback`, `state_feedback`,
|
|
112
|
+
`augment_integrator`
|
|
113
|
+
|
|
114
|
+
**Estimation**
|
|
115
|
+
`kalman`, `ekf`, `ukf`, `rts`, `uks`
|
|
116
|
+
`kalman_predict`, `kalman_update`, `kalman_step`
|
|
117
|
+
`ekf_predict`, `ekf_update`, `ekf_step`
|
|
118
|
+
`kalman_gain`, `mhe_objective`, `mhe`, `mhe_warm_start`
|
|
119
|
+
|
|
120
|
+
**Analysis**
|
|
121
|
+
`ctrb`, `obsv`, `poles`, `evalfr`, `freqresp`, `dcgain`,
|
|
122
|
+
`ctrb_gramian`, `obsv_gramian`, `lyap`, `dlyap`, `zeros`
|
|
123
|
+
|
|
124
|
+
**Diagnostics**
|
|
125
|
+
`innovation_diagnostics`, `likelihood_diagnostics`, `ukf_diagnostics`,
|
|
126
|
+
`smoother_diagnostics`, `phs_diagnostics`, `innovation_rms`
|
|
127
|
+
|
|
128
|
+
**Parameterization**
|
|
129
|
+
`positive_exp`, `positive_softplus`, `spd_from_cholesky_raw`, `diagonal_spd`,
|
|
130
|
+
`lower_triangular`
|
|
131
|
+
|
|
132
|
+
**Interoperability**
|
|
133
|
+
`contrax.compat.python_control` — optional bidirectional conversion with
|
|
134
|
+
[python-control](https://python-control.readthedocs.io/) (`pip install control`)
|
|
135
|
+
|
|
136
|
+
## Solver Status
|
|
137
|
+
|
|
138
|
+
- **`dare`** — structured-doubling forward solve with implicit-differentiation VJP. Most mature path.
|
|
139
|
+
- **`care`** — Hamiltonian stable-subspace solver with implicit backward pass. Validated, less benchmarked than `dare`.
|
|
140
|
+
- **`place`** — JAX-native KNV0/YT-style robust pole placement; Ackermann retained as SISO fallback only.
|
|
141
|
+
- **`ekf` / `ukf` / `rts` / `uks`** — differentiable nonlinear filtering and smoothing with full JAX transform support.
|
|
142
|
+
- **`mhe`** — LBFGS-backed fixed-window MHE. Useful optimization-based estimation primitive; not a full NLP framework.
|
|
143
|
+
|
|
144
|
+
LTI workflows are the most mature slice. Nonlinear models, PHS support, and
|
|
145
|
+
fixed-window MHE are real public capabilities, but they should be read with
|
|
146
|
+
more explicit solver-maturity caution than the core discrete design path.
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
git clone https://github.com/givani30/Contrax.git
|
|
152
|
+
cd Contrax
|
|
153
|
+
uv sync --group dev
|
|
154
|
+
uv run pre-commit install
|
|
155
|
+
uv run pytest tests/ -q
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
|
159
|
+
|
|
160
|
+
## Acknowledgements
|
|
161
|
+
|
|
162
|
+
Contrax is built on top of several excellent JAX-ecosystem libraries:
|
|
163
|
+
|
|
164
|
+
- **[JAX](https://github.com/google/jax)** — the foundation: JIT compilation, autodiff, and vectorization.
|
|
165
|
+
- **[Equinox](https://github.com/patrick-kidger/equinox)** — pytree-compatible modules used for all result bundles and system types.
|
|
166
|
+
- **[Diffrax](https://github.com/patrick-kidger/diffrax)** — ODE solvers powering `simulate()` on continuous-time models.
|
|
167
|
+
- **[Optimistix](https://github.com/patrick-kidger/optimistix)** — LBFGS solver backing `mhe()`.
|
|
168
|
+
- **[Lineax](https://github.com/patrick-kidger/lineax)** — linear solvers used in the estimation and Riccati paths.
|
|
169
|
+
|
|
170
|
+
The DARE structured-doubling custom VJP is adapted from
|
|
171
|
+
[trajax](https://github.com/google/trajax) (Google) and the DiLQR approach
|
|
172
|
+
(ICML 2025). The UKF sigma-point rules follow Wan & van der Merwe (2000).
|
contrax-0.1.0/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Contrax
|
|
2
|
+
|
|
3
|
+
**Differentiable control theory primitives for JAX.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/givani30/Contrax/actions/workflows/ci.yml)
|
|
6
|
+
[](https://givani30.github.io/Contrax/)
|
|
7
|
+
[](https://pypi.org/project/contrax/)
|
|
8
|
+
[](https://pypi.org/project/contrax/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
Contrax is a JAX-native systems, estimation, and control toolbox.
|
|
12
|
+
MATLAB-familiar names at the API surface — `ss`, `lqr`, `kalman`, `place` —
|
|
13
|
+
with `jit`, `vmap`, and `grad` behavior underneath.
|
|
14
|
+
|
|
15
|
+
**[Documentation](https://givani30.github.io/Contrax/)** · [Getting started](https://givani30.github.io/Contrax/getting-started/) · [API reference](https://givani30.github.io/Contrax/api/systems/)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install contrax
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Requires Python 3.11+ and JAX 0.4+. For GPU support, install JAX separately
|
|
26
|
+
per the [JAX installation guide](https://jax.readthedocs.io/en/latest/installation.html)
|
|
27
|
+
before installing Contrax.
|
|
28
|
+
|
|
29
|
+
## Why Contrax
|
|
30
|
+
|
|
31
|
+
A controller design step can sit inside an ordinary differentiable objective
|
|
32
|
+
instead of being a separate offline calculation:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import jax
|
|
36
|
+
jax.config.update("jax_enable_x64", True)
|
|
37
|
+
|
|
38
|
+
import jax.numpy as jnp
|
|
39
|
+
import contrax as cx
|
|
40
|
+
|
|
41
|
+
A = jnp.array([[1.0, 0.05], [0.0, 1.0]])
|
|
42
|
+
B = jnp.array([[0.0], [0.05]])
|
|
43
|
+
SYS = cx.dss(A, B, jnp.eye(2), jnp.zeros((2, 1)), dt=0.05)
|
|
44
|
+
X0 = jnp.array([1.0, 0.0])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def closed_loop_cost(log_q_diag, log_r):
|
|
48
|
+
K = cx.lqr(SYS, jnp.diag(jnp.exp(log_q_diag)), jnp.exp(log_r)[None, None]).K
|
|
49
|
+
_, xs, _ = cx.simulate(SYS, X0, lambda t, x: -K @ x, num_steps=80)
|
|
50
|
+
return jnp.sum(xs**2) + 1e-2 * jnp.sum((xs[:-1] @ K.T) ** 2)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
cost, (dq, dr) = jax.jit(jax.value_and_grad(closed_loop_cost, argnums=(0, 1)))(
|
|
54
|
+
jnp.zeros(2), jnp.array(0.0)
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This is the central Contrax idea: control primitives that behave like normal
|
|
59
|
+
JAX building blocks.
|
|
60
|
+
|
|
61
|
+
## Scope
|
|
62
|
+
|
|
63
|
+
**Systems**
|
|
64
|
+
`ss`, `dss`, `c2d`, `nonlinear_system`, `phs_system`, `canonical_J`,
|
|
65
|
+
`schedule_phs`, `linearize`, `linearize_ss`, `phs_to_ss`, `series`, `parallel`
|
|
66
|
+
|
|
67
|
+
**Simulation**
|
|
68
|
+
`lsim`, `simulate`, `rollout`, `step_response`, `impulse_response`,
|
|
69
|
+
`initial_response`, `sample_system`, `foh_inputs`
|
|
70
|
+
|
|
71
|
+
**Control**
|
|
72
|
+
`lqr`, `lqi`, `dare`, `care`, `place`, `feedback`, `state_feedback`,
|
|
73
|
+
`augment_integrator`
|
|
74
|
+
|
|
75
|
+
**Estimation**
|
|
76
|
+
`kalman`, `ekf`, `ukf`, `rts`, `uks`
|
|
77
|
+
`kalman_predict`, `kalman_update`, `kalman_step`
|
|
78
|
+
`ekf_predict`, `ekf_update`, `ekf_step`
|
|
79
|
+
`kalman_gain`, `mhe_objective`, `mhe`, `mhe_warm_start`
|
|
80
|
+
|
|
81
|
+
**Analysis**
|
|
82
|
+
`ctrb`, `obsv`, `poles`, `evalfr`, `freqresp`, `dcgain`,
|
|
83
|
+
`ctrb_gramian`, `obsv_gramian`, `lyap`, `dlyap`, `zeros`
|
|
84
|
+
|
|
85
|
+
**Diagnostics**
|
|
86
|
+
`innovation_diagnostics`, `likelihood_diagnostics`, `ukf_diagnostics`,
|
|
87
|
+
`smoother_diagnostics`, `phs_diagnostics`, `innovation_rms`
|
|
88
|
+
|
|
89
|
+
**Parameterization**
|
|
90
|
+
`positive_exp`, `positive_softplus`, `spd_from_cholesky_raw`, `diagonal_spd`,
|
|
91
|
+
`lower_triangular`
|
|
92
|
+
|
|
93
|
+
**Interoperability**
|
|
94
|
+
`contrax.compat.python_control` — optional bidirectional conversion with
|
|
95
|
+
[python-control](https://python-control.readthedocs.io/) (`pip install control`)
|
|
96
|
+
|
|
97
|
+
## Solver Status
|
|
98
|
+
|
|
99
|
+
- **`dare`** — structured-doubling forward solve with implicit-differentiation VJP. Most mature path.
|
|
100
|
+
- **`care`** — Hamiltonian stable-subspace solver with implicit backward pass. Validated, less benchmarked than `dare`.
|
|
101
|
+
- **`place`** — JAX-native KNV0/YT-style robust pole placement; Ackermann retained as SISO fallback only.
|
|
102
|
+
- **`ekf` / `ukf` / `rts` / `uks`** — differentiable nonlinear filtering and smoothing with full JAX transform support.
|
|
103
|
+
- **`mhe`** — LBFGS-backed fixed-window MHE. Useful optimization-based estimation primitive; not a full NLP framework.
|
|
104
|
+
|
|
105
|
+
LTI workflows are the most mature slice. Nonlinear models, PHS support, and
|
|
106
|
+
fixed-window MHE are real public capabilities, but they should be read with
|
|
107
|
+
more explicit solver-maturity caution than the core discrete design path.
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
git clone https://github.com/givani30/Contrax.git
|
|
113
|
+
cd Contrax
|
|
114
|
+
uv sync --group dev
|
|
115
|
+
uv run pre-commit install
|
|
116
|
+
uv run pytest tests/ -q
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
|
120
|
+
|
|
121
|
+
## Acknowledgements
|
|
122
|
+
|
|
123
|
+
Contrax is built on top of several excellent JAX-ecosystem libraries:
|
|
124
|
+
|
|
125
|
+
- **[JAX](https://github.com/google/jax)** — the foundation: JIT compilation, autodiff, and vectorization.
|
|
126
|
+
- **[Equinox](https://github.com/patrick-kidger/equinox)** — pytree-compatible modules used for all result bundles and system types.
|
|
127
|
+
- **[Diffrax](https://github.com/patrick-kidger/diffrax)** — ODE solvers powering `simulate()` on continuous-time models.
|
|
128
|
+
- **[Optimistix](https://github.com/patrick-kidger/optimistix)** — LBFGS solver backing `mhe()`.
|
|
129
|
+
- **[Lineax](https://github.com/patrick-kidger/lineax)** — linear solvers used in the estimation and Riccati paths.
|
|
130
|
+
|
|
131
|
+
The DARE structured-doubling custom VJP is adapted from
|
|
132
|
+
[trajax](https://github.com/google/trajax) (Google) and the DiLQR approach
|
|
133
|
+
(ICML 2025). The UKF sigma-point rules follow Wan & van der Merwe (2000).
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
from contrax.analysis import (
|
|
2
|
+
ctrb,
|
|
3
|
+
ctrb_gramian,
|
|
4
|
+
dcgain,
|
|
5
|
+
dlyap,
|
|
6
|
+
evalfr,
|
|
7
|
+
freqresp,
|
|
8
|
+
lyap,
|
|
9
|
+
obsv,
|
|
10
|
+
obsv_gramian,
|
|
11
|
+
poles,
|
|
12
|
+
zeros,
|
|
13
|
+
)
|
|
14
|
+
from contrax.control import (
|
|
15
|
+
augment_integrator,
|
|
16
|
+
care,
|
|
17
|
+
dare,
|
|
18
|
+
feedback,
|
|
19
|
+
lqi,
|
|
20
|
+
lqr,
|
|
21
|
+
place,
|
|
22
|
+
state_feedback,
|
|
23
|
+
)
|
|
24
|
+
from contrax.estimation import (
|
|
25
|
+
ekf,
|
|
26
|
+
ekf_predict,
|
|
27
|
+
ekf_step,
|
|
28
|
+
ekf_update,
|
|
29
|
+
innovation_diagnostics,
|
|
30
|
+
innovation_rms,
|
|
31
|
+
kalman,
|
|
32
|
+
kalman_gain,
|
|
33
|
+
kalman_predict,
|
|
34
|
+
kalman_step,
|
|
35
|
+
kalman_update,
|
|
36
|
+
likelihood_diagnostics,
|
|
37
|
+
mhe,
|
|
38
|
+
mhe_objective,
|
|
39
|
+
mhe_warm_start,
|
|
40
|
+
rts,
|
|
41
|
+
smoother_diagnostics,
|
|
42
|
+
soft_quadratic_penalty,
|
|
43
|
+
ukf,
|
|
44
|
+
ukf_diagnostics,
|
|
45
|
+
uks,
|
|
46
|
+
)
|
|
47
|
+
from contrax.parameterization import (
|
|
48
|
+
diagonal_spd,
|
|
49
|
+
lower_triangular,
|
|
50
|
+
positive_exp,
|
|
51
|
+
positive_softplus,
|
|
52
|
+
spd_from_cholesky_raw,
|
|
53
|
+
)
|
|
54
|
+
from contrax.simulation import (
|
|
55
|
+
as_ode_term,
|
|
56
|
+
foh_inputs,
|
|
57
|
+
impulse_response,
|
|
58
|
+
initial_response,
|
|
59
|
+
lsim,
|
|
60
|
+
rollout,
|
|
61
|
+
sample_system,
|
|
62
|
+
simulate,
|
|
63
|
+
step_response,
|
|
64
|
+
)
|
|
65
|
+
from contrax.systems import (
|
|
66
|
+
ContLTI,
|
|
67
|
+
DiscLTI,
|
|
68
|
+
NonlinearSystem,
|
|
69
|
+
PHSSystem,
|
|
70
|
+
block_matrix,
|
|
71
|
+
block_observation,
|
|
72
|
+
c2d,
|
|
73
|
+
canonical_J,
|
|
74
|
+
dss,
|
|
75
|
+
linearize,
|
|
76
|
+
linearize_ss,
|
|
77
|
+
nonlinear_system,
|
|
78
|
+
parallel,
|
|
79
|
+
partition_state,
|
|
80
|
+
phs_diagnostics,
|
|
81
|
+
phs_system,
|
|
82
|
+
phs_to_ss,
|
|
83
|
+
project_psd,
|
|
84
|
+
schedule_phs,
|
|
85
|
+
series,
|
|
86
|
+
ss,
|
|
87
|
+
symmetrize_matrix,
|
|
88
|
+
)
|
|
89
|
+
from contrax.types import (
|
|
90
|
+
InnovationDiagnostics,
|
|
91
|
+
KalmanGainResult,
|
|
92
|
+
KalmanResult,
|
|
93
|
+
LikelihoodDiagnostics,
|
|
94
|
+
LQRResult,
|
|
95
|
+
MHEResult,
|
|
96
|
+
PHSStructureDiagnostics,
|
|
97
|
+
RTSResult,
|
|
98
|
+
SmootherDiagnostics,
|
|
99
|
+
UKFResult,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
__all__ = [
|
|
103
|
+
# system types
|
|
104
|
+
"ContLTI",
|
|
105
|
+
"DiscLTI",
|
|
106
|
+
"NonlinearSystem",
|
|
107
|
+
"PHSSystem",
|
|
108
|
+
"partition_state",
|
|
109
|
+
"block_observation",
|
|
110
|
+
"block_matrix",
|
|
111
|
+
"symmetrize_matrix",
|
|
112
|
+
"project_psd",
|
|
113
|
+
"phs_diagnostics",
|
|
114
|
+
# constructors
|
|
115
|
+
"ss",
|
|
116
|
+
"dss",
|
|
117
|
+
"c2d",
|
|
118
|
+
"nonlinear_system",
|
|
119
|
+
"phs_system",
|
|
120
|
+
"phs_to_ss",
|
|
121
|
+
"schedule_phs",
|
|
122
|
+
"canonical_J",
|
|
123
|
+
"linearize",
|
|
124
|
+
"linearize_ss",
|
|
125
|
+
"series",
|
|
126
|
+
"parallel",
|
|
127
|
+
# control
|
|
128
|
+
"lqr",
|
|
129
|
+
"lqi",
|
|
130
|
+
"dare",
|
|
131
|
+
"care",
|
|
132
|
+
"place",
|
|
133
|
+
"state_feedback",
|
|
134
|
+
"feedback",
|
|
135
|
+
"augment_integrator",
|
|
136
|
+
# simulation
|
|
137
|
+
"rollout",
|
|
138
|
+
"foh_inputs",
|
|
139
|
+
"sample_system",
|
|
140
|
+
"lsim",
|
|
141
|
+
"simulate",
|
|
142
|
+
"step_response",
|
|
143
|
+
"impulse_response",
|
|
144
|
+
"initial_response",
|
|
145
|
+
"as_ode_term",
|
|
146
|
+
# estimation
|
|
147
|
+
"kalman",
|
|
148
|
+
"kalman_gain",
|
|
149
|
+
"kalman_predict",
|
|
150
|
+
"kalman_update",
|
|
151
|
+
"kalman_step",
|
|
152
|
+
"innovation_diagnostics",
|
|
153
|
+
"innovation_rms",
|
|
154
|
+
"likelihood_diagnostics",
|
|
155
|
+
"ekf",
|
|
156
|
+
"ekf_predict",
|
|
157
|
+
"ekf_update",
|
|
158
|
+
"ekf_step",
|
|
159
|
+
"mhe_objective",
|
|
160
|
+
"mhe_warm_start",
|
|
161
|
+
"mhe",
|
|
162
|
+
"soft_quadratic_penalty",
|
|
163
|
+
"smoother_diagnostics",
|
|
164
|
+
"ukf",
|
|
165
|
+
"ukf_diagnostics",
|
|
166
|
+
"uks",
|
|
167
|
+
"rts",
|
|
168
|
+
# analysis
|
|
169
|
+
"ctrb",
|
|
170
|
+
"obsv",
|
|
171
|
+
"poles",
|
|
172
|
+
"zeros",
|
|
173
|
+
"evalfr",
|
|
174
|
+
"freqresp",
|
|
175
|
+
"dcgain",
|
|
176
|
+
"ctrb_gramian",
|
|
177
|
+
"obsv_gramian",
|
|
178
|
+
"lyap",
|
|
179
|
+
"dlyap",
|
|
180
|
+
# parameterization
|
|
181
|
+
"positive_exp",
|
|
182
|
+
"positive_softplus",
|
|
183
|
+
"lower_triangular",
|
|
184
|
+
"spd_from_cholesky_raw",
|
|
185
|
+
"diagonal_spd",
|
|
186
|
+
# result types
|
|
187
|
+
"LQRResult",
|
|
188
|
+
"InnovationDiagnostics",
|
|
189
|
+
"SmootherDiagnostics",
|
|
190
|
+
"KalmanGainResult",
|
|
191
|
+
"KalmanResult",
|
|
192
|
+
"LikelihoodDiagnostics",
|
|
193
|
+
"UKFResult",
|
|
194
|
+
"RTSResult",
|
|
195
|
+
"MHEResult",
|
|
196
|
+
"PHSStructureDiagnostics",
|
|
197
|
+
]
|