pockit: Python Optimal Control KIT
😃 Welcome to the pockit project page.
Introduction
Pockit is a Python package for solving optimal control problems numerically. It combines advanced techniques to deliver a powerful, user-friendly, and fast solution.
- 💪 Powerful: Pockit is designed to solve multi-phase optimal control problems with support for path, algebraic, and boundary condition constraints.
- 🔢 User-friendly: Pockit features a SymPy-based interface that makes defining and solving problems intuitive.
- ⚡ Fast: Pockit achieves high performance through symbolic differentiation (with SymPy), just-in-time compilation (with Numba), vectorization, and other advanced techniques.
For more information, visit the documentation and API reference.
总之,pockit 利用伪谱法数值求解最优控制问题,挺好用的。请访问 pockit 文档 和 API 文档 获取详细信息。
Issues and Bug Reports
For any issues, questions, or bug reports, please open a GitHub issue at the project's issue tracker.
如果有任何问题,最好直接在 GitHub Issues 上讨论,这样讨论比较集中而且大家都能看到。中文、英文都可以,现在自动翻译已经比较好用,可以自行翻译。
Support the Project
If you find pockit helpful, please consider starring the project on GitHub. Thank you!
To support the project's development financially, you can make a contribution via GitHub Sponsors. Your support is greatly appreciated!
如果有帮助,请帮忙点下 Star,谢谢 🙏。如果你很有钱,可以考虑赞助项目 😂。
Citation
If you use pockit in your research, please cite the following works:
@misc{zou2025vectorizedsparsesecondorderforward,
title={Vectorized Sparse Second-Order Forward Automatic Differentiation for Optimal Control Direct Methods},
author={Yilin Zou and Fanghua Jiang},
year={2025},
eprint={2506.11537},
archivePrefix={arXiv},
primaryClass={eess.SY},
url={https://arxiv.org/abs/2506.11537},
}
@misc{zou2025reexamininglegendregausslobattopseudospectralmethods,
title={Re-examining the Legendre-Gauss-Lobatto Pseudospectral Methods for Optimal Control},
author={Yilin Zou and Fanghua Jiang},
year={2025},
eprint={2507.01660},
archivePrefix={arXiv},
primaryClass={eess.SY},
url={https://arxiv.org/abs/2507.01660},
}
We sincerely appreciate your support.
LQR in 1 Minute
Install the optional Ipopt and plotting dependencies:
pip install "pockit-optimal-control[ipopt,examples]"
from pockit.lobatto import System, constant_guess
from pockit.optimizer import ipopt
import matplotlib.pyplot as plt
# LQR problem:
# min ∫_0^1 (q * x^2 + r * u^2) dt + s * x_f^2 / 2
# s.t. x' = a * x + b * u, x(0) = 1
# Set parameters
a, b, s, q, r = -1, 1, 1, 1, 0.1
# Set up the system
system = System(["x_f"]) # the system has one free parameter x_f
x_f, = system.s # extract the SymPy symbol x_f
phase = system.new_phase(["x"], ["u"]) # the phase has one state x and one control u
x, = phase.x # extract the SymPy symbol x
u, = phase.u # extract the SymPy symbol u
phase.set_dynamics([a * x + b * u]) # x' = a * x + b * u
phase.set_integral([q * x ** 2 + r * u ** 2]) # I = ∫ q * x^2 + r * u^2 dt
phase.set_boundary_condition([1], [x_f], 0, 1) # x(0) = 1, x(t_f) = x_f, t_0 = 0, t_f = 1
phase.set_discretization(10, 10) # 10 subintervals with 10 collocation points in each subinterval
system.set_phase([phase]) # bind the phase to the system
system.set_objective(phase.I[0] + s * x_f ** 2 / 2) # define the objective function
# Solve the problem
guess_p = constant_guess(phase, 0) # initial guess for the phase
guess_s = [0.0] # initial guess for the free parameter x_f
# var_p, var_s: the optimal solution for the phase and the free parameter
[var_p, var_s], info = ipopt.solve(system, [guess_p, guess_s])
# Print the results
print("status:", info["status_msg"].decode())
print("objective:", info["obj_val"]) # 0.2319139744522318
# Plot the results
plt.plot(var_p.t_x, var_p.x[0], label="x") # only one state variable and one control variable,
plt.plot(var_p.t_u, var_p.u[0], label="u") # so the indices are 0 for both
plt.legend()
plt.minorticks_on()
plt.grid(linestyle='--')
plt.show()
Metadata
Release files for pockit-optimal-control 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pockit_optimal_control-0.1.0.tar.gz | 230.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pockit_optimal_control-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 300.9 kB
Release files / pockit_optimal_control-0.1.0.tar.gz
| Download URL | pockit_optimal_control-0.1.0.tar.gz |
|---|---|
| Size | 230.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc88861d1ba11497bc8dbe51ac7f3ca2a13f8456da072eab5894b1be9833bf44
|
|
BLAKE2b-256 checksum How to use checksums |
523a56ea9537714b200e191224eae8b97761ceaf3bdc0f7b1e676f29a0583b14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / pockit_optimal_control-0.1.0-py3-none-any.whl
| Download URL | pockit_optimal_control-0.1.0-py3-none-any.whl |
|---|---|
| Size | 70.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c611eb785c3b0af1a5799ef128b2e99917ee64ada49fcc5fa950df4d648b7903
|
|
BLAKE2b-256 checksum How to use checksums |
0a6dab6211ae68b8a7e549a48438ee38950b96fd5e3e012abae1af1e5452a2c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency log