Shortest Path calculation problem

4 次查看(过去 30 天)
vimal r
vimal r 2020-3-17
评论: KSSV 2020-3-17
%mat = [0,10,15,20;10,0,35,25;15,35,0,30;20,25,30,0]
pkg load io
mat = xlsread('distance matrix2.xlsx')
source = 1
len = length(mat)
vertex = zeros(1,len-1)
for i=1:len-1
vertex(i)=i+1
end
minpath = intmax
num = factorial(len-1)
count=0
while(count<num)
current_pathweight=0
k=source
for i=1:len-1
current_pathweight=current_pathweight+mat(k,vertex(i))
k=vertex(i)
end
current_pathweight=current_pathweight+mat(k,source)
if(current_pathweight<minpath)
minpath=current_pathweight
end
vertex=myperms(vertex)
count = count+1
end
when i run shows error:
Undefined function or variable 'pkg'.
Error in main (line 2)
pkg load io

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by