versão mpressa ISSN 0101-7438 / versão onlne ISSN 1678-5142 FORTRAN SUBROUTINES FOR NETWORK FLOW OPTIMIZATION USING AN INTERIOR POINT ALGORITHM L. F. Portugal Dep. de Cêncas da Terra Unversdade de Combra Combra Portugal M. G. C. Resende Internet and Networ Systems Research Center AT&T Labs Research Florham Par NJ, USA mgcr@research.att.com G. Vega HTF Software Ro de Janero RJ, Brazl gvega@gmal.com J. Patríco Insttuto Poltécnco de Tomar Tomar Portugal e Insttuto de Telecomuncações Polo de Combra Portugal Joao.Patrco@am.estt.pt.pt J. J. Júdce Dep. de Matemátca Unv. de Combra Combra e Insttuto de Telecomuncações Polo de Combra Portugal Joaqum.Judce@co.t.pt Correspondng author / autor para quem as correspondêncas devem ser encamnhadas Recebdo em 01/2007; aceto em 04/2008 Receved January 2007; accepted Aprl 2008 Abstract We descrbe Fortran subroutnes for networ flow optmzaton usng an nteror pont networ flow algorthm, that, together wth a Fortran language drver, mae up PDNET. The algorthm s descrbed n detal and ts mplementaton s outlned. Usage of the pacage s descrbed and some computatonal experments are reported. Source code for the software can be downloaded at http://www.research.att.com/~mgcr/pdnet. Keywords: optmzaton; networ flow problems; nteror pont method; conjugate gradent method; FORTRAN subroutnes. Resumo É apresentado o sstema PDNET, um conjunto de subrotnas em Fortran para a otmzação de fluxos lneares em redes utlzando um algortmo de pontos nterores. O algortmo e a sua mplementação são descrtos com algum detalhe. A utlzação do sstema é explcada e são apresentados alguns resultados computaconas. O códgo fonte está dsponível em http://www.research.att.com/~mgcr/pdnet. Palavras-chave: otmzação; problemas de fluxo em rede; método de ponto nteror; método do gradente conjugado; subrotnas FORTRAN. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 243
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm 1. Introducton Gven a drected graph G = ( VE, ), where V s a set of m vertces and E a set of n edges, let (, j ) denote a drected edge from vertex to vertex j. The mnmum cost networ flow problem can be formulated as cx subject to (1) mn j j (, j) E x x = b, V j j (, j) E ( j,) E (2) l x u,(, j) E, j j j where x j denotes the flow on edge (, j ) and c j s the cost of passng one unt of flow on edge (, j ). For each vertex V, b denotes the flow produced or consumed at vertex. If b > 0, vertex b s a source. If b < 0, vertex s a sn. Otherwse ( b = 0 ), vertex s a transshpment vertex. For each edge (, j) E, l j ( u j ) denotes the lower (upper) bound on flow on edge (, j ). Most often, the problem data are assumed to be nteger. In matrx notaton, the above networ flow problem can be formulated as a prmal lnear program of the form (3) mn { c x Ax= b; x+ s= u; x, s 0} where c s a m n vector whose elements are c j, A s the m n vertex-edge ncdence matrx of the graph G = ( VE, ),.e. for each edge (, j ) n E there s an assocated column n matrx A wth exactly two nonzero entres: an entry 1 n row and an entry 1 n row j ; b, x, and u are defned as above, and s s an n-dmensonal vector of upper bound slacs. Furthermore, an approprate varable change allows us to assume that the lower bounds l are zero, wthout loss of generalty. The dual of (3) s (4) max { b y u w A y w+ z = c; z, w 0} where y s the m -dmensonal vector of dual varables and w and z are n -dmensonal vectors of dual slacs. If graph G s dsconnected and has p connected components, there are exactly p redundant flow conservaton constrants, whch are sometmes removed from the problem formulaton. Wthout loss of generalty, we rule out trvally nfeasble problems by assumng where j V b = 0, = 1,, p, V s the set of vertces for the -th component of G. If t s requred that the flow x j be nteger, (2) s replaced wth l x u, x nteger, (, j) E. j j j j j 244 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm In the descrpton of the algorthm, we assume wthout loss of generalty, that l j = 0 for all (, j) E and that c 0. A smple change of varables s done n the subroutnes to transform the orgnal problem nto an equvalent one wth l j = 0 for all (, j) E. The flow s transformed bac to the orgnal problem upon termnaton. The case where c = 0 s a smple feasblty problem, and s handled by solvng a maxmum flow problem [1]. Before concludng ths ntroducton, we present some notaton and outlne the remander of the paper. We denote the -th column of A by A, the -th row of A by A and a n submatrx of A formed by columns wth ndces n set S by A S. Let x R. We denote by X the n n dagonal matrx havng the elements of x n the dagonal. The Eucldean or 2-norm s denoted by. Ths paper descrbes Fortran subroutnes used n an mplementaton of PDNET, an nteror pont networ flow method ntroduced n Portugal, Resende, Vega & Júdce [12]. The paper s organzed as follows. In Secton 2 we revew the truncated nfeasble-prmal feasble-dual nteror pont method for lnear programmng. The mplementaton of ths algorthm to handle networ flow problems s descrbed n Secton 3. Secton 4 descrbes the subroutnes and ther usage. Computatonal results, comparng PDNET wth the networ optmzer n CPLEX 10, are reported n Secton 5. Concludng remars are made n Secton 6. 2. Truncated prmal-nfeasble dual-feasble nteror pont algorthm In ths secton, we recall the nteror pont algorthm mplemented n PDNET. Let n+ m+ n+ n+ n Q + = {( xyswz,,,, ) R : x > 0, s > 0, w > 0, z > 0} S = {( x, yswz,,, ) Q : x+ s= u, A y w+ z= c}. + + The truncated prmal-nfeasble dual-feasble nteror pont (TPIDF) algorthm [12] starts 0 0 0 0 0 wth any soluton ( x, y, s, w, z ) S +. At teraton, the Newton drecton ( x, y, s, w, z ) s obtaned as the soluton of the lnear system of equatons (5) A x = b Ax + r, x + s = 0, A y w + z = 0, Z x + X z = µ e X Z e, W s + S w = µ e W S e, where e s a vector of ones of approprate order, r s such that (6) r β0 Ax b,0 β0 < β1, wth β 1 = 0.1, and ( x ) z + ( w ) s (7) µ = β1. 2n Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 245
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm Prmal and dual steps are taen n the drecton ( x, y, s, w, z ) to compute new terates accordng to + 1 x = x + α p x, + 1 s = s + α p s, (8) + 1 y = y + αd y, + 1 w = w + αd w, + 1 z = z + α z, where α p and α d are step-szes n the prmal and dual spaces, respectvely, and are gven by (9) αp = p max{ α: x + α x 0, s + α s 0}, αd = d max{ α: w + α w 0, z + α z 0}, where = = 0.9995. p d The soluton of the lnear system (5) s obtaned n two steps. Frst, we compute the component of the drecton as the soluton of the system of normal equatons 1 1 (10) AΘ A y = AΘ ( µ ( X ) e µ ( S ) e c+ A y ) + ( b Ax ), where Θ s gven by 1 1 1 (11) Θ = ( Z ( X ) + W ( S ) ). The remanng components of the drecton are then recovered by 1 1 x = Θ A y +Θ ( µ ( X ) e µ ( S ) e c+ A y ), s = x, (12) 1 1 z = z + µ ( X ) e Z ( X ) x, 1 1 w = w + µ ( S ) e W ( S ) s. d y 3. Implementaton We dscuss how the truncated prmal-nfeasble dual-feasble algorthm can be used for solvng networ flow problems. For ease of dscusson, we assume, wthout loss of generalty, that the graph G s connected. However, dsconnected graphs are handled by PDNET. 3.1 Computng the Newton drecton Snce the exact soluton of (10) can be computatonally expensve, a precondtoned conjugate gradent (PCG) algorthm s used to compute approxmately an nteror pont search drecton at each teraton. The PCG solves the lnear system 1 1 (13) M ( AΘ A ) y = M b, where M s a postve defnte matrx and Θ s gven by (11), and 1 1 b = AΘ ( µ ( X ) e µ ( S ) e c+ A y ) + ( b Ax ). 246 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm The am s to mae the precondtoned matrx (14) 1 M ( AΘ A ) less ll-condtoned than AΘ A, and mprove the effcency of the conjugate gradent algorthm by reducng the number of teratons t taes to fnd a feasble drecton. Pseudo-code for the precondtoned conjugate gradent algorthm mplemented n PDNET s presented n Fgure 1. The matrx-vector multplcatons n lne 7 are of the form AΘ A p, and can be carred out wthout formng AΘ A explctly. PDNET uses as ts ntal drecton y 0 the drecton y produced n the prevous call to the conjugate gradent algorthm,.e. durng the prevous nteror pont teraton. The frst tme pcg s called, we assume y 0 = (0,,0). The precondtoned resdual s computed n lnes 3 and 11 when the system of lnear equatons (15) Mz+ 1 = r+ 1, s solved. PDNET uses prmal-dual varants of the dagonal and spannng tree precondtoners descrbed n [15,16]. Procedure pcg ( A, Θ, b, ε, y ) 1. y 0 : = y ; 2. r0 : = b AΘ A y0; 1 3. z0 : = M r0 ; 4. p0 : = z0 ; 5. : = 0; 6. Do stoppng crteron not satsfed 7. q : = AΘ A p ; 8. α : = z r / p q ; cg 9. y+ 1 : = y + αp ; 10. r+ 1 : = r αq ; 1 11. z : = M r ; + 1 + 1 β : z+ r+ / z r 12. = 1 1 ; 13. p+ 1: = z+ 1+ βp ; 14. : = + 1; 15. Od; 16. y : = y End pcg Fgure 1 The precondtoned conjugate gradent algorthm. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 247
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm The dagonal precondtoner, M = dag( AΘ A ), can be constructed n On ( ) operatons, and maes the computaton of the precondtoned resdual of the conjugate gradent possble wth Om ( ) dvsons. Ths precondtoner has been shown to be effectve durng the ntal nteror pont teratons [11,14,15,16,18]. In the spannng tree precondtoner [16], one dentfes a maxmal spannng tree of the graph G, usng as weghts the dagonal elements of the current scalng matrx, w= Θ e, where e s a unt n -vector. An exact maxmal spannng tree s computed wth the Fbonacc heap varant of Prm s algorthm [13], as descrbed n [1]. At the -th nteror pont teraton, let T = { t1,, t q } be the ndces of the edges of the maxmal spannng tree. The spannng tree precondtoner s M = A Θ A, where For smplcty of notaton, we nclude n T T T T t1 tq Θ = dag( Θ,, Θ ). A T the lnear dependent rows correspondng to the redundant flow conservaton constrants. At each conjugate gradent teraton, the precondtoned resdual system Mz+ 1 = r+ 1 s solved wth the varables correspondng to redundant constrants set to zero. Snce A T can be ordered nto a bloc dagonal form wth trangular dagonal blocs, then the precondtoned resduals can be computed n Om ( ) operatons. A heurstc s used to select the precondtoner. The ntal selecton s the dagonal precondtoner, snce t tends to outperform the other precondtoners durng the ntal nteror pont teratons. The number of conjugate gradents taen at each nteror pont teraton s montored. If the number of conjugate gradent teratons exceeds m /4, the current computaton of the drecton s dscarded, and a new conjugate gradent computaton s done wth the spannng tree precondtoner. The dagonal precondtoner s not used agan. The dagonal precondtoner s lmted to at most 30 nteror pont teratons. If at teraton 30 the dagonal precondtoner s stll n effect, at teraton 31 the spannng tree precondtoner s trggered. Also, as a safeguard, a hard lmt of 1000 conjugate gradent teratons s mposed. To determne when the approxmate drecton y produced by the conjugate gradent algorthm s satsfactory, one can compute the angle θ between ( AΘ A ) y and b and stop when 1 cos θ <ε cos, where ε cos s the tolerance at nteror pont teraton [8,15]. PDNET ntally uses 0 ε = 10 3 and tghtens the tolerance after each nteror pont teraton as follows: cos + 1 cos = cos cos ε ε ε, 248 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm where, n PDNET, ε = 0.95. The exact computaton of cos b ( AΘ A ) y cosθ = b ( AΘ A ) y has the complexty of one conjugate gradent teraton and should not be carred out every conjugate gradent teraton. Snce ( AΘ A ) y s approxmately equal to b r, where r s the estmate of the resdual at the -th conjugate gradent teraton, then b ( b r ) cosθ b ( b r). Snce, on networ lnear programs, the precondtoned conjugate gradent method fnds good drectons n few teratons, ths estmate s qute accurate n practce. Snce t s nexpensve, t s computed at each conjugate gradent teraton. 3.2 Stoppng crtera for nteror pont method In [15], two stoppng crtera for the nteror pont method were used. The frst, called the prmal-basc (PB) stoppng rule, uses the spannng tree computed for the tree precondtoner. If the networ flow problem has a unque soluton, the edges of the tree converge to the optmal basc sequence of the problem. Let T be the ndex set of the edges of the tree, and defne + Ω = { {1,2,, n} T : x / z > s / w} to the ndex set of edges that are fxed to ther upper bounds. If the soluton system T T, + Ω A x b u A = x T of the lnear s such that 0 xt u, then x T s a feasble basc soluton. Furthermore, f the data s nteger, then x T has only nteger components. Optmalty of x T can be verfed by computng a lower bound on the optmal objectve functon value. Ths can be done wth a strategy ntroduced ndependently n [15] and [10,17]. Denote by x the -th component of x T and let F = { T :0 < x < u }. A tentatve optmal dual soluton y (havng a possbly better objectve value than the current dual nteror pont soluton supportng affne space of the dual face complementary to feasblty, we compute y ) can be found by orthogonally projectng y as the soluton of the least squares problem m y R F mn { y y : A y = c }. y onto the x T. In an attempt to preserve dual F Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 249
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm Resende & Vega [15] descrbe a Om ( ) operaton procedure to compute ths projecton. A feasble dual soluton ( y, z, w ) s bult by adjustng the dual slacs. Let δ = c A y. Then, δ f δ < 0 0 f δ < 0 w = z =. 0 otherwse δ otherwse If c x b y + u w = 0, then ( x, s ) and ( y, w, z ) are optmal prmal and dual solutons, respectvely. If the data s nteger and 0< c x b y + u w < 1, ( x, s ) s a prmal optmal (nteger) soluton. To apply the second stoppng procedure of [15], called the maxmum flow (MF) stoppng crteron, an ndcator functon to partton the edge set nto actve and nactve (fxed at upper or lower bounds) s needed. In PDNET, the ndcator used s the so-called prmal-dual ndcator, studed by Gay [5] and El-Bary, Tapa & Zhang [4]. Let ξ be a small tolerance. Edge s classfed as nactve at ts lower bound f x s 1 < ξ and > ξ. z w Edge s classfed as nactve at ts upper bound f x 1 s > ξ and < ξ. z w The remanng edges are set actve. In PDNET, ξ s ntally set to tghtened each tme the MF test s trggered accordng to PDNET, ξ = 0.95. 3 10 and ths tolerance s new old ξ = ξ ξ, where, n We select a tentatve optmal dual face F as a maxmum weghted spannng forest lmted to the actve edges as determned by the ndcator. The edge weghts used n PDNET are those of the scalng matrx Θ. As n the PB ndcator, we project the current dual nteror soluton F. Once the projected dual soluton y orthogonally onto y s at hand, we attempt to fnd a feasble flow x complementary to y. A refned tentatve optmal face s selected by redefnng the set of actve edges as = n c A y < r F { {1,2,, }: ε }, 8 where ε r s a small tolerance ( ε r = 10 n PDNET). The method attempts to buld a prmal feasble soluton, x, complementary to the tentatve dual optmal soluton by settng the nactve edges to lower or upper bounds,.e., for {1, 2,, n} F, 0 f Ω = { j {1,2,, n} F: cj A j y > 0} x =. + u f Ω = { j {1,2,, n} F: cj A j y < 0} 250 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm By consderng only the actve edges, a restrcted networ s bult. Flow on ths networ must satsfy (16) A x = b = b ua F F, + Ω 0 x u, F. Clearly, from the flow balance constrants (16), f a feasble flow x F for the restrcted networ exsts, t defnes, along wth x and Ω + x Ω, a prmal feasble soluton complementary to y. A feasble flow for the restrcted networ can be determned by solvng a maxmum flow problem on the augmented networ defned by the underlyng graph G = ( VE, ), where V = { σ} { π} V and E =Σ Π F. In addton, for each edge (, j) F there s an assocated capacty u j. Let V + = { V : b > 0} and V = { V : b < 0}. The addtonal edges are such that Σ= {( σ, ): V }, wth assocated capacty b for each edge ( σ, ), and Π= {(, π ): V }, wth assocated capacty b for each edge (, π ). It can be shown that f M σ, π s the maxmum flow value from σ to π, and x s a maxmal flow on the augmented networ, then M, = b f and only f x F s a feasble flow for σπ + V the restrcted networ [15]. Therefore, fndng a feasble flow for the restrcted networ nvolves the soluton of a maxmum flow problem. Furthermore, f the data s nteger, ths feasble flow s nteger, as we can select a maxmum flow algorthm that provdes an nteger soluton. Snce ths stoppng crteron nvolves the soluton of a maxmum flow problem, t should not be trggered untl the nteror pont algorthm s near the optmal soluton. The crteron s trggered at teraton, when µ < ε µ occurs for frst tme. The choce ε µ = 1 used n PDNET s approprate for the set of test problems consdered here. In a more general purpose mplementaton, a scale nvarant crteron s desrable. All subsequent teratons test ths stoppng rule. In PDNET, the mplementaton of Goldfarb & Grgorads [6] of Dnc s algorthm s used to solve the maxmum flow problems. + 3.3 Other mplementaton ssues To conclude ths secton, we mae some remars on other mportant mplementaton ssues of the prmal-nfeasble, dual-feasble algorthm, namely the startng soluton, the adjustment of parameter µ, and the prmal and dual stepszes. Recall that the algorthm starts wth any soluton 0 0 0 0 0 { x, s, y, w, z } satsfyng (17) 0 0 0 0 x > 0, s > 0, w > 0, z > 0, Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 251
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm (18) and (19) 0 0 x + s = u, 0 0 0 A y w + z = c, 0 but does not have to satsfy Ax = b. Addtonally, t s desrable that the ntal pont also satsfy the remanng equatons that defne the central path (5),.e. (20) for µ > 0. For (, j) E, let 0 0 X z x s z w = µ e and 0 0 S w 0 j = ν juj, 0 j = (1 ν j ) uj, 0 j = µ /( νj uj ), 0 j = µ νj uj /((1 ) ), = µ e, be the startng soluton, where 0< ν j < 1 and µ > 0. It s easy to verfy that ths startng soluton satsfes (17-18) as well as (20). Condton (19) s satsfed f, for (, j) E, ν j s chosen as ν j 1 µ 1 µ ( ) 2 + + f ϑj > 0, 2 ϑjuj 4 ϑjuj 1 µ 1 µ ( ) 2 = + + + f ϑj < 0, 2 ϑjuj 4 ϑjuj 1 f ϑj = 0, 2 where, for some ntal guess 0 y of the dual vector y, 0 0 j y yj cj ϑ = + +. In PDNET, we set the ntal guess max{ c : (, ) } 0 j j E y = b max{ b : V } and parameter µ = 0.2 max{ ϑ u :(, j) E } j The prmal-dual parameter has an ntal value µ 0 = β 1 µ, where n PDNET β 1 = 0.1. Subsequently, for teratons 1, µ s computed as n (7). The stepsze parameters p and d are both set to 0.995 throughout the teratons, slghtly more conservatve than as suggested by [9]. j 252 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm 4. Fortran subroutnes The current mplementaton PDNET conssts of a collecton of core subroutnes wth addtonal subsdary modules wrtten n Fortran [7]. The software dstrbuton assocated wth ths paper provdes fully functonal utltes by ncludng Fortran reference mplementatons for the man program, provdng default parameter settngs and supplyng addtonal routnes for data nput and output functons. In ths secton, we descrbe the usage of the PDNET framewor wth comments on user extensons. Specfc nstructons for buldng and nstallng PDNET from the source code are provded wth the software dstrbuton. Table 1 lsts all modules provded n the PDNET software dstrbuton. Table 1 Source code fles. Fle Name dblas1.f dnsubs.f fdrver.f90 pdnet_default.f90 pdnet_maxflow.f90 pdnet_feasble.f90 pdnet.f90 pdnet_solreport.f90 pdnet_read.f90 Descrpton Fortran Level 1 BLAS reference mplementaton Fortran mplementaton of Dnc s Algorthm Fortran man program Fortran functon settng parameter defaults Fortran subroutne for nvong maxmum flow computaton Fortran subroutne for networ feasblty checng PDNET core subroutnes PDNET report generator Fortran functons for readng networ data We adopted several desgn and programmng style gudelnes n mplementng the PDNET routnes n Fortran. We requred that all arrays and varables be passed as subroutne arguments, avodng the use of COMMON blocs. The resultng code s expected to comple and run wthout modfcaton under most software development and computng envronments. 4.1 PDNET core subroutnes The PDNET core subroutnes are nvoed va a sngle nterface provded by subroutne pdnet(). Followng the specfcatons lsted n Table 2, the callng program must provde data va the nput arguments and allocate the nternal and output arrays approprately as descrbed n Subsecton 4.3 n fle fdrver.f90. We provde reference mplementatons of the PDNET man program whch also serve as gudes for developng custom applcatons nvong the PDNET core subroutnes. In Subsecton 4.2, we dscuss n detal the nput and output routnes used n the reference mplementatons. Subsecton 4.4 dscusses the settng of parameters n PDNET. In addton, the core subroutnes call an external functon for maxmum flow computaton, whch s provded n a subsdary module, wth ts nterface dscussed n Subsecton 4.5. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 253
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm 4.2 Data nput Programs nvong the PDNET subroutnes must supply an nstance for the mnmum-cost flow problem. As presented n Table 3, the data structure ncludes the descrpton of the underlyng graph, node netflow values, arc costs, capactes and lower bounds. All node and arc attrbutes are nteger valued. Table 2 Arguments for pdnet(). Varable Sze Type Status descrpton b nn nteger nput netflow values for each node c na nteger nput cost for each arc dnfo 34 double precson nput parameters and statstcs endn na nteger nput end node for each arc nfo 23 nteger nput parameters and statstcs l na nteger nput lower bound of flow for each arc na - nteger nput number of arcs nn - nteger nput number of nodes optflo na nteger output optmal flow for each arc strn na nteger nput start node for each arc u na nteger nput upper bound of flow for each arc Table 3 Networ data structure. Varable Dmenson Type descrpton na - nteger number of nodes nn - nteger number of arcs strn na nteger start node for each arc endn na nteger end node for each arc b nn nteger flow values for each node c na nteger cost for each arc l na nteger lower bound of flow for each arc u na nteger upper bound of flow for each arc The reference mplementatons of the man program PDNET reads networ data from an nput fle by nvong functons avalable n the Fortran module pdnet_read.f90. These functons buld PDNET nput data structures from data fles n the DIMACS format [2] wth nstances of mnmum cost flows problems. As llustrated n the PDNET module fdrver.f90, we provde specalzed nterfaces used n Fortran programs usng dynamc memory allocaton. 4.3 Memory allocaton In PDNET, total memory utlzaton s carefully managed by allocatng each ndvdual array to a temporary vector passed as argument to nternal PDNET functons. Furthermore, nput and output arrays, presented n Table 4, are passed as arguments to subroutne pdnet() and must be allocated by the callng procedure. 254 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm Table 4 External arrays. varable dmenson type descrpton dnfo 34 double precson parameters and statstcs nfo 23 nteger parameters and statstcs optflo na nteger optmal flow for each arc 4.4 Parameter settng PDNET executon s controlled by a varety of parameters, selectng features of the underlyng algorthm and the nterface wth the callng program. A subset of these parameters s exposed to the callng procedure va a PDNET core subroutne. The remanng parameters are set at comple tme wth default values assgned n nsde module pdnet_default.f90. The run tme parameters lsted n Tables 5 and 6 are set wth Fortran functon pdnet_setntparm(). The nteger parameters are assgned to components of vector nfo and double precson parameters are assgned to vector dnfo. 4.5 Maxmum flow computaton PDNET ncludes a maxmum flow computaton module called pdnet_maxflow, featurng the mplementaton of Goldfarb and Grgorads [6] of Dnc s algorthm, that s used to chec the maxmum flow stoppng crteron. Furthermore, a modfcaton of ths module, called pdnet_feasble, s called by the module pdnet_checfeas() after readng the networ fle to compute a maxmum flow on the networ, therefore checng for nfeasblty. 4.6 Runnng PDNET Module fdrver nputs the networ structure and passes control to module pdnet(). Ths subroutne starts by readng the control parameters from the vector nfo, wth pdnet_getnfo(). Correctness of the nput s checed wth pdnet_chec(), and data structure created wth pdnet_datastruct(). Internal parameters for methods are set wth pdnet_default(), and addtonal structures are created wth pdnet_buldstruct(). Subroutnes pdnet_transform() and pdnet_perturb() are called n order to shft the lower bounds to zero and to transform the data nto double precson, respectvely. Subroutnes pdnet_probdata() and pdnet_checfeas() chec the problem characterstcs and nqure f the networ has enough capacty to transport the proposed amount of commodty. The prmal-dual man loop s then started and the rght-hand-sde of the search drecton system s computed by pdnet_comprhs(). The maxmum spannng tree s computed by pdnet_heap(), and ts optmalty s tested by pdnet_optchec(). Under certan condtons ( µ < 1), the maxflow stoppng crteron s nvoed by subroutne pdnet_checmaxflow(). If requred, precondtoner swtch taes place, followed by a call to pdnet_precconjgrd() to solve the Newton drecton lnear system usng the chosen precondtoner. A summary of the teraton s prnted by pdnet_prntout(). Prmal and dual updates are made by pdnet_updatesol() and stoppng crtera chec taes place, before returnng to the start of the teraton loop. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 255
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm We now present a usage example. Let us consder the problem of fndng the mnmum cost flow on the networ represented n Fgure 2. In ths fgure, the ntegers close to the nodes represent the node s produced (postve value) or consumed (negatve value) net flows, and the ntegers close to the arcs stand for ther unt cost. Furthermore the capacty of each arc s bounded between 0 and 10. In Fgure 3, we show the DIMACS format representaton of ths problem, stored n fle test.mn. Furthermore, Fgures 4 and 5 show the begnnng and the end of the prntout gven by PDNET, respectvely. Table 5 Lst of runtme nteger parameters assgned to vector nfo. component varable descrpton 1 bound used for buldng maxmum spannng tree 2 prcnd precondtoner used 3 out output fle unt (6: standard output) 4 maxt maxmum number of prmal-dual teratons 5 mxcgt maxmum number of PCG teratons 6 mxfv vertces on optmal flow networ 7 mxfe edges on optmal flow networ 8 nbound used for computng addtonal data structures 9 nbu number of bucets 10 pdut number of prmal-dual teratons performed 11 root sets begnnng of structure 12 opt flags optmal flow 13 pcgt number of PCG teratons performed 14 pf teraton level 15 error flags errors n nput 16 cgstop flags how PCG stopped 17 mfstat maxflow status 18 oflag controls the output level of the summary 19 prttyp prntout level 20 optgap dualty gap optmalty ndcator flag 21 optmf maxmum flow optmalty ndcator flag 22 optst spannng tree optmalty ndcator flag 23 mr estmate of maxmum number of teratons Fgure 2 Example of a mnmum cost flow networ. 256 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm Table 6 Lst of runtme double precson parameters assgned to vector dnfo. component varable descrpton 1 dobj dual objectve functon value 2 dof dual objectve functon value on tree 3 factor factor for Newton step 4 fcttol factorzaton zero tolerance 5 gap value of the gap 6 grho0 factor for rho0 update 7 gtolcg factor for PCG tolerance 8 gtolmf update factor for maxflow tolerances 9 mfdopt maxflow value 10 mu value of nteror-pont µ parameter 11 mntlcg lower bound for PCG tolerance 12 mrho0 lower bound for rho0 13 oldtol value of resdual n prevous PCG teraton 14 pcgres value of resdual n current PCG teraton 15 pobj objectve functon value 16 pof prmal objectve functon value on tree 17 rho0 parameter from IQRD precondtoner 18 s1fctr factor for mu 19 stptol tolerance for dual slacs 20 stpval value of largest slac on dual face 21 tol1 lower bound of tolerance for maxflow 22 tol2 upper bound of tolerance for maxflow 23 tolcg tolerance for PCG stoppng crteron 24 tolcg0 guess for tolerance for PCG stoppng crteron 25 tolsl zero for dual slacs 26 huge largest real number 27 tolpcg ntal value for tolcg 28 oldcos value of cosne n prevous PCG teraton 29 pcgcos value of cosne n current PCG teraton 30 zero value for zero 31 tolsw1 maxmum value for sw1 32 tolsw2 maxmum value for sw2 33 sw1 ter lmt on PCG for dagonal to spannng tree swtch 34 sw2 ter lmt on PCG for spannng tree to IQRD swtch Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 257
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm p mn 4 5 n 1 2 n 2-2 n 3-4 n 4 4 a 1 2 0 10 3 a 2 4 0 10-7 a 4 3 0 10 1 a 3 1 0 10-4 a 2 3 0 10 2 Fgure 3 Fle test.mn wth the DIMACS format representaton of the problem of Fg. 2. Fgure 4 Startup and frst two teratons of a typcal PDNET sesson. Fgure 5 Last teraton and results prntout n typcal PDNET sesson. 5. Computatonal results A prelmnary verson of PDNET was tested extensvely wth results reported n [12]. In ths secton, we report on a lmted experment wth the verson of PDNET n the software dstrbuton. The experments were done on a PC wth an Intel Pentum IV processor runnng at 2 Ghz and 2 Gb of man memory. The operatng system s Ubuntu Lnux 7.10 (ernel 2.6.22). The code was compled on the Intel Fortran compler verson 10.0 usng the flags -O3. CPU tmes n seconds were computed by callng the Fortran 90 functon cpu_tme(). The test problems are nstances of the classes mesh, grd and netgen_lo of mnmum-cost networ flow problems, taen from the Frst DIMACS Implementaton Challenge [3]. The specfcatons of the mesh nstances generated are presented n Table 7. The specfcatons used n the GRIDGEN generator to buld the grd problems are dsplayed n Table 8. Fnally, 258 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm the nstances of the test set netgen_lo were generated accordng to the gudelnes stated n the computatonal study of Resende and Vega [15], usng the NETGEN generator followng the specfcatons presented n Table 9. All these generators can be downloaded from the FTP ste dmacs.rutgers.edu. Table 7 Specfcatons for nstances n class mesh. Problem n m maxcap maxcost seed x y xdeg ydeg 1 256 4096 16384 4096 270001 36 7 9 5 2 2048 32768 16384 4096 270001 146 14 9 5 3 8192 131072 16384 4096 270001 409 20 9 5 Problem nodes grd sze Table 8 Specfcatons for nstances n class grd. arc costs arc caps sources sns average degree supply mn max mn max 1 101 10x10 50 50 16 100000 0 2000 0 2000 2 901 30x30 450 450 16 100000 0 2000 0 2000 3 2501 50x50 1250 1250 16 100000 0 2000 0 2000 Instances of ncreasng dmenson were consdered. The three netgen_lo nstances presented were generated consderng x = 9, x = 13 and x = 15 respectvely. In Table 10, the number of teratons (IT) and the CPU tme (CPU) of PDNET and CPLEX 10 are compared. The reported results show that PDNET tends to outperform CPLEX n the larger nstances of the mesh and netgen_lo set problems, but fals to do so n grd set problems. For testset netgen_lo the dfference s qute notceable for the largest nstance. We observed that n ths problem about 90% of the CPU tme and teraton count n CPLEX 10 was spent computng a feasble soluton. The results n ths experence and those reported n [12] show that ths code s qute compettve wth CPLEX and other effcent networ flow codes for large-scale problems. 6. Concludng remars In ths paper, we descrbe a Fortran mplementaton of PDNET, a prmal-nfeasble dualfeasble nteror pont method for solvng large--scale lnear networ flow problems. The subroutnes are descrbed, and drectons for usage are gven. A number of techncal features of the mplementaton, whch enable the user to control several aspects of the program executon, are also presented. Some computatonal experence wth a number of test problems from the DIMACS collecton s reported. These results llustrate the effcency of PDNET for the soluton of lnear networ flow problems. Source code for the software s avalable for download at http://www.research.att.com/~mgcr/pdnet. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 259
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm Table 9 NETGEN specfcaton fle for class netgen_lo. seed Random number seed: 27001 problem Problem number (for output): 1 nodes Number of nodes: m = 2 x sources Number of sources: 2 2 x sns Number of sns: 2 2 x densty Number of (requested) arcs: 3 2 x+ mncost Mnmum arc cost: 0 maxcost Maxmum arc cost: 4096 supply Total supply: 2( 2) 2 x tsources Transshpment sources: 0 tsns Transshpment sns: 0 hcost Seleton arcs wth max cost: 100% capactated Capactated arcs: 100% mncap Mnmum arc capacty: 1 maxcap Maxmum arc capacty: 16 Table 10 Computatonal experence wth nstances of the sets mesh, grd and netgen_lo of test problems. CPLEX 10 PDNET Set Problem V E IT CPU IT CPU 1 256 4096 8383 0.04 40 0.08 mesh 2 2048 32768 108831 2.28 59 1.31 3 8192 131072 545515 51.06 76 10.20 1 101 1616 282 0.01 27 0.02 grd 2 901 14416 1460 0.03 35 0.36 3 2501 40016 4604 0.19 44 1.70 1 512 4102 3963 0.03 28 0.08 netgen_lo 2 8192 65709 135028 5.19 46 3.30 3 32768 262896 800699 112.24 59 27.50 References (1) Ahuja, N.K.; Magnant, T.L. & Orln, J.B. (1993). Networ Flows. Prentce Hall, Englewood Clffs, NJ. (2) DIMACS (1991). The frst DIMACS nternatonal algorthm mplementaton challenge: Problem defntons and specfcatons. World-Wde Web document. (3) DIMACS (1991). The frst DIMACS nternatonal algorthm mplementaton challenge: The benchmar experments. Techncal report, DIMACS, New Brunswc, NJ. 260 Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008
Portugal, Resende, Vega, Patríco & Júdce Fortran subroutnes for networ flow optmzaton usng an nteror pont algorthm (4) El-Bary, A.S.; Tapa, R.A. & Zhang, Y. (1994). A study on the use of ndcators for dentfyng zero varables for nteror-pont methods. SIAM Revew, 36, 45-72. (5) Gay, D.M. (1989). Stoppng tests that compute optmal solutons for nteror-pont lnear programmng algorthms. Techncal report, AT&T Bell Laboratores, Murray Hll, NJ. (6) Goldfarb, D. & Grgorads, M.D. (1988). A computatonal comparson of the Dnc and networ smplex methods for maxmum flow. Annals of Operatons Research, 13, 83-123. (7) Internatonal Organzaton for Standardzaton (1997). Informaton technology Programmng languages Fortran Part 1: Base language. ISO/IEC 1539-1:1997, Internatonal Organzaton for Standardzaton, Geneva, Swtzerland. (8) Karmarar, N.K. & Ramarshnan, K.G. (1991). Computatonal results of an nteror pont algorthm for large scale lnear programmng. Mathematcal Programmng, 52, 555-586. (9) McShane, K.A. & Monma, C.L. & Shanno, D.F. (1989). An mplementaton of a prmal-dual nteror pont method for lnear programmng. ORSA Journal on Computng, 1, 70-83. (10) Mehrotra, S. & Ye, Y. (1993). Fndng an nteror pont n the optmal face of lnear programs. Mathematcal Programmng, 62, 497-516. (11) Portugal, L.; Bastos, F.; Júdce, J.; Paxão, J. & Terlay, T. (1996). An nvestgaton of nteror pont algorthms for the lnear transportaton problem. SIAM J. Sc. Computng, 17, 1202-1223. (12) Portugal, L.F.; Resende, M.G.C.; Vega, G. & Júdce, J.J. (2000). A truncated prmalnfeasble dual-feasble networ nteror pont method. Networs, 35, 91-108. (13) Prm, R.C. (1957). Shortest connecton networs and some generalzatons. Bell System Techncal Journal, 36, 1389-1401. (14) Resende, M.G.C. & Vega, G. (1993). Computng the projecton n an nteror pont algorthm: An expermental comparson. Investgacón Operatva, 3, 81-92. (15) Resende, M.G.C. & Vega, G. (1993). An effcent mplementaton of a networ nteror pont method. In: Networ Flows and Matchng: Frst DIMACS Implementaton Challenge [edted by Davd S. Johnson and Catherne C. McGeoch], volume 12 of DIMACS Seres n Dscrete Mathematcs and Theoretcal Computer Scence, 299-348. Amercan Mathematcal Socety. (16) Resende, M.G.C. & Vega, G. (1993). An mplementaton of the dual affne scalng algorthm for mnmum cost flow on bpartte uncapactated networs. SIAM Journal on Optmzaton, 3, 516-537. (17) Ye, Y. (1992). On the fnte convergence of nteror-pont algorthms for lnear programmng. Mathematcal Programmng, 57, 325-335. (18) Yeh, Quey-Jen (1989). A reduced dual affne scalng algorthm for solvng assgnment and transportaton problems. PhD thess, Columba Unversty, New Yor, NY. Pesqusa Operaconal, v.28, n.2, p.243-261, Mao a Agosto de 2008 261