SkillAgentSearch skills...

Mealpy

A Collection Of The State-of-the-art Metaheuristic Algorithms In Python (Metaheuristic/Optimizer/Nature-inspired/Biology)

Install / Use

/learn @thieu1995/Mealpy

README

<p align="center"> <img style="height:400px;" src="https://thieu1995.github.io/post/2022-04/19-mealpy-tutorials/mealpy5-nobg.png" alt="MEALPY"/> </p>

GitHub release Wheel PyPI version PyPI - Python Version Downloads Tests & Publishes to PyPI GitHub Release Date Chat Documentation Status DOI License: MIT


MEALPY is the world's largest Python library, offering a comprehensive collection of cutting-edge meta-heuristic algorithms. These include nature-inspired algorithms, bio-inspired algorithms, black-box optimization, global search optimizers, iterative learning algorithms, continuous optimization, derivative-free optimization, gradient-free optimization, zeroth-order optimization, stochastic search optimization, and random search optimization. All these methods fall under the category of population-based metaheuristics (PBMs), which are among the most popular algorithms in the field of approximate optimization. For detailed updates in each new version, please refer to the ChangeLog file.

  • Free software: MIT license
  • Total algorithms: 233 (206 official (original, hybrid, variants), 27 developed)
  • Documentation: https://mealpy.readthedocs.io/en/latest/
  • Python versions: >=3.8x
  • Dependencies: numpy, scipy, pandas, matplotlib, tqdm

📌 Goals

Our goals are to implement all classical as well as the state-of-the-art nature-inspired algorithms, create a simple interface that helps researchers access optimization algorithms as quickly as possible, and share knowledge of the optimization field with everyone without a fee. What you can do with mealpy:

  • Analyse parameters of meta-heuristic algorithms.
  • Perform Qualitative and Quantitative Analysis of algorithms.
  • Analyse rate of convergence of algorithms.
  • Test and Analyse the scalability and the robustness of algorithms.
  • Save results in various formats (csv, json, pickle, png, pdf, jpeg)
  • Export and import models can also be done with Mealpy.
  • Solve any optimization problem

📄 Citation Request

Please include these citations if you plan to use this library:

@article{van2023mealpy,
  title={MEALPY: An open-source library for latest meta-heuristic algorithms in Python},
  author={Van Thieu, Nguyen and Mirjalili, Seyedali},
  journal={Journal of Systems Architecture},
  year={2023},
  publisher={Elsevier},
  doi={10.1016/j.sysarc.2023.102871}
}

