minilink
Write the equations once. Simulate, analyze, control, plan, optimize, learn.
|
|
|
|
|
| trajectory optimization |
impedance control interactive 3-D |
model predictive control interactive 3-D |
reinforcement learning |
Minilink is an open-source Python framework for dynamical systems, control, and optimization.
Engineers, students, and researchers write a physical model once as a continuous DynamicSystem.
The same model powers simulation, classical and modern control, optimal control (MPC, MPPI, etc.), machine learning (neural nets, reinforcement learning), and parameter optimization.
NumPy and SciPy provide a zero-friction default for courses; the identical equations compile, batch, and differentiate under JAX for high performance.
1. The Minilink Backbone
Three mathematical foundations hold the framework together:
- The Model (
System): Continuous differential equations $\dot{x} = f(x, u, t; p)$ and observations $y = h(x, u, t; p)$. - The Task (
PlanningProblem): The model paired with boundary sets $\mathcal{X}, \mathcal{U}, \mathcal{X}_f$, cost $J$, and time horizon $t_f$. - The Solver Boundary (
MathematicalProgram&Optimizer): Standard non-linear program $\min_z J(z) \text{ s.t. } g(z) \le 0, h(z) = 0$ connecting problems to plug-and-play numerical solvers.
One differentiable path connects modeling, analytical control, trajectory optimization, and learning:
Full pipeline reference: docs/pipelines.md.
2. Continuous Core & Functional Purity
A physical model is defined by three pure mathematical mappings:
$$\dot{x} = f(x, u, t; p) \quad \text{(dynamics)}$$ $$y = h(x, u, t; p) \quad \text{(outputs, default } y = x\text{)}$$ $$T = \mathrm{tf}(x, u, t; p) \quad \text{(body poses for 3D animation)}$$
Functional purity means equations are stateless: arrays in, arrays out. No simulation time or state is mutated on self.
This purity allows precise numerical integration, reproducible experiments, exact linear analysis, arbitrary composition into nested systems, parallel GPU rollouts, and automatic differentiation.
import numpy as np
from minilink import DynamicSystem
class MassSpringDamper(DynamicSystem):
def __init__(self):
super().__init__(n=2, input_dim=1, output_dim=1)
def f(self, x, u, t=0, params=None):
m, k, b = 1.0, 4.0, 0.3
p, v = x
a = (u[0] - b * v - k * p) / m
return np.array([v, a])
def h(self, x, u, t=0, params=None):
return np.array([x[0]]) # sensor measures position only
plant = MassSpringDamper()
plant.x0[0] = 1.0
plant.compute_trajectory(tf=10.0)
plant.plot_trajectory()
3. Compositional Closure: Diagrams as Code
Code is the single source of truth. Minilink replaces GUI wiring and opaque binary files with pure, version-controlled Python expressions:
- Algebraic Shortcuts:
ctrl @ plant(feedback loop),a >> b(series),a + b(parallel),sys % Δ(zero-order hold digital clock sampling). - Explicit 1-Line Wiring:
diag.connect("controller", "u", "plant", "u")connects arbitrary multi-loop networks with immediate port checks. - Auto-Generated Diagrams:
loop.plot_diagram()generates clean, read-only visual inspection diagrams directly from code.
from minilink import PID, MassSpringDamper
plant = MassSpringDamper()
ctrl = PID(kp=10.0, ki=1.0, kd=2.0)
# Feedback composition: loop is itself a pure DynamicSystem
loop = ctrl @ plant
loop.plot_diagram()
Because a composite diagram is itself a DynamicSystem, every analysis verb works identically on closed loops: loop.linearize(), loop.bode(), loop.nyquist(), loop.root_locus(), loop.pzmap(), loop.step_response(), and loop.kalman().
4. Interactive Play & 3D Visualization
- Real-Time Wall-Clock Play:
plant.game()drives plants with keyboard or gamepad (via Pygame). - Decoupled Geometry: Body poses $T = \mathrm{tf}(x, u, t; p)$ describe kinematics without cluttering the differential equations with rendering code.
- Hardware-Accelerated 3D WebGL:
plant.animate(traj, renderer="meshcat")opens an interactive 3D browser viewer with orbit, pan, and playback controls. - Multi-DoF Robotics Catalog: Built-in kinematic and dynamic models for robot arms (
UR5Manipulator), ground vehicles (KinematicBicycle,UdeSRacecar), quadrotors (Drone2D,Drone3D), and aerospace vehicles (Rocket).
from minilink import UR5Manipulator
robot = UR5Manipulator()
traj = robot.compute_trajectory(tf=5.0)
robot.animate(traj, renderer="meshcat") # interactive 3D WebGL in browser
Live interactive 3D demos: UR-5 Impedance Control • Racecar MPC.
5. Differentiable & Accelerated with JAX
The exact same equation $f(x, u, t; p)$ traces under JAX without rewriting physics:
- Exact Machine-Precision Sensitivities: Analytical Jacobians: $$A = \frac{\partial f}{\partial x}, \quad B = \frac{\partial f}{\partial u}, \quad S_p = \frac{\partial f}{\partial p}$$
- Parallel GPU-Batched Rollouts: Vectorized simulation across parameter sweeps via JAX
vmap(1,000 rollouts in 27 ms vs. 32 s in pure Python). - Plant & Controller Co-Design: Compute closed-loop objective gradients $\nabla_\theta J$ to optimize control gains and physical parameters simultaneously.
- Opt-In Acceleration: Pure NumPy remains the default classroom engine; JAX is activated with a single flag (
backend="jax").
import jax
import numpy as np
from minilink import PID, Optimizer, Pendulum, PlanningProblem, QuadraticCost
plant = Pendulum()
# Exact machine-precision Jacobians
A = plant.jacobian("f", "x", x_eq)
S = plant.jacobian("f", "params", x_eq)
# Vectorized rollouts over 1,000 rod lengths in a single call
ev = plant.compile(backend="jax")
x0s = np.tile([1.0, 0.0], (1000, 1))
lengths = np.linspace(0.5, 2.0, 1000)
xs = ev.rollout_batch(x0s, n_steps=1000, dt=0.005, params=dict(plant.params, l=lengths))
# Closed-loop gradient descent on gains and physical parameters
tuning = PlanningProblem(plant, x_start=[1.0, 0.0], cost=QuadraticCost.from_system(plant), tf=4.0)
pe = tuning.compile(PID(2.0, 0.5, 1.0), dt=0.02)
dJ = jax.grad(lambda p: pe.evaluate(p).objective)(pe.params)
best = Optimizer(pe.program(wrt=["controller.Kp", "plant.l"])).solve()
6. The Unified Optimization Boundary
All transcriptions lower late to a single, canonical mathematical program:
$$\min_z J(z; p) \quad \text{s.t.} \quad g(z; p) \le 0, \quad h(z; p) = 0$$
- Lego-Block Decoupling: Trajectory collocation, parameter tuning, and policy search all lower to
MathematicalProgram. - Pluggable Solvers: Decoupled interfaces allow any optimizer to run on any program:
- First-order autodiff:
gd,adam,l-bfgs(via JAX). - Constrained non-linear programming: SciPy (
SLSQP), Ipopt (interior-point). - Custom user algorithms and native fixed-step solvers.
- First-order autodiff:
from minilink import Optimizer
# Solvers plug into any problem definition
prog = pe.program(wrt=["controller.Kp", "controller.Ki", "controller.Kd"])
opt = Optimizer(prog, method="l-bfgs") # or method="ipopt", "slsqp", "adam"
sol = opt.solve()
7. One Problem, Every Planner
A PlanningProblem bundles the physical plant, boundary sets ($\mathcal{X}, \mathcal{U}, \mathcal{X}_f$), cost function $J$, and horizon $t_f$.
The identical problem definition is handed to completely different solver paradigms:
- Dynamic Programming (VI): Global value iteration on state/action grids.
- Tree Search (RRT): Kinodynamic motion planning with obstacle collision checking.
- Trajectory Optimization (TrajOpt): Direct collocation and multiple shooting NLP.
- Reinforcement Learning (RL): PPO / SAC neural policy optimization.
Every planner returns a PlanningSolution whose policy is itself a System that closes the loop via policy @ plant:
import numpy as np
from minilink import (
BallSet, DynamicProgrammingPlanner, Pendulum, PlanningProblem,
QuadraticCost, RRTPlanner, TrajectoryOptimizationPlanner, compare,
)
plant = Pendulum()
x_down, x_up = np.array([0.0, 0.0]), np.array([np.pi, 0.0])
problem = PlanningProblem(
sys=plant, x_start=x_down, Xf=BallSet(x_up, 0.2), tf=4.0,
cost=QuadraticCost.from_system(plant, Q=np.eye(2), R=np.eye(1), xbar=x_up),
X=plant.state.box, U=plant.input_box,
)
vi = DynamicProgrammingPlanner(problem, x_grid=(101, 101), u_grid=(11,), dt=0.05)
rrt = RRTPlanner(problem, seed=0)
opt = TrajectoryOptimizationPlanner(problem, n_steps=40, transcription="direct_collocation")
vi_sol = vi.solve() # policy is a lookup controller
rrt_sol = rrt.solve() # kinodynamic trajectory
opt_sol = opt.solve() # continuous trajectory solution
# Closed-loop composition: policy is a standard System
loop = vi_sol.policy @ plant
# Objective benchmark across solver paradigms
print(compare(problem, VI=vi_sol, RRT=rrt_sol, TrajOpt=opt_sol, dt=0.05))
8. What Minilink is NOT
- Not a Heavy Multibody Contact Engine: For complex contact or high-DoF meshes, wrap an external multibody simulator as a
Systemleaf. Minilink focuses on control architecture, analytical derivatives, and trajectory optimization. - Not a 100+ Knot Sparse NLP Modeling Language: Minilink programs and solvers do not exploit sparse Jacobian structure, unlike dedicated sparse modeling packages.
- Continuous-Time is Primary: Dynamics $f$ represent instantaneous rates ($\dot{x} = dx/dt$), not discrete next-step maps.
9. Key Advantages
| Advantage | What It Solves |
|---|---|
| One Model Across All Domains | Define physics once ($\dot{x} = f$); seamlessly move between frequency analysis, LQR, TrajOpt, and RL without rewriting models. |
| Zero-Friction Install | Pure NumPy/SciPy baseline; runs immediately in 1-click Google Colab with zero compilation. |
| Git-Native Diagrams as Code | Pure Python operators (>>, +, @, %) replace opaque binary files with clear, reviewable pull request diffs. |
| Hardware-Accelerated with JAX | Machine-precision autodiff sensitivities, GPU vmap rollouts, and exact plant-controller co-design ($\nabla_\theta J$). |
| Unified Optimization Boundary | Standardized MathematicalProgram and PlanningProblem decouple formulations from plug-and-play numerical solvers. |
Install
Python 3.10+. Recommended: conda, everything included (JAX, Graphviz, Ipopt, 3-D animation, Jupyter):
git clone https://github.com/alx87grd/minilink.git && cd minilink
conda env create -f environment.yml && conda activate minilink
conda env config vars set PYTHONPATH="$PWD" && conda deactivate && conda activate minilink
Colab: open any notebook with "Open in Colab", or start yours with:
!git clone https://github.com/alx87grd/minilink
import sys; sys.path.insert(0, "/content/minilink")
pip:
pip install minilinkruns simulation, plots, LQR, and value iteration on standard NumPy, SciPy, and Matplotlib.pip install "minilink[full]"adds JAX, Plotly, MeshCat, Pygame, SymPy, and Gymnasium.
Optional system dependencies:
plot_diagram()requires Graphviz (download, thenpip install graphviz).- Ipopt solver:
conda install -c conda-forge cyipopt(trajectory optimization runs on SciPy without it).
Learn More & Tutorials
- Interactive Pitch Deck — self-contained 14-slide executive, academic, and industrial presentation deck.
- Showcase Notebook — the complete tool ladder demonstrated on real plants.
- JAX Showcase — write $f$ once, get exact derivatives and batched GPU rollouts.
- From RL to Bode Showcase — 6-axis robot, impedance loop, neural policy, and frequency response.
- Tutorial Series 00–11 — 12 guided notebooks covering core dynamics through reinforcement learning.
- Teaching Notebooks — swing-up control, dynamic programming, and PPO.
Minilink is the successor of pyro.
Metadata
Release files for minilink 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| minilink-0.3.0.tar.gz | 6.9 MB | With provenance | Details for minilink-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| minilink-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for minilink-0.3.0-py3-none-any.whl |
Total release size: 7.9 MB
Release files / minilink-0.3.0.tar.gz
| Download URL | minilink-0.3.0.tar.gz |
|---|---|
| Size | 6.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ba4eec71c0c2c090f77d1bc225924d0aaa174599d51fb1cab615a085f6f7a6b
|
|
BLAKE2b-256 checksum How to use checksums |
5ac8b2e9e2d8912e4e865fd5b9c04210e74c1cdefe40170058d3eb53277fb22d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 30, 2026.
Transparency logRelease files / minilink-0.3.0-py3-none-any.whl
| Download URL | minilink-0.3.0-py3-none-any.whl |
|---|---|
| Size | 989.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
907d2c8a1b3178ccb7b129ab5f16dd1b370706807a3df431e861f632fc417f26
|
|
BLAKE2b-256 checksum How to use checksums |
5f7167f60c9425b9defa1daa22f8c4e96430bc9ae80079f2c4f329e80e34744c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 30, 2026.
Transparency logSecurity for minilink 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for minilink-0.3.0.tar.gz
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 Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.