0% found this document useful (0 votes)
13 views31 pages

Supp 05

The document describes algorithms for solving network models, focusing on the transportation problem. It presents the transportation algorithm, which is a two-part method for finding the optimal solution. First, an initial basic feasible solution is found using a starting procedure, then subsequent solutions are generated until optimality. The northwest corner rule is provided as an example of an efficient starting procedure.

Uploaded by

odd elzainy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views31 pages

Supp 05

The document describes algorithms for solving network models, focusing on the transportation problem. It presents the transportation algorithm, which is a two-part method for finding the optimal solution. First, an initial basic feasible solution is found using a starting procedure, then subsequent solutions are generated until optimality. The northwest corner rule is provided as an example of an efficient starting procedure.

Uploaded by

odd elzainy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Supplement CD5

Algorithms for
Network Models

I N C HAPTER 4 WE presented mathematical models


that can be represented by networks. These include
the transportation, capacitated transshipment, assign-
programming techniques, because of their special net-
work structure, more efficient input and solution proce-
dures are available. Here we present an overview of the
ment, traveling salesman, shortest path, minimal span- algorithms used in many general-purpose management
ning tree, and maximum flow models. We pointed out science solution modules to determine the optimal solu-
that, although each of these models can be formulated tion to these network models.
as a linear program and solved using standard linear

I The Transportation Problem—


