一、粒子群算法简介

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 EDIT
gui_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{:});
elsegui_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_PSO
handles.output = hObject;% Update handles structure
guidata(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 structure
varargout{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

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.

【优化覆盖】基于matlab GUI粒子群算法求解传感器覆盖优化问题【含Matlab源码 709期】相关推荐

  1. 【优化算法】基于matlab量子粒子群算法求解单目标优化问题【含Matlab源码 2203期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]基于matlab量子粒子群算法求解单目标优化问题[含Matlab源码 2203期] 点击上面蓝色字体,直接付费下载,即可. 获 ...

  2. 【PSO TSP】基于matlab GUI粒子群算法求解旅行商问题【含Matlab源码 1334期】

    ⛄一.TSP简介 旅行商问题,即TSP问题(Traveling Salesman Problem)又译为旅行推销员问题.货郎担问题,是数学领域中著名问题之一.假设有一个旅行商人要拜访n个城市,他必须选 ...

  3. 【定位问题】RSSI和模拟退火优化粒子群算法求解无线传感器网络定位问题【含Matlab源码 1766期】

    ⛄一.简介 1 引言 随着物联网技术的发展,传感器之间通过通信方式连接在一起,构成了极为庞大的无线传感器网络,这使得传感器在各行各业的应用相当广泛[.然而,因为大规模抛撒的传感器节点无法全部配备价格昂 ...

  4. 【电力系统】基于matlab粒子群算法求解热电联产系统优化配置问题【含Matlab源码 2298期】

    ⛄一.热电联产系统优化配置问题 1 能量枢纽模型 能量枢纽模型通过增加能源的供给路径提升能源系统的经济性.灵活性和安全性[6].图1展示了一种典型的能量枢纽模型. 图1 典型能量枢纽模型示意图 1.2 ...

  5. 【ACO三维路径规划】基于matlab GUI蚁群算法无人机三维路径规划【含Matlab源码 254期】

    一.无人机简介 0 引言 随着现代技术的发展,飞行器种类不断变多,应用也日趋专一化.完善化,如专门用作植保的大疆PS-X625无人机,用作街景拍摄与监控巡察的宝鸡行翼航空科技的X8无人机,以及用作水下 ...

  6. 微电网优化调度|基于多目标粒子群算法的微电网优化调度【风、光、储能、柴油机、电网交互燃汽轮机】(Matlab代码实现)

  7. 【车间调度】粒子群算法求解6X6车间调度问题【含Matlab源码 411期】

    ⛄一.车间调度简介 1 车间调度定义 车间调度是指根据产品制造的合理需求分配加工车间顺序,从而达到合理利用产品制造资源.提高企业经济效益的目的.车间调度问题从数学上可以描述为有n个待加工的零件要在m台 ...

  8. 【多式联运】基于帝国企鹅算法、遗传算法、粒子群算法求解多式联运路径优化问题附matlab代码

    1 内容介绍 在军事运输中,采用多种运输方式联合投送是加强战略投送能力建设发展的重要途径,而路径规划是制定多式联运输送保障方案的关键第一步.本文提出了一个以遗传算法为主框架的解决方案,用来求解多式联运 ...

  9. 【微电网优化】基于量子行为粒子群算法机组燃烧控制系统建模含Matlab源码

    1 简介 能源问题与环境问题随着现代社会的快速发展已成为中国乃至全世界关注的焦点.就我国现状来说,由于独特的能源架构和社会形态,直接决定了我国的电力工业在当今乃至未来相当长的一段时期内将以燃煤火电机组 ...

  10. 【优化求解】基于粒子群算法求解多目标优化问题matlab源码

    [优化求解]基于粒子群算法求解多目标优化问题matlab源码 1 算法介绍 1.1 关于速度和位置 粒子群算法通过设计一种无质量的粒子来模拟鸟群中的鸟,粒子仅具有两个属性:速度和位置,速度代表移动的快 ...

最新文章

  1. java基础----Runtime类的使用(一)
  2. 高性能MySQL读书笔记---查询优化
  3. 剑指Offer - 面试题50. 第一个只出现一次的字符(unordered_map)
  4. spring的事务隔离_spring事务基础及常见问题详解
  5. Bootstrap导航条中组件的排列
  6. Anaconda中如何查看已经安装的包
  7. Ubuntu 14.04/16.04 (使用apt-get进行安装) 安装Docker
  8. c语言头文件格式图片_阿波罗 STM32F767 开发板资料连载第四十九章 图片显示实验...
  9. hibernate 联合主键
  10. Linux vsFTPd服务详解——文件加密传输配置
  11. 算法习题---4-5IP网络(Uva1590)
  12. 追求--MarsCoara
  13. 针式打印机打印发虚_针式打印机打印输出字符模糊不清晰的原因有哪些
  14. python爬取起点中文网小说
  15. 八核版9500odin3线刷通刷以及root教程
  16. mysql 特殊符号_mysql 特殊字符问题
  17. 计算机中的数据(原码,反码,补码)
  18. 厦门大学计算机研究生2020专业目录,报录比|厦门大学各院系专业2020年硕士生报考录取数据统计表...
  19. laravel 中 使用 composer 的中国镜像安装时报错(找不到包)
  20. 2022年葡萄糖基甜菊糖市场前景分析及研究报告

热门文章

  1. 离散数学 | ∅ 与 {∅} 出现在离散数学幂集合中
  2. python--Django从创建一个项目说起
  3. Redis 锁的实现方案
  4. JIRA数据库的迁移,从HSQL到MYSQL/Oracle
  5. dstat 性能监测工具
  6. [Fatal Error] :3:13: Open quote is expected for attribute {1} associated with an element type i...
  7. [SOA] Mule ESB 3.x 入门(二)—— 配置(spring, properties, log4j)
  8. IP网络中的路由聚合的解析
  9. Java的日期格式化常用方法
  10. 执行数据库命令Command对象——ADO.NET学习应用笔记之三