Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

cmenpy

cmenpy

License: GPL v3 PyPI - Version PyPI - Python Version PyPI - Wheel PyPI - Downloads Publish Testing Typed

Compute Metaheuristic Engine for Python (cmenpy or /siːmɛnpaɪ/) is an extensible, flexible, and vectorized Python framework for designing and prototyping metaheuristic and population-based optimization algorithms.

It provides the clean abstractions necessary to build custom evolutionary algorithms, swarm intelligence methods, and hybrid heuristics from scratch — with absolute architectural control.

Installation

pip install cmenpy

Requires Python >=3.11. Numba is optional: kernels compile when it is installed (pip install "cmenpy[numba]"), and run as pure NumPy/Python when it is not — or whenever a model asks with numba=False.

To develop or build the docs:

git clone https://github.com/ltsim/cmenpy.git
cd cmenpy
uv sync --extra dev        # tests, type checks, linters
uv sync --extra docs       # ... plus the MkDocs toolchain
uv sync --extra benchmarks # ... plus opfunu-core / enoppy-core test functions

Quick example

import numpy as np
import cmenpy as cm


@cm.declare(x=cm.Argument[int, (0, 3), 2])
def my_algorithm(args, epoch, ctx):
    pop = cm.PopulationSwarm(ctx.buff)
    pop.compute << ctx.rng.uniform(
        ctx.bounds.low, ctx.bounds.up, (pop.size, ctx.bounds.ndim)
    )
    for _ in epoch:  # one epoch of your operator, per iteration
        ...


best_fitness, best_x = my_algorithm(x=1).solve(
    lambda x: np.sum(x**2), cm.Bounds([(-1, 1)] * 3), epochs=150, pop_size=15
)

See the Quickstart for both the function (@cm.declare) and class (@cm.template) styles.

Core pillars

  • Vectorized data structures. Population arrays, agent states, and search spaces use a flattened, vectorized layout with no per-individual objects. Buffer views (pop.X, pop.F) interoperate with NumPy through the explicit cm.cast(...) helper and can be passed directly to cmenpy kernels, which unwrap them internally.
  • Extensible architecture. Custom operators, mutation rules, or entirely new paradigms require overriding only a few decoupled, well-defined methods. Reusable Operator Modules (@cm.module) share kernels, helpers, and cm.Constant fields across models.
  • Non-monolithic flexibility. No visualization tools, file exporters, or rigid loggers — just the mathematical engine and its structural flow.
  • Research ready. Licensed under the GNU GPLv3. Design, modify, and distribute your algorithms freely; derivative works stay open, keeping the software a public good for research and commercial development.

Documentation

Full guides and the API reference are published at ltsim.github.io/cmenpy.

Guide Covers
Quickstart Solve your first problem in minutes
Models @cm.declare vs @cm.template, the ctx object
Build a custom model Step-by-step tutorial implementing your own optimizer
Numba kernels @cm.precompile, @cm.vectorize, @cm.reduce
Population PopulationSwarm, buffers, selection, ranking
Target functions Objectives, NFE budget, vectorized targets
Examples Runnable algorithms in example/
Test functions Benchmarks with opfunu-core and enoppy-core
API reference Full reference for every public symbol, by category
Roadmap Planned and scheduled work
Changelog Release notes

To preview locally: uv sync --extra docs && .venv/bin/mkdocs serve.

Contributing

Contributions are welcome — see CONTRIBUTING.md and the list of contributors.


Developed by LTSIM @ 2026. Licensed under GNU GPLv3.

Metadata

Release files for cmenpy 2026b1

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

Source distribution (sdist)

Source distribution for cmenpy 2026b1
File Size Uploaded Provenance
cmenpy-2026b1.tar.gz 75.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cmenpy 2026b1
File Interpreter ABI Platform
cmenpy-2026b1-py3-none-any.whl Python 3 none any Details

Total release size: 161.4 kB

Release files / cmenpy-2026b1.tar.gz

Download URL cmenpy-2026b1.tar.gz
Size 75.7 kB
Tags Source
SHA-256 checksum
How to use checksums
71eb07545ece9fbb20c1d8b146ece9d562f02725b239b67af8ec31ce42263d91
BLAKE2b-256 checksum
How to use checksums
91322e1fc2304828751c25f71148e9daafa275229a5d7ddedfac54e1ae42d20e
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 21, 2026.

Transparency log

Release files / cmenpy-2026b1-py3-none-any.whl

Download URL cmenpy-2026b1-py3-none-any.whl
Size 85.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b780e0008aa616c3ded9e7b20ee0bdadf4a84a8f6bf22d3b91833f5373bf2ba
BLAKE2b-256 checksum
How to use checksums
af7d87ac2903a6ae3a974856339e43fe43156890b736d30bc1e19c59c46948b4
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 21, 2026.

Transparency log

Security for cmenpy 2026b1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cmenpy-2026b1.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 21, 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.

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