Operation Rechers Network Flow Programming Methods

Embed Size (px)

Citation preview

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    1/12

    Chapter 5 Page 1

    Network Flow Programming Methods

    The focus of this chapter is on the development of algorithms for solving network flowproblems. We begin with a discussion of the most prominent special cases, including thetransportation problem, the shortest path problem, the maximum flow problem and theirvariants, and conclude with a presentation of the primal simplex algorithm for the pureminimum cost flow problem. Although virtually all of the special cases are instances of theminimum cost flow problem, a great deal can be learned by studying them separately. Theindividual algorithms provide insight into different ways of solving problems, and have thebenefit of being extremely efficient. In addition, many applications of the minimum costflow problem embody features of the special cases. From a modeling perspective, it ishelpful to know how these features can be incorporated in broader formulations.

    5.1 Transportation Problem

    The transportation problem is concerned with finding an optimal distribution plan for asingle commodity. A given supply of the commodity is available at a number of sources,there is a specified demand for the commodity at each of a number of destinations, and thetransportation cost between each source-destination pair is known. In the simplest case,the unit transportation cost is constant. The problem is to find the optimal distribution planfor shipments from sources to destinations that minimizes the total transportation cost.

    Matrix Model

    The traditional way to describe a transportation problem is with a matrixor tableau as in Fig. 1. The m sources at which the commodity isavailable are identified by name at the left side of the matrix, and the ndestinations to which the commodity is to be shipped are arrayed alongthe top. The quantities available at the sources are shown as numbers atthe right of the matrix with si the supply at source i. The quantities

    required by the destinations are shown as numbers along the bottomwith the demand dj required at destinationj. The numbers in the body

    of the matrix are the unit costs of shipping from sources to destinationswith cij the cost from source i to destinationj. If it is not possible to

    ship between a given source and destination, a large cost ofMis enteredin the appropriate cell.

    A requirement of most solution algorithms is that total supply

    equal total demand; i.e., isi = jdj. This is known as thefeasibilityproperty. All instances of the traditional transportation problem can be

    modified so that this requirement is satisfied by simply adding either adummy source if demand exceeds supply, or a dummy destination ifsupply exceeds demand.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    2/12

    2 Network Flow Programming Methods

    Destinationsd1 d2 dn Supplies

    s 1 c11 c12 c1n s1

    Sources s 2 c21 c22 c2n s2: : : : :

    sm cm1 cm2 cmn sm

    Demands d 1 d2 dn

    Figure 1. Matrix model of the transportation problem

    A solution to this model is an assignment of flows to the cells ofthe matrix. In general, we callxij the flow in the cell representing ship-

    ments from source s i to destination dj. For a feasible solution, the sum

    of the flows across a row of the matrix must equal the supply at the as-sociated source, and the sum of the flows down a column of the matrixmust equal the demand at the associated destination.

    A numerical example is given in Fig. 2a. The optimal solution isdisplayed in Fig. 2b.

    a. Transportation model b. Optimal solution

    d1 d2 d3 Supply d1 d2 d3 Shipped

    s1 9 12 10 15 s1 0 5 10 15

    s2 8 15 12 15 s2 10 0 5 15

    s3 13 17 19 15 s3 0 15 0 15

    Demand 10 20 15 Received 10 20 15

    Figure 2. Instance of transportation problem in matrix format

    The transportation problem is a linear program so it can be solved usingthe simplex method described in earlier chapters. Because of its specialstructure, however, the simplex method can be considerably simplified.In the following, we assume that total supply equals total demand.

    Example

    Throughout this section we use the example presented in Fig. 3 inmatrix or tableau format. The example has three sources and fivedestinations. The supplies at the sources are shown in the right column

    of the table, and the demands at the destinations are shown along thebottom.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    3/12

    Simplex Method for the Transportation Problem 3

    D1 D2 D3 D4 D5 Supply

    S1 15 15 16 11 115 10 15

    S2 13 11 15 9 60 15 15

    S3 8 12 11 7 80 5 10 15

    Demand 5 10 15 5 10

    Figure 3. Example problem

    A cell is identified for each supply-demand combination, and theunit cost of shipping is the boxed number in the upper left corner of thecell. The bold number in the lower right is the flow assigned to the cell.Because the total supply equals the total demand, the flows in each rowsum to the supply at the corresponding source. The flows in each

    column sum to the demand at the corresponding destination. The flowsshown in Fig. 3 are feasible but not optimal. The goal of this section isto describe an algorithm to find the optimal flow, that is, the flow thatminimizes total cost.

    Theory

    Primal Linear Programming Model

    Letx ij be the flow from source i to destinationj. The transportationproblem has a linear programming model.

    Minimize the total shipping cost:

    MinimizeZ = cijxijj =1

    n

    i =1

    m

    subject to

    (i) the supply at each source must be used:

    j =1

    n

    xij = si for i = 1,...,m. PS(i)

    (ii) the demand at each destination must be met:

    i =1

    m

    xij = dj forj = 1, ...,n. PD(i)

    (iii) nonnegativity:

    xij 0 for i = 1,...,m andj = 1,...,n.

    Although we have an equality constraint for every source anddestination, one of the equality constraints of the model is redundant.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    4/12

    4 Network Flow Programming Methods

    This can be seen by separately adding the m supply constraints and the ndemand constraints and observing from the feasibility property that thetwo sums are equal. Thus them+ n equations are linearly dependent.As we will see, the transportation algorithm exploits this redundancy.

    Basic Solutions

    The primal problem has n + m constraints with one redundantconstraint. A basic solution for this problem is determined by aselection ofn + m - 1 independent variables. The basic variablesassume values to satisfy the supplies and demands, while the nonbasicvariables are zero.

    For the example problem, m = 3 and n = 5, so the number ofbasic variables is 7. Figure 3 shows a basic solution. The flows in theseven basic cells, identified with bold-faced numbers, uniquely satisfythe supplies and demands. The fact that some of the basic flows arezero indicates that this basic solution is degenerate.

    Cells are said to be dependent and do not form a basis if one cantrace a closed path through the cells in the tableau. The path consists of

    a series of horizontal and vertical moves turning only at the selectedcells. Figure 4 depicts a selection of dependent cells and the closed paththat connects them.

    D1 D2 D3 D4 D5 Supply

    S1 15 15 16 11 11n n 15

    S2 13 11 15 9 6 n n 15

    S3 8 12 11 7 8 n n 15

    Demand 5 10 15 5 10

    Figure 4. Dependent cells

    A basis is any collection ofn + m 1 cells that does not includea dependent subset. The basic solution is the assignment of flows to thebasic cells that satisfies the supply and demand constraints. The solu-tion is feasible if all the flows are nonnegative. From the theory of lin-ear programming we know that there is an optimal solution that is abasic feasible solution.

    Dual Linear Programming Model

    The dual of the primal linear programming model has a dual variable foreach constraint of the primal.

    Let ui be the dual variable corresponding to the constraint PS(i).

    Let vj be the dual variable corresponding to the constraint PD(j).

    Then using the procedures of Section 4.4, the dual problem isconstructed as below.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    5/12

    Simplex Method for the Transportation Problem 5

    Maximizey0 = i =1

    m

    siui + j =1

    n

    djvj .

    subject toui + vj cij for i = 1,...,m , j = 1,...,n. D(i, j)

    The values ofui and vj are unrestricted in sign for all i andj.

    Conditions for Optimality

    From duality theory we know that a complementary pair of primal anddual feasible solutions are optimal to their respective problems. Tosimplify our discussion, define the slack variable for the general dualconstraint to be w ij, where

    w ij = cij ui vj. (1)

    The complementary slackness property states that for every basic primalvariable the corresponding dual constraint must be satisfied as an

    equality; i.e.,

    ui + vj = cij or w ij = 0 for every basic variablexij (2)

    Because of the redundant primal constraint, one of the dual variables canbe arbitrarily set to zero. The others can be determined with Eq. (2).

    By construction we assure that the primal solution is feasible. Ifall the dual constraints are satisfied for the dual solution, both the primaland dual solutions are optimal. The condition for dual feasibility is asfollows:

    ui + vj cij or w ij 0 for all nonbasic cells (3)

    This result is the foundation for the solution algorithm described below.

    In numerical examples, we use the graphical construction of Fig.5 to show the dual variables and the corresponding dual slack variables.The dual variables ui are shown along the right margin and the variables

    vj are shown along the bottom. The dual slacks are shown in the

    nonbasic cells in the upper right corner. These values are zero for thebasic cells and are not shown.

    D1 D2 D3 D4 D5 Supply ui

    S1 15 15 16 3 11 -4 11 -5 85 10 15

    S2 13 2 11 15 9 -2 6 -6 4

    0 15 15S3 8 1 12 5 11 7 8 0

    0 5 10 15

    Demand

    5 10 15 5 10

    vj 7 7 11 7 8

    Figure 5. Dual variables shown on the matrix

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    6/12

    6 Network Flow Programming Methods

    The tableau is constructed for any basic solution by arbitrarilyassigning zero to one of the ui or vj variables. In the examples, wealways assign the zero value to the row or column with the mostbasiccells. This simplifies the process of determining the other dual values.Given the basic cells, it is a simple matter to compute the values of the

    remaining n + m 1 dual variables. This is done by solving the n + m 1 simultaneous equations given by Eq. (2) using back substitution.Note that there is no requirement that ui or vj be nonnegative. Once thedual variables are determined, the values ofw ij for the nonbasic cells arecomputed using Eq. (1).

    Figure 5 shows the complete tableau that we use fortransportation problems. Given the basic cells, there is a uniqueassignment of flows to satisfy the supplies and demands. Once one ofthe dual variables is assigned arbitrarily to zero, the others are uniquelydetermined. The value ofw ij is, in fact, the marginal benefit ofallowingxij to enter the basis. Evidently the basis picked for Fig. 5 isnot optimal because some of the w ij are negative. The value ofw25= -6indicates that the objective value will be reduced by 6 for every unit

    increase inx25. The primal simplex algorithm proceeds by allowingx25to enter the basis as described presently.

    The Simplex Algorithm

    Step 1.Construct the initial tableau.

    Prepare the initial tableau showing problem parameters. Startwith some selection of independent basic cells for which theprimal solution is feasible. Determine the unique values of thebasic variables (cell flows) for this basis and place them in thecells.

    Step 2.Compute the dual variables for the current basis and check for optimality.

    a. Assign the value of zero for the dual variable of the row orcolumn with the most basic cells. Determine the values of theothers so that the complementary slackness condition (w ij = 0

    for basic cells) is satisfied. Place these values at the boundariesof the tableau.

    b. For each nonbasic cell compute the dual slack variable w ijand place it in the body of the cell.

    c. If all the values ofw ij are nonnegative, stop with the optimal

    solution; otherwise go to Step 3.

    Step 3.Change the basis

    a. (Find the cell to enter the basis) Select the entering cell asthe one with the most negative value ofw ij.

    b. (Find the cell to leave the basis) . Construct the cycle thatstarts with the entering cell, passes through only basic cells, and

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    7/12

    Simplex Method for the Transportation Problem 7

    returns to the entering cell. Show the cycle in the tableau as asequence of alternating vertical and horizontal lines connectingpairs of cells on the cycle. Mark the entering cell with a plus(+). Mark the first basic cell on the cycle with a minus ().Alternately mark each basic cell on the cycle with (+) or () untilthe entering cell is reached. Find the basic cell marked with a

    minus having the smallest value of flow. This is the cell that isto leave the basis. If there is a tie, select any one of the tied cellsarbitrarily. Let be the value of the basic variable for theleaving cell.

    c. (Change the basic solution) . For every cycle cell markedwith a plus, increase the basic variable by . For every cyclecell marked with a minus, decrease the basic variable by .Remove the leaving cell from the basis. Add the entering cell tothe basis with flow equal to .

    d. Return to Step 2.

    Solution to the Example Problem

    We illustrate how the algorithm works with the example problemstarting from the basic solution shown in Fig. 5. A step of thealgorithm is completely described with a tableau similar to that shown inFig. 6. The basic cells are identified by the cells with the flow indicatedin the lower right. The dual slack variables are computed for thenonbasic cells and shown in the upper right. A cell with a negative w ijis selected to enter the basis as indicated by a + sign. We find theunique cycle formed by this cell and some of the cells of the currentbasis. The small arrows indicate the cells on the cycle. The signs withthe arrows indicate the direction in which the basic flows will change.

    Note that the signs alternate in the cells of the cycle. Figure 6 showsthese steps for the first iteration of the algorithm.

    D1 D2 D3 D4 D5 Supply ui

    S1 15 15 16 3 11 -4 11 -5 85 10 15

    S2 13 2 11 15 9 -2 6 -6 40 15 + 15

    S3 8 1 12 5 11 7 8 0 + 0 5 10 15

    Demand 5 10 15 5 10

    vj 7 7 11 7 8

    Figure 6. First iteration for example;

    x25enters the basis andx35 leaves with = 10The cells that have negative signs determine the maximum flow

    change in the cycle and hence the variable to leave the basis. In the ex-ample, cells (2, 3) and (3, 5) experience a decrease in flow. The

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    8/12

    8 Network Flow Programming Methods

    minimum flow in these two cells determines the flow change, = 10.The basis change will have cell (2, 5) entering the basis and cell (3, 5)leaving. Figure 7 shows the tableau of the second iteration.

    D1 D2 D3 D4 D5 Supply ui

    S1 15 15 16 3 11 -4 11 1 45 10 + 15

    S2 13 2 11 15 9 -2 6 0 + 0 5 10 15

    S3 8 1 12 5 11 7 8 6 4 + 10 5 15

    Demand 5 10 15 5 10

    vj 11 11 15 11 6

    Figure 7. Second iteration for example;

    x14enters the basis andx23 leaves with = 5The second iteration selects cell (1, 4) to enter the basis. The

    cycle formed is shown by the arrows, with the direction of flow changeindicated by the signs of the cycle cells. The minimum flow in the cellscontaining negative signs is the value of the flow change, = 5. Bothcells (2, 3) and (3, 4) have this value, and we select (2, 3) arbitrarily.Because of the tie for the leaving variable, the flowx34will be zero inthe next tableau, a degenerate solution.

    The remaining iterations are shown in Figs. 8 10. All thevalues ofw ij are nonnegative in the final figure, indicating that the

    optimum has been found.

    D1 D2 D3 D4 D5 Supply ui

    S1 15 15 16 1 11 11 1 0 5 5 + 5 15

    S2 13 2 11 15 4 9 2 6 45 10 15

    S3 8 -3 12 1 11 7 8 2 4 + 15 0 15

    Demand 5 10 15 5 10

    vj 15 15 15 11 10

    Figure 8. Third iteration;x31enters the basis andx34 leaves with = 0

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    9/12

    Simplex Method for the Transportation Problem 9

    D1 D2 D3 D4 D5 Supply ui

    S1 15 15 16 -2 11 11 1 0 5 5 + 5 15

    S2 13 2 11 15 1 9 2 6 45 10 15

    S3 8 12 4 11 7 3 8 5 7 + 0 15 15

    Demand 5 10 15 5 10

    vj 15 15 18 11 10

    Figure 9. Fourth iteration;x13enters the basis andx11 leaves with = 5

    D1 D2 D3 D4 D5 Supply ui

    S1 15 2 15 16 11 11 1 0

    5 5 5 15S2 13 4 11 15 3 9 2 6 4

    5 10 15

    S3 8 12 2 11 7 1 8 3 55 10 15

    Demand 5 10 15 5 10

    vj 13 15 16 11 10

    Figure 10. Optimal solution

    Finding an Initial Basic Feasible Solution

    Algorithm

    The simplex algorithm starts from any feasible basic solution. Whenfirst encountering a problem, though, some procedure must be used tofind this solution. A general algorithm follows based on the process ofcrossing out rows and columns until all the supply is exhausted and allthe demand is met. Once again, we assume that the feasibility propertyholds.

    Initialization Step Draw a tableau showing all problem parameters.None of the rows or columns is crossed out.

    Iterative Step According to some criterion, select a cell that has notbeen crossed out. Let that cell be basic. Assign a value to the basicvariable for the cell that will use up either the remaining supply in therow or the remaining demand in the column (i.e., pick the smaller of thetwo). Reduce the remaining supply for the row and the remainingdemand for the column by the amount assigned. Cross out the row orcolumn whose supply or demand goes to zero. If both go to zero, crossout only one.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    10/12

    10 Network Flow Programming Methods

    Stopping Rule If only one row or column remains, let all the cells notyet crossed out be basic and assign them all the remaining supply ordemand. Stop with a basic solution defined by the selected cells. Ifmore than one row and more than one column remain, go to iterativestep.

    There are alternative possibilities for the selection rule in theiterative step. They differ with respect to the work required to carrythem out and the quality of the initial solution they generate. Generally,methods requiring greater effort will yield better solutions. For handcalculations the effort may be justified. For computer implementations itis often true that the simpler methods are more effective because theiterative step of the transportation simplex algorithm is so efficient.Several alternatives are described below.

    Northwest Corner Rule

    The upper left-hand corner of the tableau is called the northwest corner.The rule is to select the uncrossed cell closest to the northwest corner.

    This is the simplest rule to apply. The initial solution used in the exam-ple, as seen in Figs. 5 and 6, was obtained by the northwest corner rule.

    Vogel's Method

    This method looks ahead one step and constructs a penalty for not beingable to assign a flow to the remaining cells in a row or column whosecost is smallest, but instead having to pick the cell with the secondsmallest cost. In economic terms, the idea is to determine theopportunity cost associated with each possible assignment and then pickthe cell with the greatest opportunity cost. To begin, compute for eachuncrossed row the difference between the smallest cost in the row andthe second smallest cost. Do the same for uncrossed columns. Select

    the row or column with the greatest of the differences. The rule is tochoose the uncrossed cell in the selected row or column with thesmallest cost.

    When done by hand, Vogel's method is usually performed di-rectly on the tableau. The selection of basic variables in each iteration isaccompanied by the crossing out of a row or column and the re-computation of differences as well as supplies and demands. Thetableau becomes so messy, however, that we suggest using the formatshown in Table 1 together with the transportation matrix. Each row ofthe table lists the row and column differences, the basic variableassigned, the adjustment of demands and supplies, and the row orcolumn crossed out. Vogel's method on the example problem yields theoptimal solution shown in Fig. 10 without additional iterations.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    11/12

    Simplex Method for the Transportation Problem 11

    Table 1. Format for Vogel computations

    Iterationno.

    Rowdifferences

    Columndifferences

    Basicvariable Action

    1 2 3 1 2 3 4 5

    1 0 3 1 5 1 4 2 2 x31

    = 5 d1

    = 0, s3

    = 10

    Cross out column 12 0 3 1 1 4 2 2 x33 = 10 d3 = 5, s3 = 0

    Cross out row 33 0 3 4 1 2 5 x25 = 10 d5 = 0, s2 = 5

    Cross out column 54 4 2 4 1 2 x14 = 5 d4 = 0, s1 = 10

    Cross out column 45 1 4 4 1 x 22 = 5 d2 = 5, s2 = 0

    Cross out row 26 Only row 1 remains x12= 5 d2 = 0, s1 = 5

    7 Only row 1 remains x13= 5 d3 = 0, s1 = 0

    Russell's Method

    This method makes use of the reduced costs associated with cells not yetassigned. At each iteration, compute for the uncrossed rows andcolumns

    ui = value of the largest uncrossed cost in row i.

    vj = value of the largest uncrossed cost in columnj

    For each uncrossed cell compute

    w ij = cij ui vj.

    The rule is to choose the uncrossed cell with the largest negative valueofw ij.

    Illustrating Russell's method for the example problem we obtainthe results in Table 2. As can be seen, the basic feasible solutionidentified by this method is also optimal.

  • 8/9/2019 Operation Rechers Network Flow Programming Methods

    12/12

    12 Network Flow Programming Methods

    Table 2. Computations for Russells method

    Iterationno.

    Rows(ui) Columns (vj) Basicvariable Action

    1 2 3 1 2 3 4 5

    1 16 15 12 15 15 16 11 11 x25= 10 d5 = 0, s2 = 5

    Cross out column 52 16 15 12 15 15 16 11 x22= 5 d2 = 5, s2 = 0

    Cross out row 23 16 12 15 15 16 11 x31= 5 d1 = 0, s3 = 10

    Cross out column 14 16 12 15 16 11 x33= 10 d3 = 5, s3 = 0

    Cross out row 35 Only row 1 remains x12= 5 d2 = 0, s1 = 10

    6 Only row 1 remains x13= 5 d3 = 0, s1 = 5

    7 Only row 1 remains x14= 5 d4 = 0, s1 = 0