H.P. WILLIAMS LONDON SCHOOL OF ECONOMICS MODELS FOR SOLVING THE TRAVELLING SALESMAN PROBLEM h.p.williams@lse.ac.uk STANDARD FORMULATION OF THE (ASYMMETRIC) TRAVELLING SALESMAN PROBLEM Conventional Formulation: (cities 1,2, …, n) (Dantzig, Fulkerson, Johnson) (1954). xij is a link in tour c x Minimise: ij i,j subject to: ij x 1 all j x 1 all i ij i ij j i , jS xij | S | - 1 all S {2..., n} e.g. 2 6 3 x32 x26 x63 x23 x62 x36 2 0(2n) Constraints = (2n-1 + n –2) 0(n2) Variables = n(n – 1) EQUIVALENT FORMULATION Replace subtour elimination constraints with x 1 all S 1,2, ,..., n iS jS ij ____ S S Add second set of constraints for all i in S and subtract from subtour elimination constraints for S OPTIMAL SOLUTON TO A 10 CITY TRAVELLING SALESMAN PROBLEM 8 6 3 1 2 1 0 5 7 4 Cost = 881 9 FRACTIONAL SOLUTION FROM CONVENTIONAL (EXPONENTIAL) FORMULATION) Cost = 878 (Optimal Cost = 881) Sequential Formulation (Miller, Tucker, Zemlin (1960)) ui = Sequence Number in which city i visited Defined for i = 2,3, …, n Subtour elimination constraints replaced by S: ui - uj +nxij n – 1 i,j = 2,3, …, n Avoids subtours but allows total tours (containing city 1) 2 u2 – u6+ nx26 n-1 6 u6 – u3+ nx63 n-1 u3 – u2+ nx32 n-1 3 3n 0(n2) 0(n2) Constraints Variables = = 3(n – 1) (n2 – n + 2) (n – 1) (n + 1) Weak but can add 'Logic Cuts' e.g. uk 1 xij x jk x1 j FRACTIONAL SOLUTION FROM SEQUENTIAL FORMULATION Subtour Constraints Violated : e.g. Logic Cuts Violated: e.g. Cost = 773 3/5 x x 1 27 72 u 1 x x x 9 27 79 17 (Optimal Cost = 881) Flow Formulations Single Commodity (Gavish & Graves (1978)) Introduce extra variables (‘Flow’ in an arc) Replace subtour elimination constraints by F1: y (n 1) x all i, j ij ij y n 1 j 1j y y 1 all j 1 i ij k jk Can improve (F1’) by amended constraints: y ( n 2) x ij ij all i, j 1 Network Flow formulation in yij variables over complete graph 4 1 1 2 1 n-1 3 1 Graph must be connected. Hence no subtours possible. 2 0( n ) 2 0( n ) Constraints n(n 2) Variables 2n(n 1) FRACTIONAL SOLUTION FROM SINGLE COMMODITY FLOW FORMULATION 2 Cost = 794 9 (Optimal solution = 881) FRACTIONAL SOLUTION FROM MODIFIED SINGLE COMMODITY FLOW FORMULATION Cost = 794 43 48 (Optimal solution = 881) (192=3x64) Two Commodity Flow (Finke, Claus Gunn (1983)) y is flow of commodity 1 in arc i j ij z is flow of commodity 2 in arc i j ij y y ij j F2: z z ij j z z j j ij j y z ij j 1 i 1 n 1 i 1 ji 1 i 1 (n 1) i 1 ji n 1 all i = ji (n 1) xij all i, j = ij 1 Commodity 1 1 3 2 1 1 n-1 Commodity 2 n-1 Commodity 2 Commodity 1 0( n ) Constraints n(n 4) 2 0( n ) Variables 3n(n 1) 2 1 Multi-Commodity (Wong (1980) Claus (1984)) “Dissaggregate” variables y is flow in arc destined for k k ij y x all i, j, k k ij F3 ij y 1 y 1 k i k ik i 1i y 0 k i i1 y 0 all k k j kj y y all j, k , j 1, j k. k i ij k i ji 3 Constraints n 2n 6n 3 3 Variables 0( n ) 0( n ) 3 2 n n 1 2 LP Relaxation of equal strength to Conventional Formulation. But of polynomial size. Tight Formulation of Min Cost Spanning Tree + (Tight) Assignment Problem FRACTIONAL SOLUTION FROM MULTI COMMODITY FLOW FORMULATION (= FRACTIONAL SOLUTION FROM CONVENTIONAL (EXPONENTIAL) FORMULATION) Cost = 878 (Optimal Cost = 881) Stage Dependent Formulations First (Fox, Gavish, Graves (1980)) = 1 if arc i j traversed at stage t = T1: 0 otherwise y n t ij i , j ,t ty ty 1 i 2, 3...n n n j 1 t 2 t ij n n j 1 t 1 t ji (Stage at which i left 1 more than stage at which entered) y 0, t n t i1 y 0, t 1 t 1j y 0, i 1 1 ij 0n Constraints n 0n Variables n n 1 3 2 Also convenient to introduce x variables with constraints ij x y ij t t ij FRACTIONAL SOLUTION FROM 1ST (AGGREGATED) TIME-STAGED FORMULATION Cost = 364.5 (Optimal solution = 881) NB ‘Lengths’ of Arcs can be > 1 Second (Fox, Gavish, Graves (1980)) T2: Disaggregate to give yijt 1 all j yijt 1 all i yijt 1 i j ,t j i ,t i , j ,i j n n ty j 1 t 2 t ij all t n - n ty j1 t 1 t ji 1 i 2,3, ... n Initial conditions no longer necessary 0(n) Constraints = 4 n – 1 0(n3) Variables = n2 (n – 1) FRACTIONAL SOLUTION FROM 2nd TIME-STAGED FORMULATION Cost = 799 164 357 (optimal solution = 881) (714 = 2 x 3 x 7 x 17) Third T3: (Vajda/Hadley (1960)) t y ij interpreted as before yijt 1 all j yijt 1 all i yijt 1 all t i j j i t yijt y tjk1 y11 j = 1 yin1 = 1 i j j 1 i 1 k j = 0 all j, t 0 (n2) Constraints = (2n2+ 3) 0 (n3) Variables = n2(n-1) FRACTIONAL SOLUTION FROM 2nd TIME 2nd TIME-STAGED FORMULATION Cost = 804 1 2 Optimal solution = 881 OBSERVATION Multicommodity Flow Formulation y y 0 t ij i y t ij t k is flow i j jk destined for node t Time Staged Formulation y y 0 t 1 t i k ij j k y 1 iff go i j at stage t t ij Are these formulations related? Can extra variables y , introduced syntactically, be given different semantic interpretations? t ij COMPARING FORMULATIONS Minimise: cx Subject to: Ax By b x, y 0, x integer W {w | wB 0, w 0} W forms a cone which can be characterised by its extreme rays giving matrix Q such that QB 0 Hence QAx Qb This is the projection of formulation into space of original variables x ij COMPARING FORMULATIONS Project out variables by Fourier-Motzkin elimination to reduce to space of conventional formulation. P (r) is polytope of LP relaxation of projection of formulation r. Formulation S (Sequential) Project out around each directed cycle S by summing u u nx n 1 i j ij n x n 1 S i , jS ie x S i , jS ij ij S n Hence PS PC weaker than |S|-1 (for S a subset of nodes) Formulation F1 (1 Commodity Network Flow) Projects to ijs Hence xij | S | |S| |S| stronger t han | S | n 1 n P( S ) P( F1) P(C ) Formulation F1' (Amended 1 Commodity Network Flow) Projects to Hence 1 n 1 jS {1} jS xij xij | S | i , jS |S| n 1 P( S ) P( F1) F ( F1' ) P(C ) Formulation F2 (2 Commodity Network Flow) Projects to i, j Hence xij | S | |S| n 1 P(F2) = P(F1) Formulation F3 (Multi Commodity Network Flow) Projects to x ij | S | 1 i, j S Hence Formulation T1 P(F3) = P(C) (First Stage Dependant) Projects to x iS j S {1} ij |S | n 1 x n i , jN ij (Cannot convert 1st constraint to ‘ xij ‘form since i , j5 Assignment Constraints not present) Formulation T2 (Second Stage Dependant) Projects to 1 n 1 x ij iS jS {1} 1 n 1 x x | S | i S {1} j S ij ijjs ij |S| n 1 + others Hence P(T2) P(F1') Formulation T3 (Third Stage Dependant) Projects to 1 n 1 x i S jS {1} ij 1 |S| xij xij | S | n , j S n 1 ijSS{1} n 1 + others Can show stronger than T2 Hence P(T3) P(T2) Computational Results of a 10-City TSP in order to compare sizes and strengths of LP Relaxations Model Size C (Conventional LP Obj Its Secs IP Obj Nodes Secs 502x90 (Ass. Relax +Subtours (5) +Subtours (3) +Subtours (2) 766 804 835 878 37 40 43 48 1 1 1 1 766 804 835 881 0 0 0 9 1 1 1 1 S (Sequential) 92x99 773.6 77 3 881 665 16 F1 1(Commodity Flow F' (F1 Modified) 120x180 794.22 148 1 881 449 13 120x180 794.89 142 1 881 369 11 F2 (2 Commodity Flow) 140x270 794.22 229 2 881 373 12 F3 (Multi Commodity Flow) 857x900 878 1024 7 881 9 13 T1 (1st Stage Dependent) 90x990 (10)x(900) 364.5 63 4 881 120x990 (39) x (900) 799.46 246 18 881 483 36 193x990 (102)x(900) 804.5 307 5 881 145 27 (2nd T2 Stage Dependent) T3 (3rd Stage Dependent) Solutions obtained using NEW MAGIC and EMSOL P(TSP) TSP Polytope – not fully known P(X) Polytope of Projected LP relaxations Reference AJ Orman and HP Williams, A Survey of Different Formulations of the Travelling Salesman Problem, in C Gatu and E Kontoghiorghes (Eds), Advances in Computational Management Science 9 Optimisation, Econometric and Financial Analysis (2006) Springer