# bees

Bees in nature can always find high-quality nectar sources with high efficiency in any environment, and can adapt to changes in the environment. The nectar harvesting system of honeybee colony is composed of nectar source, hired bees and non-hired bees. The merits and demerits of a nectar source have many factors, such as the size of nectar source, the distance from the hive, the difficulty of extraction, etc. The hired bees contacted the specific nectar source and told the nectar source information to their companions in a certain probability form. The responsibility of non-hired bees is to find the nectar source to be mined. There are two types of bees: follower bees and scout bees. The following peak is waiting in the hive and scout bees are exploring the new nectar source around the hive. When bees collect honey, part of the bees in the hive act as scouts, constantly and randomly looking for nectar sources near the hive. If they find nectar sources exceeding a certain threshold value, the scouts turn into hired bees and start to hunt honey. After collecting nectar, they fly back to the hive and dance to inform them to follow the peak. Swing dance is a basic form of information communication between bees, which conveys important information about nectar sources around the hive, such as nectar source direction and distance from the nest, etc., and the quality of nectar sources around the hive is accurately evaluated by following the peak. When the hired bees have finished their waggle dance, they return to the source of the honey with some followers from the hive. The number of followers depends on the quality of the source. In this way, the colony can quickly and efficiently locate the nectar source with the highest nectar yield.

The swarm intelligence of honeybees is realized through communication and cooperation between different roles. The specific honey gathering process is shown in the figure. In the initial stage, the bees in the form of scouts, and honeycomb weeks Wei honey no understand, because the bee internal motivation and external conditions of different scouts have two choices: 1) become employed bees, began to random search honey around the hive, as shown in figure in line (2) be follow peak, began the search after observing the swing nectar source, as shown in figure in the route. Suppose that two nectar sources are found and, after finding the nectar source, the scout bee becomes a hire bee. The hire bee uses its own attributes to remember the location of the nectar source and immediately invests in the nectar gathering. After collecting nectar, the bees return to the hive with a full load of nectar and unload the nectar to the unloading chamber. After unloading, the hired bees have three possible behaviors: (1) to abandon the nectar source they found was not high, and become an unrestrained non-hired bee, as shown in the figure; (2) in

Do a swing dance in the recruiting area, recruiting some to stay in the hive to follow the peak and lead them back to the path shown in the picture. ③ Do not recruit other bees and continue to return to the original nectar source to collect honey as shown in the picture. In real life, not all bees start to collect honey right away, and most bees return to the recruiting area and do a swing dance to recruit more bees.

# Algorithm model

Artificial bee colony algorithm is a new intelligent optimization algorithm which simulates the honey gathering process of bees. It is also composed of three parts: food source, hired bees and non-hired bees.

Food source: Food source is honey source. In any optimization problem, the feasible solution is given in a certain form. In the artificial bee colony algorithm, food source is the feasible solution of the problem to be optimized, and it is the basic object to be dealt with in the artificial bee colony algorithm. The quality of food source is evaluated by the size of nectar from nectar source, namely fitness.

Hireling bees: Hireling bees correspond to the location of the food source, one food source corresponds to one hireling bee. In the artificial colony algorithm, the number of food sources is equal to the number of lead bees. The task of the guide bees is to discover the food source information and share it with the following bees in a certain probability. The calculation of probability is the selection strategy in artificial bee colony algorithm, which is generally calculated by roulette based on fitness value.

Non-hire bees: Non-hire bees include follower bees and scout bees follow bees in the recruitment area of the hive to select a food source based on nectar information provided by the guide bees, while scout bees search for new food sources near the hive. In artificial swarm algorithm, follower bees search for new food sources near the food sources according to the information delivered by the leader bees and make greedy selection. If a food source has not been renewed after several times, the lead bee becomes a scout, and the scout bee searches for a new food source to replace the original food source.

# Algorithmic search process

In the artificial bee colony algorithm, artificial bees are divided into three types: lead bees, follow bees and scout bees. In each search process, the lead bees and the scout bees mine the food source successively to find the optimal solution, while the scout bees observe whether they fall into the local optimal. If they fall into the local optimal, they randomly search for other possible food sources. Each food source represents a possible solution to the problem, and the amount of nectar of the food source corresponds to the quality (fitness value FITI) of the corresponding solution.

I. in the search process of artificial bee colony algorithm, initialization is required first, including the determination of population number, maximum number of iterations MCN, control parameter limit and the determination of search space, i.e., the range of solution, in which initial solution xi(I =1,2,3… ,SN),SN is the number of food sources, each solution xi is a d-dimensional vector, and D is the dimension of the problem. After initialization, the whole population would repeat the search process of lead, follow and scout bees until the maximum number of iterations MCN or allowable error ε was reached.

2. At the beginning of the search process, each lead bee generates a new solution, i.e. a new food source, from Equation (2-3).

Vij = xij + Φ ij (xij XKJ) – (2-3)

Type, * * k ∈ {1, 2,… , SN}, j ∈ {1, 2,… , D}, * * indicates the I and k; φ ij is a random number between [-1,1]. Calculate the FITI of the new solution and evaluate it. If the FITI of the new solution is better than the old one, the bees are led to remember the new solution and forget the old one. Instead, it preserves the old solution.

3. After all the leader bees have completed the search, the leader bees will dance in the recruitment area to share the information and information with the following bees. The following bee calculates the selection probability of each solution according to the formula,

