一、TSP简介

旅行商问题,即TSP问题(Traveling Salesman Problem)又译为旅行推销员问题、货郎担问题,是数学领域中著名问题之一。假设有一个旅行商人要拜访n个城市,他必须选择所要走的路径,路径的限制是每个城市只能拜访一次,而且最后要回到原来出发的城市。路径的选择目标是要求得的路径路程为所有路径之中的最小值。
TSP的数学模型

二、遗传算法简介

1 引言


2 遗传算法理论
2.1 遗传算法的生物学基础


2.2 遗传算法的理论基础




2.3 遗传算法的基本概念






2.4 标准的遗传算法


2.5 遗传算法的特点


2.6 遗传算法的改进方向

3 遗传算法流程



4 关键参数说明

三、部分源代码

function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_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% Last Modified by GUIDE v2.5 18-May-2021 14:58:12% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @GUI_OpeningFcn, ...'gui_OutputFcn',  @GUI_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 is made visible.
function GUI_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 (see VARARGIN)% Choose default command line output for GUI% Update handles structure% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = GUI_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 button1.
function button1_Callback(hObject, eventdata, handles)
n=get(handles.edit1,'string');
data=1+500*rand(str2num(n),2);
set(handles.listbox1,'string',num2str(data))% hObject    handle to button1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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.function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: listbox 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% --- 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)
data1=get(handles.listbox1,'string');
if strcmp(data1,'随机坐标显示框')~=1data2=str2num(data1);%这里直接转换就行,直接转换成对应的坐标矩阵t1=clock;bestLu=SATSP(data2);t2=clock;t=etime(t2,t1);set(handles.listbox2,'string',{['运算完成,运行时间为:',num2str(t),'秒'],['最短路径长度:',num2str(bestLu),'(长度单位)']})%字符串拼接,并可以分行显示
elseset(handles.listbox2,'string','请首先生成随机坐标')
end% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
data1=get(handles.listbox1,'string');
if strcmp(data1,'随机坐标显示框')~=1data2=str2num(data1);%这里直接转换就行,直接转换成对应的坐标矩阵t1=clock;bestLu=GATSP(data2);t2=clock;t=etime(t2,t1);set(handles.listbox2,'string',{['运算完成,运行时间为:',num2str(t),'秒'],['最短路径长度:',num2str(bestLu),'(长度单位)']})%字符串拼接,并可以分行显示
elseset(handles.listbox2,'string','请首先生成随机坐标')
end% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: listbox 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.

【TSP】基于matlab GUI模拟退火+蚁群+遗传算法求解旅行商问题【含Matlab源码 1611期】相关推荐

  1. 【路径规划-TSP问题】基于蚁群算法求解旅行商问题含Matlab代码

    ✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信.

  2. 【路径规划-TSP问题】基于粒子群结合蚁群算法求解旅行商问题附matlab代码

    1 内容介绍 一种基于粒子群优化的蚁群算法求解TSP问题的方法.该方法在求解TSP问题时,利用粒子群优化的思想,对蚁群算法的参数取值进行优化并选择.在粒子群算法中,将蚁群算法的5个参数(q,α,β,ρ ...

  3. 【ACO TSP】基于matlab改进的蚁群算法求解旅行商问题【含Matlab源码 242期】

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

  4. 【ACO TSP】基于matlab GUI蚁群算法求解旅行商问题【含Matlab源码 1032期】

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

  5. 基于matlab GUI Powell+蚁群算法图像配准

    基于matlab GUI Powell+蚁群算法图像配准 一.简介 1 蚁群算法(ant colony algorithm,ACA)起源和发展历程 Marco Dorigo等人在研究新型算法的过程中, ...

  6. 基于MATLAB GUI的蚁群算法路径规划实现电动汽车充电站与换电站协调

    基于MATLAB GUI的蚁群算法路径规划实现电动汽车充电站与换电站协调 摘要: 随着电动汽车的普及和发展,电动汽车充电站与换电站的布局和规划变得尤为重要.本文基于MATLAB GUI平台,结合蚁群算 ...

  7. 【电力预测】基于matlab GUI灰色模型电力负荷预测【含Matlab源码 769期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源: [电力负荷预测]基于matlab GUI灰色模型电力负荷预测[含Matlab源码 769期] 获取代码方式2: 通过订阅紫极神光博客付费专 ...

  8. 【Matlab DVRP】蚁群算法求解带距离的车辆路径规划问题【含源码 1040期】

    一.代码运行视频(哔哩哔哩) [Matlab DVRP]蚁群算法求解带距离的车辆路径规划问题[含源码 1040期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1 ...

  9. 【芯片识别】基于matlab GUI形态学PCB板芯片识别【含Matlab源码 1820期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[芯片识别]基于matlab GUI形态学 PCB板芯片识别[含Matlab源码 1820期] 点击上面蓝色字体,直接付费下载,即可. 获 ...

  10. 【大米粒计数】基于matlab GUI形态学大米粒颗粒识别【含Matlab源码 915期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[大米粒计数]基于matlab GUI形态学大米粒颗粒识别[含Matlab源码 915期] (https://download.csdn. ...

最新文章

  1. 在CentOS 6.6 64bit上安装Oracle VirtualBox 5.0.12
  2. c语言装饰,C++设计模式之装饰模式(Decorator)
  3. 2020 北京智源大会首日精华速递
  4. 【原创 HadoopSpark 动手实践 1】Hadoop2.7.3 安装部署实践
  5. JBoss 系列八十一: jBPM 6 中使用 jbpm-console 创建执行 BPM 流程 - II
  6. 【Spring-Boot】【入门 01】第一个 Spring Boot 程序
  7. 环形数组最大子数组之和
  8. python面向对象(2)——继承(4)
  9. 深圳敏捷云计算机科技,敏捷云 | 关于我们 | 敏捷云
  10. java 1000到9999_java – 可以0.99999999999乘以四舍五入到1.0?
  11. php5向下兼容php4吗,PHP5与PHP4的区别小议
  12. Java Elasticsearch 使用
  13. Linux权限管理命令
  14. 用Java操作Office 2007
  15. 这场直播,我们把 Apache 顶级项目盛会搬来了!
  16. Latex初学入门记载
  17. oracle 索引个数限制,oracle索引详解
  18. 有权图的单源最短路算法
  19. 微信小程序tab切换效果
  20. Python3 利用阿里接口,根据银行卡号获取银行名称和logo

热门文章

  1. Hbase架构与实现
  2. 函数-在函数里修改列表数据
  3. ArcGIS紧凑型切片读取与应用2-webgis动态加载紧凑型切片(附源码)
  4. [POI2012]STU-Well(二分答案+神仙操作)
  5. LUOGU P4178 Tree
  6. 利用JavaScript生成随机数字!
  7. Listview实现不同类型的布局
  8. 181025词霸有道扇贝每日一句
  9. Atitit 常用加密算法 aes des rsa 比较 历史演进 目录 1.1. 常规加密算法如下 Aes 3des des rsa 1 2. 加密算法历史演进 按照出现时间和加密强度 流行
  10. Atitit 文档资料的摘要与压缩技术总结abstract tech v4 目录 1. 概念包含了原文本中的重要信息,其长度不超过或远少于原文本的一半” 1 2. 1. 摘要的作用 应用场景 1 2