【优化选址】基于matlab蚁群算法求解电动汽车充电站与换电站选址优化问题【含Matlab源码 1182期】
一、蚁群算法简介
1 概要
模拟蚂蚁觅食行为(最短路径原理)设计的算法。讲蚂蚁群觅食的特点抽象出来转化成数学描述。
• 蚁群算法(Ant Colony Algorithm, ACA)由Marco Dorigo于1992年在他的博士论文中首次提出。
• 蚂蚁在寻找食物源时,会在其经过的路径上释放一种信息素,并能够感知其它蚂蚁释放的信息素。信息素浓度的大小表征路径的远近,信息素浓度越高,表示对应的路径距离越短。
• 通常,蚂蚁会以较大的概率优先选择信息素浓度较高的路径,并释放 一定量的信息素,以增强该条路径上的信息素浓度,这样,会形成一个正反馈。最终,蚂蚁能够找到一条从巢穴到食物源的最佳路径,即距离最短。
• 生物学家同时发现,路径上的信息素浓度会随着时间的推进而逐渐衰减。
• 将蚁群算法应用于解决优化问题,其基本思路为:用蚂蚁的行走路径表示待优化问题的可行解,整个蚂蚁群体的所有路径构成待优化问题的解空间。路径较短的蚂蚁释放的信息素量较多,随着时间的推进,较短 的路径上累积的信息素浓度逐渐增高,选择该路径的蚂蚁个数也愈来愈多。最终,整个蚂蚁会在正反馈的作用下集中到最佳的路径上,此时对应的便是待优化问题的最优解。
类比GA(遗传算法)的交叉、选择、变异,PSO(粒子群算法)的个体、群体极值优化,蚁群算法也有自己的优化策略:正反馈的信息机制、信息素浓度的更新、蚂蚁对能够访问的路径的筛选。
2 基本思想
蚁群算法的基本原理来源于自然界蚂蚁觅食的最短路径原理。根据昆虫学家的观察,发现自然界的蚂蚁虽然视觉不发达,但它可以在没有任何提示的情况下找到从食物源到巢穴的最短路径,并且能在环境发生变化(如原有路径上有了障碍物)后,自适应地搜索新的最佳路径。蚂蚁是如何做到这一点的呢?
原来,蚂蚁在寻找食物源时,能在其走过的路径上放一种蚂蚁特有的分泌物-信息 素,也可称为信息素,使得一定范围内的其他蚂蚁能够察觉到并由此影响它们以后的行为。当一些路径上通过的蚂蚁越来越多时,其留下的信息素也越来越多,以致信息素强度增大(当然,随时间的推移会逐渐减弱,所以蚂蚁选择该路径的概率也越高,从而更增加了该路径的信息素强度,这种选择过程被称之为蚂蚁的自催化行为。 由于其原理是一种正反馈机制,因此,也可将蚂蚁王国理解为所谓的增强型学习系统。 这里我们用一个图来说明蚂蚁觅食的最短路径选择原理,如图所示。在中,假设A点是蚂蚁的巢穴,B点是食物,A、B两点间有一个障碍物,那么此时从A点到B点 的蚂蚁就必须决定往左走还是往右走,而从B点到A点的蚂蚁也必须决定选择走哪条路径。 这种决定会受到各条路径上以往蚂蚁留下的信息素浓度(即残留信息素浓度)的影响。 如果往 右走的路径上的信息素浓度比较大,那么右边的路径被蚂蚁选中的可能性也就大一些。但对于第一批探路的蚂蚁,因为没有信息素的影响或影响比较小,所以它们选择向左或者向右的可能性是一样的,正如图所示的那样。随着觅食过程的进行,各条道路上信息 素的强度开始出现变化,有的线路强,有的 线路弱。现以从A点到B点的蚂蚁为例说明(从B点到 A点的蚂蚁,过程也基本是一样的)随后过程的变化。由于路径 ADB比路径ACB要短,因此选择ADB路径的第一只蚂蚁要比选择ACB的第一只蚂蚁早到达B点。此时,从B点向 A点看,路径BDA A上的信息素浓度要比路径BCA上的信息素浓度大。因此从下一时刻开始,从B点到A 点的蚂蚁,它们选择 BDA路径的可能性要比选择BCA路径的可能性就大些,从而使ABDA路线上的信息素进一步增强,于是依D赖信息素强度选择路径的蚂蚁逐渐偏向于选择路径 ADB,如图所示。随着时间的推移,几乎所有的蚂蚁都会选择路径 ADB(或 BDA)搬运食物,而我们同时也会发现:ADB路径也正是事实上的最短路径。这种蚁群寻径的原理可简单理解为:对于单个的蚂蚁,它并没有要寻找最短路径的主观上的故意;但对于整个蚁群系统,它们又确实达到了寻找到最短路径的观上的效果。 在自然界中,蚁群的这种寻找路径的过程表现为一种正反馈的过程,“蚁群算法”就是模拟 生物学上蚂蚁群觅食寻找最短路径的原理衍生出来的。例如,我们把只具备了简单功能的工 作单元视为“蚂蚁”,那么上述寻找路径的过程可以用于解释蚁群算法中人工蚁群的寻优过程。 这也就是蚁群算法的基本思想。
3 算法设计的流程
这里以TSP问题为例,算法设计的流程如下:
步骤1:对相关参数进行初始化,包括蚁群规模、信息素因子、启发函数因子、信息素挥发因子、信息素常数、最大迭代次数等,以及将数据读入程序,并进行预处理:比如将城市的坐标信息转换为城市间的距离矩阵。
步骤2:随机将蚂蚁放于不同出发点,对每个蚂蚁计算其下个访问城市,直到有蚂蚁访问完所有城市。
步骤3:计算各蚂蚁经过的路径长度Lk,记录当前迭代次数最优解,同时对路径上的信息素浓度进行更新。
步骤4:判断是否达到最大迭代次数,若否,返回步骤2;是,结束程序。
步骤5:输出结果,并根据需要输出寻优过程中的相关指标,如运行时间、收敛迭代次数等。
4 数学模型
二、部分源代码
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 a new 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});
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 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,'请等待......');
for i=1:100waitbar(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');
endfunction 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');
endfunction 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');
endfunction 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');
endfunction 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');
endfunction 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');
endfunction 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
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
【优化选址】基于matlab蚁群算法求解电动汽车充电站与换电站选址优化问题【含Matlab源码 1182期】相关推荐
- 【Matlab优化选址】蚁群算法求解电动汽车充电站与换电站选址优化问题【含源码 1182期】
一.代码运行视频(哔哩哔哩) [Matlab优化选址]蚁群算法求解电动汽车充电站与换电站选址优化问题[含源码 1182期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文 ...
- 【优化选址】蚁群算法求解电动汽车充电站与换电站选址优化问题【含Matlab源码 1182期】
⛄一.蚁群算法简介 1 概要 模拟蚂蚁觅食行为(最短路径原理)设计的算法.讲蚂蚁群觅食的特点抽象出来转化成数学描述. • 蚁群算法(Ant Colony Algorithm, ACA)由Marco D ...
- 【路径规划】基于蚁群算法求解电动汽车充电站与换电站协调路径规划matlab源码含GUI
1.蚁群算法(ant colony algorithm,ACA)起源和发展历程 Marco Dorigo等人在研究新型算法的过程中,发现蚁群在寻找食物时,通过分泌一种称为信息素的生物激素交流觅食信息从 ...
- 【路径规划】蚁群算法求解电动汽车充电站与换电站协调路径规划【含GUI Matlab源码 796期】
⛄一.蚁群算法简介 1 引言 在自然界中各种生物群体显现出来的智能近几十年来得到了学者们的广泛关注,学者们通过对简单生物体的群体行为进行模拟,进而提出了群智能算法.其中, 模拟蚁群觅食过程的蚁群优化算 ...
- 【TWVRP】基于matlab蚁群算法求解带时间窗车辆路径规划问题【含Matlab源码 1930期】
⛄一.VRP简介 1 VRP基本原理 车辆路径规划问题(Vehicle Routing Problem,VRP)是运筹学里重要的研究问题之一.VRP关注有一个供货商与K个销售点的路径规划的情况,可以简 ...
- 【TWVRP】蚁群算法求解带时间窗车辆路径规划问题【含Matlab源码 1930期】
⛄一.VRP简介 1 VRP基本原理 车辆路径规划问题(Vehicle Routing Problem,VRP)是运筹学里重要的研究问题之一.VRP关注有一个供货商与K个销售点的路径规划的情况,可以简 ...
- 【ACO TSP】基于matlab蚁群算法求解31城市旅行商问题【含Matlab源码 1147期】
一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[TSP]基于matlab蚁群算法求解31城市旅行商问题[含Matlab源码 1147期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...
- 【Matlab DVRP】蚁群算法求解带距离的车辆路径规划问题【含源码 1040期】
一.代码运行视频(哔哩哔哩) [Matlab DVRP]蚁群算法求解带距离的车辆路径规划问题[含源码 1040期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1 ...
- MATLAB粒子群算法求解带充电站(桩)的电动车辆路径规划EVRP问题代码实例
MATLAB粒子群算法求解带充电站(桩)的电动车辆路径规划EVRP问题代码实例 问题实例描述: 现有一个配送中心需要向20个客户点进行送货.每个客户点有不同货物需求量和卸货服务时间.配送中心和客户点的 ...
- 【Matlab路径规划】改进的遗传算法机器人避障路径规划【含GUI源码 703期】
一.代码运行视频(哔哩哔哩) [Matlab路径规划]改进的遗传算法机器人避障路径规划[含GUI源码 703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...
最新文章
- 如何在本地访问远程服务器的jupyter notebook?
- 项目启动时socket自动启动_spring boot 项目在启动时调用接口
- 减少模型方差的方法借鉴
- mysql 5.5 barracuda_MySQL Antelope和Barracuda的区别分析
- vue 数组数据改变 视图不更新解决方案
- 次梯度(subgradient)
- Lack of free swap space on Zabbix server
- freemarker html 引入script_HTML编码规范
- 一阶低通滤波器方程_一阶RC低通滤波器杂记
- 百度编辑器上传图片配置php,谁配置过百度编辑器ueditor1.4.3的图片上传路径?
- 如何安装python3.6_python3.6环境下如何安装freetype库和基本使用方法
- 计算机二级Java上机环境安装与使用
- dosbox 中文操作系统_中兴新支点国产操作系统新版本了,越来越好用了
- 华为服务器如何正确加装扩展内存
- PCB设计中电流与线宽的关系
- 【CV】MLP-Mixer:用于CV任务的全 MLP 架构
- 相对丰度会歪曲实际丰度,联合16S扩增子测序和总菌qPCR获得的绝对丰度可靠吗?...
- 【Leetcode】460. LFU Cache
- CMD/DOS学习笔记
- 二维图形的基本变换与裁剪的变换矩阵
热门文章
- day20T3改错记
- 学习笔记day1-计算机介绍
- HDU 6127 Hard challenge (极角排序)
- Linux安装redis及redis的php扩展。
- Visual Studio 开发环境安装与配置
- 在2003上实现Custom Task Pane
- 探索科学的奥秘之门Science,Cell, Nature
- 20190608每日一句
- Atitit httpclient feign使用总结RestTemplate Httpclient重要的功能 重试与超时 1.RedirectExec执行器的默认策略是,在接收到重定向错误码3
- Atitit 命令行返回 cli 返回解析 tab分割csv格式 v4 t34.docx Atitit 命令行返回 cli 返回解析 csv 格式 cliutil 目录 1.1. 线使用tab