Skip to main content

Professional Metaheuristic Algorithm Library with 130+ algorithms, AI-powered recommendations, and modern web interface

Project description

๐Ÿš€ MHA Flow - Meta-Heuristic Algorithms Optimization Library

Version 2.0.4 | Production Ready | 130+ Algorithms | AI-Powered Recommendations

A comprehensive Python library for meta-heuristic optimization algorithms with AI-powered algorithm recommendations, modern web interface, and support for feature selection, hyperparameter tuning, and benchmark testing.

Python 3.8+ License: MIT Web Interface


โœจ What's New in v2.0.4

  • ๐Ÿค– AI-Powered Algorithm Recommender - Smart recommendations based on dataset characteristics
  • ๐ŸŽจ Modern 3-Step Workflow - Intuitive guided interface
  • ๐ŸŒ Online Web Interface - Access from anywhere at mha-flow.streamlit.app
  • ๐Ÿ“Š Enhanced Visualizations - Real-time convergence plots and comparisons
  • ๐Ÿ” Multi-User Authentication - Personal optimization history tracking
  • ๐Ÿ’ซ 130+ Algorithms - Expanded algorithm library with hybrids

๐Ÿ“Š Features

  • โœ… 130+ Meta-Heuristic Algorithms with hybrid combinations
  • ๐Ÿค– AI-Powered Algorithm Recommendations based on dataset analysis
  • ๐ŸŽฏ 13 Algorithm Categories (Swarm, Bio-Inspired, Physics-Based, etc.)
  • ๐Ÿ”ง 4 Usage Modes: Python Library, Web UI, Online Interface, CLI
  • ๐Ÿ“ˆ Real-Time Visualization with interactive plots
  • ๐Ÿ’พ Complete Results Saving with comprehensive analysis
  • ๐Ÿ”„ Multi-User Session Management with authentication
  • ๐Ÿ“ค Export Results: CSV, Excel, JSON, PNG
  • ๐Ÿ“š Comprehensive Documentation and examples
  • ๐ŸŒ Access Anywhere - Online or local deployment

๐Ÿš€ Quick Start

Installation

# Install from PyPI (recommended)
pip install mha-flow

# With web interface
pip install mha-flow[ui]

# Complete installation (all features)
pip install mha-flow[complete]

# Or install from source
git clone https://github.com/Achyut103040/MHA-Algorithm.git
cd MHA-Algorithm
pip install -e .

Launch Commands

# Open online web interface (no local installation needed)
mha-flow-web

# Launch local web interface
mha-flow

# Command-line interface
mha-flow-cli

# Run demo system
mha-demo

Python Library Usage

from mha_toolbox import MHAToolbox
from sklearn.datasets import load_iris

# Load data
X, y = load_iris(return_X_y=True)

# Initialize toolbox
toolbox = MHAToolbox()

# Run optimization
result = toolbox.optimize('pso', X=X, y=y, population_size=30, max_iterations=100)

# Access results
print(f"Best fitness: {result.best_fitness_}")
print(f"Runtime: {result.execution_time_}s")
print(f"Best solution: {result.best_solution_}")

AI-Powered Recommendations

from mha_toolbox import AlgorithmRecommender

# Initialize recommender
recommender = AlgorithmRecommender()

# Get recommendations based on your dataset
recommendations = recommender.recommend_algorithms(X, y, top_k=5)

for algo, confidence, reason in recommendations:
    print(f"{algo.upper()}: {confidence:.1f}/10 - {reason}")

๐ŸŒ Web Interfaces

Online Interface (Recommended)

No installation required! Access the full-featured web interface at: ๐Ÿ‘‰ https://mha-flow.streamlit.app/

Features:

  • ๐Ÿ” User authentication & history
  • ๐Ÿค– AI-powered algorithm recommendations
  • ๐Ÿ“Š 6 sample datasets included
  • ๐Ÿ“ˆ Real-time visualizations
  • ๐Ÿ’พ Export results in multiple formats

Local Interface

Run the web interface on your machine:

mha-flow

๐Ÿ“ฆ 130+ Available Algorithms

๐Ÿ Swarm Intelligence (18)

PSO, GWO, WOA, ACO, ABC, BA, FA, SSA, ALO, MFO, CS, FPA, KH, etc.

๐Ÿงฌ Bio-Inspired (21)

