MuJoCo MJX Origami Engine
This project is a dual-backend MuJoCo MJX origami folding simulator — a migration of origami-engine from the classic MuJoCo C++ runtime to MJX, with two interchangeable backends in one package. The crease-pattern parsing, geometry reconstruction, and MJCF model generation are shared between backends; only the simulation execution differs.
What this project does
- Keeps the same crease → face → MJCF pipeline as the classic engine (
p1,p2,angledata in, MuJoCo model out) - Runs the simulation on MJX-JAX (
mujoco.mjxon JAX/XLA) or MJX-Warp (mujoco_warpon NVIDIA Warp) behind a singleOrigamiEnginefacade - Supports differentiable simulation and
jax.jit/jax.vmap/jax.lax.scanon the JAX backend (CPU, NVIDIA GPU, or TPU) - Supports high-throughput batched population evaluation on the Warp backend (NVIDIA CUDA GPU, e.g. Colab T4)
- Measures the forward displacement of the paper as a fitness signal, for single genomes or whole populations
- Scores how well the paper folds to its target angles and blends that with movement at any percentage split (
movement_weight/fold_weight), with per-hinge actuation (drive some hinges, leave others passive, or switch them on/off during a run) - Exposes ES / RL / AI integration interfaces (a fixed-topology search space, a stateless evaluator, Gymnasium and JAX-functional environments, optimizer adapters) without shipping any optimization or learning algorithm
- Offers a configurable design space (
DesignSpace: fold angles, crease endpoints/geometry, crease count) and population seeding helpers (seed files, interpolation, random and mixed initialization) on top of the default fixed-topology search space - Auto-selects a backend with
backend="auto"(warpif a CUDA GPU is available, otherwisejax)
Backends
| Backend | Flag | Engine | Hardware | Best for |
|---|---|---|---|---|
| MJX-JAX | backend="jax" |
mujoco.mjx on JAX/XLA |
CPU (local dev), NVIDIA GPU, TPU (Colab) | Differentiable simulation, jax.jit / jax.vmap / jax.lax.scan, CPU testing |
| MJX-Warp | backend="warp" |
mujoco_warp on NVIDIA Warp |
NVIDIA CUDA GPU only (Colab T4) | High-throughput batched population evaluation |
Simulation Output
Below is the physical rendering of the simulation output, demonstrating how the paper layout reacts to active hinge joint torques and support table vibrations:
|
Reference Miura-ori 4x4 | 16 faces |
Reference Crease Pattern The default Miura-ori crease pattern shared by both backends, tiling a square sheet into 16 polygonal faces. Crease Pattern JSON Schema — validates the structure of crease input files. reference_miura_4x4.json — the reference crease pattern data (p1, p2, and angle per crease). Mountain folds are negative angles (creasing "up"), Valley folds are positive angles (creasing "down"). |
| Vibrating Table: Amplitude & Frequency | Fold Crease | Video Preview |
|---|---|---|
| Lower amplitude & frequency | Partial / standard | |
| High amplitude & frequency | Full | |
| Higher amplitude & frequency | Full |
This repository is structured as a library for crease pattern simulation and analysis on MJX. For full documentation, see the dedicated files below.
Quick start
Install from PyPI
# Core (geometry, patterns, XML generation — no GPU needed)
pip install origami-engine-mjx
# + MJX-JAX backend (CPU works out of the box)
pip install 'origami-engine-mjx[jax]'
# + MJX-Warp backend (requires NVIDIA CUDA GPU)
pip install 'origami-engine-mjx[warp]'
# Everything
pip install 'origami-engine-mjx[all]'
Run a simulation
from origami_engine_mjx import OrigamiEngine, load_default_creases
# CPU (local dev) — MJX-JAX
engine = OrigamiEngine(backend="jax")
creases = load_default_creases()
# Single simulation -> forward displacement (m)
score = engine.evaluate(creases, duration=2.0)
print(f"forward displacement: {score:.4f} m")
# Batch population evaluation
population = [creases, creases, creases] # replace with your genomes
result = engine.evaluate_population(population, duration=2.0)
print(result.scores)
Optimise for folding, not just movement
from origami_engine_mjx import fold_report
# A short run keeps a CPU honest; raise the duration on a GPU.
# How far off are the hinges from the angles the design asks for?
result = engine.run(creases, duration=0.02)
print(fold_report(result, percent=True)["score"]) # 0..100
# 70 % movement + 30 % folding (the default is movement only)
score = engine.evaluate(creases, duration=0.02, movement_weight=70, fold_weight=30)
# Drive only the first two hinges; the others fold passively
result = engine.run(creases, duration=0.02, actuated=[True, True] + [False] * 13)
See FITNESS.md.
On Google Colab with an NVIDIA T4:
engine = OrigamiEngine(backend="warp") # CUDA GPU via MuJoCo Warp
result = engine.evaluate_population(population, duration=8.0, batch_size=128)
Validate (source installation)
pip install -e '.[dev,jax]'
pytest tests_mjx -q # fast tests (no long sims)
pytest tests_mjx -q -m slow # includes short MJX-CPU simulations
Performance notes
- MJX-JAX on CPU is slow for mesh-contact models: the 16-face reference Miura model costs ~70 s/step on CPU (mesh–mesh collision in XLA). Tiny models run at ~1.4 s/step. Use CPU only for correctness tests with short durations; use GPU for real workloads.
- JIT compilation of
mjx.stepis expensive for this model; the JAX backend runs eager by default (jit=False). - On a Colab T4 GPU, both backends should be dramatically faster — see
examples/colab_gpu_validation.pyand the benchmark in COLAB_GPU.md.
📖 Documentation
For in-depth information, see the dedicated documentation files:
- GETTING_STARTED.md — installation and first run
- TUTORIALS.md — nine step-by-step recipes
- CREASE_FORMAT.md — crease & JSON schema reference
- API_REFERENCE.md — complete API signatures
- SIMULATION.md — model structure, stepping loop, rendering
- EVALUATION.md — fitness functions and population evaluation
- FITNESS.md — movement vs. folding fitness, per-hinge actuation, weighted blends
- ARCHITECTURE.md — package layout, data flow, backend responsibilities
- BACKENDS.md — MJX-JAX vs MJX-Warp: semantics, features, limitations
- COLAB_GPU.md — Colab T4 setup, validation checklist, benchmarking
- MIGRATION.md — migrating from
origami-engine(classic MuJoCo) - TROUBLESHOOTING.md — runtime problems and guidance
- GLOSSARY.md — terminology used across the codebase
- CONTRIBUTING.md — how to contribute, tests, CI
- INTEGRATIONS.md — ES/RL/AI integration interfaces overview
- OPTIMIZATION_ES.md — search space, evaluator, optimizer adapters, QD descriptors
- SEARCH_SPACE.md — the configurable
DesignSpace(angles, geometry, crease count) - POPULATIONS.md — population seeding / initialization
- RL.md — Gymnasium and JAX-functional reinforcement-learning environments
- notebook_examples/ — Colab-ready notebooks for external optimizers, RL and LLM agents (start with 05 ·
evosax, switch algorithms) examples/— runnable scripts (see the table below)
All documentation lives in docs/.
Examples
| Script | Demonstrates |
|---|---|
examples/01_evaluate_cpu_jax.py |
Single sim + population on CPU (MJX-JAX) |
examples/02_evaluate_warp_gpu.py |
MJX-Warp on NVIDIA GPU |
examples/03_batch_population.py |
Batch population evaluation with configurable batch size |
examples/colab_gpu_validation.py |
Full GPU validation + benchmark script for Colab T4 |
Core modules (brief)
origami_engine_mjx/constants.py— physical / solver constants (shared)origami_engine_mjx/types.py—Crease,Pattern,SimulationResult,PopulationResultorigami_engine_mjx/geometry.py— crease graph → faces → spanning tree (shared, Shapely)origami_engine_mjx/model.py—generate_xml(): Pattern → MJCF XML (shared, no MuJoCo needed)origami_engine_mjx/serialization.py— JSON crease I/O (shared)origami_engine_mjx/patterns.py— reference Miura patterns (shared)origami_engine_mjx/plotting.py— crease-pattern plots (shared)origami_engine_mjx/backend.py— lazy import guards for mujoco / mjx-jax / mjx-warporigami_engine_mjx/engine.py—OrigamiEngine, the public facade with backend selectionorigami_engine_mjx/evaluation.py—evaluate_individual/evaluate_populationorigami_engine_mjx/fitness/— movement + folding (hinge-target) scores and their weighted blendorigami_engine_mjx/integrations/— ES/RL/AI interfaces (no algorithms):search_space.py(SearchSpace),design_space.py(DesignSpace, the configurable angles/geometry/crease-count space),evaluator.py(OrigamiEvaluator, descriptors),population.py(seed loading, interpolation, random / mixed initialization, population I/O),adapters.py(pymoo / nevergrad / cma / evosax),env.py(OrigamiEnv,OrigamiVectorEnv),jax_env.py(pure-JAXreset/step),plumbing.py(seeding, genome/checkpoint I/O, run logging, benchmark)origami_engine_mjx/backends/—base.py(SimulationBackendABC),jax_backend.py(put_model/make_data/mjx.step, optional jit),warp_backend.py(mjw.put_model/mjw.make_data/mjw.step, GPU), and a registry withget_backend(name)origami_engine_mjx/schemas/— JSON schema for crease filesorigami_engine_mjx/crease_patterns/—reference_miura_4x4.json
Library API
pip install -e ".[dev,jax]"
python -c "
from origami_engine_mjx import (
OrigamiEngine,
Crease,
build_pattern,
load_default_creases,
)
"
For the complete layout and data flow, see ARCHITECTURE.md.
Optimization & RL interfaces
The library is the environment / evaluator substrate for external search and learning tools — it ships no optimization or learning algorithm. origami_engine_mjx.integrations provides a fixed-topology SearchSpace (15 actuated fold angles for the default Miura pattern), a stateless picklable OrigamiEvaluator with behavior descriptors for quality-diversity, a Gymnasium OrigamiEnv plus pure-JAX reset/step (jittable / vmappable), thin adapters for pymoo / nevergrad / cma / evosax, and plumbing (seeding, genome/checkpoint I/O, run logging, throughput benchmark). The search space is configurable — DesignSpace can also vary loop-edge angles, crease endpoints (geometry) and crease count, with presets, selection and equality/symmetry constraints — and initial populations can be seeded from crease JSON files or generated by interpolation, random and mixed sampling. See INTEGRATIONS.md, OPTIMIZATION_ES.md, SEARCH_SPACE.md, POPULATIONS.md and RL.md.
License
Apache-2.0
Metadata
Release files for origami-engine-mjx 1.2.3
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 |
|---|---|---|---|---|
| origami_engine_mjx-1.2.3.tar.gz | 250.4 kB | With provenance | Details for origami_engine_mjx-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| origami_engine_mjx-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for origami_engine_mjx-1.2.3-py3-none-any.whl |
Total release size: 380.3 kB
Release files / origami_engine_mjx-1.2.3.tar.gz
| Download URL | origami_engine_mjx-1.2.3.tar.gz |
|---|---|
| Size | 250.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22b3f08fae6ca4a41589b2a17af6a403a965b67bff65be19d9d870d7347bc613
|
|
BLAKE2b-256 checksum How to use checksums |
f04f6db3d49b8e8493de9ad333af53d41cd0445d7ed3284ee23f0d6f9f3de697
|
| 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 Nov 24, 2026.
Transparency logRelease files / origami_engine_mjx-1.2.3-py3-none-any.whl
| Download URL | origami_engine_mjx-1.2.3-py3-none-any.whl |
|---|---|
| Size | 129.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc08fa72ba9a34366aa8da0aee0ff83769cc41773021833f7e8c37ae45a8a54b
|
|
BLAKE2b-256 checksum How to use checksums |
66cb2d0b892eb7aa36a47cc8cab51ec72d93db9340b27f3f5738632d4b2a2af9
|
| 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 Nov 24, 2026.
Transparency logSecurity for origami-engine-mjx 1.2.3
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 origami_engine_mjx-1.2.3.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 Nov 24, 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.