ABC, Artificial Bee Colony, Optimization Algorithm
Based on article:
Artificial Bee Colony (ABC) Optimization Algorithm for Solving Constrained Optimization Problems
Class is designed to accept lambda functions but it will work with any method, and any number of parameters.
Ackley function:
Search domain: -40 > x, y < 40
Global minimun: 0
from ArtificialBeeColony import ABC
import math
ackley_function = lambda x, y: -20 * math.exp(-.02 * math.sqrt(0.5 * (x ** 2 + y ** 2))) - math.exp(
0.5 * (math.cos(2 * math.pi * x) + math.cos(2 * math.pi * y))) + math.e + 20
sn = 10
limit = 50
mcn = 1000
bound = 40
beecolony = ABC(ackley_function, sn, bound, limit, mcn)
print(beecolony.best_solution())
>>> {
'solution': [2.7091476396022223e-15, -1.998092029953233e-15],
'function': 0.0,
'fitness': 1.0,
'trial': 39
}
- Clone this repo to your local machine using
https://github.com/juadolfob/Artificial_Bee_Colony_Algorithm
todo: gradient optimization bfgs ACO
Copyright (c) 2020 juadolfob