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
  • 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), evaluator.py (OrigamiEvaluator, descriptors), 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). See INTEGRATIONS.md, OPTIMIZATION_ES.md and RL.md.

License

Apache-2.0

Metadata

Release files for origami-engine-mjx 1.0.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.0.0
File Size Uploaded Provenance Actions
origami_engine_mjx-1.0.0.tar.gz 164.0 kB With provenance Details for origami_engine_mjx-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 227.4 kB

Release files / origami_engine_mjx-1.0.0.tar.gz

Download URL origami_engine_mjx-1.0.0.tar.gz
Size 164.0 kB
Tags Source
SHA-256 checksum
How to use checksums
17095f44bc7c65206f68221bf7736917ba38c6704d4026df1529dfcef5b09353
BLAKE2b-256 checksum
How to use checksums
1a78a66734ed657ca692cd8bbe2614f50b5d161fd426244794d9a15146fc2819
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 23, 2026.

Transparency log

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

Download URL origami_engine_mjx-1.0.0-py3-none-any.whl
Size 63.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17cb541e4b8388274daff7fcb23bf4ae3ae79e144f24aefad4f607bb5a5585ce
BLAKE2b-256 checksum
How to use checksums
642bce4aa23e3320c9d2518ab01d75e73453620bad936fda1c10b103c73eedda
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 23, 2026.

Transparency log

Security for origami-engine-mjx 1.0.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.0.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 23, 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