Artificial Bee Colony¶
Artificial Bee Colony.
artificial_bee_colony(problem, *, stop, rng=None, colony_size=20, limit=50, neighbor=swap_neighbor, max_neighbor_tries=100, max_start_tries=1000)
¶
Colony of colony_size food sources (solutions). One iteration:
- employed bees: each source tries one neighbour, kept if better;
- onlooker bees:
colony_sizetimes, pick a source by binary tournament (works for any value sign), try a neighbour, keep if better; - scouts: a source that failed to improve more than
limittimes is replaced by a freshproblem.generate(rng)solution.
Infeasible neighbours are redrawn up to max_neighbor_tries times,
else the attempt counts as a failure. history is the best value after
each iteration (first entry: the initial colony); metadata has
evaluations, termination ('stop') and state. Each iteration costs about
2 * colony_size evaluations (more when scouts fire).
bit_flip_neighbor(solution, rng)
¶
Binary move: flip one random bit.
gaussian_neighbor(solution, rng, sigma=0.1)
¶
Continuous move: add N(0, sigma) to one random coordinate. Bounds are
left to Problem.feasible (infeasible moves are redrawn).
swap_neighbor(solution, rng)
¶
Permutation move: swap two random positions.
two_opt_neighbor(solution, rng)
¶
Permutation move: reverse a random segment (2-opt).