A list,

Particle swarm Optimization (PSO) is an evolutionary computation technology. It comes from the study of predation behavior in flocks of birds. The basic idea of particle swarm optimization algorithm is to find the optimal solution through the cooperation and information sharing among individuals in the group. The advantage of PSO is that it is simple and easy to implement without many parameters adjustment. It has been widely used in function optimization, neural network training, fuzzy system control and other applications of genetic algorithms.

2. Analysis of particle swarm optimization

2.1 Basic Ideas

Particle swarm optimization (PSO) simulates a bird in a flock by designing a massless particle that has only two properties: speed and position. Speed represents how fast the bird moves, and position represents the direction of the bird. Each particle separately searches for the optimal solution in the search space, and records it as the current individual extreme value, and shares the individual extreme value with other particles in the whole particle swarm, and finds the optimal individual extreme value as the current global optimal solution of the whole particle swarm. All particles in a swarm adjust their speed and position based on the current individual extremum they find and the current global optimal solution shared by the whole swarm. The following GIF vividly shows the process of the PSO algorithm:



2 Update Rules

PSO initializes as a group of random particles (random solutions). Then find the optimal solution through iteration. At each iteration, the particle updates itself by tracking two “extreme values” (PBest, GBest). After finding these two optimal values, the particle updates its velocity and position by using the formula below.



The first part of formula (1) is called [memory term], which represents the influence of the magnitude and direction of the last speed. The second part of Formula (1) is called [self cognition term], which is a vector pointing from the current point to the particle’s own best point, indicating that the particle’s action comes from its own experience. The third part of Formula (1) is called [group cognition term], which is a vector from the current point to the best point of the population, reflecting the cooperation and knowledge sharing among particles. The particle is determined by its own experience and the best experience of its companions. Based on the above two formulas, the standard form of PSO is formed.



Formula (2) and Formula (3) are regarded as standard PSO algorithms.

3. Process and pseudocode of PSO algorithm

Ii. Source code

function varargout = GUIbiyeshiji(varargin)
% GUIBIYESHIJI M-file for GUIbiyeshiji.fig
%      GUIBIYESHIJI, by itself, creates a new GUIBIYESHIJI or raises the existing
%      singleton*.
%
%      H = GUIBIYESHIJI returns the handle to a new GUIBIYESHIJI or the handle to
%      the existing singleton*.
%
%      GUIBIYESHIJI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUIBIYESHIJI.M with the given input arguments.
%
%      GUIBIYESHIJI('Property'.'Value',...). creates anew GUIBIYESHIJI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUIbiyeshiji_OpeningFunction gets called.  An
%      unrecognized property name orinvalid value makes property application % stop. All inputs are passed to GUIbiyeshiji_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 GUIbiyeshiji

% Last Modified by GUIDE v2. 5 22-May- 2021. 03:05:52

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUIbiyeshiji_OpeningFcn, ...
                   'gui_OutputFcn',  @GUIbiyeshiji_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 GUIbiyeshiji is made visible.
function GUIbiyeshiji_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 data (see GUIDATA)
% varargin   command line arguments to GUIbiyeshiji (see VARARGIN)

% Choose default command line output for GUIbiyeshiji
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUIbiyeshiji wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = GUIbiyeshiji_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 data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc; clear; %close(1); close(2); close(3); close(4);
handles=guihandles;
p1=get(handles.edit1,'String'); p=eval(p1); Object_num=p; Number of obstacles of % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % random obstacles points % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% num=Object_num; x=rand(num,1);
y=rand(num,1);
point=[x,y];

% % load('D:\MATLAB71\work\ Graduation design \ goodPoint.mat ')
% % x=point(:,1); y=point(:,2); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % on the dot graph drawing obstacle environment % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% global photo_ll photo_cc photo; photo_ll=300; photo_cc=300;
photo=ones(photo_ll,photo_cc);
[photo_point,aaa]=plot2photo(point);

[photo_point_amount,aaa]=size(photo_point);
for i=1:photo_point_amount
    photo_point_around=square(photo_point(i,:),15); % % % % % % % % % % % % % % % % % % % % draw the graphics of the size of the aaa = blacken_photo (photo_point_around); end global photo_connect_points; photo_connect_points=photo;figure
imshow(photo)
title('Obstructed environment')

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc; clear; %close(1); close(2); close(3); close(4);
handles=guihandles;
p1=get(handles.edit1,'String'); p=eval(p1); Object_num=p; Number of obstacles of % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % random obstacles points % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% num=Object_num; x=rand(num,1);
y=rand(num,1);
point=[x,y];

% % load('D:\MATLAB71\work\ Graduation design \ goodPoint.mat ')
% % x=point(:,1); y=point(:,2); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % on the dot graph drawing obstacle environment % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% global photo_ll photo_cc photo; photo_ll=300; photo_cc=300;
photo=ones(photo_ll,photo_cc);
[photo_point,aaa]=plot2photo(point);

[photo_point_amount,aaa]=size(photo_point);
for i=1:photo_point_amount
    photo_point_around=square(photo_point(i,:),15); % % % % % % % % % % % % % % % % % % % % draw the graphics of the size of the aaa = blacken_photo (photo_point_around); end global photo_connect_points; photo_connect_points=photo; % % figure % % imshow(photo) % % title('Obstructed environment') %%%%%%%%%%% to obtain its Voronoi diagramfigure
voronoi(x,y)
title('Voronoi diagram of obstacle particles')
[connect_point,round_point_cell]=voronoin(point);
connect_point(1, :) = []; tri=delaunay(x,y);hold on
plot(point(:,1),point(:,2),'r*');
hold off

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc; clear; %close(1); close(2); close(3); close(4);
handles=guihandles;
p1=get(handles.edit1,'String'); p=eval(p1); Object_num=p; Number of obstacles of % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % random obstacles points % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% num=Object_num; x=rand(num,1);
y=rand(num,1);
point=[x,y];

% % load('D:\MATLAB71\work\ Graduation design \ goodPoint.mat ')
% % x=point(:,1); y=point(:,2); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % on the dot graph drawing obstacle environment % % % % % % % % % % % % % % % % % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% global photo_ll photo_cc photo; photo_ll=300; photo_cc=300;
photo=ones(photo_ll,photo_cc);
[photo_point,aaa]=plot2photo(point);

[photo_point_amount,aaa]=size(photo_point);
for i=1:photo_point_amount
    photo_point_around=square(photo_point(i,:),20); % % % % % % % % % % % % % % % % % % % % draw the graphics of the size of the aaa = blacken_photo (photo_point_around); end global photo_connect_points; photo_connect_points=photo; % % figure % % imshow(photo) % % title('Obstructed environment') %%%%%%%%%%% to obtain its Voronoi diagramfigure
voronoi(x,y)
close;
% %% title('Voronoi diagram of obstacle particles')
[connect_point,round_point_cell]=voronoin(point);
connect_point(1, :) = []; tri=delaunay(x,y);Copy the code

3. Operation results













Fourth, note

Version: 2014 a