@article{van2023groundwater,
  title={Groundwater level modeling using Augmented Artificial Ecosystem Optimization},
  author={Van Thieu, Nguyen and Barma, Surajit Deb and Van Lam, To and Kisi, Ozgur and Mahesha, Amai},
  journal={Journal of Hydrology},
  volume={617},
  pages={129034},
  year={2023},
  publisher={Elsevier},
  doi={https://doi.org/10.1016/j.jhydrol.2022.129034}
}

@article{ahmed2021comprehensive,
  title={A comprehensive comparison of recent developed meta-heuristic algorithms for streamflow time series forecasting problem},
  author={Ahmed, Ali Najah and Van Lam, To and Hung, Nguyen Duy and Van Thieu, Nguyen and Kisi, Ozgur and El-Shafie, Ahmed},
  journal={Applied Soft Computing},
  volume={105},
  pages={107282},
  year={2021},
  publisher={Elsevier},
  doi={10.1016/j.asoc.2021.107282}
}

⚙️ Usage

<details><summary><h2>🛠️ Installation</h2></summary>
$ pip install mealpy --upgrade
  • Install the alpha/beta version from PyPi
$ pip install mealpy==2.5.4a6
  • Install the pre-release version directly from the source code:
$ git clone https://github.com/thieu1995/mealpy.git
$ cd mealpy
$ python setup.py install
  • In case, you want to install the development version from Github:
$ pip install git+https://github.com/thieu1995/mealpy 

After installation, check the version to ensure successful installation:

$ python
>>> import mealpy
>>> mealpy.__version__

>>> print(mealpy.get_all_optimizers())
>>> model = mealpy.get_optimizer_by_name("OriginalWOA")(epoch=100, pop_size=50)
</details>

💬 Decision Variables

Before we dive into some examples, let's briefly consider the type of problem you're aiming to solve with MEALPY. Understanding your specific problem and its desired solution can help you select the most appropriate approach.

To assist you in choosing the right tools, refer to the table below. It outlines different types of decision variables available in MEALPY, along with their syntax and common problem applications. This will guide you in defining your search space effectively.

<div align="center">

| Class | Syntax | Problem Types | |-------------------|-----------------------------------------------------------------------------------------------------------------|-----------------------------| | FloatVar | FloatVar(lb=(-10., )*7, ub=(10., )*7, name="delta") | Continuous Problem | | IntegerVar | IntegerVar(lb=(-10., )*7, ub=(10., )*7, name="delta") | LP, IP, NLP, QP, MIP | | StringVar | StringVar(valid_sets=(("auto", "backward", "forward"), ("leaf", "branch", "root")), name="delta") | ML, AI-optimize | | BinaryVar | BinaryVar(n_vars=11, name="delta") | Networks | | BoolVar | BoolVar(n_vars=11, name="delta") | ML, AI-optimize | | PermutationVar | PermutationVar(valid_set=(-10, -4, 10, 6, -2), name="delta") | Combinatorial Optimization | | CategoricalVar | CategoricalVar(valid_sets=(("auto", 2, 3, "backward", True), (0, "tournament", "round-robin")), name="delta") | MIP, MILP | | SequenceVar | SequenceVar(valid_sets=((1, ), {2, 3}, [3, 5, 1]), return_type=list, name='delta') | Hyper-parameter tuning | | TransferBoolVar | TransferBoolVar(n_vars=11, name="delta", tf_func="sstf_02") | ML, AI-optimize, Feature | | TransferBinaryVar | TransferBinaryVar(n_vars=11, name="delta", tf_func="vstf_04") | Networks, Feature Selection |

</div>

📚 Optimizer Classification Table

  • Meta-heuristic Categories: (Based on this article)
    • Evolutionary-based: Algorithms inspired by Darwin's law of natural selection and evolutionary computing principles
    • Swarm-based: Algorithms drawing inspiration from the collective movement and interaction of swarms (e.g., birds, social insects).
    • Physics-based: Algorithms derived from physical laws and phenomena (e.g., Newton's law of universal gravitation, black holes, multiverse theory).
    • Human-based: Algorithms inspired by human interactions and behaviors (e.g., queuing search, teaching-learning processes).
    • Biology-based: Algorithms based on biological creatures or microorganisms.
    • System-based: Algorithms inspired by ecological systems, immune systems, or network systems.
    • Math-based: Algorithms developed from mathematical forms or laws (e.g., sine-cosine functions).
    • Music-based: Algorithms drawing inspiration from musical instruments or compositions.

MEALPY3-0-0

  • Difficulty - Difficulty Level (Personal Opinion): Objective observation from author. Depend on the number of parameters, number of equations, the original ideas, time spend for coding, source lines of code (SLOC).
    • Easy: A few paras, few equations, SLOC very short
    • Medium: more equations than Easy level, SLOC longer than Easy level
    • Hard: Lots of equations, SLOC longer than Medium level, the paper hard to read.
    • Hard* - Very hard: Lots of equations, SLOC too long, the paper is very hard to read.

** For newbie, we recommend to read the paper of algorithms which difficulty is "easy" or "medium" difficulty level.

[//]: # (<table><thead><tr><th>Group</th><th>Name</th><th>Module</th><th>Class</th><th>Year</th><th>Paras</th><th>Difficulty</th></tr></thead><tbody><tr><th>Evolutionary</th><td>Evolutionary Programming</td><td>EP</td><td>OriginalEP</td><td>1964</td><td>3</td><td>easy</td></tr><tr><th>Evolutionary</th><td></td><td></td><td>LevyEP</td><td>*</td><td>3</td><td>easy</td></tr><tr><th>Evolutionary</th><td>Evolution Strategies</td><td>ES</td><td>OriginalES</td><td>1971</td><td>3</td><td>easy</td></tr><tr><th>Evolutionary</th><td>

View on GitHub
GitHub Stars1.2k
CategoryDevelopment
Updated2d ago
Forks253

Languages

Python

Security Score

100/100

Audited on Mar 25, 2026

No findings