1, Introduction
1 origin and development of ant colony algorithm (ACA)
In the process of studying the new algorithm, Marco Dorigo and others found that when ant colony is looking for food, they can exchange foraging information by secreting a biological hormone called pheromone, so they can quickly find the target. Therefore, in their doctoral thesis in 1991, they systematically proposed a new intelligent optimization algorithm "Ant system (AS) based on ant population for the first time. Later, The proposer and many researchers have made various improvements to the algorithm and applied it to a wider range of fields, such AS graph coloring problem, quadratic assignment problem, workpiece scheduling problem, vehicle routing problem, job shop scheduling problem, network routing problem, large-scale integrated circuit design and so on. In recent years, M.Dorigo and others have further developed ant algorithm into a general optimization technology "Ant Colony Optimization (ACO)", and called all algorithms in line with ACO framework "ACO algorithm".
Specifically, each ant starts looking for food without telling where the food is in advance. When one finds food, it will release a volatile secretion pheromone (called pheromone, which will gradually volatilize and disappear over time. The pheromone concentration represents the distance of the path). Pheromone can be perceived by other ants and play a guiding role. Usually, when there are pheromones on multiple paths, ants will preferentially choose the path with high pheromone concentration, so that the pheromone concentration of the path with high concentration is higher, forming a positive feedback. Some ants do not always repeat the same path as other ants. They will find another way. If the other path is shorter than the original one, then gradually, more ants are attracted to this shorter path. Finally, after a period of operation, the shortest path may be repeated by most ants. Finally, the path with the highest pheromone concentration is the optimal path finally selected by ants.
Compared with other algorithms, ant colony algorithm is a relatively young algorithm, which has the characteristics of distributed computing, no central control, asynchronous and indirect communication between individuals, and is easy to be combined with other optimization algorithms. After the continuous exploration of many people with lofty ideals, a variety of improved ant colony algorithms have been developed today, but the principle of ant colony algorithm is still the backbone.
2. Solution principle of ant colony algorithm
Based on the above description of ant colony foraging behavior, the algorithm mainly simulates the foraging behavior in the following aspects:
(1) The simulated graph scene contains two pheromones, one represents home and the other represents the location of food, and both pheromones are volatilizing at a certain rate.
(2) Each ant can only perceive information in a small part of its surroundings. When ants are looking for food, if they are within the perceptual range, they can go directly. If they are not within the perceptual range, they should go to the place with more pheromones. Ants can have a small probability not to go to the place with more pheromones and find another way. This small probability event is very important, which represents an innovation in finding a way and is very important for finding a better solution.
(3) The rules for ants to return to their nest are the same as those for finding food.
(4) When moving, the ant will first follow the guidance of pheromone. If there is no guidance of pheromone, it will go inertia according to its moving direction, but there is also a certain chance to change the direction. The ant can also remember the road it has traveled and avoid going to one place again.
(5) Ants leave the most pheromones when they find food, and then the farther away from the food, the less pheromones they leave. The rules for finding the amount of pheromone left in the nest are the same as those of food. Ant colony algorithm has the following characteristics: positive feedback algorithm, concurrency algorithm, strong robustness, probabilistic global search, independent of strict mathematical properties, long search time and easy to stop.
Ant transfer probability formula:
In the formula: is the probability of ant k transferring from city i to j; α,β The relative importance of pheromones and heuristic factors; Is the pheromone quantity on edge (i,j); Is heuristic factor; Select the city allowed for ant k next step. The above formula is the pheromone update formula in ant system, which is the amount of pheromone on edge (i,j); ρ Is pheromone evaporation coefficient, 0< ρ< 1; Is the pheromone quantity of the kth ant left on the edge (i,j) in this iteration; Q is a normal coefficient; Is the path length of the kth ant in this tour.
In ant system, pheromone update formula is:
3. Solving steps of ant colony algorithm:
(1) Initialization parameters at the beginning of calculation, relevant parameters need to be initialized, such as ant colony size (number of ants) m and pheromone importance factor α, Heuristic function importance factor β, Pheromone will send Silver ρ, Total pheromone release Q, maximum number of iterations iter_max, initial value of iteration times iter=1.
(2) The solution space is constructed. Each ant is randomly placed at different starting points. For each ant K (k=1,2,3... m), the next city to be visited is calculated according to (2-1) until all ants have visited all cities.
(3) Update the information, calculate the path length Lk(k=1,2,..., m) of each ant, and record the optimal solution (shortest path) in the current number of iterations. At the same time, the pheromone concentration on each urban connection path is updated according to equations (2-2) and (2-3).
(4) Judge whether to terminate if ITER < ITER_ Max, then make iter=iter+1, clear the record table of ant passing path, and return to step 2; Otherwise, the calculation is terminated and the optimal solution is output.
(5) Judge whether to terminate if ITER < ITER_ Max, then make iter=iter+1, clear the record table of ant passing path, and return to step 2; Otherwise, the calculation is terminated and the optimal solution is output. 3. Judge whether to terminate if ITER < ITER_ Max, then make iter=iter+1, clear the record table of ant passing path, and return to step 2; Otherwise, the calculation is terminated and the optimal solution is output.
2, Source code
function varargout = antinfacewzz(varargin) % ANTINFACEWZZ M-file for antinfacewzz.fig % ANTINFACEWZZ, by itself, creates a new ANTINFACEWZZ or raises the existing % singleton*. % % H = ANTINFACEWZZ returns the handle to a new ANTINFACEWZZ or the handle to % the existing singleton*. % % ANTINFACEWZZ('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ANTINFACEWZZ.M with the given input arguments. % % ANTINFACEWZZ('Property','Value',...) creates a new ANTINFACEWZZ or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before antinfacewzz_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to antinfacewzz_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help antinfacewzz % Last Modified by GUIDE v2.5 18-May-2021 16:07:17 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @antinfacewzz_OpeningFcn, ... 'gui_OutputFcn', @antinfacewzz_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before antinfacewzz is made visible. function antinfacewzz_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % varargin command line arguments to antinfacewzz (see VARARGIN) % Choose default command line output for antinfacewzz handles.output = hObject; % Update handles structure guidata(hObject, handles); h=waitbar(0,'Please wait......'); for i=1:100 waitbar(i/100); end delete(h); % UIWAIT makes antinfacewzz wait for user response (see UIRESUME) % uiwait(handles.handles); % --- Outputs from this function are returned to the command line. function varargout = antinfacewzz_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function edit_initao_Callback(hObject, eventdata, handles) % hObject handle to edit_initao (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_initao as text % str2double(get(hObject,'String')) returns contents of edit_initao as a double % --- Executes during object creation, after setting all properties. function edit_initao_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_initao (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_q_Callback(hObject, eventdata, handles) % hObject handle to edit_q (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_q as text % str2double(get(hObject,'String')) returns contents of edit_q as a double % --- Executes during object creation, after setting all properties. function edit_q_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_q (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_alpha_Callback(hObject, eventdata, handles) % hObject handle to edit_alpha (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_alpha as text % str2double(get(hObject,'String')) returns contents of edit_alpha as a double % --- Executes during object creation, after setting all properties. function edit_alpha_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_alpha (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_rou_Callback(hObject, eventdata, handles) % hObject handle to edit_rou (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_rou as text % str2double(get(hObject,'String')) returns contents of edit_rou as a double % --- Executes during object creation, after setting all properties. function edit_rou_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_rou (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_beta_Callback(hObject, eventdata, handles) % hObject handle to edit_beta (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_beta as text % str2double(get(hObject,'String')) returns contents of edit_beta as a double % --- Executes during object creation, after setting all properties. function edit_beta_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_beta (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_ncmax_Callback(hObject, eventdata, handles) % hObject handle to edit_ncmax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user state (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_ncmax as text % str2double(get(hObject,'String')) returns contents of edit_ncmax as a double % --- Executes during object creation, after setting all properties. function edit_ncmax_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_ncmax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
3, Operation results
4, Remarks
Version: 2014a