SMA, HBA, DMO, EHO, GAO, TSO, MRFO, SOS, BMO, etc.

๐ŸŒก๏ธ Physics-Based (12)

SA, EO, GSA, MSA, CSA, AOA, MVO, HGSO, WDO, WCA, etc.

๐Ÿ” Search-Based (20)

TS, VNS, HS, HC, HGS, ILS, GLS, etc.

๐Ÿง  Human-Based (9)

TLBO, LCA, LCBO, SOS, ICA, TBO, CHIO, QSA, etc.

๐Ÿ”ฅ Hybrid Algorithms (22)

PSO_GA, GWO_PSO, ABC_DE, ACO_PSO, FA_DE, WOA_GA, SMA_DE, etc.

๐Ÿงฌ Evolutionary (2)

GA, DE

๐ŸŽฏ Advanced Meta-Heuristics (6)

SCA, HHO, AO, GTO, RSA, ASO

๐Ÿ“ Mathematical (4)

CEM, GCO, GBMO, GSKA

๐ŸŒŠ Nature-Inspired (1)

DA (Dragonfly Algorithm)

๐Ÿฆ  Pandemic-Inspired (1)

CHIO (Coronavirus Herd Immunity)

๐ŸŽฎ Game-Based (1)

THRO (Throwing Game)

๐Ÿ”ฌ Other Specialized (8)

Various domain-specific algorithms


๐ŸŽฏ Usage Modes

1๏ธโƒฃ Python Library (Programmatic)

from mha_toolbox import optimize, MHAToolbox

# Simple API - Quick optimization
result = optimize('pso', X=X, y=y)

# Advanced API - Full control
toolbox = MHAToolbox(verbose=False)
algorithms = toolbox.list_algorithms()  # Returns 125 algorithms
hybrids = toolbox.registry.list_hybrid_algorithms()  # Returns 22 hybrids

# Run with custom parameters
result = toolbox.optimize(
    'PSO_GA_Hybrid',
    X=X, y=y,
    population_size=50,
    max_iterations=200,
    verbose=True
)

# Access all results
print(f"Best solution: {result.best_solution_}")     # numpy array
print(f"Best fitness: {result.best_fitness_}")       # float
print(f"Convergence: {result.global_fitness_}")      # list
print(f"Agent history: {result.local_fitness_}")     # list
print(f"Positions: {result.local_positions_}")       # list
print(f"Algorithm: {result.algorithm_name_}")        # string
print(f"Runtime: {result.execution_time_}s")         # float

2๏ธโƒฃ Web Interface (Streamlit)

# Launch the web UI
python mha_ui_complete.py

# Or use streamlit directly
streamlit run mha_ui_complete.py

Features:

  • 125 algorithms with interactive parameter tuning
  • Real-time visualization of convergence
  • Multi-user session management
  • Compare multiple algorithms
  • Export results (CSV, Excel, JSON, PNG)
  • Algorithm recommendations

3๏ธโƒฃ Command-Line Interface (CLI)

# List all algorithms
python -m mha_toolbox list

# List only hybrid algorithms
python -m mha_toolbox list --filter hybrid

# Get algorithm information
python -m mha_toolbox info pso

# Get recommendations
python -m mha_toolbox recommend --problem-type feature_selection

# Launch web interface
python -m mha_toolbox ui

# Show demo
python -m mha_toolbox demo

๐Ÿ”ฅ Hybrid Algorithms (All 22 Working)

Hybrid algorithms combine the strengths of multiple optimization approaches:

from mha_toolbox import optimize

