- 16
- 0
- 约1.52万字
- 约 15页
- 2016-02-25 发布于江苏
- 举报
matlab 算法程序.doc
一基于matlab Dijkstra算法的实现
function [l,z]=Dijkstra(W)n = size (W,1);for i = 1 :n ??? l(i)=W(1,i);??? z(i)=1;end i=1;while i=n??? for j =1 :n??????? if l(i)l(j)+W(j,i)??????????? l(i)=l(j)+W(j,i);??????????? z(i)=j;??????????? if ji??????????????? i=j-1;??????????? end??????? end??? end??? i=i+1;end % W =[ 0???? 2???? 1???? 8?? Inf?? Inf?? Inf?? Inf%???? 2???? 0?? Inf???? 6???? 1?? Inf?? Inf?? Inf%????? 1?? Inf???? 0???? 7?? Inf?? Inf???? 9?? Inf%????? 8???? 6???? 7???? 0???? 5???? 1???? 2?? Inf%??? Inf???? 1?? Inf???? 5???? 0???? 3?? Inf???? 9%??? Inf?? Inf?? Inf???? 1???? 3???? 0???? 4???? 6%??? Inf?? Inf???? 9???? 2?? Inf???? 4???? 0???? 3%??? Inf?? Inf?? Inf?? Inf???? 9???? 6???? 3???? 0? ]; 二/基于matlab TSP问题模拟退火法实现
%this program is written by 刘学智. Finished time is 05.1.23 16:03 %utilizing it solving TSP problem by simulating stealing algorithm% [fval,route]=sa_tsp(d,10,0.1,.87)% d=[0? 2? 1? 2? 0? 0? 1? 0? 1? 2? 1? 1? 1? 1% 2? 0? 1? 4? 1? 0? 1? 1? 1? 3? 1? 0? 2? 1% 1? 1? 0? 1? 0? 0? 0? 3? 1? 1? 0? 2? 2? 1% 2? 4? 1? 0? 1? 1? 2? 1? 0? 2? 1? 0? 1? 1% 0? 1? 0? 1? 0? 2? 0? 1? 1? 1? 0? 1? 1? 2% 0? 0? 0? 1? 2? 0? 1? 2? 1? 1? 1? 2? 1? 2% 1? 1? 0? 2? 0? 1? 0? 1? 1? 1? 0? 2? 2? 1% 0? 1? 3? 1? 1? 2? 1? 0? 1? 2? 1? 4? 2? 2% 1? 1? 1? 0? 1? 1? 1? 1? 0? 1? 1? 1? 3? 1% 2? 3? 1? 2? 1? 1? 1? 2? 1? 0? 1? 0? 0? 3% 1? 1? 0? 1? 0? 1? 0? 1? 1? 1? 0? 3? 1? 1% 1? 0? 2? 0? 1? 2? 2? 4? 1? 0? 3? 0? 1? 0% 1? 2? 2? 1? 1? 1? 2? 2? 3? 0? 1? 1? 0? 4% 1? 1? 1? 1? 2? 2? 1? 2? 1? 3? 1? 0? 4? 0];
%the result is fval=2; route=14?? 9? 4? 13? 10? 12? 2? 6? 3? 11? 7? 5? 1? 8
function [fval,route]=sa_tsp(d,t0,tf,alpha)%d is the distance matrix;t0,tf is the initial and finil temperature;%alpha is controling temperature coeffientn=length(d);%the number of citiesL=100*n;%the length of Markov chainroute=randperm(n);%the initial traveling routefval=value(route,d);%the initial goal valuet=t0;ticwhile ttffor i=1:L[fval_after,route_after]=exchange(route,d);if f
您可能关注的文档
最近下载
- 行者讲课脉法下篇.doc VIP
- (人教版)数学一年级上册寒假应用题“天天练”作业设计,含30份题组,附参考答案.doc
- 多参数监护仪技术参数和要求.doc VIP
- HL德國創新機能家電烤箱HL-840用户手册.pdf
- (高清!)2025年3月29日河北省事业单位联考C类《职测》真题及答案.pdf VIP
- ZORRO遥控器中文说明书.pdf
- 多参数监护仪技术参数.doc VIP
- 05R417-1 室内管道支吊架建筑工程图集 高清.docx VIP
- 2025届安徽省江南十校高三下学期第一次联考(一模)数学试题含答案.pdf VIP
- 三年级上册数学思维训练题30题,拓展孩子思维能力201123.pdf VIP
原创力文档

文档评论(0)