Skip to main content

A lightweight Python library for metaheuristic optimization.

Project description

MetaHeurOpt

PyPI - License PyPI - Version PyPI - Python Version PyPI Downloads

Description

MetaHeurOpt is a modular Python library designed for the execution, benchmarking, and statistical analysis of metaheuristic optimization algorithms. It provides a standardized framework to compare diverse algorithms, ranging from classic evolutionary strategies to modern physics-inspired and swarm intelligence models, on complex continuous optimization problems.

Installation

You can install the stable version of MetaHeurOpt directly from PyPI:

pip install metaheuropt

Usage Example

Below is a quick start guide to comparing solvers. For a more detailed walkthrough, including statistical tables and 3D landscape visualization, check out the /examples/example.ipynb notebook.

import numpy as np
from metaheuropt.solvers import GA, PSO
from metaheuropt.core import Optimizer
from metaheuropt.analysis import ResultsAnalyzer

# 1. Define your objective function
def sphere(x):
    return np.sum(np.square(x))

# 2. Configure experiment
dims = 10
bounds = (np.array([-5.12] * dims), np.array([5.12] * dims))
num_runs = 5
max_iter = 100

# 3. Select solvers
solvers = [
    GA(bounds=bounds, pop_size=50, max_iter=max_iter),
    PSO(bounds=bounds, pop_size=50, max_iter=max_iter),
]

# 4. Run optimization
opt = Optimizer(solvers=solvers, obj_func=sphere, num_runs=num_runs)
opt.run(save_results=True, results_folder="demo_results")

# 5. Analyze and visualize
analyzer = ResultsAnalyzer("demo_results")
analyzer.plot_convergence()
analyzer.perform_stats(full=True)

Available Algorithms

The library currently supports the following high-performance metaheuristics:

Code Name Original Reference
ABC Artificial Bee Colony Karaboga (2007)
CMA-ES Covariance Matrix Adaptation Evolution Strategy Hansen & Ostermeier (2001)
DE Differential Evolution Storn & Price (1997)
GA Genetic Algorithm K. F. Man et al. (1976)
GSA Gravitational Search Algorithm Rashedi et al. (2009)
GWO Grey Wolf Optimizer Mirjalili et al. (2014)
HHO Harris Hawks Optimization Heidari et al. (2019)
JADE Adaptive Differential Evolution with Archive Zhang & Sanderson (2009)
MVO Multi-Verse Optimizer Mirjalili et al. (2016)
NSGA-II Non-dominated Sorting Genetic Algorithm II Deb et al. (2002)
PSO Particle Swarm Optimization Kennedy & Eberhart (1995)
SA Simulated Annealing Kirkpatrick et al. (1983)
TLBO Teaching-Learning-Based Optimization Rao et al. (2011)
WOA Whale Optimization Algorithm Mirjalili & Lewis (2016)

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

metaheuropt-0.1.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

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

metaheuropt-0.1.0-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: metaheuropt-0.1.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaheuropt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8792ef4fdd4bc24489387d40cf6893e35d01e5a469bc99abffd98b252636811c
MD5 67f79f1315eb7c8570030c20a5d0049d
BLAKE2b-256 afc14bf8ac8279789b06789e856ade5df81e0741e70633619b1c6ee383b97583

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaheuropt-0.1.0.tar.gz:

Publisher: python-publish.yml on alejotoro-o/metaheuropt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metaheuropt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: metaheuropt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaheuropt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd9dabbe03dc8be4639ff63748d0b62773e1a308ae57bf221f6a5eac6ad380c9
MD5 2943c8c5cf6f4c4718cfb1c48fd4d5f8
BLAKE2b-256 45e13d314e13c94bf00ac0894be693439c2512d0032f5c8218f9353405996939

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaheuropt-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on alejotoro-o/metaheuropt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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