Skip to main content

MuJoCo MJX Origami Engine

Latest Release CI Python MuJoCo MJX JAX NVIDIA Warp
NumPy Shapely pytest JSON Schema
Last Commit Issues Stars License



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, angle data in, MuJoCo model out)
  • Runs the simulation on MJX-JAX (mujoco.mjx on JAX/XLA) or MJX-Warp (mujoco.warp on NVIDIA Warp) behind a single OrigamiEngine facade
  • Supports differentiable simulation and jax.jit / jax.vmap / jax.lax.scan on 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
  • 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" (warp if a CUDA GPU is available, otherwise jax)

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 crease pattern

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)

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.step is 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.py and the benchmark in COLAB_GPU.md.

📖 Documentation

For in-depth information, see the dedicated documentation files:

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, PopulationResult
  • origami_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-warp
  • origami_engine_mjx/engine.py — OrigamiEngine, the public facade with backend selection
  • origami_engine_mjx/evaluation.py — evaluate_individual / evaluate_population
  • origami_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-JAX reset / step), plumbing.py (seeding, genome/checkpoint I/O, run logging, benchmark)
  • origami_engine_mjx/backends/ — base.py (SimulationBackend ABC), jax_backend.py (put_model / make_data / mjx.step, optional jit), warp_backend.py (mjw.make_model / make_data / mjw.step, GPU), and a registry with get_backend(name)
  • origami_engine_mjx/schemas/ — JSON schema for crease files
  • origami_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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for origami-engine-mjx 1.2.0
File Size Uploaded Provenance Actions
origami_engine_mjx-1.2.0.tar.gz 233.3 kB With provenance Details for origami_engine_mjx-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for origami-engine-mjx 1.2.0
File Interpreter ABI Platform Actions
origami_engine_mjx-1.2.0-py3-none-any.whl Python 3 none any Details for origami_engine_mjx-1.2.0-py3-none-any.whl

Total release size: 351.5 kB

Release files / origami_engine_mjx-1.2.0.tar.gz

Download URL origami_engine_mjx-1.2.0.tar.gz
Size 233.3 kB
Tags Source
SHA-256 checksum
How to use checksums
804dae3713606cd0e3619c2fc049b5c7bf0625c9ecd713be6132fff4ade644a0
BLAKE2b-256 checksum
How to use checksums
3d46c7c39434ed641466281868c2713d564458b6e870408f8fd1930f57b38af5
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 log

Release files / origami_engine_mjx-1.2.0-py3-none-any.whl

Download URL origami_engine_mjx-1.2.0-py3-none-any.whl
Size 118.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfd73db2601327d5e15361ed45764f92899c4a27dc4f0733e13bba350f50d4e1
BLAKE2b-256 checksum
How to use checksums
d0d2eb4acefe93c05b2b2d070e48c8d6e5411990a5cd0dc133330cbc3fae505f
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 log

Security for origami-engine-mjx 1.2.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.

Select from 2 files

Attestation for origami_engine_mjx-1.2.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 Nov 24, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page