PI = fiti / ∑ snfitk k = 1. (2-4)

Then a number is randomly generated in the interval [-1,1]. If the probability value of the solution is greater than the random number, the follower bees will generate a new solution from Equation (2-3) and test the FITI of the new solution. If the FITI of the new solution is better than the previous one, the follower bees will remember the new solution and forget the old one. Instead, it preserves the old solution.

4. If a solution has not been further updated after the limit cycle after all the following bees have completed the search process, the solution is considered to be trapped in the local optimal, and the food source will be abandoned. If food source XI is abandoned, the lead bee corresponding to this food source becomes a scout bee. The scout bee produces a new food source from Equations (2-5) to replace it.

Xij xminj + = rand (0, 1) (xmaxj – xminj) (2-5)

The j ∈ {1, 2… , D}. It then returns to the lead bee search and begins the cycle again.

5. Generally, the larger the quality of food source of artificial bee colony algorithm is, the better, that is, the larger the fitness value is, the better. Corresponding to the problem to be optimized, it needs to be considered in two cases: minimum and maximum problem. Fi is assumed to be the objective function of the optimization problem, so if the fitness function is the deformation of FI when optimizing the minimum value problem, it is generally expressed by Formula (2-6). If the maximum problem is optimized, the fitness function is the objective function.

fiti={1+abs(fi) fi>=01/1+fi fi>0 (2-6)

Artificial bee colony algorithm generally conducts greedy selection according to Formula (2-7) when evaluating food sources.

vi={xi fit(xi)<=fit(vi)vi fit(vi)>fit(xi) (2-7)

Artificial swarm algorithm is to find the optimal food source or the optimal solution through circular search.

# Algorithm steps

Specific implementation steps of artificial bee colony algorithm are as follows:

Step 1: initialize the population: initialize each parameter, including the total number of bee colonies SN, the number of food sources being collected (i.e., the maximum number of iterations MCN) and the control parameter limit, determine the search range of the problem, and randomly generate the initial solution xi(I =1,2… SN).

Step 2: Calculate and evaluate the fitness of each initial solution.

Step 3: Set the loop condition and start the loop

Step 4: The leader bees conducted neighborhood search for solution XI according to Formula (2-3) to generate a new solution (food source) VI, and calculated its fitness value;

Step 5: Greedy selection is made according to Formula (2-7) : if the fitness value of VI is better than xi, xi is replaced by VI, and vi is regarded as the current best solution; otherwise, XI is kept unchanged;

Step 6: Calculate the probability PI of food source according to Equation (2-4);

Step 7: Follow bees select solution or food source according to probability PI, search and generate new solution (food source) VI according to Formula (2-3), and calculate its fitness.

Step 8: Make greedy selection according to Formula (2-7); If the fitness of vi is better than that of XI, replace xi with vi and take vi as the current best solution; otherwise, xi remains unchanged;

Step 9: Determine if there are any solutions to abandon. If so, the scout bees randomly generate new solutions to replace them according to Equation (2-5).

Step 10: Record the optimal solution so far;

Step 11: Determine whether the loop termination conditions are met. If so, the loop ends and the optimal solution is output; otherwise, return to Step 4 to continue searching.

`% % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- information extraction procedure -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the clear all; close all; clc; rand('state', sum(100*clock)); format bank; % - the number of test samples under the four files - seq_dataset =,18,54,18 [21]; % number of test examples in set2-set5 %---- parameter Settings ---- runs = 20; Max_iter = 500000; % the maximum number of iterations of each experiment is 500k % the total amount of data in each folder is 21,18,54,18 respectively; % folder sequence number: 1-4-> set2-set5; %----Start---- tic for num_folder = 1:4% 1:4% Serial numbers of folders: 1-4 Corresponding folders set2-set5; seq_data = seq_dataset(num_folder); % num_folder Total number of test samples in the folder nn = seq_data; The second problem in %set2 result.name=0; result.val=0; all_result_pool=cell(1,nn); For SEq = 1: SEq_data %1:seq_data %---- Warehouse, satellite, customer coordinates, vehicle information and customer requirements for extracting files ---- % COORD_DEp: warehouse coordinates % COord_SAT: satellite (transfer station) coordinates %coord_cus: Client coordinates % fleet: vehicle information, fleet (1, 1) for the first layer of the maximum load for vehicle fleet (1, 2) for the first layer can use number of vehicle fleet (2, 1) for the second maximum load of the vehicle fleet (2, 2) the second layer can be used as the vehicle number of % demand: [COord_DEp, COord_sat, Coord_cus, Fleet,demand,name] = ExtractData (num_Folder,seq); [result_pool, fitness_pool] = run_abc (coord_dep coord_sat, coord_cus, fleet, demand, 50100); minval = min(fitness_pool); id = find(minval==fitness_pool); result_best = result_pool{id(1)}; % plot tool draw_plot(result_best,coord_dep,coord_sat,coord_cus,name); [s2s_dist,s2d_dist,c2s_dist,c2c_dist] =compute_dist2(coord_dep,coord_sat,coord_cus); result.name = name; result.val = minval; result.path = result_best; all_result_pool{seq} = result; %% lay_out(result_best,name,demand, c2C_dist, c2S_dist, s2D_dist,s2s_dist,minval,fleet); end save all_result_pool all_result_pool; end tocCopy the code`

Complete code or simulation consulting to add QQ1575304183