1 / 47

The Train Marshalling Problem

The Train Marshalling Problem. Joe Ryan University of Ballarat joint work with Elias Dahlhaus, Peter Horak and Mirka Miller. Outline of Talk. Define the problem TMP is NP-Complete Reduction from NMTS TMP  NMTS Upper bound in terms of n Conclusion. The Train Marshalling Problem.

trung
Download Presentation

The Train Marshalling Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Train Marshalling Problem Joe Ryan University of Ballarat joint work with Elias Dahlhaus, Peter Horak and Mirka Miller

  2. Outline of Talk • Define the problem • TMP is NP-Complete • Reduction from NMTS • TMP  NMTS • Upper bound in terms of n • Conclusion

  3. The Train Marshalling Problem • The cars have different destinations, • we use auxiliary rails to rearrange their order so that all cars with the same destination will be grouped together. • Since, in general, there may be several trains at the station to be processed at the same time, the target is to use as few auxiliary rails as possible for each train. 1 2 3 4 5 6 7 8 9 10 11

  4. 1 2 3 4 5 6 7 8 9 10 11 Station 1: Cars 1,6,11 Station 2: Cars 5,10 Station 3: Cars 3,8 Station 4: Cars 2,7 Station 5: Cars 4,9 Track A Track B Track C Track D Reassemble the train from Track D followed, in order, by tracks C, B and A.

  5. 1 6 11 2 7 8 3 4 9 10 5 Train Ready to Distribute Carriages Station 1 Station 4 Station 3 Station 5 Station 2

  6. The Train Marshalling Problem Given a partition S of {1,…,n} into disjoint sets S1,…,St, find the smallest number k = K(S) so that there exists a permutation p(1),…,p(t) of {1,…,t} with the property: The sequence of numbers 1,2,…,n,1,2,…,n,…,1,2,…,n, where the interval 1,2,…,n is repeated k times, contains all the elements of Sp(1) , then all elements of Sp(2),… etc., and finally all elements of Sp(t) .

  7. The Train Marshalling Problem n = 11 1,2,3,4,5,6,7,8,9,10,11 S = {S1,S2,S3,S4,S5} S1 = {1,6,11} S2 = {5,10} S3 = {3,8} S4 = {2,7} S5 = {4,9} 1234567891011,1234567891011,1234567891011,1234567891011 k = K(S) = 4

  8. Numerical Matching with Target Sums* a1,a2,a3, …,ai,…,aj,…,ak,…,an-1,an + + b1,b2,b3, …,bi,…,bj,…,bk,…,bn-1,bn = = c1,c2,c3, …,ci,…,cj,…,ck,…,cn-1,cn * Garey and Johnson:- Problem SP17

  9. Numerical Matching with Target Sums Instance: positive integers I: a1,a2,…,an,b1,b2,…,bn,c1,c2,…cn Question: Are there permutations 1 and 2 such that for all i = 1,2,…n, a1(i)+ b2(i) = ci? Restriction ai 2, bi2, cj bi, cj  ai + 2.

  10. The Reduction • Let a1,a2,…,an,b1,b2,…,bn,c1,c2,…cn be positive integers satisfying the restrictions. • Let N = nci. • To the set (train) IN = {1,2,…,N} we assign a partition, R, of 2n elements (destinations); S1,…,Sn,T1,…Tn. • Divide the train into blocks X1,X2,…Xn and subblocks Xi = Dij, j = 1,…,ci(in order).

  11. The Reduction • For any subblock Dij, and any destination M, Dijcontains either 0 or 1 car going to M. • There is a car of destination Skin Dij iff j = ci−ak+1,…,ci • And a car of destination Tkin Dij iff j = 1,…,bk. • In any subblock, cars with S destinations precede cars with T destinations and Si (Ti) precedes Sj (Tj) iff i < j.

  12. The Reduction • In each block there are ai cars with destination Si and bi cars with destination Ti. • In each block there are ai+ bi= ci cars. • So there are N =nci cars in R. • The first 2 subblocks in any block contain n cars of T destinations (bi > 2) and no cars of S destinations (ai+2  cj). • The last subblock is made up of n cars of S destinations (bi < cj).

  13. Example Let a1=2,a2=3,a3=3,b1=3,b2=4,b3=3,c1=5,c2=7,c3=6. Then train R consists of N = 3(5+7+6) = 54 cars. Recall • There is a car of destination Skin Dij iff j = ci−ak+1,…,ci • And a car of destination Tkin Dij iff j = 1,…,bk.

  14. Example Let a1=2,a2=3,a3=3,b1=3,b2=4,b3=3,c1=5,c2=7,c3=6. Then train R consists of N = 3(5+7+6) = 54 cars t1t2t3−t1t2t3−s2s3t1t2t3−s1s2s3t2−s1s2s3║t1t2t3−t1t2t3−t1t2t3−t2 −s2s3−s1s2s3−s1s2s3║t1t2t3−t1t2t3−t1t2t3−s2s3t2−s1s2s3−s1s2s3 3−3−5−4−3║3−3−3−1−2−3−3║3−3−3−3−3−3 Partition is T1={1,4,9,19,22,25,37,40,43}T2={2,5,10,15,20,23,26,28,38,41,44,48} T3={3,6,11,21,24,27,39,42,45} S1={12,16,31,34,49,52} S2={7,13,17,29,32,35,46,50,53} S3={8,14,18,30,33,36,47,51,54}

  15. Claim: TMP is NP-Complete K(R) 2n−1  a1,…,an,b1,…,bn,c1,…,cn have a numerical matching. (i.e.) the conditions of NMTS are satisfied.

  16. K(R)  2n−1 NMTS • We have permutations 1 and 2 satisfying NMTS and need to show K(R)  2n−1. • i.e. there is an orderOof the 2n destinations so that the sequence J = (2n−1)INcontains all cars of the first destination of O followed by all cars of the second etc.

  17. K(R)  2n−1 NMTS Let O = T2(n),S1(n),T2(n-1),S2(n-1),…,T2(1),S1(1) Choose as first car of T2(i) on J, the car in Then the last placed car of T2(i) is in Choose as first car of S1(i) on J, the car in Then the last placed car of S1(i) is in

  18. Example 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 S1 T1 S2 T2 S3 T3

  19. K(R)  2n−1 NMTS • Cars from the first destination are placed in the first round. • Cars from the i-th destination are placed in the (i-1)-th round and the beginning of the i-th round. • The last car of T2(1)is in • So all the cars of S1(1)can be placed in the same (2n−1)-th round. for this part

  20. K(R)  2n−1 NMTS • Consider the sequence J = 1,2,…,N,1,2,…,N,…,1,2,…,N (2n−1) repetitions • For destination M, let fM be the car of M placed first and lM the car of M placed last. • Let JM be the interval on J from fM to lM. • For each m  IN we say m is covered by M (destination) if at least 1 of the (2n−1) occurrences of m in J belong to interval JM.

  21. Example JT3 = [3,45], JS3 = [47,54][1,36] 4 is covered by both destinations T3 and S3 JT3 covers 4 in the first round of J and JS3 covers 4 in the second round of J. 46 is covered by neither of them. 40 is covered by T3 but not by S3. Each element of IN belongs to at most 2n−1 intervals.

  22. K(R)  2n−1 NMTS • Let xi = number of car of Tn in Di1 • Let yi = number of car of S1 in Dici For i=1,..,n, xi is not covered by either • Any T destination (T  Tn) with fT in • Any Sj destination with fSj in For i=1,…n, yi is not covered only by • Any T destination with fT in • Any S destination (S  S1) with fS in

  23. Example • Let xi = number of car of Tn in Di1 • Let yi = number of car of S1 in Dici

  24. K(R)  2n−1 NMTS • All T destinations are of type ii) so all S destinations are of type iii). • For each i there is one T with fT in Xi and one S with fS in Xi. • Let Tk be the T with fTk X(i+1)modn • Let Sj be the S with fSj Xi. • Then lTk < fSj. • Subblock with lTkprecedes subblock with fSj

  25. K(R)  2n−1 NMTS • Tk does not cover the last ci−bk subblocks in Xi. • Sj does not cover the first ci−aj subblocks in Xi.

  26. S1 T1 S2 T2 S3 T3 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 3−3−5−4−3║3−3−3−1−2−3−3║3−3−3−3−3−3

  27. K(R)  2n−1 NMTS • Tk does not cover the last ci−bk subblocks in Xi. • Sj does not cover the first ci−aj subblocks in Xi. So ci−bk+ci−aj ci i.e. ci aj + bk but we can set1(i) = j and 2(i) = k Then we get, for i = 1,…,n, ci a1(i) + b2(i) However we haveai + bi = ci so inequality becomes equality.

  28. Take next exit Continue

  29. The Upper Bound • Since TMP is NP-complete, an upper bound for K(S) in terms of n may be useful. (We know that for t destinations K(S)  t−1.) • Let Kn be that maximum of K(S) where S ranges over all partitions of {1,…,n}. • Main result for this section Kn =  n/4 + ½ 

  30. Notation • For S a partition of {1,…,n}, say S = {S(1), S(2),…,S(s)}, we use S(i) to denote the set containing i. If we use a number xi, yi etc. then this number is from the same set as i. So S(i) = {i, xi, yi,…} • Let T−1be the train obtained from T by reversing the cars. Then K(T) = K(T−1).

  31. Observations • For S′ = {S(i1),…,S(ir)} a subset of S where |S(i1) …  S(ir)| = t then K(S)  K(S′) + K(S−S′)  K(S′) + Kn-t • Let S contain a destination with r cars or r destinations with a single car each. Then, K(S)  1 + Kn−r

  32. Observations • If all numbers of S(i) are smaller than all numbers of destination S(j) then we say that S(i) and S(j) do not overlap. • If |S(i)| + |S(j)| = r and S(i) and S(j) do not overlap then K(S)  1 + Kn−r

  33. Lemma • Let S(i1),…,S(ik) be destinations of S such that |S(i1)| + |S(ik)| = t and all the numbers of the interval {1,…,j} belong to U = S(i1)…S(ik). If it is possible to arrange all numbers from U into k rounds so that the last (k-th) round contains only numbers from the interval {1,…,j} then K(S)  k−1+Kn−t

  34. Kn   n/4 + ½  • We may assume n  5, and that n is even. From the previous observations we have – • At most one destination contains a single car. • For all other destinations 2  |S(i)|  3. • Any two destinations with at least 4 cars in total must overlap.

  35. The Proof Case 1: Let |S(1)| = |S(2)| = 2, then K(S)  1+Kn−4n/4 + ½ S(1) = {1,x1} differs from S(2) = {2,x2}, then either 1, x1, x2, * 2 or 2, x2, x1, * 1. 2 x2 x1 1 . . .

  36. The Proof Case 2: If one of S(1) and S(2) is of cardinality 1, then K(S)  1+Kn−4n/4 + ½ Suppose |S(1)|=1, then there is no overlap with any destination of cardinality 3. If there is no 3 car set then |S(n−1)|=|S(n)|=2 and use K(T−1). If |S(2)|=1 then either |S(1)|=3 whence 2,x1,y1,*1 Or there is |S(i)|=3 such that S(2) and S(i) do not overlap.

  37. 1 2 x1 x2 y2 y1 y1 y2 1 2 x2 x1 xi xi yi yi i i The Proof Case 3: Let |S(1)| = |S(2)| = 3 then either K(S)  1+Kn−4n/4 + ½ orK(S)  2+Kn−8n/4 + ½ Let S(i) be the set with the smallest index after 2. If |S(i)|=1 then the 3 sets can be placed in 2 rounds with any of 1,2,…,i in the third and use Lemma. If |S(i)|=3 then the three sets can be placed in 2 rounds with 1,2,…,i in the third and use Lemma.

  38. The Proof Case 3: Let |S(1)| = |S(2)| = 3 then either K(S)  1+Kn−4n/4 + ½ orK(S)  2+Kn−8n/4 + ½ Let S(i) be the set with the smallest index after 2. If |S(i)|=2 then we can add a dummy car to S(i) and number it n+1 (it comes at the end of the train). Call this new partition S′. Then, employing the Lemma, we have K(S)  K(S′)  2+Kn+1−9 2+Kn−8 n/4 + ½

  39. The Proof Case 4: Let |S(1)| + |S(2)| = 5, then either K(S)  1+Kn−4n/4 + ½ orK(S)  2+Kn−8n/4 + ½ Let S(1), S(2) be {a1,a2}, {b1,b2,b3}, then If a2<b2<b3 use a1,a2,b2,b3,*b1 and the Lemma If b2<b3<a2 use b1,b2,b3,a2,*a1 and the Lemma If b2<a2<b3 then 4a: consider S(j) such that |S(j)|=3 and S(j)={c1,c2,c3}. Now consider U, the union of S(1), S(2), S(j) viz, 1,2,d3,d4,…,d8 (in increasing order).

  40. The Proof 4a:We have 1<2<d3<d4<…<d8 and a2= di, i={5,6,7} The following satisfy the assumptions of the Lemma and yield the bound; If a2=d7 use b1,b2,b3,*c1,c2,c3,a2,*a1 If a2=d6 use c1,c2,c3,b3,*b1,b2,a2,*a1 (2 cases) If a2=d5 use b1,b2,b3,c2,c3,*c1,a2,*a1 b3<c2<c3 c1,c2,c3,b3,*b1,b2,a2,*a1 c2<c3<b3 For d5=a2<c2<b3<c3 use previous cases on S(n−1), S(n) and consider K(S−1).

  41. The Proof 4b: Let S(n), S(n−1) be {u1,u2}, {v1,v2,v3}. Assume there is nosuch S(j)={c1,c2,c3}, then {b1,b2,b3} = {v1,v2,v3}. Since n is even there must be a destination with a single car, {w}. Then either 4b1:{a1,a2} = {u1,u2} which gives, since the sets must overlap, {b1,b2,b3} = {1,b2,n} so we can use w, b2, n,* 1, or

  42. The Proof 4b2: {a1,a2}  {u1,u2} then consider • {a1,b1} = {1,2}, {b3,u2} = {n-1,n} and u1<b2<w<a2 • Same as i) with a2 and w interchanged. Apply Lemma to S(1), S(2), {u1,u2} and {w} with • b1,b2,b3,u2,*u1,w,a2,*a1 for u2>b3 u1,u2,b3,*b1,b2,w,a2,*a1 for u2<b3 • a1,a2,w,u2,*u1,b2,b3,*b1 The proof of the statement Knn/4 + ½ is now complete.

  43. Kn =  n/4 + ½  • We present a partition showing equality. • Let k = n/2 and S = {S(1),…,S(k)} where S(i) = {i, i+k}, i = 1,…,k. • Let A be an arrangement of cars in K(S) rounds of In. • Then any round contains at most 4 cars and the first round contains at most 3 cars. • So K(S)  (n−3)/4+1 =  n/4 + ½ 

  44. Conclusion A dispatcher in a marshalling yard knows that the TMP is NP-complete and that they must assume that they need min(Kn,T−1) auxiliary rails (T is the number of destinations). To improve this bound the dispatcher needs some additional information. The minimum number of cars per destination should be readily available.

  45. Conclusion Let K(n,m) = max K(s) where the train has n cars and at least m go to any one destination. Then Conjecture: K(n,m)  (m1)d2/n+1/m where d = n/m Putting S(i) = {i,i+d,…,i+(m−1)d}, i = 1,…,d gives K(n,m)  (m−1)d2/n+1/m where d = n/m. So that if the conjecture is true, this bound is the best possible.

  46. Dĕkuji

More Related