economic lot sizing an algorithm that runs in linear time in the wagner

Upload: fmunoz7

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    1/13

    Economic Lot Sizing: An O(n log n) Algorithm That Runs in Linear Time in the Wagner-

    Whitin CaseAuthor(s): Albert Wagelmans, Stan Van Hoesel, Antoon KolenSource: Operations Research, Vol. 40, Supplement 1: Optimization (Jan. - Feb., 1992), pp. S145-S156Published by: INFORMSStable URL: http://www.jstor.org/stable/3840844 .

    Accessed: 12/05/2011 16:58

    Your use of the JSTOR archive indicates your acceptance of JSTOR's Terms and Conditions of Use, available at .http://www.jstor.org/page/info/about/policies/terms.jsp. JSTOR's Terms and Conditions of Use provides, in part, that unless

    you have obtained prior permission, you may not download an entire issue of a journal or multiple copies of articles, and you

    may use content in the JSTOR archive only for your personal, non-commercial use.

    Please contact the publisher regarding any further use of this work. Publisher contact information may be obtained at .http://www.jstor.org/action/showPublisher?publisherCode=informs. .

    Each copy of any part of a JSTOR transmission must contain the same copyright notice that appears on the screen or printed

    page of such transmission.

    JSTOR is a not-for-profit service that helps scholars, researchers, and students discover, use, and build upon a wide range of

    content in a trusted digital archive. We use information technology and tools to increase productivity and facilitate new forms

    of scholarship. For more information about JSTOR, please contact [email protected].

    INFORMS is collaborating with JSTOR to digitize, preserve and extend access to Operations Research.

    http://www.jstor.org

    http://www.jstor.org/action/showPublisher?publisherCode=informshttp://www.jstor.org/stable/3840844?origin=JSTOR-pdfhttp://www.jstor.org/page/info/about/policies/terms.jsphttp://www.jstor.org/action/showPublisher?publisherCode=informshttp://www.jstor.org/action/showPublisher?publisherCode=informshttp://www.jstor.org/page/info/about/policies/terms.jsphttp://www.jstor.org/stable/3840844?origin=JSTOR-pdfhttp://www.jstor.org/action/showPublisher?publisherCode=informs
  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    2/13

    ECONOMICLOT SIZING:AN O(n log n) ALGORITHM HATRUNSIN LINEARTIME IN THE WAGNER-WHITINASEALBERTWAGELMANS nd STAN VAN HOESEL

    Erasmus University, Rotterdam, The NetherlandsANTOON KOLEN

    Limburg University, Maastricht, The Netherlands(Received October 1989; revision received October 1990; accepted November 1990)

    We consider the n-period economic lot sizing problem, where the cost coefficients are not restricted in sign. In theirseminalpaper,H. M. Wagner nd T. M. Whitinproposedan 0(n2) algorithmor thespecialcaseof thisproblem,wherethe marginalproductioncostsareequalin all periodsand the unit holdingcostsarenonnegative. t is well knownthattheirapproach an also be used to solve thegeneralproblem,withoutaffecting he complexityof the algorithm. n thispaper,we presentan algorithm o solve the economic lot sizing problem n 0(n logn) time, and we show how theWagner-Whitin ase can even be solved in linear time. Our algorithmcan easily be explained by a geometricalinterpretation nd the time bounds are obtainedwithoutthe use of any complicateddata structure.Furthermore,weshow how Wagnerand Whitin'sand our algorithmare relatedto algorithms hat solve the dual of the simple plantlocation ormulationof the economic ot sizingproblem.

    In 1958,Wagner ndWhitinpublishedheir eminalpaper,"DynamicVersionof the EconomicLotSize Model."Theirapproach o solve the economiclot sizingproblem till standsasa classical pplicationof dynamicprogrammingndit is frequently sed npractice;or nstance,n MRPpackageshealgorithmis oftenusedto solvesubproblemshat occur n com-plex productiontructures.In thispaper,we consider he economic ot sizingproblem orwhich hemarginal roduction ostsmaydiffer betweenperiodsand all cost coefficientsareunrestrictedn sign.Theproblem riginallyreated yWagner ndWhitin s a specialcase of thisproblembecause heyassumed denticalmarginalproductioncostsandnonnegative nitholdingcosts.However,tis wellknown hatthe Wagner-Whitinlgorithm aneasilybe modified o dealwiththe generalcase. Forbothcases healgorithm uns n O(n2) ime,wherenis the numberof periodsof the problemnstance;oran efficientmplementation,eeEvans 1985).Intheirpaper,Wagner nd Whitinsuggested wayto lowerthe computationalburden;relatedresults can befoundin Zabel(1964),Eppen,Gouldand Pashigian(1969), and Lundin and Morton(1975). However,althoughpossiblyusefulin practice, hese resultsdonot affect hecomplexityof thealgorithm.

    Wewillpresent nalgorithmo solvethe economiclot sizing problem that runs in O(n log n) time andshow how a special case-including the Wagner-Whitin case- can be solved in O(n) time. The algo-rithm sbasedona wellknowndynamicprogrammingformulation hichusesabackwardecursion.Assum-ing productionn a givenperiod, he recursion or-mulaprescribes n optimalnext productionperiod.Our algorithm dentifiesperiodsthat will neverbechosen as productionperiods n an optimalproduc-tionplan.Thecrucial deais thatfrom heremainingperiods t is relatively asyto selectan optimalnextproduction eriod.Aggarwaland Park (1990), and Federgruen ndTzur 1991) ndependentlybtained esults imilar othosepresentedn thispaper.However, urapproachis significantlydifferent rom theirsand the mainadvantage f our method s that it can be explainedeasilybygivinganinsightful eometricnterpretation.In Section 1, we discussthe economiclot sizingproblemand make some preliminary emarks.Ouralgorithms explainedn Section2 andthenecessarymodifications o solve the Wagner-Whitinase inlinear ime arediscussedn Section3. Thealgorithmwasdiscovered ysolving he dualof thesimpleplantlocation formulationof the economic lot sizing

    Subject lassifications:Analysisof algorithms, omputationalomplexity: conomic ot sizingproblem.Dynamicprogramming,pplications:conomiclot sizingby dynamicprogramming.nventory/production:omplexityof economic ot sizing.Areaofreview:OPTIMIZATIONOperationsResearch 0030-364X/92/4001-S145 01.25Vol.40, Supp.No. 1,January-February992 S145 ? 1992OperationsResearch ocietyof America

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    3/13

    S146 / WAGELMANS, OESELAND KOLENproblem,and in Section 4 we show how the structureof this dual enables us to solve it by inspection. Twoalgorithmsare given:a greedyforwardalgorithmthatcorresponds to the Wagner-Whitinapproach and anongreedybackwardalgorithmthat is essentiallythealgorithm of Section 2. Concluding remarkscan befound in Section 5.1. THE ECONOMICLOT SIZINGPROBLEMIn the economic lot sizingproblem (ELS)one is askedto satisfy at minimum cost the known nonnegativedemands for a specific commodity in a number ofconsecutive periods (the "planning horizon"). It ispossible to store units of the commodity to satisfyfuture demands, but backloggingis not allowed. Foreveryperiod,the productioncosts consist of two com-ponents: a cost per unit produced and a fixed setupcost that is incurred whenever production occurs inthe period. In addition to the production costs, thereare holding costs which are linear in the inventorylevel at the end of the period. Both the inventory atthe beginning and at the end of the planning horizonare assumed to be zero. We can always assume thatthe demand in the last period is positive, becauseotherwise we could delete this period without reallychangingthe problem.Note that we do not make any assumption aboutthe sign of the cost coefficients. This is motivated bythe fact that instances of ELS often occur as subprob-lems while solving complex production problems.When, for instance, Langrangianrelaxation is used,thesesubproblemsmayhavenegativecost coefficients.It is useful to consider some mathematical formu-lations of ELS. Let n be the length of the planninghorizon and di, pi, f, hi denote, respectively, thedemand, marginal production cost, setup cost andunit holding cost in period i, i = 1, ..., n. Given theproblem description above, the most naturalway toformulateELS as a mixed-integerprogram s by usingthe following variables:xi: the number of units producedin period i;si: the number of units in stock at the end ofperiod i;

    I_ if a setup occurs in period iY lo0 otherwise.Define dij = Ej=i dt, 1 < i < j < n, then a correctformulationof ELS is as follows.FormulationIMinimize E (pixi + fYi + hisi)i=l

    subjecttoXi + Si_- - Si = didinyi - Xi 0

    for i = 1,..., nfori = 1,..., n

    SO = Sn = 0

    xi O, si 3 0, yi E {0, 1} for i = 1, ..., n.Because Si = Et=i xi - S=ldt, i = 1, ..., n, we caneliminate these variables from the formulation. Thisresultsin the next formulation.FormulationII

    n nMinimize E (cixi + fiyi) - hi dlii=l i=lsubjectton

    xt = dlnt=l

    Z Xt 2 diit=ldinyi- xi > 0

    for i = 1,..., n - 1fori= 1,...,n

    xi > 0, yi E {0, 1} for i = 1,..., n.Hereci pi + ,=iht, i= 1, ... n.. Note that thelast summation in the objectivefunction is a constantand can thereforebe omitted. This reformulationisuseful because it shows us that we can restrict ouranalysis to instance of ELS where the holding costsare zero.From now on, we shall work with the marginalproduction costs ci, i = 1, ..., n. As mentionedbefore, we do not make any assumption about thesign of these costs. The fact that such an assumptionis unnecessaryfollows from the first constraintof II,which implies that adding the same amount to allmarginalproductioncosts shiftsthe objectivefunctionof all feasible solutions by the same amount. Hence,not the values, but rather the differences betweenmarginal production costs play a role in determiningthe optimal solution. The algorithmthat we presentin the next section assumes nonnegative setup costs.However, this does not mean that instances withnegative setup costs cannot be solved. Iff, < 0, then itwill always be profitableto set up in period i (even ifthere is no production in that period). By redefiningthe setup costs for those periodsto be zero, we obtaina problem instance with nonnegative setup costs.Solving this instance and adding all negative setupcosts to the obtained solution value gives the optimalvalue of the originalinstance.

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    4/13

    Economic Lot Sizing Algorithm / S 147A third formulation played an important role indiscoveringthe algorithmthatwe aregoingto present.In this formulationthe xi-variablesare disaggregatedinto variablesxit:

    xit: the numberof units producedin periodi to satisfydemand of period t > i.The formulation is as follows.FormulationIII

    n nMinimize E (fiyi + ci E xit)1i= t=isubjecttot fort= 1, ..., nxit = dti=1dtYi- xit > 0 for i = 1, ..., n,for t = i,..., nxit >0, yiE{0, 1} fori= 1, ..., n,for t = i,..., n.This formulation is a scaled version of the so-calledsimple plant location formulation of ELS, in whichone uses the variables:zit: the fractionof demand of period t satisfiedbyproductionin period i < t;(i.e., zit= xi/tdt if dt> 0). It hasbeen shown in Krarupand Bilde (1977) that the LP-relaxationof that for-mulationhasoptimalsolutionin whichthey-variablesare integer;of course, this must also hold for the LP-relaxation of III. Althoughthe dual programsof bothrelaxations areessentiallythe same, it is more conven-ient to solve the dual of the relaxation of III, especiallywhen we want to allow zero-demandin some periods.In Section 4, we shall presentalgorithmsto solve thisdual.ELS is traditionallynot solved by explicitly usingany of the formulations above, but by dynamic pro-gramming.The key observationto obtain a dynamicprogrammingformulation of the problem is that itsuffices to consider only feasible solutions in whichthe inventory at the beginning of production periodsis zero(the "zero-inventoryproperty");n otherwords,productionin period i equals 0 or dikfor some k > i.This propertywas stated firstby Wagnerand Whitin(1958) for their special case. Later, Wagner (1960)showed that the property even holds under theassumption of concave production costs (see alsoZangwill 1968).In the next section, we shall present our algorithmwhich is essentially a backward dynamic program-

    ming algorithm.Forthe sakeof completeness,we notehere that a similar algorithm based on a forwardrecursion can be derived. However, the latter algo-rithm uses a somewhat more complicated data struc-ture than the one given below; for details we refertoVan Hoesel (1991).2. AN O(n log n) ALGORITHM O SOLVE ELSIn this section, we assume that all setup costs arenonnegative. We define G(t) to be the cost of anoptimal solution to the instance of ELS with aplanning horizon consisting of periods t to n, t =1,..., n. Furthermore,G(n + 1)is defined to be zero.Because of the zero-inventory propertythe followingrecursion holds:

    min f + ci di,t- + G(t) ifdi >i

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    5/13

    S148 / WAGELMANS, OESELANDKOLEN

    o (i+dl)

    ~~~~0~~~~~~~~~~~I

    Figure1. Diagramof minimal cost versus cumulativedemand.

    z = di+ , to be breakpoints. It is obvious that if zis a breakpoint, then (z, g(z)) = (d,,, G(t) for someperiod t e Ii + 1, ..., n + II. Suppose that thereare r breakpoints of g and let i + 1 = t(l) < ...

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    6/13

    Economic Lot Sizing Algorithm / S 149

    i di, t(q)-1+ (t(q)) ------------------

    G(t(q))-

    0d do t(q),n i, nFigure3. Geometric determination of minimumvalue.

    axis of the lowest of these intersectionpoints is equalto min cidij,-1+ G(I).Proof. Suppose that [G(k) - G(I)]/dk,_l-< ci, thenG(k) < Cidk,o-_+ G(l). Adding cidi,k_- on both sidesof the inequality sign results in cidi,k-l + G(k) cidi,t(p+)- + G(t(p + 1))

    andcidi,t(p)- + G(t(p)) 1,we want to proceed with the analogouscalculation ofG(i - 1). However, first we must update the set ofefficient periods. Geometrically we can apply thefollowing procedure: add the point (din, G(i))and find the smallest efficient period t(s), such thatthe slope of the line segment connecting (din, G(i))to (dt(),n, G(t(s))) is greater than the slope of theline segment connecting (dt(s+l),n,G(t(s + 1))) to(dt(s),n, G(t(s))). The new set of efficient periodsconsists of period i and the periods t(s) to t(r) (seeFigure4).

    G(i

    -inFigure4. Updating the lower convex envelope.orp= 1, .., q- 1

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    7/13

    S150 / WAGELMANS, OESELAND KOLENTo define t(s) formally a few remarks are needed.We adopt the convention that if di = 0, then theefficientperiodi + 1is replacedby the efficientperiodi. It is trivial that in the case where di = 0 and G(i) =G(i - 1), all other efficient periods remain efficient,i.e., we let s := 2. Otherwise, it always holds that

    s S q. To see this, suppose that q < r. By the defini-tion of t(q) and because G(i) = fi + cidi,t(q)-l+G(t(q)) the following holdsG(i) - G(t(q)) _ c> G(t(q)) - G(t(q + 1))

    dl,t(q)-l dt(q),t(q+l)-1and this implies that s < q.We then define s as:s := min q, minp I< p < q, di,(p)_-> 0

    and G(i) - G(t(p)) G(t(p)) - G(t(p + 1))di,t(p)- l dt(p),t(p+ )-lNote that di,(,p)_= 0 can only occur if t(p) = i + 1and di = 0. Hence, the condition di,t(p)-> 0 guaran-tees that if di = 0 the periodi + 1is no longerefficient.To find s we simply compareG(i) - G(t(p))

    di,t(p)-toG(t(p)) - G(t(p + 1))

    dt(p),t(p+l)-ifor increasingp, 1 S p < q, and stop as soon as thefirst expression is greaterthan the second. Note thatif a period is not efficient during the calculation ofG(i), it can never be efficient during the calculationof G(j) for allj < i; i.e., a periodbecomes inefficientat most once.Before giving a complete description of the algo-rithm a few remarksmay clarifythat it can indeed beimplementedto run in O(n log n) time. First note thatthe marginalproductioncosts ci, i = 1,..., n, can becalculated frompi and hi, i = 1, ..., n, in O(n) time.Redefining the setup costs is of the same complexity.In the implementationbelow we assume nonnegativesetup costs; the modifications needed otherwise arestraightforward.Furthermore, it is not necessary tocalculatedijfor all pairs i,j with 1 < i j < n. At thestartof the algorithmwe only calculatethe coefficientsdi,, i = 1, ..., n (againin linear time). Because dij=di - dj+l,n, 1 < i < j < n, these coefficients can thenbe obtained in constant time when needed.

    The main part of the algorithm consists of n iter-ations: G(i) is calculated in iteration n - i + 1. Theimplementation below uses a list ("stack")L thatcontains the efficient periods at the beginningof iter-ation n - i + 1 in increasingorder. As noted before,we can find the periodt(q) by binarysearch n L. Thetotal time spent on searchingis thereforeO(n log n).In everyiterationwe have to make a few comparisonsto determine the period t(s). After every comparison,we eitherconclude that we have found t(s) or we haveto continue by consideringthe next periodin L. Thefirstcase occurs exactlyonce in everyiteration,i.e., intotal n times. In the second case, we delete a periodfrom L. As every period is deleted from L at mostonce, this case can occur no more than n times. Thus,the overall complexity of calculating G(1) isO(n log n). At the end of the algorithm an optimalsolution is constructed in linear time using informa-tion obtained during the iterations. The output isgivenin terms of thex- andy-variablesusedin modelsI and II of Section 1. Initially L is empty and allvariablesare equal to zero.The next description should be self-explanatory,except for l(p) which is used to indicate the successorofp in L.Algorithm(Input:p, hE DR, ; d E RIoOutput:x E R, yE B).Initializationcalculate ci and din, i = 1, ..., nadd n + 1 to L.IterationsFor i := n down to 1 dobegin

    search for q(i) := min n + 1,

    min E L p < n + 1d G(p)- G(l(p))< ci}dpn dl(p),n

    G(i) :=f; + ci[dln - dq(i),n] + G(q(i)),if (di = 0 and G(i + 1) < G(i)) then,beginG(i) :=G(i + 1)s:=l(i+ 1)end

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    8/13

    elsebeginif d > O, thens:= i+ 1 elses:=l(i+ 1)while(i)- G(s) G(s) - G(l(s)) ands 0,i = 1, ..., n. For the marginal production costsCi pi + ?=ihi, it follows that ci > ci+1, i = 1,...,n - 1. The discussion of the complexity of our algo-rithm in the previous section makes clear that apartfrom the binary searches,the number of elementaryoperationsis O(n). We shall now show that when themarginalproductioncostsarenonincreasingover timewe can replacethe binarysearchesby a much simplersearch strategythat requires in total O(n) compari-sons. Hence, the Wagner-Whitinmodel is an interest-ing special case of a class of lot sizing problems thatcan be solved in lineartime.In our exposition, we shall use the same notationas in the descripton of the algorithm at the end ofthe previous section. Consider iteration n - i + 1,1 < i < n, in which we determineq(i) := min n + 1, min E{ L p < n + 1

    and G(p) - G(l(p)) < ci}dpn- dl(p),nwhereL is the currentlist of efficient periods.First suppose that q(i + 1) c L, then it must haveoccurredin iteration n - i that s > q(i + 1). But this

    Economic Lot Sizing Algorithm / S151is only possible if di+, = 0, G(i + 1) = G(i + 2) andq(i + 1) = i + 2. In that case, L has been updatedbysimply replacingperiod i + 2 by period i + 1. Hence,l(i + 1) is the same periodas the successor of i + 2 initerationn - i. It follows thatG(i + 1) - G(l(i + 1)) G(i + 2) - G(l(i + 1))

    /di+l,/(i+l)- /di+2,l(i+l)-l< Ci+l Ci,

    where the strict inequality follows from the definitionof q(i + 1). We conclude that q(i) = i + 1.Now suppose that q(i + 1) E L. Note that aslong as q(i + 1) is efficient it has the same succes-sor l(i + 1) in L. Using again the definition ofq(i + 1) we obtainG(q(i + 1)) - G(l(q(i + 1))) < Ci+\ < Ci.dq(i+l),l(q(i+ 1))-1Hence, it follows that in this case q(i) < q(i + 1).We can adaptthe implementation of the algorithmas follows: Let m(p) denote the predecessorofp in L.Initialize s and q(n + 1) to n + 1 and replace the"searchfor q(i)" by the following statements:if s > q(i + 1), then q(i) := i + 1 elsebeginq(i) := m(q(i + 1))

    while G(q(i))- G(l(q(i))) < chile

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    9/13

    S152 / WAGELMANS, OESELAND KOLENTable I

    Input Data (7=1 hidi = 3860)i din f ci1 630 85 122 561 102 113 532 102 104 496 101 95 435 98 86 374 114 77 348 105 68 314 86 59 247 119 410 202 110 311 135 98 212 56 114 1

    To end this section, we give the results of ouralgorithmfor the example from Wagner and Whitin(1958). The (transformed) nput data aredisplayedinTable I.The output is given in Table II and should beinterpretedas follows: Iterationscorrespondto rows.The first column of every row contains the period ifor which we are calculating G(i). In the secondcolumn we show the efficientperiodsat the beginningof the corresponding iteration. For the efficientperiods between bracketswe have alreadyconcludedthat q(j) is less than these periodsforj < i. The valuesof q(i) and G(i) are given in the next two columns.The last column contains the ratioG(i) - G(l(i))

    di,n- dl(i),nthat is calculated at the end of the iteration. To findq(i) we compare Ciwith the ratios of the efficientperiods that are not between brackets, startingwiththe largestone. We stop as soon we find a ratio thatis greater han ci.The optimal policy is to produce in periods 1, 3, 5,8, 10 and 11. Because of the transformation of thecost coefficients we should subtract 3,860 from thevalue 4,724 to obtain the optimal value 864.4. SOLVINGTHE DUAL OF THE SIMPLEPLANTLOCATIONFORMULATIONIn this section, we show how our algorithmrelates toone that solves the dual of the LP-relaxationof thesimple plant location formulation of ELS. In fact thealgorithmpresented n the previoussectionwas devel-oped after an O(n log n) algorithmto solve this dualhad been found. As mentioned in Section 1, we knowthat the LP-relaxationof the simple plant location

    formulationhas an integeroptimal solution. This factwas first proven in Krarupand Bilde who suggestedan O(n2) algorithm to solve this formulation. Forconvenience, we shall consider a slightly differentformulation, viz. the LP-relaxation of model III ofSection 1. For the dual the only consequence is thatthe variablesare scaleddifferently.Apartfromthe factthat this facilitatesthe exposition, this dual is easier totreat when zero-demandis allowed.The dual of the LP-relaxationof III is the followingprogram.ProgramD

    n nMaximize E dt,v - xt=l i=1subjectton

    i dtwit- Xi < fi for i = 1, ..., nt=ivt-wit, Ci fori= 1, ..., n,fort= i,...,nwit,Xi>0 for = 1, ...,n,for t = i,..., nvt free for t= 1,..., n.

    In an optimal solution we can always take wit :=max{0, v, - ci\. IfJi> 0, then the restrictionyi < 1 inthe LP-relaxation of III is superfluousand thereforethe correspondingdual variableXican be taken equalto zero. If f < 0 we can take X, = -fi and solve theremainingproblem.This correspondsto the way neg-ative setup costs have been treatedbefore. We there-fore show how to solve the following program,wheref> 0, i= 1,..., n.

    Table IIResults of Algorithmi EfficientPeriods q(i) G(i) Ratio12 13 13 170 3.0411 13,12 13 368 2.7310 13,11 11 679 4.649 (13)11,10 11 935 5.698 (13) 11,10,9 10 1325 5.827 (13,11)10,9,8 8 1634 9.096 (13, 11,10,9)8,7 8 1859 8.905 (13,11, 10,9)8,6 8 2391 8.814 (13,11,10,9)8,5 5 3041 10.663 (13,11,10,9,8)5,4 5 3463 11.722 (13, 11, 10,9,8)5,4,3 4 3858 13.621 (13,11,10,9,8,5)4,3,2 3 4724 12.87

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    10/13

    EconomicLot SizingAlgorithm / S153

    Maximize E d,tvt=lsubject onE dtmax{0,v, - cil < f for i = 1, ..., n.t=iThisprograms highlystructured ndcan be solvedbyinspection.Onewayof doing hat sby consideringthe variables n the order of increasing ndex: Ifdj= 0 wecangivevj,anarbitraryalue,otherwiseweletj :=min c + f E- i dtmax{O,vt- cii j f dj J

    i.e., givenvt, t < j, vj is assigneda valueas largeaspossible.The solutionconstructedn thisgreedy or-wardwayis clearly easibleand to proveoptimalitywe first show that if dj $ 0 and dj+1$ 0, thenVj Uj+l:Letk < j be such thatfk - S tjk dtmax {0, Vt - Ck}Vj = Ck 'd dj

    Thus vj > ck and k - Ej=k dtmax{0, Vt - Ck}= 0.Becausefk- jt=kdtmax{0, Vt - CkUj+l ~ Ck +. dj+i

    it followsthat vj+1< Ck < vj. Since the variablescorrespondingo periodswith zero-demand an begiven an arbitrary alue, we may assumethat theconstructed olutionsatisfiesvj > vj+, j = 1, ...,n - 1.Now define F(j) to be the cost of an optimalsolutionto the ELS with the planninghorizoncon-sisting of periods 1 to j, j = 1, ..., n. To proveoptimality f the solution t is sufficiento showthatdZ=i dtvt = F(j), becauseby dualityand the structureof (D '), It=l dtt F(j) must hold. The proof is byinductionon j, startingwithj = 1 for which thestatements trivial.Forj > 1 we only have to consider he case ofdj $ 0, because, otherwise, F(j) = F(j - 1). Letk < j be suchthat

    fk - E-k1 dtmax{O,vt - Ckuj -- Ck ' .=

    j k-IdtUt = Ckdj + fk + E dtvtt=l t=l

    j-+ L d,(v,- max{0, Vt - Ck}).t=k

    Using the induction hypothesis k-1 dtv = F(k - 1),and the fact that v, > vj > Ck, F(j), which ogetherwith

    j=1ldtvt< F(j) yields he desired esult.From our discussionabove (in particular, qua-tion(2)) t isclear hatsolvingD' inthegreedyorwardway directlyprovides n optimalsolutionof ELSandisclosely elatedo the forward ynamicprogrammingapproachof Wagnerand Whitin.In fact this dualalgorithms thealgorithm iven n Krarup ndBilde,where t waspresentedn a moregeneral ontext.AnalternativepproachosolveD' isclosely elatedto the algorithmpresented n Section2. It will notcomeasasurprisehat hisalgorithmworksbackward,i.e., variables nd constraints re consideredn orderof decreasingndex. Contrary o the forwardalgo-rithm, we cannot follow a greedystrategy:Whiledetermining propervalue for vj we may have torevise,at the sametime,valuesof some variables t,t > j. It is somewhat urprisinghat in spiteof this,thealgorithman beimplementedorun n O(n ogn)time,while the greedy orward lgorithm as a com-plexity of O(n2). The gain in complexity comes fromthe fact hatwe canagaindetermine ertainmportantindicesby binarysearchand revisingvaluesof vari-ablescan subsequently e done in constant ime. Inour expositionwe shalltry to clarify he correspon-dence o thealgorithm f Section2.Throughouthe algorithm he idea is to keep thevariables such that vj > uj+i,j = i,..., n - 1. Here iis theindexof thevariable ndthe constraint hatweareconsideringn the current teration.At thebegin-ning of the iteration he variablesvi+l to Vn atisfytheconstraintsndexed + 1to n andwillalwayshavethe followingproperty.Thereare indices i + 1 =t(l) < ... < t(r) = n + 1, such that t(p) > vt(p+I)and vt = vt(p)or all t with t(p) < t < t(p + 1)andp =1,..., r - 1. (Here vn+lis defined sufficientlysmall.)

    Program D' then

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    11/13

    S154 / WAGELMANS, OESELAND KOLENFurthermore, it holds that dt(p),t(p+l)-1 0 andEtnt(p) tvt = G(t(p)) for all p < r.We shall call this the staircase property.Of course,the indices t(l) to t(r) correspond to the efficientperiodsof Section 2. Note that

    v(t(p)) = G(t(p)) - G(t(p + 1))dt(p),t(p+l)-iWe arenow going to show how to obtain a solution

    vu',t > i, such that this solution satisfies he constraintsindexed i to n and the staircasepropertyholds, i.e., inparticular tn=i d,vt = G(i). The currentslack in con-strainti isnfi=f - E dtmax(0, v, - ci)t=i+l

    t(q)-1= f - dt(vt ci),t=i+lwhere q := min[r, minp I 1 < p < rand vt < ci}].We distinguishbetween three cases.Case 1. di = 0. By taking v' := vt, t > i, andvi := v'+l, we obtain a solution with all the desiredproperties,becausen n n

    d,tu = d,tv = d,v,t=i t=i+l t=i+= G(i + 1) > G(i)

    and by duality, I=i dtv'[ < G(i).Case 2. di 0 and divi+1 < cidi + 61. Let v :=ci + 6b/diandvu= vt, t > i, then v'/> vu'+,constraintsi to n are satisfied and

    dtv't=i= cidi + 61 + Y dt,v;t=i+

    t(q)-1 n= cidi +f- dt(v, - ci) + i dtuvt=i+l t=i+ln

    =fi + Cidi,t(q)- + i dtvtt=t(q)= f + cid,,t(q)-+ G(t(q)) > G(i).

    Again, we conclude that t=idiv' = G(i).Case 3. divi+l > cidi + 61.Satisfyingconstrainti witha solution v', t = i, ..., n, such that vK' v'+l, t =

    i, ..., n - 1, is now only possible if v[ < v, forsome t, i + 1 S t < t(q) - 1. Consideran arbitraryu,2 < u < q and suppose that we would choose thesolution Vt:= vt(u), < t < t(u), vt = v,, t(u) < t n,then the slack in constraint i would bet(u)-1

    1 - di(Vi- c,) + i dt(vt - ,t)t=i+lt(u)-

    =bj-di(vt(u)-ci)+ dt(vt-v,t())t=i+l

    t=i+lt(u)--di(vt(u) ci)+ dt(vt- v,())t=i+l

    t(q)-i=fi+ idi,t(q)- - vt(u)di,t(u)-l dtvtt=t(u)=fJ+cidi,t(q)- vt(u)dit()-i - G(t(u))+ G(t(q)). (3)

    The value of expression(3) must increasefor increas-ing u and it is certainlypositive for u = q. Let s be thesmallest index, such that (3) is positive if u = s. Inotherwords,s is the smallestindex among 1to q, suchthat by letting all variableswith a smaller index beequal to vt(), while not changing the values of theother variables,constraint i is satisfied. Let 62be thecorrespondingslack, i.e.,62 '= fi + Cidi,t(q)-- - Ut(s) di,t(s)-

    - G(t(s)) + G(t(q)) > 0.The solution vt, t > i, is now defined as:U := Vt(s)+ 62/di,t(s)-l, t = 1, . . . , t() - 1v; := vt, t > t(s).

    The new solution satisfies constrainti with equalityand the constraintsi + 1to n are also satisfiedbecauset' Ut, t > i + 1. Moreover, the staircasepropertyholds becausen t(s)-1 n

    dtv = Z dtv' + E dtvtt=i t=i t=t(s)= t(s) di,t(s)-I + 62 + G(t(s))= fi + cidi,t(q)-+ G(t(q)).

    It follows that t=idtv' = G(i) = f7+ cidi,t(q)- +G(t(q)). Now the equivalence of the choice of shere and in Section 2 becomes clear: (3) is positive

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    12/13

    if and only ifG(i) - vt(u)di,t(,,) - G(t(u)) > 0

    G(i) - G(t(u))4=~ > U (u)di,t(u)-iG(t(u)) - G(t(u + 1))dt(u),t(u+l)-i

    This completes the description of an iteration of thebackwardalgorithmto solve D' (and at the same timeELS).The reader should have no difficulties in findingan implementation of the algorithm that runs inO(n log n) time. The crucial observation to be madeis that the solution is always completely determinedby the values vt(p), = 1, ., r - 1.5. CONCLUDINGREMARKSWe have shown that ELS can be solved in O(n log n)time and how this factis relatedto the specialstructureof the dual of the simple plant location formulation.Furthermore,we showedthat the Wagner-Whitincasecan be solved in linear time.The algorithmpresentedhere has some similaritieswith the algorithmto solve ELS that can be found inVan Hoesel, Kolen and Wagelmans(1991). This lastalgorithmis based on solving the dual of a completelineardescriptionof the convex hull of feasible solu-tions of formulation II, which was found by Barany,Van Roy and Wolsey (1984). It also worksbackward,but instead of considering the periods one by one itcanbe regardedas only calculatingG(t) for the periodst that are efficient after the last iteration of thealgorithm in Section 2. The algorithm is of thegreedy type and runs in O(n2) time. A nongreedyO(n log n) algorithmto solve the same dual may wellexist.In Van Hoesel (1991), the approach described inSection2 is generalizedand appliedto other lot sizingproblems.For instance, it turns out that the model inwhich backlogging is allowed can be solved inO(n log n) time. (Using the differentapproachesthisresult has also been obtained by Aggarwaland Park1990, and Federgruenand Tzur 1991.)In this paper, we have focused on the theoreticalpropertiesof our algorithm.However,it seems worth-while to study the performance of the algorithm onpracticalproblems.For instance, a proper implemen-tation of the algorithm can be expected to be com-putationally more efficient than the efficient imple-

    EconomicLot Sizing Algorithm / S 155mentation of the Wagner-Whitinalgorithmdescribedin Evans (1985), while requiring less storage. Thealgorithm could also be competitive with variouswidelyused heuristics(see, e.g., Baker 1989), althoughthese may produce solutions that are more attractivefrom other points of view. For limited computationalresults we referto Van Hoesel.ACKNOWLEDGMENTWe thank Karen Aardal, Alexander Rinnooy Kan,Luk Van Wassenhove and LaurenceWolsey for theircomments on an earlierdraft of this paper,and HeinHeuvelmans for his assistance in making the figures.Part of this work was done while the first author wasvisiting the Center for Operations Research andEconometrics (CORE), Louvain-la-Neuve, Belgium.The researchof the second author was supported bythe NetherlandsOrganizationfor Scientific Research(NWO) under grant611-304-017.REFERENCESAGGARWAL,A., AND J. K. PARK. 1990. ImprovedAlgorithms for Economic Lot-Size Problems.WorkingPaper,Laboratoryor ComputerScience,Massachusettsnstituteof Technology, CambridgeMass.BAKER, K. R. 1989.Lot-SizingProcedures nd a Stand-ard Data Set: A Reconciliationof the Literature.

    Report,The Amos Tuck School of BusinessAdmin-istration,DartmouthCollege,Hanover,N.H.BARANY, ., T. J. VAN ROYAND L. A. WOLSEY. 984.UncapacitatedLot-Sizing:The ConvexHullof Solu-tions. Math.Prog.Study22, 32-43.EPPEN,G. D., F. J. GOULDAND B. P. PASHIGIAN.969.Extensionsof the PlanningHorizonTheorem n theDynamic Lot Size Problem. Mgmt. Sci. 15,268-277.EVANS,. R. 1985. An EfficientImplementationof theWagner-WhitinAlgorithm orDynamic Lot-Sizing.J. Opns.Mgmt.5, 229-235.FEDERGRUEN,., ANDM. TZUR.1991. A SimpleFor-wardAlgorithm o SolveGeneralDynamicLot Siz-ing Models With n Periodsin O(nlogn) or O(n)Time.Mgmt.Sci. 37, 909-925.FEDERGRUEN,., ANDM. TZUR.1990. The DynamicLot Sizing Model With Backlogging:A SimpleO(nlog n) Algorithm. Working Paper, GraduateSchool of Business, Columbia University, NewYork.

    KRARUP,J., AND 0. BILDE.1977. Plant Location, SetCovering and Economic Lot Size: An O(mn)-Algorithm for StructuredProblems. NumerischeMethoden bei Optimierungsaufgaben,Band 3:

  • 8/6/2019 Economic Lot Sizing an Algorithm That Runs in Linear Time in the Wagner

    13/13

    S156 / WAGELMANS, HOESELAND KOLENOptimierungbei Graph-Theoretischennd Ganz-zahligen Problemen. Birkhauser Verlag, Basel,Switzerland,155-180.LUNDIN,R. A., AND T. E. MORTON.1975. PlanningHorizonsfor the Dynamic Lot Size Model: Zabelvs. Protective Procedures and ComputationalResults.Opns.Res. 23, 711-734.

    VAN HOESEL, C. P. M. 1991. Algorithms for SingleItem Lot-Sizing Problems. Ph.D. Dissertation,ErasmusUniversity Rotterdam, Rotterdam,TheNetherlands.VAN HOESEL,C. P. M., A. W. J. KOLENAND A. P. M.WAGELMANS.991. A Dual Algorithm for the Eco-

    nomic Lot-SizingProblem.Eur. J. Opnl.Res. 52,315-325.WAGNER,. M. 1960. A Postscript o DynamicProb-lems in the Theoryof the Firm.NavalRes. Logist.Quart.7, 7-12.WAGNER, H. M., AND T. M. WHITIN. 1958. DynamicVersion of the Economic Lot Size Model. Mgmt.

    Sci. 5, 89-96.ZABEL,E. 1964. Some Generalizations of an InventoryPlanning Horizon Theorem. Mgmt. Sci. 10,465-471.ZANGWILL,W. I. 1968. Minimum Concave Cost Flowsin CertainNetworks.Mgmt.Sci. 14, 429-450.