已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本文档含两个m文件dial.m和 dijkstra1.m ,dial需要调用dijkstra1。算例如下:算法如下:Dial.medge = 1 1 2 2 3 4 4 5 5 6 7 8 ;. 2 4 3 5 6 5 7 6 8 9 8 9 ;. 2 2 2 2 2 1 2 1 2 2 2 2 ; ; n=9; weight=inf*ones(n, n);Q = 1000;start =1 ;endn = 9;r =zeros(1,n);s = zeros(1,n);theta = 1;L = zeros(n); OD= zeros(n);%=for i=1:n weight(i, i)=0;endfor i=1:size(edge,2)weight(edge(1, i), edge(2, i)=edge(3, i);endLmin = zeros(1,n);for i=1: n dis, path=dijkstra1(weight, i, 9) ;s(i) = dis; % 任意节点到终点s的最小时间 dis, path=dijkstra1(weight, 1, i) ; r(i) =dis; % 起点r到任意节点最小时间 endfor i = 1 : n for j = 1:n if weight(i,j) 0 & weight(i,j) inf & r(i) s(j) L(i,j) = exp( theta *(r(j) -r(i) -weight(i,j) ) ; %所有路段似然值 end end end LMax =2000;temp =0 ;tempr =zeros(1,n);rr= zeros(1,n);rr = r ;% 出发节点i排序for i =1 :n Min = 2000; for j= 1 :n if rr(j) Min Min = rr(j); temp = j ; end end rr(temp)= Max; tempr(i) =temp;endLW = zeros(n);% 前向计算路段权重for i = 1 : n for j = 1 :n if i = start LW (tempr(i),j)= L(tempr(i),j) ; else sumlw = 0; for tempi =1 :9 sumlw = sumlw +LW(tempi,tempr(i) ); end LW (tempr(i),j)= L(tempr(i),j)*sumlw; end endendtemprLWMax =2000;temp =0;temps =zeros(1,n);ss = s ;% 到达节点j排序for i =1 :n Min = 2000; for j= 1 :n if ss(j) 0 | OD(temps(j),tempi ) =0 tempOD = tempOD+OD(temps(j),tempi ); end end for i = 1 :n sumlw = 0; if temps(j)= endn for tempi =1 :9 sumlw = sumlw +LW(tempi,temps(j) ); end OD(i,temps(j)= Q* LW(i,temps(j)/sumlw ; else for tempi =1 :9 sumlw = sumlw +LW(tempi,temps(j) ); end OD(i,temps(j) = LW(i,temps(j)*tempOD/ sumlw ; end end endODfunction distance,path=dijkstra1(A,s,e)% DISTANCE,PATH=DIJKSTRA(A,S,E)% returns the distance and path between the start node and the end node.% A: adjcent matrix% s: start node% e: end node% initializen=size(A,1); % node numberD=A(s,:); % distance vectorpath=; % path vectorvisit=ones(1,n); % node visibilityvisit(s)=0; % source node is unvisibleparent=zeros(1,n); % parent node% the shortest distancefor i=1:n-1 % BlueSet has n-1 nodes temp=zeros(1,n); count=0; for j=1:n if visit(j) temp=temp(1:count) D(j); else temp=temp(1:count) inf; end count=count+1; end value,index=min(temp); j=index; visit(j)=0; for k=1:n if D(k)D(j)+A(j,k) D(k)=D(j)+A(j,k); parent(k)=j; end endenddistance=D(e);% the shortest distance pathif parent(e)=0 return;endpath=zeros(1,2*n); % path preallocationt=e; path(1)=t; count=1;while t=s & t0 p=parent(t); path=p path(1:count); t=p; count=count+1;endif count=2*n error
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 房屋认购委托协议书
- 房屋过户申请协议书
- 房屋院子托管协议书
- 房款协议书范本模板
- 房租延期谈合同协议
- 房租赠与车位协议书
- 房车客车转让协议书
- 手工艺项目合同范本
- 手机壳购销合同范本
- 手续项目咨询协议书
- 天津师范大学《土木工程施工组织设计》2023-2024学年第二学期期末试卷
- 电能质量技术监督培训课件
- (2025)事业单位考试(面试)试题与答案
- T/CNCIA 02005-2020室外用仿石涂料涂装施工及验收规范
- 智慧农业智能大棚系统设计
- 《临床医师技能培训》课件
- 股份分配协议书范本
- 数独基础课程讲座
- 2025年中考语文常考作文押题《10个主题+15篇范文》
- 智能机器人创客基本训练知到课后答案智慧树章节测试答案2025年春仲恺农业工程学院
- 中国典籍外译知到课后答案智慧树章节测试答案2025年春山东建筑大学
评论
0/150
提交评论