Skip to main content

A Pythonic toolkit for Ant Colony, Particle Swarm, and Bee Colony optimization — written in Rust for high performance, designed for real-world use.

Project description

colonyx

colonyx is a Python library for solving optimization problems using swarm intelligence algorithms like Ant Colony Optimization (ACO), Particle Swarm Optimization (PSO), Artificial Bee Colony (ABC), Grey Wolf Optimization (GWO), Firefly (FA), Simulated Annealing (SA), Cuckoo Search (CS), Bat Algorithm (BA), Glowworm Swarm Optimization (GSO), Bacterial Foraging (BFO), and Differential Evolution (DE).

While the interface is Pythonic and easy to use, the core is written in Rust to deliver better performance for larger or more complex problems.

Documentation: see docs/index.md for the library guide and API overview.

This is an early version — contributions, suggestions, and feedback are all welcome.

Features

  • Ant Colony Optimization (ACO) — for discrete problems like TSP
  • Particle Swarm Optimization (PSO) — for continuous function optimization
  • Artificial Bee Colony (ABC) — inspired by bee foraging behavior
  • Grey Wolf Optimization (GWO), Firefly (FA), Simulated Annealing (SA)
  • Cuckoo Search (CS), Bat Algorithm (BA), Glowworm Swarm Optimization (GSO)
  • Bacterial Foraging (BFO), Differential Evolution (DE)
  • CMA-ES for covariance-adaptive continuous search
  • Binary PSO, permutation GA, NSGA-II, and MOPSO for advanced search
  • ACO variants including ACS, elitist, and MMAS behavior
  • Simple, clean Python API
  • Fast backend powered by Rust

Installation

pip install colonyx

(Install from source while release automation is being prepared.)

Example

All algorithms are used through the unified AutoColony interface, selected via the mode parameter.

Continuous optimization (PSO / ABC) — minimize an objective function over a box, given per-dimension bounds:

from colonyx import AutoColony

def sphere(x):
    return sum(xi * xi for xi in x)  # minimum 0 at the origin

opt = AutoColony(mode="pso", n_iterations=150, random_state=42)
opt.fit(sphere, bounds=[(-5, 5), (-5, 5), (-5, 5)])

opt.predict()  # best position, ~ [0, 0, 0]
opt.score()    # objective value at that position, ~ 0

# Artificial Bee Colony works the same way:
AutoColony(mode="abc", n_iterations=200).fit(sphere, bounds=[(-5, 5)] * 3)

Discrete optimization (ACO) — find a short tour through a square distance matrix (TSP):

import numpy as np
from colonyx import AutoColony

distance_matrix = np.array([
    [0, 1, 9, 9, 1],
    [1, 0, 1, 9, 9],
    [9, 1, 0, 1, 9],
    [9, 9, 1, 0, 1],
    [1, 9, 9, 1, 0],
], dtype=float)

opt = AutoColony(mode="aco", n_iterations=100, random_state=42)
opt.fit(distance_matrix)

opt.predict()  # best tour, e.g. [0, 1, 2, 3, 4]
opt.score()    # tour length (lower is better)

Use mode="auto" to let colonyx pick ACO for a square matrix or PSO for an objective function automatically.

For advanced optimizers, see docs/algorithms/advanced.md.

Documentation

  • Library guide: docs/index.md
  • AutoColony API: docs/autocolony-api.md
  • CLI: docs/cli.md
  • Getting started: docs/getting-started.md
  • Algorithm overview: docs/algorithms.md
  • Release and packaging notes: docs/release.md

License

MIT

Project details


Download files

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

Source Distribution

colonyx-0.1.0.tar.gz (95.5 kB view details)

Uploaded Source

Built Distribution

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

colonyx-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (410.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: colonyx-0.1.0.tar.gz
  • Upload date:
  • Size: 95.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for colonyx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f9d18b72cec3484046caa17a21856129cef00e08002509cf22470fe4ae9de26
MD5 a9d8930cf1e5478522c9eb0675ecd97b
BLAKE2b-256 fc3b035b56cf3dc97d03f63be6d8d0911265ce5c5b3dd2d76b8ebccd2497ccdc

See more details on using hashes here.

File details

Details for the file colonyx-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for colonyx-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ebec764c8e4cdbac948d08b15ea29af39cd6e18a86f1cb412b25b9c7bb4b0fae
MD5 c88641724523d5a5b9531953c5b86375
BLAKE2b-256 f54e0f713285aec543887bf1985c29fab2fca564b2281ebce5136db7598f114b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page