Interface to travelling salesperson problem solver.
Consider an integer linear programming (ILP) formulation of DFJ (Dantzig et al, 1954) used in this research. Let G=(V,A) be a graph with a set V of n vertices and A be a set of arcs or edges. Let C=(cij) be a distance (or cost) matrix associated with A. Elements of the distance matrix C,cij, are positive integers, i,j∈V,i=j.
The TSP focuses on finding a minimum distance circuit (a tour or Hamiltonian circuit) that passes through each vertex once and only once. The DFJ formulation is
minimizeL=j=i∑cijδij (1)
subject toj=1∑nδij=1,i=1,...,n (2)
i=1∑nδij=1,j=1,...,n (3)
i,j∈S∑δij≤∣S∣−1,S⊂V,2≤∣S∣≤n−2 (4)
δij∈0,1,i,j=1,...,n,i=j (5)
Constraints (2) and (3) are known as degree constraints indicating that every vertex should be entered and left exactly once correspondingly. Constraints (4) are subtour elimination constraints that prevent from forming subtours (several unconnected tours on subsets of less than n vertices), with ∣S∣ denoting the number of vertices in S.
In the DFJ formulation there are n(n−1) unknown binary variables, 2n degree constraints and 2n−2n−2 subtour elimination constraints. Since the number of subtour elimination constraints increases exponentially, solving this problem directly using an integer linear programming code is in general intractable. However, relaxed versions of the integer linear programming problem where some constraints are initially removed, and later restored via an iterative process, have been proposed and extensively used.
Here it is proposed to combine heuristics (to get an initial feasible solution) and a linear Diophantine equation (nilde) relaxation to develop a new exact algorithm that constructs all existing optimal solutions for the TSP in an efficient way.
Below is a brief summary of the proposed algorithm.
Step 1. (Initialization) Solve a corresponding assignment problem to obtain an initial lower bound on the value of the optimal TSP solution. Apply heuristics to obtain an initial upper bound.
Step 2. (Subproblem solution) Given the initial lower bound construct all 0-1 solutions to a linear Diophantine equation introduced by Voinov and Nikulin (1997).
Step 3. (Degree constraints check) Remove solutions that do not satisfy the degree constraints.
Step 4. (Subtour elimination) Remove solutions that contain subtours by applying a new simple subtour elimination routine. If there is a solution(s) that contains no subtours, it forms the optimal solution(s): stop. Otherwise, increase the initial lower bound by one and go to step 2. Repeat until the upper bound is reached.
The integer programming formulation of the assignment problem solved in Step 1 of the above algorithm is obtained by relaxing constraints (4), i.e. given by (1) subject to constraints (2), (3) and (5).
For implementing Step 2, solutions of the corresponding subset sum problem should be enumerated. A subset sum problem formulation can be expressed as [REMOVE_ME]a1s1+a2s2+…+apsp=L,(6)[REMOVEME2]
where si∈{0,1},i=1,…,p,p=n(n−1) is the number of unknown binary variables of the original TSP. ai are positive integers matching the costs cij of the cost matrix C.
Voinon and Nikulin (1997) introduced an algorithm that enumerates all nonnegative integer solutions of equation (6) by using the corresponding generating function and the binomial theorem. All 0−1 solutions to the equation in (6) can be found by means of the following generating function: [REMOVE_ME]ΨL(z)=(za1+za2+…+zap)L=k=L⋅mini(ai)∑k=L⋅maxi(ai)Rk(L,p),[REMOVEME2]
where [REMOVE_ME]Rk(L,p)=sp=0∑min(1,[apL])sp−1=0∑min(1,[ap−1L−apsp])…s2=0∑min(1,[a2L−apsp−…−a3s3])(L−s1−…−sp)!s1!…sp!L!,[REMOVEME2]
[REMOVE_ME](7)[REMOVEME2]
s1=a1L−apsp−…−a2s2 is necessarily either 0 or 1. Otherwise, the equation in (6) does not have any solutions. The notation [x] denotes the greatest integer part of x.
The right-hand side multiplier in (7) presents the total number of compositions that satisfy the above condition. If the value of that multiplier is set to 1, (7) gives the number of 0−1 solutions for the equation (6). The solutions, if exist, are written explicitly as [REMOVE_ME]{a1s1,a2s2,…,apsp},(8)[REMOVEME2]
where {s2,…,sp} are sets of summation indices in (7), with s1 as specified above. The notation (8) means that in a particular partition (a solution of the equation (6)) there are s1 terms equal to a1,s2 terms of a2 and so on.
Description
Interface to travelling salesperson problem solver.
Consider an integer linear programming (ILP) formulation of DFJ (Dantzig et al, 1954) used in this research. Let G=(V,A) be a graph with a set V of n vertices and A be a set of arcs or edges. Let C=(cij) be a distance (or cost) matrix associated with A. Elements of the distance matrix C,cij, are positive integers, i,j∈V,i=j.
The TSP focuses on finding a minimum distance circuit (a tour or Hamiltonian circuit) that passes through each vertex once and only once. The DFJ formulation is
minimizeL=j=i∑cijδij (1)
subject toj=1∑nδij=1,i=1,...,n (2)
i=1∑nδij=1,j=1,...,n (3)
i,j∈S∑δij≤∣S∣−1,S⊂V,2≤∣S∣≤n−2 (4)
δij∈0,1,i,j=1,...,n,i=j (5)
Constraints (2) and (3) are known as degree constraints indicating that every vertex should be entered and left exactly once correspondingly. Constraints (4) are subtour elimination constraints that prevent from forming subtours (several unconnected tours on subsets of less than n vertices), with ∣S∣ denoting the number of vertices in S.
In the DFJ formulation there are n(n−1) unknown binary variables, 2n degree constraints and 2n−2n−2 subtour elimination constraints. Since the number of subtour elimination constraints increases exponentially, solving this problem directly using an integer linear programming code is in general intractable. However, relaxed versions of the integer linear programming problem where some constraints are initially removed, and later restored via an iterative process, have been proposed and extensively used.
Here it is proposed to combine heuristics (to get an initial feasible solution) and a linear Diophantine equation (nilde) relaxation to develop a new exact algorithm that constructs all existing optimal solutions for the TSP in an efficient way.
Below is a brief summary of the proposed algorithm.
Step 1. (Initialization) Solve a corresponding assignment problem to obtain an initial lower bound on the value of the optimal TSP solution. Apply heuristics to obtain an initial upper bound.
Step 2. (Subproblem solution) Given the initial lower bound construct all 0-1 solutions to a linear Diophantine equation introduced by Voinov and Nikulin (1997).
Step 3. (Degree constraints check) Remove solutions that do not satisfy the degree constraints.
Step 4. (Subtour elimination) Remove solutions that contain subtours by applying a new simple subtour elimination routine. If there is a solution(s) that contains no subtours, it forms the optimal solution(s): stop. Otherwise, increase the initial lower bound by one and go to step 2. Repeat until the upper bound is reached.
The integer programming formulation of the assignment problem solved in Step 1 of the above algorithm is obtained by relaxing constraints (4), i.e. given by (1) subject to constraints (2), (3) and (5).
For implementing Step 2, solutions of the corresponding subset sum problem should be enumerated. A subset sum problem formulation can be expressed as
a1s1+a2s2+…+apsp=L,(6)
where si∈{0,1},i=1,…,p,p=n(n−1) is the number of unknown binary variables of the original TSP. ai are positive integers matching the costs cij of the cost matrix C.
Voinon and Nikulin (1997) introduced an algorithm that enumerates all nonnegative integer solutions of equation (6) by using the corresponding generating function and the binomial theorem. All 0−1 solutions to the equation in (6) can be found by means of the following generating function:
s1=a1L−apsp−…−a2s2 is necessarily either 0 or 1. Otherwise, the equation in (6) does not have any solutions. The notation [x] denotes the greatest integer part of x.
The right-hand side multiplier in (7) presents the total number of compositions that satisfy the above condition. If the value of that multiplier is set to 1, (7) gives the number of 0−1 solutions for the equation (6). The solutions, if exist, are written explicitly as
{a1s1,a2s2,…,apsp},(8)
where {s2,…,sp} are sets of summation indices in (7), with s1 as specified above. The notation (8) means that in a particular partition (a solution of the equation (6)) there are s1 terms equal to a1,s2 terms of a2 and so on.
data: An n x n matrix of costs/distances of the TSP (with 0's or NAs on the main diagonal). Costs/distances of the unconnected edges must be supplied as NA.
labels: An n vector of optional city labels. If not given, labels are taken from data.
cluster: Degree constraints can be checked in parallel using parLapply from the parallel package. cluster is either 0 (default) for no parallel computing to be used; or 1 for one less than the number of cores; or user-supplied cluster on which to do checking. a cluster here can be some cores of a single machine.
upper_bound: A positive integer, an upper bound of the tour length (cost function), if not supplied (default: NULL) heuristic solution is obtained using
TSP::solve_TSP(data,method).
lower_bound: A positive integer, a lower possible value of the tour lenght (cost function); if not supplied (default: NULL), obtained by solving a corresponding assignment problem using lpSolve::lp.assign(data)
method: Heuristic method used in TSP::solve_TSP()
(default: cheapest_insertion)
no_go: A suitably large value used in the distance/cost matrix to make related edges infeasible, if NULL (default) set to max(data)*10^5. It can be set to Inf for TSP(). However, lpSolve() is very sensitive to too large values and can result in high values of the lower_bound.
Returns
tour: optimal tour(s).
tour_length: an optimal (minimal) length of the obtained tour(s).
coming_solutions: a list of coming feasible tours obtained within [lower_bound, upper_bound].
coming_tour_lengths: a vector of feasible tour length gone within [lower_bound, upper_bound].
iter: a number of feasible tour length gone through
upper_bound: an upper bound of the tour length
lower_bound: a lower bound value of the tour lenght
Author(s)
Vassilly Voinov, Natalya Pya Arnqvist
References
Voinov, V. and Nikulin, M. (1997) On a subset sum algorithm and its probabilistic and other applications. In: Advances in combinatorial methods and applications to probability and statistics, Ed. N. Balakrishnan, , Boston, 153-163.
Dantzig, G., Fulkerson, R. and Johnson, S. (1954) Solution of a large-scale traveling-salesman problem. Journal of the operations research society of America , 2(4):393-410.
## Not run:## some examples...library(nilde)set.seed(3)d <- matrix(sample(1:100,25,replace=TRUE),5,5)diag(d)<-NA# although no need to specify as the code assumes NAs by defaultg <- tsp_solver(d)g
## End(Not run)