A list,
1 profileAn algorithm designed to simulate ant foraging behavior (shortest path principle). Take the characteristics of ant foraging and abstract them into a mathematical description.
• Ant Colony Algorithm (ACA) was first proposed by Marco Dorigo in 1992 in his doctoral thesis. • Ants release a pheromone in their path as they search for a food source and are able to sense the pheromone released by other ants. The pheromone concentration represents the distance of the path. The higher the pheromone concentration, the shorter the corresponding path distance. • In general, ants preferentially choose the path with a higher pheromone concentration, and release a certain amount of pheromone to enhance the pheromone concentration in that path, thus creating a positive feedback. Eventually, the ants are able to find the best route from the nest to the food source, which is the shortest distance. • Biologists have also found that pheromone concentrations along the pathway decline over time. • Ant colony algorithm is applied to solve optimization problems. The basic idea is that the feasible solution of the problem to be optimized is represented by the ant walking path, and all the paths of the entire ant colony constitute the solution space of the problem to be optimized. With the advance of time, the concentration of pheromone accumulated on the short path gradually increased, and the number of ants choosing the short path also increased. Finally, the entire ant will concentrate on the best path under the action of positive feedback, and then the corresponding optimal solution of the problem to be optimized. Analogizing GA (genetic algorithm) crossover, selection, mutation, PSO (particle swarm optimization) of individual, population extreme value optimization, ANT colony algorithm also has its own optimization strategy: positive feedback information mechanism, pheromone concentration update, ants can access the path selection.
2. Basic IdeasThe basic principle of ant colony algorithm comes from the shortest path principle of ants foraging in nature. According to the observation of entomologists, it is found that although the natural ant vision is underdeveloped, it can find the shortest path from the food source to the nest without any hint, and can adapt to search for the best new path when the environment changes (such as obstacles on the original path). How do ants do this? It turns out that ants in search of a food source can place pheromones, or pheromones, which are unique to ants, along their path, so that other ants within a certain range can detect them and influence their future behavior. When their ants’ through some path, its left by more and more, so that the pheromone strength increase (of course, with the passage of time will gradually weaken, so the ant chooses the path of the probability is higher, thus increased the path pheromone intensity, the selection process is referred to as the catalytic behavior of ants. Since the principle is a positive feedback mechanism, the ant kingdom can also be understood as a so-called enhanced learning system. Here we use a diagram to illustrate the principle of ants’ shortest path selection for foraging, as shown in the figure. In, suppose there is an obstacle between point A and point B, which is the ant’s nest, and point B, which is the food, then the ant going from point A to point B must decide whether to go left or right, and the ant going from point B to point A must also decide which path to take. This decision is influenced by the concentration of previous pheromones (known as residual pheromone concentrations) left by ants along each path. If the pheromone concentration on the right path was higher, the right path was more likely to be selected by the ant. But the first group of ants, with little or no pheromone influence, were just as likely to go left or right, as the figure shows. With the progress of foraging process, pheromone intensity on each road began to change, some lines were strong, some lines were weak. Let’s take an ant going from point A to point B (the process is basically the same for an ant going from point B to point A). Since the path ADB is shorter than the path ACB, the first ant that chooses ADB arrives at point B sooner than the first ant that chooses ACB. At this point, from point B to point A, the pheromone concentration on path BDA A is larger than that on path BCA. Therefore, from the next moment, the ants from point B to point A are more likely to choose THE BDA path than the BCA path, which further enhances the pheromone on the ABDA route. As A result, the ants that choose the path based on the pheromone intensity of D gradually prefer the path ADB, as shown in the figure. Over time, almost all the ants chose the ADB(or BDA) path to carry the food, and we also found that the ADB path was actually the shortest path. The principle of this colony path finding can be simply understood as follows: for individual ants, there is no subjective intention to find the shortest path; But for the entire ant colony, they do have the visual effect of finding the shortest path. In nature, the process of ant colony searching for a path is a positive feedback process, and the “ant colony algorithm” is derived by simulating the principle of ants foraging for the shortest path in biology. For example, if we consider work units with simple functions as “ants”, then the process of path finding can be used to explain the optimization process of human worker ant colony in ant colony algorithm. That’s the basic idea of ant colony algorithm.3 process of algorithm designHere in the TSP problem, for example, the algorithm design process is as follows: step 1: initialize the related parameters, including ant colony size, pheromone factor, heuristic function factor, pheromone volatilization factor, information used to number and maximum number of iterations, as well as the data is read in the program, and preprocessing, such as the city information is converted to the coordinates of the distance between the matrix. Step 2: Randomly place ants at different starting points and calculate the next city to visit for each ant until all the cities have been visited. Step 3: Calculate the path length Lk of each ant, record the optimal solution of the current iteration times, and update the pheromone concentration on the path. Step 4: Check whether the maximum number of iterations is reached. If not, return to Step 2. Yes, terminate the program. Step 5: Output the results, and output relevant indicators in the optimization process as required, such as running time, convergent iterations, etc.
4 Mathematical Model
Ii. Source code
function varargout = antinface(varargin)
% ANTINFACE M-file for antinface.fig
% ANTINFACE, by itself, creates a new ANTINFACE or raises the existing
% singleton*.
%
% H = ANTINFACE returns the handle to a new ANTINFACE or the handle to
% the existing singleton*.
%
% ANTINFACE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ANTINFACE.M with the given input arguments.
%
% ANTINFACE('Property'.'Value',...). creates anew ANTINFACE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before antinface_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to antinface_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 antinface
% Last Modified by GUIDE v2. 5 02-Jun- 2021. 10:29:35
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @antinface_OpeningFcn, ...
'gui_OutputFcn', @antinface_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 antinface is made visible.
function antinface_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 antinface (see VARARGIN)
% Choose default command line output for antinface
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
h=waitbar(0.'Please wait for...... ');
for i=1:100
waitbar(i/100);
end
delete(h);
% UIWAIT makes antinface wait for user response (see UIRESUME)
% uiwait(handles.handles);
% --- Outputs from this function are returned to the command line.
function varargout = antinface_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
function edit_antsum_Callback(hObject, eventdata, handles)
% hObject handle to edit_antsum (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_antsum as text
% str2double(get(hObject,'String')) returns contents of edit_antsum as a double
% --- Executes during object creation, after setting all properties.
function edit_antsum_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_antsum (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
Copy the code
Third, the operation result
Fourth, note
Version: 2014 a