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.
โจ 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:
- Create algorithm file in
mha_toolbox/algorithms/ - Inherit from
BaseOptimizer - Implement
_optimize()method - Add tests
- Submit pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ง Contact
- Author: MHA Development Team
- GitHub: Achyut103040/MHA-Algorithm
- Issues: GitHub Issues
๐ 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de34f219abd811c3c53dc1e935e8feb20c76b7f73dfc3b9440c83f36f059b11
|
|
| MD5 |
4d39daae00d09e0e72779bbed4a6179f
|
|
| BLAKE2b-256 |
2642421d699ad1c26df5424439199663fb0d797a618e1223f60bb98e06431e4d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e22e3144fcb31f144f94a801c23a813e7a092228d082f76c8277b9d6ffa70d0
|
|
| MD5 |
f21bb1bdd7a7e025daeec18bd585397c
|
|
| BLAKE2b-256 |
3ba7c1f5744d257876852935b8fcfb72a6d76ef0e275b619b12cae1acab12338
|