# Available hybrid algorithms:
hybrids = [
    'PSO_GA_Hybrid',           # Particle Swarm + Genetic Algorithm
    'GWO_PSO_Hybrid',          # Grey Wolf + Particle Swarm
    'ABC_DE_Hybrid',           # Artificial Bee Colony + Differential Evolution
    'ACO_PSO_Hybrid',          # Ant Colony + Particle Swarm
    'FA_DE_Hybrid',            # Firefly + Differential Evolution
    'FA_GA_Hybrid',            # Firefly + Genetic Algorithm
    'WOA_GA_Hybrid',           # Whale + Genetic Algorithm
    'WOA_SMA_Hybrid',          # Whale + Slime Mould
    'SMA_DE_Hybrid',           # Slime Mould + Differential Evolution
    'CS_GA_Hybrid',            # Cuckoo Search + Genetic Algorithm
    'ALO_PSO_Hybrid',          # Ant Lion + Particle Swarm
    'SSA_DE_Hybrid',           # Salp Swarm + Differential Evolution
    'GWO_DE_Hybrid',           # Grey Wolf + Differential Evolution
    'HS_DE_Hybrid',            # Harmony Search + Differential Evolution
    'KH_PSO_Hybrid',           # Krill Herd + Particle Swarm
    'MFO_DE_Hybrid',           # Moth Flame + Differential Evolution
    'SA_PSO_Hybrid',           # Simulated Annealing + Particle Swarm
    'TS_GA_Hybrid',            # Tabu Search + Genetic Algorithm
    'DA_GA_Hybrid',            # Dragonfly + Genetic Algorithm
    'FPA_GA_Hybrid',           # Flower Pollination + Genetic Algorithm
    'DifferentialEvolutionPSOHybrid',
    'GeneticSimulatedAnnealingHybrid'
]

# Use any hybrid algorithm
result = optimize('PSO_GA_Hybrid', X=X, y=y, population_size=30, max_iterations=100)

๐Ÿ“‹ Examples

Example 1: Feature Selection

from mha_toolbox import optimize
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# Load dataset
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)

# Optimize with PSO
result = optimize(
    'pso',
    X=X_train,
    y=y_train,
    population_size=30,
    max_iterations=50,
    verbose=True
)

print(f"Selected {sum(result.best_solution_)} features")
print(f"Best fitness: {result.best_fitness_:.6f}")

Example 2: Compare Multiple Algorithms

from mha_toolbox import optimize

algorithms = ['pso', 'gwo', 'woa', 'PSO_GA_Hybrid']
results = {}

for algo in algorithms:
    result = optimize(algo, X=X_train, y=y_train, max_iterations=30)
    results[algo] = {
        'fitness': result.best_fitness_,
        'time': result.execution_time_
    }
    print(f"{algo:15s} - Fitness: {result.best_fitness_:.6f} - Time: {result.execution_time_:.2f}s")

Example 3: Using Toolbox API

from mha_toolbox import MHAToolbox

# Initialize
toolbox = MHAToolbox(verbose=True)

# Get algorithm info
total = len(toolbox.list_algorithms())
hybrids = len(toolbox.registry.list_hybrid_algorithms())
print(f"Total algorithms: {total}")
print(f"Hybrid algorithms: {hybrids}")

# Get algorithms by category
by_category = toolbox.registry.get_algorithm_by_category()
for category, algos in by_category.items():
    print(f"{category}: {len(algos)} algorithms")

# Run optimization
result = toolbox.optimize('pso', X=X, y=y)

๐Ÿงช Testing

Quick Verification

# Test system
python final_system_test.py

# Test hybrid algorithms
python test_fixed_hybrids.py

# Quick start demo
python hybrid_quick_start.py

Run Tests

# In Python
from mha_toolbox import MHAToolbox

toolbox = MHAToolbox(verbose=False)
print(f"โœ… Algorithms discovered: {len(toolbox.list_algorithms())}")
print(f"โœ… Hybrids available: {len(toolbox.registry.list_hybrid_algorithms())}")

๐Ÿ“Š Performance Benchmarks

Tested on Iris dataset (150 samples, 4 features):

Algorithm Runtime Best Fitness Convergence
PSO 9.9s 0.071667 10 iterations
GWO_PSO_Hybrid 2.8s 0.120238 3 iterations
ABC_DE_Hybrid 5.0s 0.107143 3 iterations
ACO_PSO_Hybrid 2.3s 0.107143 3 iterations
FA_DE_Hybrid 3.1s 0.101190 3 iterations

Note: Times vary based on population size and iterations


๐Ÿ› ๏ธ Requirements

  • Python 3.8+
  • numpy >= 1.19.0
  • scipy >= 1.5.0
  • scikit-learn >= 0.23.0
  • matplotlib >= 3.3.0
  • pandas >= 1.1.0
  • streamlit >= 1.0.0 (for UI)
  • plotly >= 4.14.0 (for visualization)

๐Ÿ“ Project Structure

