Travelling salesman problem
hi all;
i'm new in the java world and im seeking some help plz
i wanna implement an exhaustive algorithm of TSP(travelling salesman problem) in java
in this algorithme the travelling salesman have to visit a set of cities only once and he have to return to the first city he left from;
its an exhaustive algorithme bcuz in it we try everypossible path and then see the path with the lowest cost but im not gonna change the first city im leavin ill fix the city that ill start from it wont change
here is the algorithm :
N = {1, 2, ... , n} is the nodes
S = (k, [i1, i2, ... ,ik], w) is an ordered set which includes a partial path (ordered list of k integers) and the sum of its edge weights w
w = w(1,2) + w(2,3) + w(3,4) + ... + w(n-1,n) + w(n,1)
Best_S_so_far = ( n, [ 1, 2, 3, ... , n-1, n ], w )
S = ( 1, [ 1 ], 0 )
Search( S, Best_S_so_far )
print Best_S_so_far
procedure Search( S, Best_S_so_far )
let ( k, [ i1, i2, ... , ik ], w ) = S
let ( n, [ i1B, i2B, ... , inB ], wB ) = Best_S_so_far
if k = n then
new_w = w + w(ik,i1)
if new_w < wB then
Best_S_so_far = ( k, [ i1, i2, ... , ik ], new_w )
end if
else
for all j not in [ i1, i2, ... , ik ]
new_w = w + w(ik,j)
New_S = ( k+1, [ i1, i2, ... , ik, j ], new_w )
Search( New_S, Best_S_so_far )
end for
endif
return
end
hope you will help me out in programin this in java :)