Bees algorithm
In computer science and operations research, the bees algorithm is a population-based search algorithm which was developed by Pham, Ghanbarzadeh et al. in 2005. It mimics the food foraging behaviour of honey bee colonies. In its basic version the algorithm performs a kind of neighbourhood search combined with global search, and can be used for both combinatorial optimization and continuous optimization. The only condition for the application of the bees algorithm is that some measure of distance between the solutions is defined. The effectiveness and specific abilities of the bees algorithm have been proven in a number of studies.
Metaphor
A colony of honey bees can extend itself over long distances and in multiple directions simultaneously to harvest nectar or pollen from multiple food sources.A small fraction of the colony constantly searches the environment looking for new flower patches. These scout bees move randomly in the area surrounding the hive, evaluating the profitability of the food sources encountered. When they return to the hive, the scouts deposit the food harvested. Those individuals that found a highly profitable food source go to an area in the hive called the “dance floor”, and perform a ritual known as the waggle dance.
Through the waggle dance a scout bee communicates the location of its discovery to idle onlookers, which join in the exploitation of the flower patch. Since the length of the dance is proportional to the scout’s rating of the food source, more foragers get recruited to harvest the best rated flower patches. After dancing, the scout returns to the food source it discovered to collect more food.
As long as they are evaluated as profitable, rich food sources will be advertised by the scouts when they return to the hive. Recruited foragers may waggle dance as well, increasing the recruitment for highly rewarding flower patches. Thanks to this autocatalytic process, the bee colony is able to quickly switch the focus of the foraging effort on the most profitable flower patches.
Algorithm
The bees algorithm mimics the foraging strategy of honey bees to look for the best solution to an optimisation problem. Each candidate solution is thought of as a food source, and a population of n agents is used to search the solution space. Each time an artificial bee visits a flower, it evaluates its profitability.The bees algorithm consists of an initialisation procedure and a main search cycle which is iterated for a given number T of times, or until a solution of acceptable fitness is found. Each search cycle is composed of five procedures: recruitment, local search, neighbourhood shrinking, site abandonment, and global search.
Pseudocode for the standard bees algorithm
1 for i=1,…,ns
i scout=Initialise_scout
ii flower_patch=Initialise_flower_patch
2 do until stopping_condition=TRUE
i Recruitment
ii for i =1,...,nb
1 flower_patch=Local_search
2 flower_patch=Site_abandonment
3 flower_patch=Neighbourhood_shrinking
iii for i = nb,...,ns
1 flower_patch=Global_search
Variants
In addition to the basic bees algorithm, there are a number of improved or hybrid versions of the BA, each of which focuses on some shortcomings of the basic BA. These variants include fuzzy or enhanced BA, grouped BA, hybrid modified BA and so on.The pseudo-code for the grouped BA is as follows.
function GBA
%% Set the problem parameters
maxIteration =..; % number of iterations
maxParameters =..; % number of input variables
min = ; % an array of the size maxParameters to indicate the minimum value of each input parameter
max = ; % an array of the size maxParameters to indicate the maximum value of each input parameter
%% Set the grouped bees algorithm parameters
R_ngh =..; % patch radius of the neighborhood search for bees in the first group
n =..; % number of scout bees
nGroups =..; % number of groups, excluding the random group
%% GBA's automatic parameter settings
k = 3 * n / ; % GBA's parameter to set the number of scout bees in each group
groups = zeros; % An array to keep the number of scout bees for each group
recruited_bees = zeros; % An array to keep the number of recruited bees for each group
a = - R_ngh)./ ; % GBA's parameter for setting neighborhood radiuses
b = R_ngh - a; % GBA's parameter for setting neighborhood radiuses
for i=1:nGroups % For each group
groups = floor; % determine the number of scout bees in each group
if groups 0
groups = 1; % there has to be at least one scout bee per each group
end
recruited_bees = ^2; % set the number of recruited bees for each group
ngh = a * i*i + b; % set the radius patch for each group
end
group_random = n - sum; % assign the remainder bees to random search
group_random = max; % make sure it is not a negative number
%% initialize the population matrix
population = zeros; % A population of n bees including all input variables and their fitness
for i=1:n
population= generate_random_solution; % random initialization of maxParameters variables between max and min
population = evalulate_fitness; % fitness evaluation of each solution and saving it at the last index of the population matrix
end
sorted_population = sortrows; % sort the population based on their fitnesses
%% Iterations of the grouped bees algorithm
for i=1:maxIteration % GBA's main loop
beeIndex = 0; % keep track of all bees
for g=1:nGroups % for each group of scout bees
for j = 1 : groups % exploit each patch within each group
beeIndex = beeIndex + 1; % increase the counter per each patch
for i = 1 : recruited_bees % for each recruited bees of the group
solution = bee_waggle_dance,ngh); % search the neighborhood around selected patch/solution within the radius of ngh
fit = evaluate_fitness; % evaluate the fitness of recently found solution
if fit < sorted_population % A minimization problem: if a better location/patch/solution is found by the recuiter bee
sorted_population = ; % copy new solution and its fitness to the sorted population matrix
end
end
end
end
for i= 1 : group_random % For the remaining random bees
beeIndex = beeIndex + 1;
solution= generate_random_solution; % generate a new random solution at the index beeIndex
solution= evaluate_fitness; % evaluate its fitness
sorted_population = ; % copy the new random solution and its fitness to the sorted population matrix
end
sorted_population=sortrows; % sort the population based on their fitnesses
Best_solution_sofar=sorted_population;
disp;disp; % Display the best solution of current iteration
end % end of GBA's main loop
end % end of main function
%% Function Bee Waggle Dance
function new_solution=bee_waggle_dance
new_solution = +;
end