Skip to main content

puggles

Fast multi-objective evolutionary optimization for Python — NSGA-II and NSGA-III, with a Rust core. Roughly 7–8× faster than pymoo and 20–30× faster than DEAP and platypus at equal solution quality.

pip install puggles

Prebuilt wheels for Linux, macOS, and Windows; Python 3.9+. No Rust toolchain needed.

Quick start

import puggles as pg

# ZDT1: two conflicting objectives over 10 variables in [0, 1].
def zdt1(x):
    g = 1 + 9 * sum(x[1:]) / (len(x) - 1)
    return [x[0], g * (1 - (x[0] / g) ** 0.5)]

problem = pg.Problem(
    solution_length=10,
    number_of_objectives=2,
    solution_data_types=[pg.Real(0.0, 1.0)] * 10,
    objective_function=zdt1,     # must return a LIST, one entry per objective
    direction=[-1, -1],          # -1 = minimize, 1 = maximize
)

ga = pg.NSGAII(problem, population_size=100, seed=42)
ga.run(10_000)                   # budget in objective-function evaluations

for s in ga.get_archive():       # the Pareto front
    print(s.variables, s.objectives)

Benchmarks

ZDT1, population 100, 10,000 evaluations, Apple M3. IGD lower is better — all libraries converge to the same quality, so the difference is pure algorithm overhead.

library ms / run IGD
puggles 31.8 0.0051
pymoo 215.4 0.0045
DEAP 843.4 0.0048
platypus 1062.1 0.0108

On DTLZ2 (3 objectives), NSGAIII reaches IGD 0.011 — the best of any library measured, against pymoo's 0.076.

Features

  • NSGA-II and NSGA-III (reference-point based; prefer it for 3+ objectives)
  • Real, Integer, and Binary decision variables, mixable in one problem
  • Constraints — objective bounds and decision-variable g(x) <= 0
  • Batch objectivesbatch_objective_function=f evaluates a whole population per call, amortizing the GIL. ~1.8× on an expensive objective; a wash on a cheap one.
  • Reproducible runsseed=42 fixes the initial population, crossover, mutation, and selection, so a run repeats exactly. Omit it for fresh randomness each time.
  • GPU evaluation via GpuProblem and a WGSL compute shader (experimental)
  • Built-in DTLZ1–7 benchmark problems

Reproducibility

A genetic algorithm is randomised: without a seed, two runs of identical code give different answers (on ZDT1, roughly 10% apart in IGD). Pass a seed to make a run exactly repeatable — essential for publishing a result, writing a regression test, or comparing two parameter settings without measuring noise.

a = pg.NSGAII(problem, seed=42); a.run(10_000)
b = pg.NSGAII(problem, seed=42); b.run(10_000)
# a and b produce identical fronts, down to the last bit

Seeding applies to NSGAIII too. Use it with execution_mode="sequential": multithreaded runs interleave evaluations non-deterministically, so they are not reproducible even when seeded.

Many objectives

ga = pg.NSGAIII(problem, divisions=12, seed=42)   # population derived from the reference points
ga.run(20_000)

Tuning operators

ga = pg.NSGAII(
    problem,
    population_size=100,
    crossover_config=pg.CrossoverConfig(real_crossover="sbx", sbx_distribution_index=20.0),
    mutation_config=pg.MutationConfig(real_mutation="polynomial"),  # probability=None -> 1/n
)

Leave probability at None unless you have a reason: it defaults to the conventional 1/n per-gene rate. A rate of 1.0 replaces the whole genome every generation, which is random search, not evolution.

Status

The NSGA-II core across all three encodings is well tested and benchmarked. The GPU evaluator is experimental and untested in CI. One Python-callable problem may be optimized at a time per process — concurrent GAs over different Python objectives in threads are not supported.

Links

License

MIT OR Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puggles-0.1.0.tar.gz (87.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

puggles-0.1.0-cp39-abi3-win_amd64.whl (325.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

puggles-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

puggles-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (443.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

puggles-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (404.0 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

puggles-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (424.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file puggles-0.1.0.tar.gz.

File metadata

  • Download URL: puggles-0.1.0.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for puggles-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d90b9b2ff7b4dd53a49d8e71cf86790d498c2b5af5065ecdaf0e071c5b216e98
MD5 46dd390fd504a6b42048c7708a3656e5
BLAKE2b-256 776f0789f090fbdd75b6b963a9d5bf85674c30abe0e3a360ecc8b556aeec05d2

See more details on using hashes here.

File details

Details for the file puggles-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: puggles-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 325.8 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for puggles-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f9465997e7e83f00b2b82c2f960c481d96ad8664b68bd90964c13350420f2525
MD5 8310ad246ffb049fa54c904b3f8d1fcf
BLAKE2b-256 106df3e587f40efaa1e868c90cd17f08816394f081bb6748675655bfc658b003

See more details on using hashes here.

File details

Details for the file puggles-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puggles-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef71e782a618bd43d65fe22655596763f11d946f2445ad8aada0a337035fa1ea
MD5 c52c92a430e499cbcb3dac165df04892
BLAKE2b-256 f9aca0756eb4f4f07ddcdabb98b3a228b04c3eaf5f3044b1c39ec0d0791a80e4

See more details on using hashes here.

File details

Details for the file puggles-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for puggles-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 16e3531471b2a52ba4e69c1a832766e1b4858a1672bb81518ae0d7283c2244f2
MD5 e73a229803915f55d5782904ef208eba
BLAKE2b-256 2ca290744e2ecaf16ba81659bf177e8c156c53dfe02790135822851cd457e772

See more details on using hashes here.

File details

Details for the file puggles-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for puggles-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29efe5d062cd932907a30ead2e75b1db64174767c405721f46012033abb06768
MD5 ef51077a3c7f5fc6b8138e739a04c485
BLAKE2b-256 4f78019daa72ccb1770aeee17ac5c3a728bd37242783e5f7ec5bda1d119102f8

See more details on using hashes here.

File details

Details for the file puggles-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for puggles-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 785039b159c7915faf92a33e0e42c7cd07d11a5be1d8c7cad6d3b0bd3c5ee1f4
MD5 7dc179b20c5e11021f1d5a618c9fb4b0
BLAKE2b-256 98b5f77325927b7454a8ffb9cc533cb869cf340941f3cc0aa44edbcf1c0b3a43

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 files

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