【布局优化】基于粒子群算法求解传感器覆盖问题matlab源码含 GUI
发布日期:2021-05-04 12:56:07 浏览次数:23 分类:技术文章

本文共 8006 字,大约阅读时间需要 26 分钟。

一、简介

1 粒子群算法的概念

粒子群优化算法(PSO:Particle swarm optimization) 是一种进化计算技术(evolutionary computation)。源于对鸟群捕食的行为研究。粒子群优化算法的基本思想:是通过群体中个体之间的协作和信息共享来寻找最优解.
PSO的优势:在于简单容易实现并且没有许多参数的调节。目前已被广泛应用于函数优化、神经网络训练、模糊系统控制以及其他遗传算法的应用领域。

2 粒子群算法分析

2.1基本思想
粒子群算法通过设计一种无质量的粒子来模拟鸟群中的鸟,粒子仅具有两个属性:速度和位置,速度代表移动的快慢,位置代表移动的方向。每个粒子在搜索空间中单独的搜寻最优解,并将其记为当前个体极值,并将个体极值与整个粒子群里的其他粒子共享,找到最优的那个个体极值作为整个粒子群的当前全局最优解,粒子群中的所有粒子根据自己找到的当前个体极值和整个粒子群共享的当前全局最优解来调整自己的速度和位置。下面的动图很形象地展示了PSO算法的过程:
在这里插入图片描述
2 更新规则
PSO初始化为一群随机粒子(随机解)。然后通过迭代找到最优解。在每一次的迭代中,粒子通过跟踪两个“极值”(pbest,gbest)来更新自己。在找到这两个最优值后,粒子通过下面的公式来更新自己的速度和位置。
在这里插入图片描述
公式(1)的第一部分称为【记忆项】,表示上次速度大小和方向的影响;公式(1)的第二部分称为【自身认知项】,是从当前点指向粒子自身最好点的一个矢量,表示粒子的动作来源于自己经验的部分;公式(1)的第三部分称为【群体认知项】,是一个从当前点指向种群最好点的矢量,反映了粒子间的协同合作和知识共享。粒子就是通过自己的经验和同伴中最好的经验来决定下一步的运动。以上面两个公式为基础,形成了PSO的标准形式。
在这里插入图片描述
公式(2)和 公式(3)被视为标准PSO算法。
3 PSO算法的流程和伪代码
在这里插入图片描述

二、源代码

function varargout = GUI_PSO(varargin)% GUI_PSO MATLAB code for GUI_PSO.fig%      GUI_PSO, by itself, creates a new GUI_PSO or raises the existing%      singleton*.%%      H = GUI_PSO returns the handle to a new GUI_PSO or the handle to%      the existing singleton*.%%      GUI_PSO('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in GUI_PSO.MyFirstText with the given input arguments.%%      GUI_PSO('Property','Value',...) creates a new GUI_PSO or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before GUI_PSO_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stopf.  All inputs are passed to GUI_PSO_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 GUI_PSO% Last Modified by GUIDE v2.5 20-May-2015 09:59:43% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @GUI_PSO_OpeningFcn, ...                   'gui_OutputFcn',  @GUI_PSO_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif 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 GUI_PSO is made visible.function GUI_PSO_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 GUI_PSO (see VARARGIN)% Choose default command line output for GUI_PSOhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes GUI_PSO wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = GUI_PSO_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 structurevarargout{1} = handles.output;function popsize_Callback(hObject, eventdata, handles)% hObject    handle to popsize (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of popsize as text%        str2double(get(hObject,'String')) returns contents of popsize as a double% --- Executes during object creation, after setting all properties.function popsize_CreateFcn(hObject, eventdata, handles)% hObject    handle to popsize (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');endfunction stopf_Callback(hObject, eventdata, handles)% hObject    handle to stopf (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of stopf as text%        str2double(get(hObject,'String')) returns contents of stopf as a double% --- Executes during object creation, after setting all properties.function stopf_CreateFcn(hObject, eventdata, handles)% hObject    handle to stopf (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');endfunction c1_Callback(hObject, eventdata, handles)% hObject    handle to c1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of c1 as text%        str2double(get(hObject,'String')) returns contents of c1 as a double% --- Executes during object creation, after setting all properties.function c1_CreateFcn(hObject, eventdata, handles)% hObject    handle to c1 (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');endfunction c2_Callback(hObject, eventdata, handles)% hObject    handle to c2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of c2 as text%        str2double(get(hObject,'String')) returns contents of c2 as a double% --- Executes during object creation, after setting all properties.function c2_CreateFcn(hObject, eventdata, handles)% hObject    handle to c2 (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');endfunction w1_Callback(hObject, eventdata, handles)% hObject    handle to w1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of w1 as text%        str2double(get(hObject,'String')) returns contents of w1 as a double% --- Executes during object creation, after setting all properties.function w1_CreateFcn(hObject, eventdata, handles)% hObject    handle to w1 (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

三、运行结果

在这里插入图片描述

四、备注

完整代码或者代写添加QQ1575304183

转载地址:https://blog.csdn.net/qq_34763204/article/details/116331035 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【预测模型】基于Elman神经网络开盘价预测matlab源码
下一篇:【图像去噪】基于全变分算法(TV)图像去噪matlab源码

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年03月09日 03时34分40秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

android studio 52 mp3下载客户端001 2019-04-21
android studio 53 mp3 2019-04-21
Android studio 53 文件下载 2019-04-21
android studio 54 下载进度条 2019-04-21
android studio 70 歌曲服务器搭建 歌曲app 完整代码(发布版) 2019-04-21
Android单击事件处理与监听003 2019-04-21
vb 读取mysql所有表名_vb怎么列举出一个mdb数据库里面所有表名? 2019-04-21
mysql行级锁升级_mysql innodb 行级锁升级 2019-04-21
c 调用mysql密码为空_C语言连MySQL - osc_srnunz15的个人空间 - OSCHINA - 中文开源技术交流社区... 2019-04-21
mysql怎么分组查询所有数据库_Mysql-4 分组查询与子查询 2019-04-21
mysql 多列union_Mysql联合查询UNION和UNION ALL的使用介绍 2019-04-21
mysql导数据出指定数量_mysql导出指定数据或部份数据的方法 2019-04-21
java thread 多线程_java用Thread方式创建多线程 2019-04-21
java 注解与反射_Java注解与反射直接上手 2019-04-21
java按钮退出_java – 如何在此程序中添加退出按钮?怎么样“清楚”? 2019-04-21
python土味情话_Python 将土味情话语录设置为桌面壁纸 2019-04-21
java ip 范围内打卡_定位地理位置PHP判断员工打卡签到经纬度是否在打卡之内 2019-04-21
与java线程有关的,线程多少和什么有关?大神们表示有话要说! 2019-04-21
php正则表达式 匹配数字,正则表达式之匹配数字范围 2019-04-21
php中带?错误,参考-此错误在PHP中意味着什么? 2019-04-21