资源简介
一个matlab代码,用遗传算法(GA)解决多旅行商(MTSP)问题,算法中可以自己设定旅行商人数等参数,比较方便,注释也比较详细,很好理解的。
代码片段和文件信息
% MTSP_GA Multiple Traveling Salesmen Problem (M-TSP) Genetic Algorithm (GA)
% Finds a (near) optimal solution to the M-TSP by setting up a GA to search
% for the shortest route (least distance needed for the salesmen to travel
% to each city exactly once and return to their starting locations)
%
% Summary:
% 1. Each salesman travels to a unique set of cities and completes the
% route by returning to the city he started from
% 2. Each city is visited by exactly one salesman
%
% Input:
% XY (float) is an Nx2 matrix of city locations where N is the number of cities
% DMAT (float) is an NxN matrix of city-to-city distances or costs
% NSALESMEN (scalar integer) is the number of salesmen to visit the cities
% MINTOUR (scalar integer) is the minimum tour length for any of the salesmen
% POPSIZE (scalar integer) is the size of the population (should be divisible by 8)
% NUMITER (scalar integer) is the number of desired iterations for the algorithm to run
% SHOWPROG (scalar logical) shows the GA progress if true
% SHOWRESULT (scalar logical) shows the GA results if true
%
% Output:
% OPTROUTE (integer array) is the best route found by the algorithm
% OPTBREAK (integer array) is the list of route break points (these specify the indices
% into the route used to obtain the individual salesman routes)
% MINDIST (scalar float) is the total distance traveled by the salesmen
%
% Route/Breakpoint Details:
% If there are 10 cities and 3 salesmen a possible route/break
% combination might be: rte = [5 6 9 1 4 2 8 10 3 7] brks = [3 7]
% Taken together these represent the solution [5 6 9][1 4 2 8][10 3 7]
% which designates the routes for the 3 salesmen as follows:
% . Salesman 1 travels from city 5 to 6 to 9 and back to 5
% . Salesman 2 travels from city 1 to 4 to 2 to 8 and back to 1
% . Salesman 3 travels from city 10 to 3 to 7 and back to 10
%
% Example:
% n = 35;
% xy = 10*rand(n2);
% nSalesmen = 5;
% minTour = 3;
% popSize = 80;
% numIter = 5e3;
% a = meshgrid(1:n);
% dmat = reshape(sqrt(sum((xy(a:)-xy(a‘:)).^22))nn);
% [optRouteoptBreakminDist] = mtsp_ga(xydmatnSalesmenminTour ...
% popSizenumIter11);
%
% Example:
% n = 50;
% phi = (sqrt(5)-1)/2;
% theta = 2*pi*phi*(0:n-1);
% rho = (1:n).^phi;
% [xy] = pol2cart(theta(:)rho(:));
% xy = 10*([x y]-min([x;y]))/(max([x;y])-min([x;y]));
% nSalesmen = 5;
% minTour = 3;
% popSize = 80;
% numIter = 1e4;
% a = meshgrid(1:n);
% dmat = reshape(sqrt(sum((xy(a:)-xy(a‘:)).^22))nn);
% [optRouteoptBreakminDist] = mtsp_ga(xydmatnSalesmenminTour ...
% popSizenumIter11);
%
% Example:
% n = 35;
% xyz = 10*rand(n3);
% nSalesmen = 5;
% minTour = 3;
% popSize = 80;
% numIter = 5e3;
% a =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1332 2011-11-07 23:10 mtsp_ga\license.txt
文件 10265 2011-11-07 23:10 mtsp_ga\mtsp_ga.m
目录 0 2013-09-12 16:42 mtsp_ga
----------- --------- ---------- ----- ----
11597 3
- 上一篇:isight调用matlab
- 下一篇:自己用matlab写的jpeg压缩,解压程序
相关资源
- 自己用matlab写的jpeg压缩,解压程序
- isight调用matlab
- 利用matlab实现H-infinity鲁棒控制
- 强化学习matlab代码
- 光伏电池输出特性曲线MATLAB代码
- 基于LMS算法的均衡器MATLAB实现代码
- 蚁群、粒子群、GA、TS等算法解决Job
- matlab关于商场人数的泊松随机过程仿
- 脉冲编码调制PCM调制与解调
- 64QAM调制解调
- matlab遗传算法程序以求解函数的极值
- 毕业论文 基于matlab的PSK通信系统仿真
- matlab 代码实现 信号 数字 变频
- KUKA六关节机器人matlab仿真
- hurst指数的MATLAB实现
- PSO-RBF的MATLAB程序实现
- 商人过河MATLAB.rar
- MatlabR2017aWin64Crack.rar
- Student_5_BDS_Positioning.m
- IEEE-6 14 30节点系统 MATLAB 潮流计算
- 飞行器六自由度建模 线性化 matlab程序
-
三相电压不平衡度计算 simuli
nk模型 - PMSM矢量控制
- xPC target
- MATLAB与DSP进行UDP通信的简单程序
- 内点法最优潮流MATLAB算法
- Logistic曲线的三种参数估计方法及ma
- TDOA等无线定位算法大全
- 内点法测试程序—matlab
- 智能优化算法及其MATLAB
评论
共有 条评论