The Transportation Algorithm
In Section 4.2 of the text, the basic transportation model for finding the minimum
total shipping cost of a particular item from m sources, each with a different supply,
to n destinations, each with a particular demand was introduced. Here a two-part
method is presented for solving such problems. First, an initial basic feasible solution
is found using a particular “starting procedure”; then subsequent basic feasible solu-
tions are generated using the transportation algorithm until an optimal solution is
found. This algorithm is actually a compact version of the simplex method (discussed
in Supplement CD3) which uses a simplified procedure for selecting the entering and
leaving basic variables and generating new tableaus. Although knowledge of the sim-
plex method is useful for understanding the “whys” of the transportation algorithm,
the steps of the procedure can be performed without this background.
To use the transportation algorithm, the total supply must equal total de-
mand. If total supply exceeds total demand, a dummy destination, whose demand
equals the difference between the total supply and total demand is created. Simi-
larly if total supply is less than total demand, a dummy source is created, whose sup-
ply equals the difference. All unit shipping costs into a dummy destination or out
of a dummy source are 0.
To illustrate the transportation procedure, consider the following problem
which includes unit shipping costs (Cij), supplies (Si, and demands (Dj); the total
supply  total demand  40.

DESTINATIONS Supply

D1 D2 D3 D4

S1 50 75 30 45 12
Sources S2 65 80 40 60 17
S3 40 70 50 55 11
Demand 10 10 10 10

CD-283
CD-284 SUPPLEMENT CD5 Algorithms for Network Models

THE TRANSPORTATION TABLEAU


The decision variables of a transportation problem, Xij, represent the amount
shipped from source i to destination j. These shipments are indicated in a tableau;
the rows represent the sources, and the columns represent the destinations. As
shown in Figure CD5.1, each variable in a transportation tableau is represented by
a box. In the upper right corner of the box, the variable’s unit shipping cost is listed.

D1 D2 D3 D4 Supply
50 75 30 45
S1 12

S2 65 80 40 60 17

S3 40 70 50 55 11

Demand 10 10 10 10 Unit
Shipment will Shipping
be placed here Cost FIGURE CD5.1
The Transportation Tableau

In the simplex method, a variable is either nonbasic (i.e., it is assigned a 0


value) or basic, in which case it can have a positive value. Only nonbasic variables
can have nonzero net marginal cost values, while the net marginal cost values for
all basic variables are 0. For those who have studied the simplex method in Supple-
ment CD3, the net marginal costs were referred to as CJ –ZJ values. Since the deci-
sion variables for this problem are denoted by double subscripts, i and j, their
CJ–ZJ values are expressed as Cij–Zij. Thus, for each variable in a transportation
problem, one need only to keep track of its Cij–Zij value if it is a nonbasic variable
(since Xij  0), or its value Xij, if it is a basic variable (since Cij–Zij  0).
For a problem with m sources and n destinations, there are m  n  1 basic
variables. Thus the above problem will have 3  4  1  6 basic variables.

STARTING SOLUTION PROCEDURES


If this problem is solved using the standard simplex technique, artificial variables
would have to be added to all constraints, thus requiring many iterations (at least six,
in this case) before obtaining the first basic feasible solution. The structure of the
transportation constraint coefficients, however, allows one to obtain an initial basic
feasible solution using one of several special starting procedures for transportation
problems. Here three of the more popular procedures are illustrated.

Northwest Corner Starting Solution


The Northwest Corner method is a quick and efficient starting solution procedure
that is easy to implement. It works as follows:

Northwest Corner Starting Procedure

1. Select the remaining variable in the upper left (northwest) corner and note the
supply remaining in the row, s, and the demand remaining in the column, d.
2. Allocate the minimum of s or d to this variable. If this minimum is s, eliminate all
variables in its row from future consideration and reduce the demand in its
column by s; if the minimum is d, eliminate all variables in the column from
future consideration and reduce the supply in its row by d.
REPEAT THESE STEPS UNTIL ALL SUPPLIES HAVE BEEN ALLOCATED.
I The Transportation Problem—The Transportation Algorithm CD-285

For this problem, the sequence of steps for the Northwest Corner starting proce-
dure is as follows:

Remaining Remaining
Supply in Demand in
Northwest the Row the Column
Corner (s) (d) Allocate Modifications

1. X11 12 10 X11  10 Eliminate column 1;


reduce row 1 supply to
12  10  2
2. X12 2 10 X12  2 Eliminate row 1; reduce
column 2 demand to
10  2  8
3. X22 17 8 X22  8 Eliminate column 2;
reduce row 2 supply to
17  8  9
4. X23 9 10 X23  9 Eliminate row 2; reduce
column 3 demand to
10  9  1

After the fourth step, only row 3 is left with a remaining supply of 11. Since the re-
maining demand is now 1 for column 3 and 10 for column 4, the allocations X33 
1, and X34  10 are made. These results are given by the transportation tableau in
Figure CD5.2. While the northwest corner procedure is quick and easy to imple-
ment, unfortunately, it ignores costs altogether and frequently results in a starting
solution that is not very close to the optimal solution.

D1 D2 D3 D4 Supply
S1 50 75 30 45
12
10 2
S2 65 80 40 60 17
8 9
S3 40 70 50 55 11
1 10
Demand 10 10 10 10
FIGURE CD5.2
Northwest Corner Starting Solution

Least Cost Starting Solution


Like the Northwest Corner method, the least cost starting procedure is also easy. It
does, however, take costs into account as follows:

Least Cost Starting Procedure


1. For the remaining variable with the lowest unit cost, determine the remaining
supply left in its row, s, and the remaining demand left in its column, d (break
ties arbitrarily).
2. Allocate the minimum of s or d to this variable. If this minimum is s, eliminate all
variables in its row from future consideration and reduce the demand in its
column by s; if the minimum is d, eliminate all variables in the column from
future consideration and reduce the supply in its row by d.
REPEAT THESE STEPS UNTIL ALL SUPPLIES HAVE BEEN ALLOCATED.
CD-286 SUPPLEMENT CD5 Algorithms for Network Models

For this problem, the sequence of steps for the least cost starting procedure is
as follows:

Remaining Remaining
Supply in Demand in
Least Cost the Row the Column
Cell (s) (d) Allocate Modifications
1. X13 12 10 X13  10 Eliminate column 3;
Cost  30 reduce row 1 supply to
12  10  2
2. X31 11 10 X31  10 Eliminate column 1;
Cost  40 reduce row 3 supply to
11  10  1
3. X14 2 10 X14  2 Eliminate row 1; reduce
Cost  45 column 4 demand to
10  2  8
4. X34 1 8 X34  1 Eliminate row 3; reduce
Cost  55 column 4 demand to
817

Since only row 2 is left with a remaining supply of 17 and the remaining demand
for the only remaining columns is now 10 for column 2 and 7 for column 4, the
final allocations are X22  10 and X24  7. This results in the transportation
tableau shown in Figure CD5.3.

D1 D2 D3 D4 Supply
S1 50 75 30 45
12
10 2
S2 65 80 40 60 17
10 7
S3 40 70 50 55 11
10 1
Demand 10 10 10 10
FIGURE CD5.3
Least Cost Starting Solution
The major problem with the least cost approach is that, after initially allocat-
ing to one or two low-cost routes, the last few allocations may be to very high-cost
routes; that is, the method does not take into account relative costs. Note, for ex-
ample, that, in least cost allocation for our sample problem, X22  10; that is, 10
units are shipped to the most costly cell (with a unit cost of $80).
Vogel’s Approximation Method (VAM)
Vogel’s Approximation Method (VAM) introduces the concept of relative costs into
the starting method. It requires more start-up calculations, but, once a starting so-
lution is reached using this method, the optimal solution is typically attained more
quickly than in the previous two methods. The VAM method proceeds as follows:

Vogel’s Approximation Method Starting Procedure


1. For each remaining row and column, determine the difference between the
lowest two remaining costs; these are called the row and column penalties.
2. Select the row or column with the largest penalty found in step 1 and note the
supply remaining for its row, s, and the demand remaining in its column, d.
3. Allocate the minimum of s or d to the variable in the selected row or column with
the lowest remaining unit cost. If this minimum is s, eliminate all variables in its
row from future consideration and reduce the demand in its column by s; if the
minimum is d, eliminate all variables in the column from future consideration
and reduce the supply in its row by d.
REPEAT THESE STEPS UNTIL ALL SUPPLIES HAVE BEEN ALLOCATED.
I The Transportation Problem—The Transportation Algorithm CD-287

Applying the Vogel Approximation Method to the above problem results in the
following iterations:

Iteration 1: Row Penalties: (1) 45  30  15


(2) 60  40  20  largest
(3) 50  40  10
Column Penalties: (1) 50  40  10
(2) 75  70  5
(3) 40  30  10
(4) 55  45  10

Since row 2 has the largest penalty, as many items as possible are allocated to the
cell with the lowest cost of 40 (column 3). Since the supply in row 2 is 17 and the
demand in column 3 is 10, X23 is set equal to 10, reducing the supply for row 2 to
17  10  7, and eliminating column 3 from future consideration.

Iteration 2: Eliminating column 3 has no effect on the remaining column


penalties but the row penalties must be recalculated:
New Row Penalties: (1) 50  45  5
(2) 65  60  5
(3) 55  40  15

The largest of these and the three remaining column penalties is the 15 for row
3. One then allocates as much supply as possible to the least cost remaining in
row 3; that is, to X31 (unit cost  40). Since the remaining supply in row 3 is 11
and the remaining demand in column 1 is 10, X31 is set equal to 10, reducing
the supply for row 3 to 11  10  1, and eliminating column 1 from future
consideration.

Iteration 3: Eliminating column 1 has no effect on the remaining column


penalties, but it does affect the row penalties:
New Row Penalties: (1) 75  45  30
(2) 80  60  20
(3) 70  55  15

The maximum of these and the two remaining column penalties (5 for column 2
and 10 for column 4) is the 30 for row 1. Now one allocates as much as possible to
the least cost remaining in row 1—that is, X14 (unit cost  45). Since the remaining
supply in row 1 is 12 and the remaining demand column 4 is 10, X14 is set equal to
10, reducing the supply for row 1 to 12  10  2, and eliminating column 4.
Now since there is only one column left, column 2, with a remaining demand
of 10, and the remaining supplies at rows 1, 2, and 3 are 2, 7, and 1, respectively,
set X12  2, X22  7, X23  1. The resulting basic feasible solution is shown in Fig-
ure CD5.4.

D1 D2 D3 D4 Supply
S1 50 75 30 45
12
2 10
S2 65 80 40 60 17
7 10
S3 40 70 50 55 11
10 1
Demand 10 10 10 10

FIGURE CD5.4 Vogel Approximation Method (VAM), Starting Solution


CD-288 SUPPLEMENT CD5 Algorithms for Network Models

SOLVING FOR THE OPTIMAL SOLUTION—


TRANSPORTATION SIMPLEX METHOD
Once a starting basic feasible solution has been determined, a compact form of
the simplex method can be used to move to an optimal solution. Since the basic
transportation problem is a minimization problem, the simplex method proceeds
as follows:

1. Find the current Cij–Zij values for each nonbasic variable and select the one
with the most negative Cij–Zij value as the entering variable; if all Cij–Zij
values are nonnegative, the current solution is optimal.
2. Determine which basic variable reaches 0 first when the entering variable is
increased.
3. Determine a new basic solution and repeat the steps.

To illustrate how the transportation simplex method performs these steps suppose
the tableau generated by the VAM starting procedure in Figure CD5.4 is used as
the starting tableau.

Step 1: Determine the C ij –Z ij Values


for the Nonbasic Variables
A method based on duality in linear programming (see Supplement CD2), known
as the modified distribution approach (MODI) is used, to determine the mar-
ginal costs for the nonbasic variables. This method assumes that, if necessary, a
dummy destination or a dummy source has been added so that total supply equals
total demand. If that is the case, m supply constraints and all n demand constraints
can be written as equalities. The approach, which is actually quite simple to imple-
ment, is developed using the following arguments.

1. If Ui is the dual variable associated with the i-th supply constraint, and
Vj is the dual variable associated with the j-th demand constraint, then
for shipments from node i to node j, one can find the corresponding
Zij value by Zij  Ui  Vj. Thus the Cij–Zij value for variable Xij is
found by

Cij  Zij  Cij  (Ui  Vj)  Cij  Ui  Vj

2. Given that there is a redundant equation among the m  n constraints


(and any of the m  n constraints can be considered the redundant one),
one can show that the Ui or Vj associated with the redundant equation
is 0. Thus one Ui or Vj can arbitrarily be selected and set to 0. Arbitrarily
choose U1  0.
3. Since the Cij–Zij values for basic variables are 0 (i.e., Cij  Ui  Vj  0 for
basic variables), we can easily solve for the remaining values of the Ui’s
and Vj’s from the m  n  1 equations for the basic variables.
4. Once the Ui’s and Vj’s have been determined, the Cij–Zij values for the
nonbasic variables can be calculated by

Cij  Zij  Cij  Ui  Vj

From Figure CD5.4 the basic variables are in cells X12, X14, X22, X23, X31, and X32.
By setting U1  0, the remaining Ui’s and Vj’s are determined as follows:
I The Transportation Problem—The Transportation Algorithm CD-289

Basic Cell Basic Cij–Zij Values  0 Substitute Implies

X12 C12  U1  V2  0 75  0  V2  0 V2  75


X14 C14  U1  V4  0 45  0  V4  0 V4  45
X22 C22  U2  V2  0 80  U2  (75)  0 U2  5
X23 C23  U2  V3  0 40  5  V3  0 V3  35
X32 C32  U3  V2  0 70  U3  (75)  0 U3   5
X31 C31  U3  V1  0 40  (5)  V1  0 V1  45

The Cij–Zij values for the nonbasic variable cells are then calculated as follows:

Variable Cell Cij–Zij Calculation

X11 C11  U1  V1  50  0  45  5
X13 C13  U1  V3  30  0  35  5
X21 C21  U2  V1  65  5  45  15
X24 C24  U2  V4  60  5  45  10
X33 C33  U3  V3  50 (5)  35  20
X34 C34  U3  V4  55 (5)  45  15

The most negative Cij–Zij value is 5, which is associated with the nonbasic vari-
able, X13; thus X13 is selected as the entering variable.

Step 2: Determine Which Current Basic Variable


Reaches 0 First
A negative Cij–Zij value for a nonbasic variable cell implies that a reduction in the
value of the objective function is possible for every unit shipped from the cell’s
source to the cell’s destination. To obtain this cost savings the values of some of
the other basic variables must be altered. The property for determining how much
the entering variable can increase is called the cycle property. It states that, for every
nonbasic variable, there is a unique cycle that joins this cell and the cells of some
(not necessarily all) of the other basic variables using only horizontal and vertical
lines on the transportation tableau.
By alternately modifying the variables in this cycle (an addition to one cell in
the cycle is followed by a subtraction from the next cell in the cycle), the conserva-
tion of supply and demand can be preserved. For small problems, such as this exam-
ple, it is easy to determine the cycle by trial and error. For example, in step 1 it was
determined that increasing the allocation to X13 will save $5 per unit. Figure CD5.5
indicates that a cycle that contains X13 and the subset of the basic variables is con-
sisting of X23, X22, and X12 will be affected by increasing X13.

D1
D2 D3 D4 Supply
5075  30 45
S1 12
2 10
S2 65  80  40 60 17
7 10
S3 40 70 50 55 11 FIGURE CD5.5
10 1 Determining the Cycle of the
Demand 10 10 10 10
Entering Variable with the
Basic Variables

Now if one unit is added to X13, a unit must be subracted from X23 (leaving 9),
added to X22 (giving 8), and subtracted from X12 (leaving 1). This will save $5. If
two units are added to X13, two must be subtracted from X23 (leaving 8), added to
X22 (giving 9), and subtracted from X12 (leaving 0). This will save 2($5)  $10.
CD-290 SUPPLEMENT CD5 Algorithms for Network Models

Since X12 has now reached 0, no further reduction is possible for this variable;
2 is the most that presently can be allocated to X13. Note that this is the minimum
amount on the cycle where a subtraction is to be made.

Step 3: Determine the Next Transportation Tableau


The transition to the next tableau is very simple. The variables along the cycle are
changed by the amount determined in Step 2 (in this case, 2). The entering vari-
able (X13) now becomes a new basic variable with a value of 2; X23 will now be
10  2  8, and X22 will be 7  2  9. X12, the basic variable that goes to 0, be-
comes a new nonbasic variable (at zero value). The result is shown in Figure
CD5.6. This three-step process is then repeated.

D1 D2 D3 D4 Supply
50 75 30 45
S1 12
2 10
S2 65 80 40 60 17
9 8
S3 40 70 50 55 11
10 1 FIGURE CD5.6
Demand 10 10 10 10
The Transportation Tableau
for Iteration 2

The steps of this method are summarized as follows:

Transportation Simplex Method


Find an initial basic feasible solution by some starting procedure. Then,
1. Set U1  0. Solve for the other Ui’s and Vj’s by:
Cij  Ui  Vj  0 for basic variables.
Then calculate the Cij–Zij values for nonbasic variables by:
Cij  Zij  Cij  Ui  Vj
Choose the nonbasic variable with the most negative Cij–Zij value as the entering
variable. If all Cij–Zij values are nonnegative, STOP; the current solution is
optimal.
2. Find the cycle that includes the entering variable and some of the BASIC
variables. Alternating positive and negative changes on the cycle, determine the
“change amount” as the smallest allocation on the cycle at which a subtraction
will be made.
3. Modify the allocations to the variables of the cycle found in step 2 by the
“change amount” and return to step 1.

Continuing with the next iteration of the algorithm on the tableau shown in
Figure CD5.6, after Step 1 setting U1  0, the other Ui’s and Vj’s are determined
as follows.

Basic Cell Basic Cij–Zij Values  0 Substitute Implies

X13 C13  U1  V3  0 30  0  V3  0 V3  30


X14 C14  U1  V4  0 45  0  V4  0 V4  45
X23 C23  U2  V3  0 40  U2  (30)  0 U2  10
X22 C22  U2  V2  0 80  10  V2  0 V2  70
X32 C32  U3  V2  0 70  U3  (70)  0 U3  0
X31 C31  U3  V1  0 40  0  V1  0 V1  40
II The Capacitated Transshipment Problem—The Out-of-Kilter Algorithm CD-291

The Cij–Zij values for the nonbasic variables are now:

Variable Cell Cij–Zij Calculation

X11 C11  U1  V1  50  0  40  10
X12 C12  U1  V2  75  0  70  5
X21 C21  U2  V1  65  10  40  15
X24 C24  U2  V4  60  10  45  5
X33 C33  U3  V3  50  0  30  20
X34 C34  U3  V4  55  0  45  10

Since all the Cij–Zij values are now nonnegative, the solution shown in Figure
CD5.6 is optimal. This solution is summarized as follows:

Unit Transportation
From To Amount Cost Cost

S1 D3 2 $30 $ 60
S1 D4 10 $45 $ 450
S2 D2 9 $80 $ 720
S2 D3 8 $40 $ 320
S3 D1 10 $40 $ 400
S3 D2 1 $70 $ 70
Total  $2020

A NOTE ON TIES IN THE PROCESS: DEGENERACY


When performing a starting procedure, it can happen that a supply is depleted and
a demand is satisfied simultaneously; thus one could eliminate both a row and a
column at the same time. This would mean that fewer than m  n  1 basic vari-
ables remain. This is called degeneracy. But there must be m  n  1 basic vari-
ables for the transportation simplex method to work!
When degeneracy occurs, arbitrarily select variables to be basic variables at 0
value until there are m  n  1 basic variables. The only restriction on the choice
of variables to be made basic is that, when these variables are collectively included
with the other basic variables, they must not form any cycles with any subset of the
other basic variables. (Recall that cycles are formed in a transportation tableau by
connecting cells using only horizontal and vertical lines.)
Degeneracy also occurs when there is a tie for the leaving variable (two or more
variables reach 0 at the same time) in step 2 of the algorithm. In this case, select only
one of these variables to be nonbasic; the others remain basic but at 0 value.

II T h e C a p a c i t a t e d T r a n s s h i p m e n t P r o b l e m —
The Out-of-Kilter Algorithm
Another streamlined form of the simplex method, the out-of-kilter algorithm,
can be used to solve a network problem with sources, destinations, intermediate
nodes, unit shipping costs, and maximum capacities between nodes. Shipments
may or may not be allowed between supply nodes or between demand nodes.1 In
the most general case, the one illustrated here, such shipments are possible.

1
The most general form of this problem allows for lower bounds on the arcs other than 0. For
simplicity, assume that all arcs have a minimum capacity of 0.
CD-292 SUPPLEMENT CD5 Algorithms for Network Models

The concepts behind this algorithm follow those of the transportation prob-
lem. Once a basic feasible solution has been found, the Cij–Zij values for the flow
along each nonbasic shipping route that is not currently being used are calculated
to see if increasing flow along the arc will reduce the overall total cost. Increasing
the flow along an arc with a negative Cij–Zij value reduces the total cost.
The new wrinkle in this problem is that arcs with flows at their upper bound
are also considered nonbasic. The Cij–Zij values for these arcs are also calculated to
see if a reduction in the flow on these arcs can possibly save money. Decreasing the
flow along an arc with a positive Cij–Zij value reduces the total cost.
If increasing the flow along an arc that is not being used or reducing the flow
along an arc used to capacity results in cost savings, the system is said to be out of
kilter. The out-of-kilter algorithm uses a simple technique for calculating the
Cij–Zij values for nonbasic arcs. Once those values are calculated, if it is deter-
mined that a modification to the flow will improve the objective function value,
the algorithm provides a way to make this change quite easily. The Cij–Zij values
for the new solution are then recalculated and the process is repeated.
The out-of-kilter method assumes that the total supply at the supply nodes
equals the total demand at the demand nodes. If not, a dummy supply node with
zero-cost arcs from the dummy node to all demand nodes, or a dummy demand
node with zero-cost arcs from all supply nodes to the dummy node is created to
balance the problem.
As stated above, there are two types of nonbasic variables in a capacitated trans-
shipment problem: (1) those at their lower bound (0); and (2) those at their upper
bound (M). Variables that are at neither their lower bound nor their upper bound
are the basic variables. There are n  1 basic variables (where n is the total number
of nodes).2 The arcs corresponding to these basic variables form a spanning tree in
the network. The following are the steps of the out-of-kilter algorithm:

The Out-of-Kilter Algorithm


Initialization: Find an initial basic feasible solution.

Iterative Steps:
1. Calculate the value of the dual variables:
(1) Set U1  0
(2) Solve for the other Uis by Cij  Ui  Uj  0 for basic variable arcs. (The flow
is FROM node i TO node j.)
2. Calculate the Cij–Zij values for the nonbasic arcs:
Cij  Zij  Cij  Ui  Uj
3. For nonbasic variables at their lower bound (0), variables with negative Cij–Zij
values are out of kilter: Determine the variable with the most negative Cij–Zij value.
For nonbasic variables at their upper bound (Mij), variables with positive Cij–Zij
values are out of kilter: Determine the variable with the most positive Cij–Zij value.
Of these two, select the one with the larger absolute Cij–Zij value as the
entering variable. If this largest value is 0, STOP; the current flow is optimal.
4. The arc for this variable forms a cycle in the network with a set of other basic
variables. If the entering variable is at its lower bound, increase the flow on the
arc; if it is at its upper bound, decrease the flow on the arc. In either case, the
flow along the other arcs in the cycle must be adjusted to maintain a feasible
flow. Adjust the flow until some arc reaches either 0 or its upper bound (Mij).
This is the new nonbasic variable.
GO TO STEP 1.

2
If the number of variables that are at neither their upper nor lower bound is less than n  1, the
problem is degenerate and any arc at its lower bound or any arc at its upper bound can be made basic
as long as the arc does not form a cycle with any of the other basic variables.
II The Capacitated Transshipment Problem—The Out-of-Kilter Algorithm CD-293

This approach illusrated for the capacitated transshipment problem shown in Fig-
ure CD5.7.

S110 $20
1 5 D512
$1 6
0
12 $7

$11
$5
8

7
3

$12
8
$6

$7
7

5
$15 $15
S215 2 4 6 D613
10 17
FIGURE CD5.7
Unit Cost Capacity Capacitated Transshipment Problem

INITIALIZATION STEP
The initial basic feasible flow was found by trial and error:
Lower Bound Upper Bound
Basic Nonbasic Nonbasic
Variables Flow Variables Flow Variables Flow
X13 9 X12 0 X15 6
X21 5 X56 0 X24 10
X34 3 X65 0
X35 6
X46 13
The basic variable tree for this solution is highlighted in Figure CD5.8; the flows
are shown in the circles below the arcs.

$20 6
S110 1 5 D512
$1 6
0 9
12 6
$5

$7
3

$11
7

3 8
5

$12 3
8

$7
5
$6
7

$15 10 $15 13
S215 2 4 6 D613
10 17
Flow
Nonbasic variables at their lower bound (0) FIGURE CD5.8
Nonbasic variables at their upper bound (Mij) Transshipment Problem:
Basic variables with flows between 0 and Mij A First Basic Feasible Solution

ITERATION 1
Step 1: Determine the U i ’s
Set U1 to 0. Then,

Basic
Variable Cij–Zij  0 Substitute Implies

X13 C13  U1  U3  0 10  0  U3  0 U3  10


X21 C21  U2  U1  0 6  U2  0  0 U2  6
X34 C34  U3  U4  0 12  (10)  U4  0 U4  22
X35 C35  U3  U5  0 7  (10)  U5  0 U5  17
X46 C46  U4  U6  0 15  (22) U6  0 U6  37
CD-294 SUPPLEMENT CD5 Algorithms for Network Models

Steps 2 and 3: Determine C ij –Z ij Values for Nonbasic Variables and


the Entering Variable
Lower Bound Variables

Variable Cij–Zij Calculation Out of Kilter?

X12 C12  U1  U2  5  0  6  11 No
X56 C56  U5  U6  11  (17)  (37)  9 Yes
X65 C65  U6  U5  7  (37)  (17)  27 No

Upper Bound Variables

Variable Cij–Zij Calculation Out of Kilter?

X15 C15  U1  U5  20  0  (17)  3 Yes


X24 C24  U2  U4  15  6  (22)  1 No

Since X56 is the variable that is most out of kilter ( 9  3) it becomes the
entering variable.

Step 4: Determine the Change to the Basic Variables


As seen in Figure CD5.8, X56 forms a cycle with the basic variables X35, X34, and
X46. Since X56 is at its lower bound (0), it is increased. As Figure CD5.9 shows,
when X56 is increased, X35 must be increased and X46 decreased. Hence X34 must
also be decreased.

X35 can increase by 2


to its upper bound of 8
5 D512
6
$7
$11
7

3 8
X56 can increase by 7
$12 3

to its upper bound of 7


8

X34 can decrease by 3


0

to its lower bound of 0

$15 13
4 6 D613
FIGURE CD5.9 17
Cycle Formed by X56 and X46 can decrease by 13
Current Basic Variables to its lower bound of 0

The calculations for the maximum amount of change in these four variables
before reaching the bounds shown in Figure CD5.9 are as follows:

Variables Current Upper Maximum


Increased Value Bound Increase

X56 0 7 707
X35 6 8 862
Variables Current Lower Maximum
Decreased Value Bound Decrease

X34 3 0 30 3
X46 13 0 13  0  13
II The Capacitated Transshipment Problem—The Out-of-Kilter Algorithm CD-295

The minimum of these maximum changes is 2, determined by increasing X35 to its


upper bound. Thus 2 is added to the flows on arcs X56 and X35 and subtracted from
the flows along the arcs X34 and X46 to get the network flow diagram depicted in
Figure CD5.10.

$20 6
S110 1 5 D512
$1 6
0 9
12 8

$5
$7

$11
7 2
3 8

$12 1
8
FIGURE CD5.10

$7
5
$6
7
Augmenting Flow by 2 on X56,
$15 10 $15 11 X35, X34, and X45 Gives the
S215 2 4 6 D613
10 17 Next Iteration

ITERATION 2

Basic Lower Bound Upper Bound


Variable Flow Nonbasic Variables Flow Nonbasic Variables Flow

X13 9 X12 0 X15 6


X21 5 X65 0 X24 10
X34 1 X35 8
X46 11
X56 2

Step 1: Determine the U i ’s


Set U1 to 0. Then,

Basic
Variable Opportunity Cost  0 Substitute Implies

X13 C13  U1  U3  0 10  0  U3  0 U3  10


X21 C21  U2  U1  0 6 U2  0  0 U2  6
X34 C34  U3  U4  0 12  (10)  U4  0 U4  22
X46 C46  U4  U6  0 15  (22)  U6  0 U6  37
X56 C56  U5  U6  0 11  U5  (37)  0 U5  26

Step 2: Determine C ij –Z ij Values for Nonbasic Variables


Lower Bound Variables

Variable Cij–Zij Calculation Out of Kilter?

X12 C12  U1  U2  5  0  6  11 No
X65 C65  U6  U5  7  (37)  (26)  18 No

Upper Bound Variables

Variable Cij–Zij Calculation Out of Kilter?

X15 C15  U1  U5  20  0  (26)  6 No


X24 C24  U2  U4 15  6  (22)  1 No
X35 C35  U3  U5 7  (10)  (26)  9 No
CD-296 SUPPLEMENT CD5 Algorithms for Network Models

Since no arcs are out of kilter, the network in Figure CD5.10 is optimal. The opti-
mal solution is:

Unit Transportation
From To Amount Cost Cost

Node 1 Node 3 9 $10 $ 90


Node 1 Node 5 6 $20 $120
Node 2 Node 1 5 $ 6 $ 30
Node 2 Node 4 10 $15 $150
Node 3 Node 4 1 $12 $ 12
Node 3 Node 5 8 $ 7 $ 56
Node 4 Node 6 11 $15 $165
Node 5 Node 6 2 $11 $ 22
Total  $645

A NOTE ON TIES FOR THE NEW


NONBASIC VARIABLE: DEGENERACY
In Step 3 of the algorithm, two or more basic variables may reach 0 or their upper
bounds at the same time. This is a case of degeneracy. Select only one of these
variables to be nonbasic at the next iteration; the others remain basic at either 0
value or their upper bound.

III T h e A s s i g n m e n t P r o b l e m —
The Hungarian Algorithm
The Hungarian algorithm for solving the assignment problem of a least cost
assignment of m workers to m jobs is based on the observation that a number
can be added to or subtracted from every number in a row or a column of an as-
signment cost matrix without affecting the optimal solution. A number sub-
tracted from all numbers in a row or column is considered a minimum amount
each worker will charge or that each job will cost; the resulting numbers can
then be thought of as a premium above this fixed amount. Similarly, adding a
number to a row or column can be regarded as an increase in the fixed price
that each worker will charge or that each job will cost. This process of adding
or subtracting a number from all numbers in a row or column is known as ma-
trix reduction.
The idea behind the Hungarian algorithm is to reduce the matrix so that only
nonnegative costs exist and at least one 0 remains in each row and column; then an
attempt is made to complete the assignment using only the 0 costs. If this is unsuc-
cessful, a systematic matrix reduction procedure is applied that creates a new ma-
trix of costs, in which an entry that previously had a positive cost is reduced to 0.
Then another attempt is made to find a complete 0 cost assignment. The process
is repeated until an assignment of only 0 entries is found.
The following description of the Hungarian algorithm assumes that:

1. There is a cost assignment matrix for the m “people” to be assigned to m


“tasks.” (If necessary dummy rows or columns consisting of all 0’s are added
so that the numbers of people and tasks are the same.)
2. All costs are nonnegative.
3. The problem is a minimization problem.
III The Assignment Problem—The Hungarian Algorithm CD-297

The Hungarian Algorithm

Initialization
1. For each row, subtract the minimum number from all numbers in that row.
2. In the resulting matrix, subtract the minimum number in each column from all
numbers in the column.
Iterative Steps
1. Make as many 0 cost assignments as possible. If all workers are assigned, STOP;
this is the minimum cost assignment. Otherwise draw the minimum number of
horizontal and vertical lines necessary to cover all 0’s in the matrix. (A method
for making the maximum number of 0 cost assignments and drawing the
minimum number of lines to cover all 0’s follows.)
2. Find the smallest value not covered by the lines; this number is the reduction value.
3. Subtract the reduction value from all numbers not covered by any lines. Add the
reduction value to any number covered by both a horizontal and vertical line.
GO TO STEP 1.

For small problems, one can usually determine the maximum number of zero-
cost assignments by observation. For larger problems, the following procedure can
be used:

Determining the Maximum Number


of Zero-Cost Assignments

1. For each row, if only one 0 remains in the row, make that assignment and
eliminate the row and column from consideration in the steps below.
2. For each column, if only one 0 remains, make that assignment and eliminate that
row and column from consideration.
3. Repeat steps 1 and 2 until no more assignments can be made. (If 0’s remain, this
means that there are at least two 0’s in each remaining row and column. Make
an arbitrary assignment to one of these 0’s and repeat steps 1 and 2.)

Again, for small problems, the minimum number of lines required to cover all
the 0’s can usually be determined by observation. The following procedure, based
on network flow arguments, can be used for larger problems:

Drawing the Minimum Number of Lines to Cover All 0’s


1. Mark all rows with no assignments (with a “•”).
2. For each row just marked, mark each column that has a 0 in that row (with a “•”).
3. For each column just marked, mark each row that has an assignment in that
column (with a “•”).
4. Repeat steps 2 and 3 until no more marks can be made.
5. Draw lines through unmarked rows and marked columns.

Figure CD5.11 shows the sequence of matrix reductions required to solve the
Ballston Electronics problem introduced in Chapter 4 of the text. In the third,
fourth, and fifth matrices, a box is placed around each 0 cost assignment. A “•” is
used to mark the rows and columns required to draw the minimum covering set of
lines using the procedures outlined above. The minimum uncovered value is circled.
CD-298 SUPPLEMENT CD5 Algorithms for Network Models

A B C D E
1 10 4 6 10 12
2 11 7 7 9 14
3 13 8 12 14 15
4 14 16 13 17 17
5 17 11 17 20 19
Row Subtraction

A B C D E
1 6 0 2 6 8
2 4 0 0 2 7
3 5 0 4 6 7
4 1 3 0 4 4
5 6 0 6 9 8

Column Subtraction

A B C D E
1 5 0 2 4 4
Minimum Uncovered
2 3 0 0 0 3
Number
3 4 0 4 4 3
4 0 3 0 2 0
5 5 0 6 7 4

A B C D E
1 3 0 0 2 2
2 3 2 0 0 3
3 2 0 2 2 1 Minimum Uncovered
4 0 5 0 2 0 Number
5 3 0 4 5 2

A B C D E
1 3 1 0 2 2
2 3 3 0 0 3
3 1 0 1 1 0
4 0 6 0 2 0
5 2 0 3 4 1

Optimal Solution
1–C 6
2–D 9
3–E 15
4–A 14 FIGURE CD5.11
5–B 11 Solution for the Ballston
65 Electronics Assignment
Problem
IV A Traveling Salesman Algorithm CD-299

CONVERSION OF A MAXIMIZATION PROBLEM


TO A MINIMIZATION PROBLEM
The Hungarian algorithm works only if the matrix is a cost matrix. In Chapter 4 it
was mentioned that a maximization assignment problem can be converted to a
minimization problem by creating a lost opportunity matrix. The problem then is
to minimize the total lost opportunity.
After adding dummy rows or columns as necessary so that the number of jobs
equals the number of workers, one can think of the lost opportunities for each job
as the regret suffered if the job is not performed by the worker who gives the high-
est return for the job. These values are found by replacing each entry in the col-
umn by the difference between the entry and the largest entry in the column.
For example, suppose the following is a profit matrix for an assignment prob-
lem with three workers and four jobs. First a dummy row of 0’s is added so that
there are four rows and columns:

J1 J2 J3 J4
W1 67 58 90 55
W2 58 88 89 56
W3 74 99 80 22
DUMMY 0 0 0 0

The lost opportunity matrix given below is derived by subtracting each num-
ber in the J1 column from 74, each number in the J2 column from 99, each number
in the J3 column from 90, and each number in the J4 from 56.

J1 J2 J3 J4
W1 7 41 0 1
W2 16 11 1 0
W3 0 0 10 34
DUMMY 74 99 90 56

The Hungarian algorithm can now be applied to this lost opportunity matrix
to determine the maximum profit set of assignments.

IV A Traveling Salesman Algorithm


The traveling salesman problem seeks a minimum cost cycle that includes all the
nodes in a network. Numerous algorithms have been proposed, but few are effi-
cient when the number of nodes is large. Here an approach is presented that has
been successful for problems with a small number of nodes (say less than 20).

THE BRANCH AND BOUND ALGORITHM


The approach begins by constructing an assignment-type matrix; the workers are
the “FROM” nodes, and the jobs are the “TO” nodes. The matrix entries are the
costs (or distances) between the FROM nodes to the TO nodes. The cost assigned
FROM a node TO itself is the huge cost “M.” The idea behind the algorithm is
to try to “assign” one city to follow another city using the assignment algorithm.
The difficulty with this approach is that the optimal solution found using the
assignment algorithm may not be a cycle, or “tour,” of all the cities, but rather an
assignment consisting of two or more cycles, or “subtours.” To eliminate the possi-
bility of a particular subtour occurring, a branch and bound algorithm that parallels
that introduced in Supplement CD4 for mixed integer linear programs is applied.
CD-300 SUPPLEMENT CD5 Algorithms for Network Models

An initial upper bound for the optimal objective function value, U, can be found
by calculating the cost of any tour. Initially, U is set to the objective function value of
the tour 1–2–3– . . . –n–1. The branches consist of problems that have been revised
by assigning a high cost (M) to one of the arcs on a subtour (thus making that sub-
tour infeasible). Then the assignment algorithm is applied to the revised problem.
Once the solution is found, its objective function value is compared to the cur-
rent upper bound, U. If it is not less than U, it is fathomed (eliminated from con-
sideration). If it is less than U and the solution is a tour, we reset U to the total
cost of the tour. If it is not a tour, additional branching from this problem must be
done. The branch and bound process is repeated until all the branches have been
fathomed.
The branch and bound steps are summarized below. (Remember that “fath-
oming” means ceasing further consideration of the branch.)

Branch and Bound Algorithm


for the Traveling Salesman Problem

Initialization Step
Solve the problem as an assignment problem. If the optimal solution is a tour, the
minimum distance has been found. It the optimal solution is not a tour, make this
solution the first active branch of the branch and bound tree and set U  the
objective function value of the tour 1–2–3–4–5 . . . –n.
Branch and Bound Steps
1. Choose an unfathomed branch. Consider the subtour consisting of the minimum
number of arcs (say, there are k arcs on this subtour). Create k branches from
this node, each corresponding to an assignment problem that assigns a very
large value M to one of the arcs of the subtour, making the subtour infeasible.
For each branch, re-solve the assignment problem, giving an objective function
value Z. (If there are no unfathomed branches, STOP; the optimal solution is the
one that gives the value of U.)
2. For each of these branches:

If Then
The problem is infeasible • Fathom the branch
ZU • Fathom the branch
The solution is a tour and Z  U • Fathom the branch
• Reset U  Z
• Fathom all branches with Z  U
The solution is not a tour and Z  U • This is a new active subproblem.
GO TO STEP 1

This approach is illustrated using the following problem.

A TRAVELING SALESMAN PROBLEM


TO
FROM 1 2 3 4 5 6

1 M 63 22 20 18 10
2 60 M 56 40 54 58
3 28 54 M 20 21 15
4 40 39 37 M 24 41
5 30 40 26 20 M 18
6 30 56 24 40 26 M
IV A Traveling Salesman Algorithm CD-301

Initialization
When this problem is solved as an assignment problem, the solution consists of
two subtours: (1–6–5–3–1) and (2–4–2), giving Z  164. Since a tour was not
found, the value of the tour (1–2–3–4–5–6–1) is calculated ( 63  56  20  24
 18  30  221) and used as our first upper bound: U  221.

Iteration 1 U  221
The subtour with the smallest number of arcs is (2–4–2). Now create two new
branches, one blocking the route from 2–4 (by changing the entry for arc (2,4) in
the assignment matrix to M), the other blocking the route from 4–2 (by chang-
ing the entry for arc (4,2) in the assignment matrix to M.) Re-solve each as an as-
signment problem.

Branch Z Result Action

Block 2–4 174 Tour: 1–6–3–5–4–2–1 Fathom this branch. Reset U to


174 (since 174  U  221).
Block 4–2 166 Two subtours: Continue branching on one of
(1–6–3–1) these subtours.
(2–4–5–2)

These results are depicted in the tree shown in Figure CD5.12.

164 U174 (1-6-3-5-4-2-1)


Subtours
1–6–5–3–1
2–4–2
–4

Bl
oc
k2

k4
oc

–2
Bl

174 166
Tour Subtours
1–6–3–5–4–2–1 1–6–3–1
2–4–5–2

Fathom–Tour
Reset U to 174
since 174 221

FIGURE CD5.12 The Traveling Salesman Approach: Iteration 1

Iteration 2 U  174
Because the number of arcs on each subtour created by blocking the route from
4–2 is the same, arbitrarily choose the subtour (2–4–5–2) to branch on. Three new
subproblems are created, which in addition to blocking the route from 4–2, block
the routes from 2–4, 4–5, and 5–2, respectively. Re-solving each of these as an as-
signment problem gives the following:
CD-302 SUPPLEMENT CD5 Algorithms for Network Models

Branch Z Result Action

Block 2–4 178 Tour: 1–6–3–4–5–2–1 Fathom this branch. Do not


reset U since 178  U  174.
Block 4–5 175 Tour: 1–6–3–5–2–4–1 Fathom this branch. Do not
reset U since 175  U  174.
Block 5–2 193 Two subtours: Fathom this branch since
(1–6–2–4–1) 193  U  174.
(3–5–3)

These results are summarized by the tree in Figure CD5.13. Since all branches are
now fathomed, the optimal solution is the tour (1–6–3–5–4–2–1) giving Z  174.

164
Subtours U174 (1-6-3-5-4-2-1)
1–6–5–3–1
2–4–2
–4

Bl
oc
k2

k4
oc

–2
Bl

174 166
Tour Subtours
1–6–3–5–4–2–1 1–6–3–1
2–4–5–2

Fathom–Tour Block 4–5

Bl
–4

oc
k2

k5
oc

–2
Bl

178 175 193


Tour Tour Subtours
1–6–3–4–5–2–1 1–6–3–5–2–4–1 1–6–2–4–1
3–5–3

Fathom–Tour Fathom–Tour Fathom–


Do not reset U Do not reset U since 193174
since 178174 since 175174

FIGURE CD5.13 The Traveling Salesman Approach: Iteration 2

V The Shortest Path Problem:


The Dijkstra Algorithm
Several algorithms have been proposed for finding the shortest path from a start
node to a terminal node in a network. Here the Dijkstra algorithm, which is one
of the easiest and most efficient algorithms for solving shortest path problems is
illustrated.
The Dijkstra algorithm begins by labeling each node with the minimum dis-
tance found from the start node to the node “so far.” The node is temporarily la-
beled with this distance. At each iteration of the process, the node with the
smallest of the temporary labels is selected and that label becomes permanent.
This permanent label is the true minimum distance from the source node to that
node because any further labels at this node include traveling through another
node with a larger temporary label value. The process is repeated until all the
nodes (or at least the terminal node) have been assigned permanent labels.
V The Shortest Path Problem: The Dijkstra Algorithm CD-303

The following is a formal statement of the Dijkstra algorithm:

The Dijkstra Algorithm


Initialization Step
Assign a temporary label of 0 to the start node and  to all other nodes. (These
are the minimum distances found thus far from the start node to all other nodes; we
do not put the  values on the network.)
Iterative Steps
1. Find the node with the smallest temporary label and make it permanent. This
node is the assigned node. If all nodes have permanent labels, STOP; the minimum
distances have been found.
2. From the assigned node, consider all arcs to its adjacent nodes with temporary
labels. For these adjacent nodes calculate:

D  (Permanent label at assigned node)  (Arc distance)

Replace the temporary label at the adjacent node by D only if the current label at
the adjacent node is greater than D. If the label is replaced, record the assigned
node that generated the label (shown next to the label valve).
GO TO STEP 1.

The shortest path is determined by retracing the path of assigned nodes from
the terminal node back to the start node. The Dijkstra algorithm will now be illus-
trated using the network shown in Figure CD5.14.

8
2 5
15
2

18 6

1 4 7
7

10
17

9
4

FIGURE CD5.14
Shortest Path: Find the
Minimum Distance from 3
18
6
Node 1 to Node 7

INITIALIZATION
All nodes have temporary labels of  (not shown), except for node 1 which has a
temporary label of 0.

ITERATION 1
According to Figure CD5.14:
Minimum Temporary Label (Made Permanent): 0 at Node 1
Temporary Nodes Adjacent to Node 1: Nodes 2 and 3

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?

2 0  18  18   Yes—18 (1)
3 0  10  10   Yes—10 (1)

This gives Figure CD5.15a.


CD-304 SUPPLEMENT CD5 Algorithms for Network Models

18 (1)
8
2 5

15
2

6
Permanent 18
Label
0 1 4 7

5
10

17

9
4
18
3 6
Temporary 10 (1) Previous
Label Node
Minimum
Distance
Found Thus Far

FIGURE CD5.15a Shortest Path Solution: Iteration 1

ITERATION 2
According to Figure CD5.15a:

Minimum Temporary Label (Made Permanent): 10 at Node 3


Temporary Nodes Adjacent to Node 3: Nodes 2, 4, and 6

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?

2 10  7  17  18 Yes—17 (3)
4 10  4  14   Yes—14 (3)
6 10  18  28   Yes—28 (3)

This gives Figure CD5.15b.

17 (3)
18 (1)
8
2 5
15
2

18

0 1 4 7
7

10
14 (3)
17

9
4

18
3 6
10 (1) 28 (3)

FIGURE CD5.15b Shortest Path Solution: Iteration 2


V The Shortest Path Problem: The Dijkstra Algorithm CD-305

ITERATION 3
According to Figure CD5.15b:
Minimum Temporary Label (Made Permanent): 14 at Node 4
Temporary Nodes Adjacent to Node 4: Nodes 2, 5, and 6

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?
2 14  2  16  17 Yes—16 (4)
5 14  15  29   Yes—29 (4)
6 14  17  31  28 No

This gives Figure CD5.15c.


16 (4)
17 (3)
18 (1) 29 (4)
8
2 5

15
2

6
18

0 1 4 7
7

5
10
14 (3)

17

9
4

FIGURE CD5.15c 18
3 6
Shortest Path Solution:
Iteration 3 10 (1) 28 (3)

ITERATION 4
According to Figure CD5.15c:
Minimum Temporary Label (Made Permanent): 16 at Node 2
Temporary Nodes Adjacent to Node 2: Node 5

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?

5 16  8  24  29 Yes—24 (2)

This gives Figure CD5.15d.

16 (4)
17 (3) 24 (2)
18 (1) 29 (4)
8
2 5
15
2

18

0 1 4 7
7

10
14 (3)
17

9
4

FIGURE CD5.15d 18
3 6
Shortest Path Solution:
Iteration 4 10 (1) 28 (3)
CD-306 SUPPLEMENT CD5 Algorithms for Network Models

ITERATION 5
According to Figure CD5.15d:
Minimum Temporary Label (Made Permanent): 24 at Node 5
Temporary Nodes Adjacent to Node 5: Nodes 6 and 7

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?

6 24  5  29  28 No
7 24  6  30   Yes—30 (5)

This gives Figure CD5.15e.

16 (4)
17 (3) 24 (2)
18 (1) 29 (4)
8
2 5

15
2

6
18

0 1 4 7 30 (5)
7

5
10
14 (3)

17

9
4

FIGURE CD5.15e 3
18
6
Shortest Path Solution:
Iteration 5 10 (1) 28 (3)

ITERATION 6
According to Figure CD5.15e:
Minimum Temporary Label (Made Permanent): 28 at Node 6
Temporary Nodes Adjacent to Node 6: Node 7

Adjacent Distance from New Temporary Label


Node Assigned Node at Adjacent Node?

7 28  9  37  30 No

This gives Figure CD5.15f.

16 (4)
17 (3) 24 (2)
18 (1) 29 (4)
8
2 5
15
2

18

0 1 4 7 30 (5)
7

10
14 (3)
17

9
4

FIGURE CD5.15f 3
18
6
Shortest Path Solution:
Iteration 6 10 (1) 28 (3)
VI The Minimal Spanning Tree Problem—The Greedy Algorithm CD-307

ITERATION 7
According to Figure CD5.15f:

Minimum Temporary Label (Made Permanent): 30 at Node 7


Temporary Nodes Adjacent to Node 7: None

This gives Figure CD5.15g.

16 (4)
17 (3) 24 (2)
18 (1) 29 (4)
8
2 5

15
2

6
18

0 1 4 7 30 (5)

5
10
14 (3)

17

9
4
FIGURE CD5.15g 18
3 6
Shortest Path Solution:
Iteration 7 10 (1) 28 (3)

Since all nodes have now been assigned a permanent label, the algorithm
terminates. The shortest distance from node 1 to node 7 is 30. Retracing the
path from node 7, observe that node 7 was reached from node 5; node 5 was
reached from node 2; node 2 was reached from node 4; node 4 was reached
from node 3; and node 3 was reached from node 1. Thus the shortest path is
1–3–4–2–5–7. The shortest distances and paths from node 1 to all other nodes
in the network are as follows:

To Distance Path

Node 2 16 1–3–4–2
Node 3 10 1–3
Node 4 14 1–3–4
Node 5 24 1–3–4–2–5
Node 6 28 1–3–6
Node 7 30 1–3–4–2–5–7

VI T h e M i n i m a l S p a n n i n g T r e e
Problem—The Greedy Algorithm
The objective of a minimal spanning tree model is to find the tree that intercon-
nects all the nodes in a network at minimum total distance. The Greedy algo-
rithm is an easy, efficient way to find this minimal spanning tree. The idea behind
the Greedy algorithm is that one is, in fact, “greedy.” The process starts by select-
ing the minimum arc out of a particular node (this can be node 1 or any node in
the network) and then continue to build a tree by adding the lowest cost arcs that
do not form cycles. The approach is formally stated as follows:
CD-308 SUPPLEMENT CD5 Algorithms for Network Models

The Greedy Algorithm

Initialization Step
Select the minimum arc out of node 1 to start the tree.
Iterative Step
Add to the current tree the connecting arc of minimum distance that does not form a
cycle. If all nodes are connected, STOP; the minimal spanning tree has been found.
Repeat the above iterative step until all nodes have been connected.
If there are n nodes, the tree consists of n  1 arcs.

In Figure CD5.16, we show in thick blue the minimal spanning tree for the same
network as the one we used to illustrate the shortest path problem. It was gener-
ated by the following iterations.

8
2 5

15

6
18 2

1 4 7
7

5
10 17
4

9
FIGURE CD5.16
Minimum Spanning 18
3 6
Tree Solution

INITIALIZATION
Choose the minimum arc out of node 1—arc (1, 3)—distance 10.

Minimum Distance Cumulative Tree


Iteration Connecting Arc Distance Add Arc to Tree? Distance

0 (1, 3) 10 Yes 10
1 (3, 4) 4 Yes 14
2 (2, 4) 2 Yes 16
3 (2, 3) 7 No—Cycle
(2, 5) 8 Yes 24
4 (5, 6) 5 Yes 29
5 (5, 7) 6 Yes 35

Thus the minimum spanning tree has a total distance of 35 and consists of arcs
(1, 3), (3, 4), (2, 4), (2, 5), (5, 6), and (5, 7).

VII T h e M a x i m a l F l o w P r o b l e m — T h e
Maximal Flow Algorithm
In a maximal flow problem, the objective is to find the maximum volume of
flow from a source node to a terminal sink node in a capacitated network. Al-
though it is a special case of the capacitated transshipment problem and can be
VII The Maximal Flow Problem—The Maximal Flow Algorithm CD-309

solved by the simplex method or the out-of-kilter algorithm, the following max-
imal flow algorithm is easy to implement and avoids the necessity of keeping
track of basic variables. In it, one determines if there is any path from the
source to the sink that can carry flow. If there is, the flow is augmented as much
as possible along this path, and the residual capacities of the arcs used on the
path are reduced accordingly.
The only complication is that we might find that “if only we hadn’t already
committed to some flow along this arc, we could find an alternative path that
could give a larger flow.” Thus, when a residual arc capacity is reduced in one
direction along an arc, the residual capacity is increased in the other direction on
the arc (known as its backwards capacity) to account for a possible future “change
of mind.” As a result, the algorithm might determine an optimal solution in
which five units are shipped from node i to node j and 3 units are shipped back
from node j to node i. Of course, this means that only 5  3  2 are shipped
from node i to node j.
A formal statement of the maximal flow algorithm is as follows:

The Maximal Flow Algorithm


1. Find a path from the source to the sink that has positive residual capacities left
on all arcs of this path. If no paths have positive flow, STOP; the maximal flow
has been found.
2. Find the minimum residual capacity of the arcs on the path (call it k) and
augment the flow on each arc by k.
3. Adjust the residual capacities of arcs on the path by decreasing the residual
capacities of the arcs in the direction of the flow by k and increasing the residual
capacities in the direction opposite the flow by k.
GO TO STEP 1.

Note that choosing which path to use in the network in Step 1 is purely arbi-
trary. Often, however, it is not easy to determine if any path of positive flow exists
from the source node to the sink node. One way to find such a path is to assign a
“distance” of “1” to all arcs with positive residual capacities and  to the other
arcs. Then a shortest path algorithm can be used to find the minimum distance
from the source node to the terminal node; if this distance is less than , a path
with positive flow has been found. In the following example, however, we simply
select the paths arbitrarily.
In the network shown in Figure CD5.17 the numbers next to each node rep-
resent the residual capacity on the arc from the node to the adjacent node.

3 3
0 2 5
2
7
2

6
2

3
1 6
3 2
0

0
3

2 2 7
0
6
1
2

0 2 Capacity from node 6


to node 4 is 1
4 2
FIGURE CD5.17 Capacity from node 4
Maximal Flow Problem to node 6 is 2
CD-310 SUPPLEMENT CD5 Algorithms for Network Models

ITERATION 1
Select the path 1–2–5–7. The capacity on arc (1, 2) is 6; on arc (2, 5) is 3; and on
arc (5, 7) is 7. Since the minimum of these is 3, the flow along this path is in-
creased by 3, as shown in Figure CD5.18a. For iteration 2, the residual capacities
along the arcs (1, 2), (2, 5), and (5, 7) are reduced by 3 to 3, 0, and 4, respectively,
and the residual backwards capacities on arcs (2, 1), (5, 2), and (7, 5) are increased
by 3 to 3, 6, and 3, respectively.

Path: 1–2–5–7
Residual Capacities
1–2 6 Augment flow by 3
2–5 3 Reduce forward capacities by 3
5–7 7 Increase backwards capacities by 3

3
3 3
0 2 5
2

7
2
3
3
6
2 3
1 6
3 2

0
0
3

2 2 7
0
6
1

FIGURE CD5.18a
2

0 2
Maximal Flow Solution: 4 2
Iteration 1

ITERATION 2
From Figure CD5.18b, observe that no additional flow is possible along arc (2, 5).
Thus a new path with positive residual capacities from node 1 to node 7 must be
found. Here the path 1–2–3–6–7 is selected. The residual capacity on arc (1, 2) is
3; on arc (2, 3) is 2; on arc (3, 6) is 2; and on arc (6, 7) is 2. Since the minimum of
these is 2, we increase the flow along this path by 2. For iteration 3, decrease the
residual capacities along the arcs (1, 2), (2, 3), (3, 6), and (6, 7) by 2 to 1, 0, 0, and
0, respectively. The residual backwards capacities on arcs (2, 1), (3, 2), (6, 3), and
(7, 6) are increased by 2 to 5, 4, 4, and 2, respectively.

Path: 1–2–3–6–7
Residual Capacities
1–2 3 Augment flow by 2
2–3 2 Reduce forward capacities by 2
3–6 2 Increase backwards capacities by 2
3–6 2
Augmented Flow 3
0 6
2 3 2 5
2
4
2

Current Flow 3
2

3
3
3
2

1 6
3 2
2
3

2 0
3

2 2 7
0
6
1

FIGURE CD5.18b
2

0 2
Maximal Flow Solution: 4 2
Iteration 2
VII The Maximal Flow Problem—The Maximal Flow Algorithm CD-311

ITERATION 3
In Figure CD5.18c, observe that no additional flow is possible along arcs (2, 3) or
(2, 5), since no further flow is possible along arc (1, 2). Thus a path from node 1 to
node 7 with positive residual capacities using arc (1, 4) must be found. Here the
path 1–4–7 is selected. The residual capacity on arc (1, 4) is 6, and on arc (4, 7) is
2. Since the minimum of these is 2, the flow along this path is increased by 2. For
iteration 4, the residual capacities along the arcs (1, 4) and (4, 7) are decreased by
2 to 4 and 0, respectively, and the residual backwards capacities on arcs (4, 1) and
(7, 4) are increased by 2 to 2 and 2, respectively.
Path: 1–4–7
Residual Capacities
1–4 6 Augment flow by 2
4–7 2 Reduce forward capacities by 2
Increase backwards capacities by 2

0 3 6
5 2 5
2

4
0
5

2
3
1
4 3
1 6
3 0
2

3
2 2 2
3

4 0 7
0
6
1

FIGURE CD5.18c 2
2

0 2
Maximal Flow Solution: 4
2
Iteration 3

ITERATION 4
In Figure CD5.18d, observe that no additional flow is possible along arc (4, 7);
thus a new path with positive residual capacities from node 1 to node 7 must be
found using arc (1, 4). Here the path 1–4–3–5–7 is selected. The residual capacity
on arc (1, 4) is 4; on arc (4, 3) is 2; on arc (3, 5) is 3; and on arc (5, 7) is 4. Since the
minimum of these is 2, the flow along this path is increased by 2. For iteration 5,
the residual capacities along the arcs (1, 4), (4, 3), (3, 5), and (5, 7) are decreased
by 2 to 2, 0, 1, and 2, respectively, the residual backwards capacities on arcs (4, 1),
(3, 4), (5, 3), and (7, 5) are increased by 2 to 4, 5, 4, and 5, respectively.
Path: 1–4–3–5–7
Residual Capacities
1–4 4 Augment flow by 2
4–3 2 Reduce forward capacities by 2
3–5 3 Increase backwards capacities by 2
5–7 4

0 3 6
5 2 5
2
4
0

5 2
2

2 3
1
3
4

1 4
2 3 0
2
3

2 2 2
3

4 0 7
2
6
1
2 2

FIGURE CD5.18d 2 2 2
Maximal Flow Solution: 4 0
Iteration 4
CD-312 SUPPLEMENT CD5 Algorithms for Network Models

ITERATION 5
In Figure CD5.18e, observe that because no additional flow is possible along arcs
(4, 3) and (4, 7), any additional flow from arc (1, 4) must flow along arc (4, 6). A
path with positive residual capacities from node 1 to node 7 using this arc is
1–4–6–3–5–7. The residual capacity on arc (1, 4) is 2; on arc (4, 6) is 2; on arc (6, 3)
is 4; on arc (3, 5) is 1; and on arc (5, 7) is 2. Since the minimum of these is 1, the
flow along this path is increased by 1. The residual capacities along the arcs (1, 4),
(4, 6), (6, 3), (3, 5), and (5, 7) are decreased by 1 to 1, 1, 3, 0, and 1, respectively,
and increase the residual backwards capacities on arcs (4, 1), (6, 4), (3, 6), (5, 3),
and (7, 5) are increased by 2 to 5, 2, 1, 5, and 6, respectively.

Path: 1–4–6–3–5–7
Residual Capacities
1–4 2
4–6 2
6–3 4 Augment flow by 1
3–5 1 Reduce forward capacities by 1
5–7 2 Increase backwards capacities by 1

0 3 6
5 2 5
4

2
0

5 1 1
2

2 5
1
1
4

1 2 1
1 3 0
2

5
4 2 2
5

4 0 7
2
6
1
2 0

1
FIGURE CD5.18e 4 2 2
Maximal Flow Solution: 4
0
Iteration 5

ITERATION 6
As seen in Figure CD5.18f, no more flow is possible because there is no residual
capacity left on the cut consisting of arcs (2, 5), (3, 5), (6, 7), and (4, 7). This is a
minimal cut for the network. Note also that, at iteration 2, there is a flow of 2 from
node 3 to node 6, while at iteration 5, there is a flow of 1 from node 6 to node 3.
This means that the maximum flow has a net flow of 2  1  1 from node 3 to
node 6.

0 3 6
5 2 5
5
1
0

5
2

3 6
1
0
4

1 1
3 1
1
6

5 2
5

3 0 2 7
2
6
2

2
FIGURE CD5.18f 1
Maximal Flow Solution: 2 Minimum
0

5 1 Cut
Final Network, No Additional 0
4
Flow Possible
VII The Maximal Flow Problem—The Maximal Flow Algorithm CD-313

Thus, for this problem, a maximum flow of 10 from node 1 to node 7 is at-
tained as follows:

From To Flow

1 2 5
1 4 5
2 3 2
2 5 3
3 5 3
3 6 1
4 3 2
4 6 1
4 7 2
5 7 6
6 7 2

You might also like