MHA-Algorithm/
โ”œโ”€โ”€ mha_toolbox/              # Main package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ base.py               # BaseOptimizer class
โ”‚   โ”œโ”€โ”€ toolbox.py            # Main MHAToolbox class
โ”‚   โ”œโ”€โ”€ complete_algorithm_registry.py  # Algorithm discovery
โ”‚   โ”œโ”€โ”€ algorithms/           # 103 algorithm implementations
โ”‚   โ”‚   โ””โ”€โ”€ hybrid/           # 22 hybrid algorithms
โ”‚   โ”œโ”€โ”€ ui.py                 # Web interface
โ”‚   โ””โ”€โ”€ __main__.py           # CLI implementation
โ”œโ”€โ”€ mha_ui_complete.py        # Complete web interface
โ”œโ”€โ”€ examples/                 # Example scripts
โ”œโ”€โ”€ objective_functions/      # Benchmark functions
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ README.md                 # This file
โ””โ”€โ”€ LICENSE

๐Ÿ’ก Tips & Best Practices

Choosing Population Size

  • Small datasets (< 1000 samples): 20-30
  • Medium datasets (1000-10000): 30-50
  • Large datasets (> 10000): 50-100

Choosing Iterations

  • Quick test: 10-20 iterations
  • Standard optimization: 50-100 iterations
  • Thorough search: 200-500 iterations

Choosing Algorithm

  • Fast convergence: PSO, GWO, WOA
  • Exploration: GA, DE, ABC
  • Balanced: Hybrid algorithms (PSO_GA, GWO_PSO)
  • Complex problems: Advanced hybrids (ABC_DE, FA_DE)

๐Ÿ› Troubleshooting

Import Error

pip install -r requirements.txt --upgrade

Algorithm Not Found

from mha_toolbox import MHAToolbox
toolbox = MHAToolbox()
print(toolbox.list_algorithms())  # Check available names

Slow Optimization

  • Reduce population_size (e.g., from 50 to 20)
  • Reduce max_iterations (e.g., from 100 to 30)
  • Use faster algorithms (PSO, GWO instead of GA)

Memory Error

  • Reduce population size
  • Process data in batches
  • Use simpler algorithms

๐Ÿค Contributing

Contributions are welcome! To add a new algorithm:

  1. Create algorithm file in mha_toolbox/algorithms/
  2. Inherit from BaseOptimizer
  3. Implement _optimize() method
  4. Add tests
  5. Submit pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ“ง Contact


๐ŸŽ‰ Acknowledgments

This library implements meta-heuristic algorithms from various research papers and combines them into a unified, easy-to-use framework.


๐Ÿ“ˆ Version History

v2.0.0 (2025-11-05) - Production Ready

  • โœ… 125 algorithms (103 main + 22 hybrids)
  • โœ… All hybrid algorithms fixed and working
  • โœ… Complete web interface with multi-user support
  • โœ… CLI implementation
  • โœ… Comprehensive documentation
  • โœ… All tests passing

v1.x - Previous versions

  • Initial implementations
  • Core algorithms
  • Basic UI

Made with โค๏ธ for the optimization community

Last Updated: November 5, 2025

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

mha_flow-2.0.6.tar.gz (802.6 kB view details)

Uploaded Source

Built Distribution

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

mha_flow-2.0.6-py3-none-any.whl (825.5 kB view details)

Uploaded Python 3

File details

Details for the file mha_flow-2.0.6.tar.gz.

File metadata

  • Download URL: mha_flow-2.0.6.tar.gz
  • Upload date:
  • Size: 802.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mha_flow-2.0.6.tar.gz
Algorithm Hash digest
SHA256 3de34f219abd811c3c53dc1e935e8feb20c76b7f73dfc3b9440c83f36f059b11
MD5 4d39daae00d09e0e72779bbed4a6179f
BLAKE2b-256 2642421d699ad1c26df5424439199663fb0d797a618e1223f60bb98e06431e4d

See more details on using hashes here.

File details

Details for the file mha_flow-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: mha_flow-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 825.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mha_flow-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9e22e3144fcb31f144f94a801c23a813e7a092228d082f76c8277b9d6ffa70d0
MD5 f21bb1bdd7a7e025daeec18bd585397c
BLAKE2b-256 3ba7c1f5744d257876852935b8fcfb72a6d76ef0e275b619b12cae1acab12338

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