新手求教,关于蚁群算法求解tsp问题函数极值问题

查看: 330|回复: 0|关注: 0
蚁群算法 求大神指教 关于蚁群算法参数问题
<h1 style="color:# 麦片财富积分
新手, 积分 5, 距离下一级还需 45 积分
本帖最后由 小蜗 于
10:09 编辑
鄙人初学蚁群算法,运行时遇到了问题。参数我输入的是:m=30;Alpha=1;Beta=5;Rho=0.1;NC_max=200;Q=100;C是一个24X2的矩阵,工作区如图。但是无法运行,显示参数不足。跪求大神指教!急!在线等!
程序如下:
function [R_best,L_best,L_ave,Shortest_Route,Shortest_Length]=UntitledYQSF5(C,NC_max,m,Alpha,Beta,Rho,Q)
%%-------------------------------------------------------------------------
%% 主要符号说明
%% C n个城市的坐标,n×2的矩阵
%% NC_max 最大迭代次数
%% m 蚂蚁个数
%% Alpha 表征信息素重要程度的参数
%% Beta 表征启发式因子重要程度的参数
%% Rho 信息素蒸发系数
%% Q 信息素增加强度系数
%% R_best 各代最佳路线
%% L_best 各代最佳路线的长度
%%=========================================================================
%%第一步:变量初始化
n=size(C,1);%n表示问题的规模(城市个数)
%%size(A,n)如果在size函数的输入参数中再添加一项n,并用1或2为n赋值,则 size将返回矩阵的行数或列数。其中r=size(A,1)该语句返回的时矩阵A的行数, c=size(A,2) 该语句返回的时矩阵A的列数。
D=zeros(n,n);%D表示完全图的赋权邻接矩阵
D(i,j)=((C(i,1)-C(j,1))^2+(C(i,2)-C(j,2))^2)^0.5;
D(i,j)=& && &%i=j时不计算,应该为0,但后面的启发因子要取倒数,用eps(浮点相对精度)表示
D(j,i)=D(i,j);& &%对称矩阵
Eta=1./D;& && && & %Eta为启发因子,这里设为距离的倒数
Tau=ones(n,n);& &&&%Tau为信息素矩阵
Tabu=zeros(m,n);& &%存储并记录路径的生成
NC=1;& && && && && &%迭代计数器,记录迭代次数
R_best=zeros(NC_max,n);& && & %各代最佳路线
L_best=inf.*ones(NC_max,1);& &%各代最佳路线的长度
L_ave=zeros(NC_max,1);& && &&&%各代路线的平均长度
while NC&=NC_max& && &&&%停止条件之一:达到最大迭代次数,停止
%%第二步:将m只蚂蚁放到n个城市上
Randpos=[];& &%随即存取
for i=1:(ceil(m/n))&&%ceil函数是取比它大的最小整数&&假如5只蚂蚁4座城市 需要循环2次
& & Randpos=[Randpos,randperm(n)];%随迭代次数改变?
Tabu(:,1)=(Randpos(1,1:m))';& & %%表示将m个蚂蚁随机,每个蚂蚁放到前面产生的城市序列中,每个蚂蚁一个城市,需要m个,所以提取前面1:m个序列
%%第三步:m只蚂蚁按概率函数选择下一座城市,完成各自的周游
for j=2:n& &&&%所在城市不计算
for i=1:m& &
visited=Tabu(i,1:(j-1)); %记录已访问的城市,避免重复访问
J=zeros(1,(n-j+1));& && & %待访问的城市
P=J;& && && && && && && & %待访问城市的选择概率分布
if isempty(find(visited==k, 1))& &%开始时置0
Jc=Jc+1;& && && && && && && && & %访问的城市个数自加1
%下面计算待选城市的概率分布
for k=1:length(J)
P(k)=(Tau(visited(end),J(k))^Alpha)*(Eta(visited(end),J(k))^Beta);
P=P/(sum(P));
%按概率原则选取下一个城市
Pcum=cumsum(P);& &&&%cumsum,元素累加即求和
Select=find(Pcum&=rand); %若计算的概率大于原来的就选择这条路线
to_visit=J(Select(1));
Tabu(i,j)=to_
Tabu(1,:)=R_best(NC-1,:);
%%第四步:记录本次迭代最佳路线
L=zeros(m,1);& &&&%开始距离为0,m*1的列向量
R=Tabu(i,:);
for j=1:(n-1)
L(i)=L(i)+D(R(j),R(j+1));& & %原距离加上第j个城市到第j+1个城市的距离
L(i)=L(i)+D(R(1),R(n));& && &%一轮下来后走过的距离
L_best(NC)=min(L);& && && &&&%最佳距离取最小
pos=find(L==L_best(NC));
R_best(NC,:)=Tabu(pos(1),:); %此轮迭代后的最佳路线
L_ave(NC)=mean(L);& && && &&&%此轮迭代后的平均距离
NC=NC+1;& && && && && && && & %迭代继续
%%第五步:更新信息素
Delta_Tau=zeros(n,n);& && &&&%开始时信息素为n*n的0矩阵
for j=1:(n-1)
Delta_Tau(Tabu(i,j),Tabu(i,j+1))=Delta_Tau(Tabu(i,j),Tabu(i,j+1))+Q/L(i);& && && &
%此次循环在路径(i,j)上的信息素增量
Delta_Tau(Tabu(i,n),Tabu(i,1))=Delta_Tau(Tabu(i,n),Tabu(i,1))+Q/L(i);
%此次循环在整个路径上的信息素增量
Tau=(1-Rho).*Tau+Delta_T %考虑信息素挥发,更新后的信息素
%%第六步:禁忌表清零
Tabu=zeros(m,n);& && && && & %%直到最大迭代次数
%%第七步:输出结果
Pos=find(L_best==min(L_best)); %找到最佳路径(非0为真)
Shortest_Route=R_best(Pos(1),:); %最大迭代次数后最佳路径
Shortest_Length=L_best(Pos(1)); %最大迭代次数后最短距离
subplot(1,2,1)& && && && && && &%绘制第一个子图形
DrawRoute(C,Shortest_Route)& &&&%画路线图的子函数
subplot(1,2,2)& && && && && && &%绘制第二个子图形
plot(L_best)
hold on& && && && && && && && & %保持图形
plot(L_ave,'r')
title('平均距离和最短距离')& &&&%标题
function DrawRoute(C,R)
%%=========================================================================
%% DrawRoute.m
%% 画路线图的子函数
%%-------------------------------------------------------------------------
%% C Coordinate 节点坐标,由一个N×2的矩阵存储
%% R Route 路线
%%=========================================================================
N=length(R);
scatter(C(:,1),C(:,2));
plot([C(R(1),1),C(R(N),1)],[C(R(1),2),C(R(N),2)],'g')
for ii=2:N
plot([C(R(ii-1),1),C(R(ii),1)],[C(R(ii-1),2),C(R(ii),2)],'g')
title('GIS配送优化结果 ')
Powered by上传用户:apmzhzldwa资料价格:5财富值&&『』文档下载 :『』&&『』学位专业:&关 键 词 :&&权力声明:若本站收录的文献无意侵犯了您的著作版权,请点击。摘要:(摘要内容经过系统自动伪原创处理以避免复制,下载原文正常,内容请直接查看目录。)蚁群算法是继模仿退火、遗传算法、忌讳搜刮等以后的又一启示式智能优化算法,它是由意年夜利学者M.Dorigo等人初次提出,并普遍运用于求解一系列组合优化成绩,如观光商成绩,二次分派成绩,车辆途径成绩和图着色成绩等,这些运用充足显示了它在处理庞杂团圆优化成绩方面的优胜性。持续空间函数优化成绩也是蚁群算法的研讨课题之一,多峰函数优化又是函数优化的一个主要方面,但今朝蚁群算法对该成绩的研讨重要是集中在求解函数的最年夜(小)值,对求解函数一切极值方面的研讨却很少。鉴于此,本文恰是将蚁群算法运用到求解函数一切极值方面,重要研讨内容以下(1)综述了蚁群算法的成长进程、生物学机理及其研讨近况,具体引见了根本蚁群算法模子及它的详细完成步调。(2)具体引见了用于求解函数一切极值的蚁群算法。起首研讨了将蚁群算法运用到求解函数一切极值时所表示出来的新特征,即蚁群经由若干次临近区间转移后,有的区间不含蚂蚁,有的区间集聚集一些蚂蚁。普通蚂蚁集合的区间恰是包括极值点的区间。然后应用这个新特征设计了求解函数一切极值的蚁群算法,该算法的特色是,只将蚂蚁集合的区间停止再次细化,从新搜刮极值点,直到细化后的区间长度足够小时才停滞算法。试验注解,本文算法不只能找出函数的一切极值点,并且求解精度高,速度快,稳固性好。(3)为了使本文算法便于懂得,本文具体引见了改良算法的数据构造和详细代码。Abstract:Ant colony algorithm is the simulated annealing, genetic algorithm, optimization algorithm and a heuristic taboo after the intelligent search, it is proposed by Italian scholars M.Dorigo et al First, and widely used in solving a series of optimization results, such as tourist business performance, the two distribution performance, vehicle performance and achievement of graph coloring approach so, the use of adequate shows its superiority in dealing with complex optimization problems in terms of reunion. Continuous space function optimization is one of the research topics of the ant colony algorithm. The optimization of multi peak function is a main aspect of function optimization. But the research on the performance of ant colony algorithm is very important to solve the problem. In view of this, this article is to use the ant colony algorithm to solve all the extreme value of the function, the important research content of the following (1) overview of the growth process, biological mechanism and research status of ant colony algorithm, the basic ant colony algorithm and its detailed steps. (2) an ant colony algorithm for solving the extreme value of the function is introduced in detail. First of all, the ant colony algorithm is used to solve all the extreme value of the function of the new feature, that is, the ant colony through a number of times after the transfer, and some of the interval is not containing ants, some of the interval set to gather some ants. The interval of the general ant colony is the range of the extreme points. Then the application of this new feature for all function extremum of ant colony algorithm design, the algorithm features, only the interval set ants stopped again from the new search refinement, extreme point, interval length until after thinning enough hours to stagnation algorithm. Test notes, the algorithm can not only find out the function of all the extreme points, and the accuracy is high, the speed is fast, the stability is good. (3) in order to make the algorithm easy to understand, this paper introduces the data structure and detailed code of the improved algorithm.目录:摘要3-4ABSTRACT4-5第一章 绪论7-12&&&&1.1 蚁群算法产生的生物学背景7-8&&&&1.2 蚁群算法的研究现状8-9&&&&1.3 本文研究目的与意义9-10&&&&1.4 本文主要工作10-12第二章 基本蚁群算法介绍12-18&&&&2.1 蚁群算法的基本原理12&&&&2.2 基本蚁群算法数学模型12-14&&&&2.3 基本蚁群算法实现过程14-17&&&&2.4 本章小结17-18第三章 应用蚁群算法求解函数所有极值18-34&&&&3.1 引言18-19&&&&3.2 基于蚁群算法改进的函数多峰值寻优19-23&&&&&&&&3.2.1 蚁群初始分布20-21&&&&&&&&3.2.2 蚁群转移规则21&&&&&&&&3.2.3 信息素更新21-22&&&&&&&&3.2.4 缩小蚁群搜索空间22-23&&&&3.3 算法实现23-24&&&&3.4 仿真算例24-33&&&&3.5 本章小结33-34第四章 问题实现34-42&&&&4.1 算法过程伪代码描述34&&&&4.2 算法的具体代码描述34-41&&&&&&&&4.2.1 调用函数35-39&&&&&&&&4.2.2 主函数39-41&&&&4.3 本章小结41-42第五章 总结与展望42-44&&&&5.1 工作总结42-43&&&&5.2 研究展望43-44参考文献44-48致谢48-49附录49分享到:相关文献|君,已阅读到文档的结尾了呢~~
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
蚁群算法求函数最大值的程序
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口自动化技术、计算机技术
蚁群算法求解离散最小约束去除问题
许波,闵华清,肖芳雄
(华南理工大学 软件学院,广州 510006)
Ant Colony Algorithm for Solving Discrete Minimum Constraint Removal (MCR) Problem
XU Bo,MIN Hua?qing,XIAO Fang?xiong
(School of Software Engineering, South China University of Technology, Guangzhou 510006, China)
Canny J. The complexity of robot motion planning [M]. Cambridge: MIT press, 1988.
Hauser, K. The minimum constraint removal problem with three robotics applications[C]∥In Proceedings of Workshop on the Algorithmic Foundations of Robotics. New York:IEEE,2012.
Hauser K. The minimum constraint removal problem with three robotics applications [J]. The International Journal of Robotics Research, ): 5?17.
Erickson L H, LaValle S M. A simple, but NP?hard, motion planning problem [C]∥In Proceedings of the Twenty?Seventh AAAI Conference on Artificial Intelligence (AAAI?13), Urbana:AAAI,2013: .
McCarthy Z, Bretl T, Hutchinson S. Proving path non?existence using sampling and alpha shapes[C]∥In Proceedings of the 2012 IEEE International Conference on Robotics and Automation. Saint Paul:IEEE,ICRA, ?2569.
G?belbecker M, Keller T, Eyerich P, et al. Coming up with good excuses: What to do when no plan can be found[C] ∥In Proceedings of the International Conference on Automated Planning and Scheduling. Toronto:AAAI Press,.
Johnson J, Hauser K. Optimal longitudinal control planning with moving obstacles[C]∥In Proceedings of 2013 IEEE Intelligent Vehicles Symposium (IV). Gold Coast, QLD:IEEE,1.
Hauser K. On responsiveness, safety, and completeness in real?time motion planning [J]. Autonomous Robots, ): 35?48.
Hauser K. Minimum constraint displacement motion planning [J]. Robotics: Science and Systems (RSS), ):1?5.
Dorigo M, Gambardella L M. Ant colony system: A cooperative learning approach to the traveling salesman problem [J]. IEEE Transactions on Evolutionary Computation, ):53?66.
St&tzle T, Dorigo M. A short convergence proof for a class of ant colony optimization algorithms [J]. IEEE Transactions on Evolutionary Computation, ): 358?365.
李翠明,龚俊,牛万才,王翀. [J]. 上海交通大学学报(自然版), ): 387-391.
姜文英,林焰,陈明,于雁云. [J]. 上海交通大学学报(自然版), ): 502-507.
王盛炜,徐雪松,姚宝恒,连琏. [J]. 上海交通大学学报(自然版), ): .
李真, 陈秀华, 汪海. [J]. 上海交通大学学报(自然版), ): 768-773.
胡凯林, 李平. [J]. 上海交通大学学报(自然版), ): .
王慧林, 冉承新, 黄维, 马满好. [J]. 上海交通大学学报(自然版), ): 954-960.
高守玮,杨叶青,张卫东. [J]. 上海交通大学学报(自然版), ): .
郭乘涛,江志斌. [J]. 上海交通大学学报(自然版), ): .
胡燕海,严隽琪,马登哲,叶飞帆
. [J]. 上海交通大学学报(自然版), ): .
姚世清,江志斌,郭乘涛,胡鸿韬. [J]. 上海交通大学学报(自然版), ): .
沪交ICP备05221
版权所有 & 2008 《上海交通大学学报》编辑部
地址:上海市华山路1954号(200030) 电话:021- 传真:021- E-mail: xuebao3373@
技术支持北京玛格泰克科技发展有限公司}

我要回帖

更多关于 蚁群算法求解tsp问题 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信