,.,I-I-.- .I-I. :,-7-1, ..-...- -.I....--,-I . ..--.. ...: I. .-.. -:.,. .. ,:-, ..--.-,---:-.-: -l --,,,1. : .1 -.II I-7 - I ,- II.I--..-. 4 .-,. :.I II ,. I,'-.,-,. -.. -I -. .. I.-... .,.,,..I-. -.'..L-II .. j, , I, II. I t ,,.4,-.--.--. ..-r,.,-,.,,,,,-'..I:.,1:, , -4 : -I-. :. ,.- 1,,,I.,,-,: -. -,-.-a--I,-.-.I...:Z,: .,..:. -..; I..--.!tI ,,,: --;ili ,,I1 ,-,".II.%:,.I,:-. .:,.-, ,-., -,f,---I---l,--, !.. ---,,,I ,--,iiI , 1..:. ,. ...-.,:,:.; ;. ,-,.,.,.-,,,-:"-,.---,II.-.---,,,..-:,1 ...-. -. ..,--- .,I -m,:.r, -.-. -- .,,--,----,-:-I,:,. . -_-"----" .,,,,,... . II---.-W..-Im,-,:,, I , . k 1. ----..,.---,,---, ,,-. 1",. :,-..,I .-, -,I,:: :..-.,-,-.:, .,-,-r--1---. ,, ,:--:--,-: :I-.., , :.I:.----: .,z ::--1--, ,lI1, :'. : -.-: _, -. , :, ----,.:, i i'l,--.---% .-..,.-..-,,I,-,':,. -,II.::-.-11-. ,.I., -, :...t-,--,--, ,j,-I -.,.I.-,I-. .!,I-, 1.-. I-.I-,--:-,,.-III. -II-.- ,-;I., II-----: -,--', . '!.. ,...-II.," --.. ,.-I--,Jerez 4%.," .:::-.-C::", ' : ,,L-.- , -,I, -1.:.-..-.II..-..-,-I11 -,,'-, -- ----;-":.:,,'",. ,I.;--.. .. .,I- --,::-,7,-,-.,;: :-t ,-1. :,.,--, --I:: .-I.,-i..-, .. I-I.zbmI-.;-, : ," .: ,", -, ,,--; ,.-,.,:..,-:,---;---,.-T-L.z',',-..,,, -.,-,:-,-.-I,--. ,-..,,, ."----I-, ;I-..IIi.,,.m .1.-7,,-,-II. ,", .1,. -.. : :,,1.-. :,,,:-`-,---,,II--. II.1.--, -... I,--I --&,,.. 1: ---Z--: ,---:-:,-I -,,,,.,v ",.-. -,,,--.,:I,-,-,,..,.,-,.7 -..--: .:-,- -.. , ,,,,di.-I.1.1-: I-.,:-.. , :..,",.,-:.: .1a , w ,-,, ,:.:. ,Z-I:. ,, --4.-,,--.. .. I-.,.- 7.-.:II.--,,. --I-.--,.:-., .,,---,,---,:..,-.ZI-.I. -,I :I--....-.-,-. I --., ",1, .,:-. -t .,.I"--,,..,I,--..-.,.,-,,--.7..,,. -I-. .----, -,, :-: `"_:,-,-. I-: " I ,.-,. -- - , .,., -..; : ,,;.. tI.II.. .. :`,,,.I:,,-. . '. ,-,,.,-". :---.I --;--, ,'1-,:--l "I. :--,1,-,, -,,-.,,-.., -,----I.I.-,,: ., , .-,.!-------,,--.,--7,.-,,..-: .-': I--, :. 1, .. , iI ,...-IIo- , -----II.t--,., :-, :I - I,-,.. :.-. II,, ". -, ,':.---.' :-,,.,,.-.,-..,---. .:,....' :',.. ! --..:-. :,, --,-.WII.,-,,,,,.-... ,,..-".--,t ... ,-.I,-,.II-.I,.-..-.,-. --. ,,,,-: ,I-,, ,:-t,-II, -,-, ,---,..:II.,.,.,..II,--.,,,I,. .,I..,-;-,I-1 :, -, I--.,.I--, ,, ,,-,,,.--,-, ;,I.,-.---I -.,:-1,.-.,-!,--.I:,..;_.. ,-,.I.,,;.t.-, -, ;;'I- ,-.,I,,: ... ,.-.% I .--- -, -'.-,.,.I--,,-,,,Z , -, ,II-, "--,,-:-,,-,,,-,,-I-., .I.,:-, -,I,: , II-.--..--.I,,---i I-t--....--..-,,...,,--. ,-....,. ,1.4,.. I -1: : 1,-1, ,;,, -,';--l--:,-..-----;-- ...-: .I.--,I-,,,,:: -:,---I:I.--.I.III ,,: i..---,-..-I - '. :, -.,I.I -. ,,..-I,1----ZT, :, --I,,:; -,z:-I,. -i.,,-. ,,--. -,. -, - 1--; ;,---, . I-,--j..:,,i.-. ,i.!---I.-., ,-.1,..--:----..I ,,,----Z.:I-..ZI.t--. , ,..- 1.:I::...:--1-,. I.I ",-!.II.I--r---,I:0.--..-:, I.-t -l.1 ,..'.--.I-.,-I - ,,,,-,.-7,--.-I.. .,,:I.;,;:`--,, :.., ,"'-,--.,, -,--,.--I,.I-. .-.. -.I-.,.,, -.. ----, 2.,....-:z..f,....,.-. ,: , ... '.., ,-,.,----'-...-I.--, ",,.' -,-- -,-,"--,;:.., ---,---:,.. ,.-- I.",, -!- ,--,:--,, .,.-.,..,.!,-.,-,I,-:..II,----tl T-, ".--"."I,.I.. --- .I11 -.,, , ,.-.-`-----.. --:-.,-1-;-:.-.. -----------.---I.,:.II.I-.4-.,,. , .: ,q..I,- ----, -: . -I ,. I. ._-__. --.-.I--I.,-,., -, ,. ,I, -,,--`-_, ,.-.,Ii--,, I .I z;I -. ,, -- ,.-,--,-.--,, -:..I,.,,:,--,-; -.-,--:-.,: --. I., ,_-..---, .II ,l . .,I,-,I-I. ..--.::.-,,: I.-..,,,--.--. -, -,--: I, -".--,I'. --, .; ,. -, ,;-,-,..,--, -1 , :: ,. . ,--,,-, -r , -. -7-I-::I-,.: -1 --,,.IllI:----::- -Z,7---, -. I. .. ,. ,.--",:I,,,I,:... .--II ,% : -I..I.... .. I, .,--,. ,, ---7,::,-,-..-,-,,:-.1,.-,i,--,--,I 1,-.-,.. --- :-,:L" ,,: ,.----,.-_,-,.i ,. .-:.,, '. ,-,--.-1. - .- ,,..,,%, ,I -I-T II,---,, -..-- -,---.-..I, -,---. 17.-.:.,I ,.-,I,I-. .:m. .-. ---.-:, .", ,, .,--,--..-,.-: .I..,, ,..f-:4---,I..-.-b -,11I. I---:-:-.',-.-1.-,.-,.r..I ,-I,-,,3,--,.i .I.I.." -: :II!::I-I-,-, .. ,.I, .r ` , -,_,': -. 1.,.,.-II: 1., ,--,-1,. .-.-, .,--, , , :,, . -;-,-.. I-.I. ,. , ---.,- ,-I:_--. ,,,::::,I.:": -,----,-,::--.----, , , ,,-bl ..- -. ,--;::..." ,, :..---, ..-. ..I . ,,,- :2 ,., .. :-:q..;,III.-.-..-t., , ,,...1 : ;, --,, , 7,,,.,.ZI---, ;,,.,-.I.-,.,I-,,,,..1,-..-, .-- .%,- -:-,.,-1 I,-,--IZ--;I-,,I.I-,--,: -j , II:'.-II-., ---,--,.':I.IiI--I-.::I---:,:.,-,;F1,-:...''-,.,_,I.!-,,.--.. I,...:,.,-I-:.--,,iI ,---, , -. -,;.,-,.--1 ,:- -_.-. ,,,,.7,. ': :,,--.-,,-,-,, :..-i,.,-,,-.: ::,-.,4-I-.I.r.I-1 ,. I..II-..., .- -,,.,-..I--, .,-.-.,--,,. -.1.,.1,.I-. -. ,-.....-I.II,-,..; "- i -,. i-I-.,,,-,--;, -,. ",:,: ' 7.... ,I-.I.--:-1. ,,.I.;l..-t.I.I.I, .v--I,,..,"II. , .:i-%.,. -, -,,-,-. -7:.L,-,I,-:.I.-.i,,.-.---II--, I.:1 PII-- I ,--,!% .":,i, -,,.: I-, ,.;,,.I ,I--Z--.7,.Ik ;. -,-...1.--I,. ;-: 1---,,-.i -I1,,.-,.--,, .., , .,,,tI---. ,c,.,-.-..:--,,;--,.:.-;",..t...,. .--. 1, ,1 , III . ., ., ,,.--. : "., -, : -,-. -.,,.-,,---: Z`,, -,II .,,.I-::7.'. ,:i--.,: ,y. ...,---.-,: l .. II--.- ::.:..,.,, ,,---,,.,-., I -,:,.-1-,,: ,I ,-I .--. -. ,.-,... .- .. ,-11.-.1 .--. I. ,-: --:. -.,1 ,;., .,,-,,-. . ,- ,-.. I1-, ;, -, ,.I': ,,.I'.--.I ". ,,-:..--,, -,.-; . ,;I ,z.---.II-,. -,,I.1,--,-.. :t.,1.--..,,-,.-1 . . -.,15-,-, .:; .,-,..-., .. --...-, .z .,.I II. -.. -t,.,,IBM ..,-,,, .. 1,:,l: ,.-.-I..,,i7i ,,.,..4, -. 7-I.-,aI-, ,!- II." ::,-:Z':'-"7-.I.. , ,: . : ',, i',:j--I-,-,- .11 ,.:,,1,--: -I-.I:, ,,-, ... ,.,..I-.,.... -.---, -.-. ..- ,.. 1,,--.-. .,II I ,,.II.. ; -. .. i ,z , 411,..:t'. --)fHl .1-..I . I,:..:- , .-.;_--.1. .'. :l ,:,,-. ;.,:., .-..I-I j-. ,. .-.,..,., --. --.:-.-.)--, ,I I - pl...,------. ,",4-,-11-II., 11 ,III. I......;.:-! -,.II;:, -,-I... j::, -,--, -, --n*!vI. , ",:;-"Kk-t 1. ,.,- % -r%--,., -,.M..F,,I.-Iff --.. ---, --,-, - -.1-.-1 ... ,-,:,-Wmkzll,"'- I.'AP%:-M,'-,,-",--'---, 1= AlL,-..1-Ct . -1- --.1%, !,,.: i ,.,-I, .,.,,:',I-'. W .,.:-,Ir -,I... -, :.la-..,---'. --, -, ,-I,,.I,.-ZF-I..II-'I .'' .. ",:..:-:";!:..,...I..,,.-:, ,. '--`., ,-- :-,,.,, :L" , -. .,. I ..- - .!.... ,---- ------;.I :, L'.,-.,-...1 ;I1-- .I, .-I-.-, !.,.I.-I-I -Z,, -.'.'-'-I ,. :--I--.II:. ,..-:.,---zI.,.III-,.I-.-I.-II -.-Z-., : -':.---,,--I- :-.-.,,..I---....--,--,..,I :. '-.,-". 1, ,I7----,,.O .:, 'L-,, ,;` .I ,-::- -,-, L-.' .., .li I -- -: :I`-'Ml :: .-1., ..II -, i ," -. LI,.I ':,IIO. .. -" .- ",-.--.:.---Tf , --,, ,, :,--,.I-.I-:,.I-I-.. :..-t,-. , ---.. ,,,-I--m_I..-I.,`,L-I1 -,.%11..,..,,, I..Z ,.,,.7-.qZ.,4,,.-.--I.-I ,I-. .,, .,I -......-.-,-...---7,:-,I .,.Z,,-...-.,, ., .,.;. I...- ,L1,! -III-.. ,I.ItI,--I-IZI .I..I...... .,-III -.-:-,--,--.I, ;,Z::,,Z,.. -1.Iq, ,,.IIIl,,;I.,.---,7,-, I.: --;,I-.:, !-I- -.... i-I, .,-...1I-..;,-,::-. -I-_-1 1.-.-I.-b--, I -1.I , --.,-.--.:,-.-,' ,-.i! I, I.-,,---._ .t. .. I,..,.,,I:I,,: -,. -.- -1 :, t.,:;,,, --I -I-r1-..:. ,,---I..I.,I-I.,.:--, ; :--: ,-. I .,...., -J. I 1:,:,,.-,.--III.I.I,. --t,--..I:--II.1, I i--- --. .--,-7 11I,,-.II.O..I...,I---..-I-11..,II--,. ':,I', -: .-;.l ,,:....-.--. , ,.-... ,.171--:,,:-.-I--,,:.,,-, ---,-,-,.---. ;-.,.III.. ..I-I,,.-.., --, 4-.-,,,----,,I.:Z.I-,-I-,.-.., -I,.-,..I, - ;,,-'.-,-:-.,--.---:,_:II:', I -..I I-I;.-1..11,--. ;,:--II-1. "I--:, I,:,I;..-.I,-1 I.,:-,. -... -I, .:---;::-.:I_-;,-.--.I--:..-.I.. .-- .. I:,-'..I-..I,.II.. ...--. I..-- .a.1I-.,I,--..-1.......:1"-.. :-, ,.,-,-I-... I.I---.I....-I..--I: ,--: t.-,-1...,-:. 7 7-, I--.,.--,:.:,,. --- .II,--..I. I -..i-I...,: -,..-I...-. I-..-,I--..:i1,.:c--.--..I....:II :.--;.-.,...1I-.. .. ,.-:.I.I ,...;.. . ;., ,-;-,-I-I-,I.:.4.. .I,:I-.. ,-,-I,r,.-,-, ...I-,-, hI., . "-,--I,. f,. ,-II%.::: d-.I-,, ,-.-, -. 1I%19 7. I.-I. .. .-. -,.I- I-I,-.. ,-I-.i,.I-I I-.---.,lI,,I..-.-. i.. ..I-..-:..-.II-:.I:,I.,I-I-.,:e-,-1.- -,. 11-II .. ..--. .': 'i .1--...IlI.,,.;-.t 7,.:..'.,., i-.-,:,-,,I'.-. .: _;-I.I:I:-,,.,..I...,-:,-..-L, , -.-I-. -...-.-.I-I' ,-,-II. ,..-; .I.-:,.,., 1..".-I. :.I: -II.--,,. ::I-,-:.:II.b-------.,I I-I..'L--,, -.-. i:I:----I--. -I...,, :,-..-.I .-. Z,-.,,:.I.. IT..... .-:,. ., ..,11 '. ..:. I -..... I:I. -.I .A.-.:I.. .. '---... -,I., ,,:.. ,: -:, ,.I-,-:%t..I..,-..: I-I,,.-I,....I%-.I--I...I11 -f :,,," --,,, -.. :,1.-I-.,v---,-.,,I.....-....,.I--':, :I.,.:. ,.71 .-. I, I.I--.-.-.. ,-,I--I-,.,,-1:"--...-. , I..1..: : : .I, -... II--I,.--I,...IIj:-,,-_,F-: -,;' ;,.-I 11,-, -.,-.,1,,., .II -A.I-.-, %-.`-II-. .- ,--:L,,_,I. .-" --i::,-. '..----,, I....;-1,,L..-I,,I.-I:-: t--..:,-r:,.,-"--.I I11.,-:---.-1:-. -1.-..I ,.T,- ,I-, . .--.,1.-,-,.'.II,I,, ,I m ,:;.., -. .'. -.-.. -.Lp-I...-:.-. . ,:.I.L,--,I, ",-_. ,,:i'. '.:-.II...:---..m-I..1-I.4,l :.:-IZ-..I...-.-:::..----, I-., . .LII, -..,II,,I.t , .-I.-.7,.I-,-: ; "I I--. , ., -, .: -------.L...-I. . .I...1, .I--...-:,-:, ,. I,-,.,,,,..1,.---..1.a .-.I .. -I ---:-:,, 3,I----,, I--,-III.,.--... -,:.,:-. ---.,, ... , .-. .I-, .;L. ,-..,."I..:.,I -,.,I., .1,--,-.,I:....-...-,:-1-.. -- ,-.._-,-- ,-,,!,,,7,., -,"7'--. .--I.q... --- -: -.. .I-I-i-:,r_. .,.4. ..1....II-.-.1,. ,.,-..-..,..:-I`i;,: I,.I-.I I,: 1, ':,;:,.-I ..,.--,I,. -I. ,,.II.-'...1. . !' I---;-.II.--,-.,-, .,. P, ." ,.---,, -,,,..,.I..,.5-I-LI. -. -'''-,,I,;.--. ,,Z, ,,-,--II!-, -II.I-. ,-. ":-.-,.., I..LL -.-. fl--I-.:: I:.-..i.I-_ ..:1:.:I: -I---III, : .Z;I-I.,-. ;!,-;,,,,.,.-I."I.' 11 "-, ,.-1,.II.Ii.-..II ",: ,. ,,':-.%. ,.I.I, -t,,., ; ,--% ; ,II.-,-1,I--,, -11 _ -. I.-.-,I,',-. ::l--,. I-l-,,.-I ..-..I.I.I,..I:-::, --I:-.: ,.--17,,..I.-,,.--., ... .,,.. : .i....,1.,. :. z,. -,I--II.'! ;-IIII.-- ... ,L,.-,, 1:::,.-,:l I.I. ,. ,..i. ,ll'-.-3 I:'l -III. :..--.I .-... ... .. ,..,: ., , , ' ,L, ..I.:IL. 'II. ,.-- .., II:,.: ,,-11.:: I,.. II `-, ,:-,.I.-.I..I-i..-II-I--.' ,.'.IIo-.II -, ... ....1P...-...I.-.L :-I.,, .I-:,-IL''-,--.I--..I.....-.',:,.-.. ", ,I "-:....IIII,-i-.,, ,-,,.Ip-.1 . .J I.,. -L-,...I ,I.I---..;I..--..-::..,,.I , is I MA:SSACUSETTS.' INSTI TUTE <at;V;;7 OF ECHNOLG PARAMETRIC SHORTEST PATH ALGORITHMS WITH AN APPLICATION TO CYCLIC STAFFING by Richard M. Karp and James B. Orlin OR 103-80 October 1980 Research supported, in part, by the U.S. Army Research Office under Contract No. DAAG29-80-C-0061. Parametric Shortest Path Algorithms with an Application to Cyclic Staffing by Richard M. Karp and James B. Orlin Abstract Let vertex G = (V,E) be a digraph with vertices including a special s. Let E' C E be a designated subset of edges. there is an associated real number f 2(e) The length of edge fl(e). For each eE E Furthermore, let 1 if e E E' : 0 if e e is flpe)-Af2(e), takes on real values. edge of n where E-E' X is a parameter that Thus the length varies additively in X for each E'. We shall present two algorithms for computing the shortest path from s to each vertex running times v E V parametrically in the parameter O(n3 ) and O(nlE l logn). X, with respective For dense digraphs the running time of the former algorithm is comparable to the fastest (non-parametric) shortest path algorithm known. This work generalizes the results of Karp [2] concerning the minimum cycle mean of a digraph, which reduces to the case that E' = E. Furthermore, the second parametric algorithm may be used in conjunction with a transformation given by Bartholdi, Orlin, and Ratliff [1] to give an algorithm for the cyclic staffing problem. -- - O(n21logn) Parametric Shortest Path Algorithms with an Application to Cyclic Staffing by Richard M. Karp and James B. Orlin Let G = (V,E) be a digraph with n vertices including a special vertex s. Let E' c E be a designated subset of edges. For each an associated real number fl(e). Furthermore, let I f2(e) The length of edge e E E there is if e E' eE' O .'if e E-E' e is fl(e)- Xf2(e), where X is a parameter that takes on real values. Thus the length varies additively in X for each edge of E'. We shall present two algorithms for computing the shortest path from to each vertex running times v E s V parametrically in the parameter X, with respective O(n3 ) and O(nlEI log n). For dense digraphs the running time of the former algorithm is comparable to the fastest (non-parametric) shortest path algorithm known. This work generalizes.the results of Karp [2] concerning the minimum cycle mean of a digraph, which reduces to the case that E' = E. Furthermore, the second parametric algorithm may be used in conjunction with a transformation given by Bartholdi, Orlin, and Ratliff [1] to give an O(n21ogn) algorithm for the cyclic staffing problem. In the following a walk is a directed edge progression from an initial vertex to a terminal vertex. A cycle is a walk in which the initial vertex 1 2 is equal to the terminal vertex. A path is a walk in which no vertex is repeated. For each walk P and for each ·Q(P,X)= : L(P,X) Thus is the length of walk X E R define (fl(e)-Xf 2(e)) k and.each P. For each integer XE R let I f2 (e) = k} gk(v,A) = {in £(P,): P is a walk :from s to v and e2E Then gk(vX) is a linear function of )X which measures the shortest length gk. path from s to v subject to the additional constraint that the path has E'. k edges of exactly s to In the following we assume that there is a path from v for each vertex v E V and that there is no cycle of negative length composed solely Thus for all of edges in E-E'. is a minimum length path from both be checked in O(nJlEl) Let value F(v,X) X, where v E V and for sufficiently small s to X there v. Of course, these assumptions may stens. be the minimum length of a walk from s to v- for fixed F(Y,X) = -~ if there is a sequence of walks with length unbounded from below. min gk(v,X) for all v E V and for all O<k<n-1 for which the resulting digraph has no cycles of negative length. Lemma 1. F(v,) Proof. '= XE R Since there are no negative length cycles, there is always a n-l minimum length walk which is a path and hence has at most I edges in E'. O The following result is a direct extension of a theorem proved by Karp in [2]. Let X* be the maximum value of X for which there are no cycles of negative length. Let V(k) = {veV: Igk(V) }. Let G(X) = min max (g(v,)-gk(v,x)). veV Okn- vE V(k) Theorem 2. Either for which G(X) Proof. X* = or else X* is the unique value of- X 0. Note first that, if G(X) is finite (i.e., there is some such that gn(v,X) f +), then v G(X) is a strictly decreasing function, and thus there is a unique value of X for which G(X) = 0. For X = X* we have that all cycles have non-negative length and hence by Lemma l, for all v V gn(V,*) > F(v,X*) = n O<k<n-l 9k('X*) Hence, G(X*) > 0. Conversely, for value at least one edge in E'. X* there must be a cycle Else we could increase C of length 0 with X* without creating a negative length cycle. Let v from be a vertex on cycle C and let P be a minimum length path s to v for value X*. P followed by any number of repetitions of C is also a minimum length walk from s to of such a walk is a minimum length walk from sufficient repetitions of v. Hence, any initial part s to its endpoint. After C there will be an initial part n edges in E' from s to w. Then P' with exactly 4 (P,X*) = g (w,X*) = G(X*) Thus _0. Thus gk(,X*) min O<k<n-1 O. G(X*) = Let d(u,v) be the minimum length of a path from u to v in G consisting solely of edges of Let E-E'. be the minimum length of g(v,A) k edges in E' and such that the last a walk from s to v with exactly edge of the walk is in E'. Then we may calculate g and g' by the following recursive scheme: gk1(u ) + f 1 (u,v) - X) gi(vx)- umin (u,v)EE· -9k(vX) = min (g(u,X)+d(u,v)) for and k =,...,n subject to the initial conditions g(V,X) =' d(s,v) In order to compute O(n3 ) F(v,X) for all X < X*, we may calculate steps from Theorem 2 and the functions F(v,X) late of g' and from Lemma 1 in another g take 0(n3 ) O(n3 ) gk(v,X), steps. X* in and we may calcu- Since the calculations steps, the entire algorithm requires 0(n3 ) steps. An O(nlE log n) Algorithm The previous algorithm is not typical for'parametric programming algorithms in that the solutions are calculated simultaneously for all values of X. The following is a more standard approach in that optimal solutions are calculated for one value of X at a time as X increases from -. 5 In the following a tree will refer to a connected subgraph of exactly n-l edges, with one directed into each vertex of tree is really an arborescence with root s to v on tree T and for each vertex v distance from TX s to v on T. Thus E' on the path from s to TX such that the is a path of minimum distance. V, let (Thus a s.) It is well known that for X < X* there is a tree unique path from V-{s}. G with dl(T,v) - Xd2(T,v) d 2 (T,v) For each denote the is the number of edges of v in T. A neighbor of tree T is a tree which differs from T in exactly one edge. Let T be any tree and let e = (u,v) E E. Then we let denote the subgraph obtained from T by adding edge unique edge of T directed into N(T,e) e and deleting the v. The following is an immediate conse- quence of this construction. Lemma 3. Let T be a tree and let e = (u,v). tree if and only if v is not on the path from If e = (u,v), s to Then N(T,e) is a u in T. 0 let Ai(T,e) = d i(T,u)+f i(e)-d i(T,v) for i = 1,2 and let P(T,v) = {wEV such that v is a vertex on the path from s to w in T} Lemma 4. Suppose T' = N(T,e) is a tree. J d (T,w) + A (T,e) di(T,w) and if A2(T,e) s 0 then X' = A(T,e)/A2(T,e) Then for if w if w i = 1,2 P(T,v) P(T,v) is the unique value of for which I X 6 dl(T,w)- Xd2 (T,w) = dl(T',w) -d Proof. w P(T,v), = A' and w EV . weP(T,v), di(T',v)-di(T,v) = i(T,e) d i(T',w) = d i(T,w). follows from the fact that for all i = 1,2 It is easy to verify that for di(T',w)-di(T,w) And for 2(T,w) The last statement in the theorem is the unique value of X for which A l(T,e)- XA2(T,e) : 0. 0 Lemma 5. If T' = N(T,e) A(T,e)/A2(T,e) .clircuit of length is not a tree and is the unique value of - 0. Proof. Suppose that . subpaths in T from s to v and from edge (u,v). X for which the digraph T' has a T' is not a tree. in T' by deleting the subpath A 2(T,e) f 0, then s Let Pv to and Pu denote the u. Then 'acycle is formed Pv from the subpath Pu and then adding The length of this circuit is thus: d1(T,u) - d(T,v) + fl (e)- X(d2 (T,u)-d2(T,v)+f 2(e)) = A (T,e) - XA2 (T,e) L The following algorithm will calculate a sequence of trees and a sequence of real numbers the tree X= T -: = XO'Xl''A), is a tree of minimum distances for T1,...,Tm = A* in such a way that X E [il,Ai] or X = -I in which case we do not define the trees. except for The trees will only be stored implicitly via appropriate data structures; otherwise, to -3 store all the trees. would take S2(n ) space. The algorithm requires a data structure to store and retrieve entries of the form (e,c(e)), where e E E and c(e) E R. The operations performed on the structure are the insertion of an entry, the deletion of the unique 7 entry (e,c(e)) associated with a given edge e, and the retrieval of an entry (e,c(e)) for which c(e) is minimum. If a balanced tree [3] is used for this purpose, then each of the basic operations can be performed in O(log IEI) steps. Algorithm 2 Step 0 (Initialize) 0.1 Let M = 1+eEElfl(e)l. Let X = -C. -M. (Use a 0.2 Let T be the tree of minimum distances for X standard O(nJEI) shortest path algorithm to determine this tree.) 0.3 Compute di(Tl,v) for i = 1,2 and v E V. 0.4 For each edge e E E let if A2 (T ,e)< 0 Ai(T1,e) c(e)= 2(Tl,e) if A2(Tl,e) > 0 0.5 Store the values c(e) for e E E in a balanced tree B. 0.6 Let i = 1. Step 1 (Compute the new tree) 1.1 Let X i = c(e') = min c(e) (by finding the minimum element of the eEE balanced tree B). If = iX then quit. Let (u,v) = e'. 1.2 Ti+ l = nTi,e') 1.3 Let Pi If u = P(Tiv). P then quit with X* = Xi; else, let Aj = Aj(Ti,e') for j = 1,2. 1.4 For each w E Pi and for j = 1,2 d (T W) = i+ dj(Tiw)+Aj if wE P dj(Tiw) if W P ; 8 Step 2 (Calculate the next change of trees) 2.1 Let E be the subset of edges of E with at least one endpoint in P. 2.2 For e EE delete the value c(e) from B and instead let Go if A2 (Ti+ 1,e) < 2Tic(e) = i if A 2 (Ti+le) > 0 and store this new value of c(e) in the balanced tree B. 2.3 Let i = i+l and return to step 1. Theorem 6. For each X E [ii-l'Xi Proof. i = l,...,m, is optimal for all with X finite. Suppose the theorem is false. there is a value X' E Choose the minimum i so that [XilXi] such that the result fails at X'. can happen for one of two reasons: for the tree T i X = X' and a vertex either there is a tree v so that the distance from less than the corresponding distance in T i for fails because there is a negative cycle for T that is optimal s to X = X'; X = X'. This v in T is else the theorem We first investigate the former case. By our choice of where for M, for X < -M it follows that k is the minimum index for which gk(v,) X E (--,-M] and thus Furthermore have that Ti_ 1 X' Xi_.1 F(v,X) = gk(v,X) I a. Thus Tl is optimal X' > -M. To see this note that by our choice of is optimal for value Xi_ 1. Lemma 4, the distances in T i and By our choice of Ti_ 1 are the same for X= Xi i-l T i is optimal at Xi-l For each l w E V let h(w,;) = d l (T,w) - d(T i ,w) - A(d2 (T,w)- d 2 (Ti,w)) . i we and by Thus 9 Then, by the optimality of T at X = ', h(s,X') = 0. Since Ti h(v,X') < 0 and that precedes for all w. Also, is not optimal at X = X', there is a v such h(u,X') = 0 for the vertex u which immediately v on the path from of T directed into hw,X') < s to v in T. Let e be the edge (u,v) v. Then h(v,) = A(T i ,e)- XA2(T i ,e) Furthermore, h(v,X') < 0 < h(v,Xi l) This can only happen if A2(Ti,e.) >0 i and Al(Ti,e) ki_< A2i,e)< But this would contradict our choice of tree X' X i in step 1, thus proving that T cannot exist. Suppose instead that there is a negative cycle for l' > Xi l, length 0 for as Ti is optimal in [X -1'l Ai1 < A* < Xi X* with E' is in C. Let C = Vl,...,Vk,Vl vj_ 1 does not precede vj . X = '. As before Let there be a cycle C of and such that at least one edge of and let on the path from vj s to be a vertexsuch that vj in T i. Let e = (vj_lvj). We now claim that A(Ti,e)/A2(Ti,e) = X* and contradicting our choice of a minimum length walk from walk. Let Thus vj_ 1 e = (Vjl,vj). the above that precedes Since A2(Ti,e) > 0 thus Xi. To see this we note first that for s to vj v followed by X = X* C is also a minimum length on some minimum length walk from s to vj. T i is a minimum distance tree, it follows from 10 dl(Tv j) - X*d2(Ti,vj) = dlTi,vj_l)+fl(e) *(d 2(Ti,vjl) + f 2 (e)) Thus Al(Ti ,e)-X* Let a(w) be the number of sets 2(Ti,e) = Pi 0 0. as defined in Step 1.3 such that w E Pi' In order to determine the number of steps taken by the algorithm, we will use the following lemma. Lemma 7. For each w E V, Proof. If w E Pi d2 (Ti,w) < n-l for all (w) < n-l. d 2 (Ti ,w) > (d2 (Ti_ 1 ,w)- then Since 0 i it follows that a(w) < n-l. We now can see that Algorithm 2 takes (1) By Lemma 7, dj(Ti,w) 0(nEi log n) steps as follows: is updated at most n-l w E V. Thus this updating may be carried out in 0(n2) (2) By Lemma 7, c(e) for each endpoint. 1>0. is updated at most 2n-2 times for each steps overall. times, Thus the total number of updates of c(e) n-l times is 0(nlEI). At each update we must both delete and insert the value into a balanced tree. These operations may be carried out in 0(log n) steps. Furthermore, we may have to choose the minimum element in the balanced tree as many as n 2 times. Thus the total computation count for these steps is 0(nlEl log n). An Application to Cyclic Staffing Vector y is said to be circular if each component has value 0 or 1 and if the components with value 1 occur consecutively, where the first and last components are considered consecutive. Matrix (resp. row) circular if each column (resp. row) of A is said to be column A is circular. 11 In [1], a certain class of cyclic staffing problems was represented as an integer programming problem minimize , (3) subject to xl+"'+xn = Ax > b x > 0 and integer where A is column circular. An example of the problem is to find the minimum number of persons needed to staff a weekly schedule so as to satisfy demands that vary from day to day within the week but repeat weekly and so that each person receives two consecutive days off per week. This problem may be represented as the integer program (3)where A '1 001 11 1 11 001 11 1 '1 10 0 1 1 1 1 1 10 01 1 1'I 1100 011 1 1 10 0011 1 1 1 The followinig s pro,:ed in [1]: is considered as a parameter, If then every basic solution to (3) is integral whenever pJ is integral. solve (3) it suffices to determine the minimum integral value of vl which (3) is feasible. To for Furthermore, this may be accomplished by transform- ing this parametric problem into an equivalent parametric shortest path problem of the type solved in this paper. The number of edges in this problem is linear in n and thus the entire problem takes 0(n2 logn) steps. We briefly describe the problem transformation given in [1]. loss of generality, we may assume that there is no pair column indices such that aij > aik for all j, Without k of distinct i; for if such a pair did 12 exist, then column k could be eliminated. We may also assume that the columns of A are in lexicographic order; i.e., if j < k then there exists some q such that aij = aik, i < q and aiq > ajq It follows that A is row circular as well as column circular; i.e., in each row of A, either all the 's are consecutive or all the O's are consecutive. We next make a change of variables that will transform our problem to a parametric shortest-path problem. yj = X,= -1 - + x 2x+ -- + xj; For in particular, YO -(xl+x 2 + --+xn). j = O,l,...,n-l, let is identically zero. The nonnegativity constraints on the YO <Yl' Yl <Y2""Yn 2 Yn-l' Yn-1 Suppose row i has consecutive l's, occurring in columns Also, let xi become -X j+l,...,j+k. Then this row represents the inequality xj+l +x j +2 which can be rewritten yj < k- bi + + xk > bi Suppose row i does not have consecu- tive l's but has consecutive O's, occurring in columns j+l,...,k, where k < n. Then this row represents the inequality (X1 X2+ .+Xn)- (Xj+l+-.-+Xk) > bi which can be rewritten Yk < Yj -bi-X The cyclic staffing problem is thus transformed to the maximization of X subject to linear inequalities, each of which is of the form Yv <y +be - XB where (4) Be E {0,1} ; I 13 Let N be a network with vertex set inequality of the form (4), an edge {O,l,...,n-l} e from u to and, for each v of parametric cost b e - XBe . Then the cyclic staffing problem is reduced to the computation of A* for the network N. Once X* is determined, yv is simply the cost of a shortest path in N from 0 to v, at X = X*. The transformation just given, coupled with Algorithm 3, yields an algorithm to solve the cyclic staffing problem in time 2 2 1 og n). O(n An experimental computer program that executes this algorithm was run on several examples in which the columns of the constraint matrix consisted of all rotations of an n-vector of k consecutive l's, and the components of the right hand side were drawn from a uniform distribution. balanced tree operations never exceeded time of the algorithm is O(nlog n). 2n, The number of suggesting that the expected 14 References 1. Bartholdi,J.J., Orlin, J.B., and Ratliff, H.D., "Cyclic scheduling via integer programs with circular ones," to appear in Operations Research. 2. Karp, R.M., "A characterization of the minimum cycle mean in a digraph," Discrete Mathematics 23 (1978) 309-311. 3. Knuth, D.E., The Art of Computer Programming. Vol. 3. Sorting and Searching, Addison-Wesley, Reading, Mass., 1973. __1_____1·_1 111_·____11_11___·_