liveBook · Manning

MEALPY

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

MEALPY is a Python library that provides implementations of nature-inspired metaheuristic optimization algorithms.

MEALPY is a Python library for applying population-based, nature-inspired metaheuristic optimization algorithms, including artificial bee colony (ABC). Install it with pip install mealpy. section 10.5

A MEALPY optimization uses a problem dictionary containing the objective function, lower and upper bounds, and minimization or maximization direction. Configure the model, then call solve() to obtain the best position and fitness. section 10.5

Minimizing the Rosenbrock function with ABC

Import OriginalABC from mealpy.swarm_based.ABC, define rosenbrock_function with bounds [-5, -5] and [5, 5], choose 200 epochs, population size 50, and n_limits 15, then call model.solve(problem_dict). One run returns a position near [1, 1] with cost 0.0009197449137428784. section 10.5

from mealpy.swarm_based.ABC import OriginalABC                        #1
  
problem_dict = {
    "fit_func": rosenbrock_function,
    "lb": [-5, -5],
    "ub": [5, 5],
    "minmax": "min",
}                                                                     #2
 
epoch = 200                                                           #3
pop_size = 50                                                         #4
n_limits = 15                                                         #5
  
model = OriginalABC(epoch, pop_size, n_limits)                        #6
  
best_position_mealpy, best_fitness_mealpy = model.solve(problem_dict) #7
  
print(f"Best solution: {best_position_mealpy}")                       #8
print(f"Best fitness: {best_fitness_mealpy}")                         #8

Browse the complete MEALPY ABC setup, including the import, problem definition, parameters, model construction, and solve call. section 10.5

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Demonstrates installation, problem specification, parameter configuration, model construction, and solving, without detailing library internals.
Examples
Uses the two-dimensional Rosenbrock function and compares ABC, MEALPY ABC, and ACO solutions.
What it assumes
Assumes a Python objective function and optimization bounds, while illustrating the remaining MEALPY setup explicitly.
What you can do after
Apply it via a Python library to configure and solve bounded minimization or maximization problems.
How it connects
Connects artificial bee colony, population-based metaheuristics, genetic algorithms, particle swarm optimization, and ant colony optimization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.