15.053 Tuesday, April 10: The Network Simplex Method For Solving The Minimum Cost Flow Problem
15.053 Tuesday, April 10: The Network Simplex Method For Solving The Minimum Cost Flow Problem
15.053 Tuesday, April 10: The Network Simplex Method For Solving The Minimum Cost Flow Problem
053
Tuesday, April 10
The Network Simplex Method for Solving the Minimum Cost Flow Problem
200
1
MIT1
6
London 0
-400
4
satellite1 0
300
2
MIT2
$. 03 $. 04
5
100 satellite2
3
MIT3
$0
7
China
-200
3
Here is the min cost assignment problem from the previous lecture.
We will be treating the min cost flow problem in which there are no capacities. The algorithm that we present here readily generalizes to the problem in which there are capacities. But we do not include the generalization here because it adds one extra level of complexity, and it is difficult to follow the first time around.
LP Formulation
n n
Minimize
c
i =1 j =1 n j =1 ij
ij ij n
subject to
x x
k =1
ki
= bi , i = 1, , n
xij 0
5
Here is an LP formulation of the generic min cost flow problem with no capacities.
We will present the simplex algorithm as it applies to the min cost flow problem NO TABLEAUS (except next two slides)
We compute the primal solution directly on the network We compute the simplex multipliers directly on the network We compute reduced costs directly on the network.
The Network simplex algorithm provides another opportunity to visualize the simplex algorithm. In this case, one can visualize the algorithm in multiple dimensions (that is lots of variables), as opposed to the lectures on geometry where we were restricted to two or three dimensions (that is, two or three variables). We will not be using tableaus. Nevertheless, we will still compute basic feasible solutions as well as reduced costs. To carry out these computations, we will work directly on the network.
= flow in (i, j) zarc costs cij zno arc capacities today znode supply/demands bi
Minimize
0 1 1 --1 -1 0 0
( i , j ) A
c ij x ij
RHS = = = =
b(1) b(2) b(3) b(4)
-1 -1 1 1 0
To recall how to compute prices, it helps to write a minimum cost flow problem as a linear program.
RHS
0 b(1) b(2) b(3) b(4)
Prices
y1 y2 y3 y4
= = = =
x12
x23
xij
4
8
We use the usual rule for pricing out. Note that we have used -1 as the coefficient of z in the z-row, and so the costs are all original costs. Assuming that the prices are denoted by the vector y, the reduced cost of cij is cij yi + yj. Its an unusually simple form for a reduced cost.
1-0+3
2-3+0
Costs are increased coming into a node. They are decreased going out.
9
We illustrate the reduced costs on a network with two arcs, one directed into node 2
and one directed out of node 2. The point of this diagram is that an increase in the
price of node 2 leads to an increase of the reduced costs of arcs coming into node 2
and a decrease of the reduced costs of arcs leaving node 2.
coke
store
coke
When the store sells a bottle of Coke, it receives a nickel and the Coke leaves the store. When an empty bottle of Coke is returned to the store, it costs the store 1 nickel. Note, assuming the number of returns is equal to the number of purchases, this pricing out has essentially no impact on the finances of a store.
10
The change in reduced costs can be thought of in terms of bottle deposits from a stores perspective. Every bottle leaving the store results in the store receiving a nickel. The cost to the store went down. Every bottle entering the store results in the store having to pay a nickel. The cost to the store went up. Assume for now that the number of bottles sold is equal to the number of bottles returned. Then the price of a bottle deposit has no net impact on the stores revenue. (Lets also ignore the time value of money and discounting.) If the deposit charge were $.10 per bottle, the store would still have the same amount of money being paid in bottle deposits as it pays in bottle deposits.
Important Fact: optimizing wrt costs c gives the same optimal solutions as optimizing wrt reduced costs c.
Using reduced costs will change the cost of each solution by a constant. Recall cij = cij - yi + yj supply 200
Increasing the price of the node from $0 to $10 will result in a net decrease in cost of any feasible flow by 200 x $10. (Why?)
11
As with all linear programs with equality constraints, prices do not affect the optimum solution. A solution is optimum with respect to the original costs if and only if it is optimum with respect to the reduced costs. This is illustrated by focusing on node 1, which has a supply of 200 units. If we increase the price of node 1 by $10, then every solution will have a net decrease in cost by $10 200 = $2,000. Since the cost of each feasible solution is changed by the constant $2,000, the change in price does not affect which solutions are optimal.
RHS
0 b(1) b(2) b(3) b(4)
= = = =
Add the last three constraints to the first constraint. What happens to the 0 first 0 0 0 0 0 0 constraint? Can we eliminate constraint 1? How many basic variables will there be?
4
12
In network flow problems, we write out the supply/demand constraint for each node. Each column has exactly one -1 and one +1, with other elements being 0. If we sum the rows, we obtain a value of 0 in each column. We also assume that b(1) + b(n) = 0, and so the RHS also sums to 0. This implies that there is a redundant constraint. We can eliminate any of the constraints and obtain an equivalent problem. For convenience, we drop constraint 1 corresponding to node 1. There is usually a price for each constraint. But if we drop constraint 1, there is no need to have a price for this constraint. Equivalently, we can just set y1 to 0.
Is it optimal?
Yes
No
No
Is the optimum unbounded from below?
Yes
We are now ready to explain the network simplex algorithm. We first review a slide used in an earlier lecture on the simplex method. Note that we are minimizing, and so the relevant question concerning unboundedness is whether the optimum objective is unbounded from below.
A minimum cost flow problem. The arc numbers are costs. The node numbers are supplies/demands
14
Here is spanning tree. We will next compute the basic solution for this spanning tree.
15
Recall that one constraint can be eliminated, and so a basic solution should have n-1 basic variables. It turns out that there is a 1-1 correspondence between basic solutions and spanning trees. Note that I did not say basic feasible solutions. It is possible that the basic solution associated with a spanning tree will be infeasible.
3 6
4 -11
7 -7
6 7 3 2 5
Start with a leaf node and assign it a unique flow. Iteratively choose leaves of the tree obtained by ignoring all arcs with flow.
17
If a node j is a leaf node, then the flow in the arc incident to node j is either b(j) or b(j) depending on whether the arc is directed from node j or into node u. So, the flow in arc (3, 4) must be 6. If we focus on the green nodes (as per the slide show), then the green nodes always form a spanning tree, and we can always select a leaf of this spanning tree and determine the flow on the arc incident to the leaf.
This spanning tree flow is a bfs. The simplex method starts with a feasible spanning tree flow.
18
Fortunately, the spanning tree flow was nonnegative, and so it corresponded to a basic feasible solution of the linear program. If one selected an arbitrary spanning tree, one would not expect that the corresponding spanning tree flow would be nonnegative. As you recall, the simplex method starts with a bfs. So, it is a legitimate question on how to find an initial spanning tree whose flow will be feasible. We will pass on this question for now, just as we passed on it when discussing the simplex algorithm for the first time; however, we will return to the question near the end of the lecture.
Is it optimal? To determine optimality, we need to compute reduced costs. To determine reduced costs, we need to compute the simplex multipliers. The simplex multipliers are prices for which the reduced costs of the basic variables are 0.
19
Once one has a feasible spanning tree solution (that is, a bfs), one needs to check whether it is optimal. In the simplex method, this is accomplished by calculating the reduced costs of all of the variables. We will break up the computation of the reduced costs into two phases. In the first phase, we calculate the simplex multipliers associated with a spanning tree. In the second phase, we use the simplex multipliers to calculate the reduced costs of the nontree arcs (that is, the nonbasic variables).
Is it optimal?
2 2
Choose the ys so that all of the arcs in the spanning tree have a reduced cost of 0. There are 6 equations, and 7 variables. We can set y1 = 0 because constraint 1 was redundant.
20
In general, the simplex multipliers are the unique prices so that the reduced costs of the basic variables are all 0. But for the prices to be unique, we need to deal with the fact that there is a redundant constraint. So, we eliminate constraint 1, and we accordingly set y1 = 0. Once we know that y1 = 0, the other prices are uniquely determined.
0 = 1 0 + y2 3 0 = 2 y2 + y4
5 5 7
0 = 2 y2 + y5 0 = 1 y3 + y4 0 = 3 y6 + y1
y y1 y11 0 0
y y4 y44 -3
y y5 y55 -3
y y6 y66 3
y y7 y77 -2
0 = 5 y6 + y7
21
In fact, simplex multipliers are associated with equality constraints of the LP. However, since each equality constraint of the LP is a supply/demand constraint for a node, we associate the simplex multipliers with nodes. The simplex multiplier for node 1 is 0, by the discussion on the last slide. We now compute the simplex multipliers for all other nodes so that the reduced costs of arcs in the spanning tree are all 0.
2 2 3
y1 1 0 0 y2 2 -1 y3 3 -2
4
y4 4 -3
7 1
y5 5 -3 y6 6 3 y7 7 -2
22
Once we know the simplex multipliers for each node, we can compute the reduced costs of the three nontree arcs. Note that the reduced cost of (6, 5) is negative. This means that if we try to increase the flow on arc (6, 5) we can adjust the flows on other tree arcs and strictly improve the objective function, assuming nondegeneracy. Accordingly, arc (6, 5) will enter the basis at the next iteration; that is, it will become an arc of the basic spanning tree.
23
2 3 3 4 2
Flow will adjust on the arcs of the cycle created by adding the nontree arc to the tree.
24
The following slides carry out the steps of the algorithm, and are self contained.
1 2- 2 5 3 6 5 5- +
3-
Add to the forward arcs of the basic cycle and subtract from the backward arcs.
Send as much flow as possible until one of the basic arcs has a flow of 0. How large can be?
25
Determine the exiting arc and the new spanning tree flow.
1 0 2- 2 5 3 6 4 7 5 3 5- + 2 7 6
= 2. Determine the new flows. Arc (6, 5) enters the basis. Arc (1, 2) leaves.
1 3-
At this point, we have a new spanning tree solution. We then compute the simplex multipliers and iterate.
26
Step 1. Start with a feasible spanning tree flow. Step 2. Compute the simplex multipliers and the reduced cost. If all reduced costs are non negative, then the flow is optimal. Otherwise, go to step 3. Step 3. Choose an arc (i, j) with negative reduced cost. Send as much flow as possible around the basic cycle. Then return to Step 2.
27
0 = 2 y6 + y5 6 5 0 = 2 y2 + y5 0 = 2 y2 + y4 0 = 1 y3 + y4
1
y2 3 y3 2
4
y4 1 y5 1
7
y6 3 y7 -2
0 = 5 y6 + y7
28
4
y4 4
1
y5 5
7
y6 6 y7 7
The current flow is not optimal. (Why?) Choose as the entering variable one that has a negative reduced cost.
29
-1
-2
7- Send as much flow as possible until one of the basic arcs has a flow of 0. How large can be?
30
Determine the exiting arc and the new spanning tree flow
1 3 5- 2 5 6
= 1. Determine the new flows. Arc (4, 7) enters the basis. Arc (2, 5) leaves.
0 - 1 4
3 2+ 7
6 5+ 3 6 1 +
6 7- At this point, we have a new spanning tree solution. We then compute the simplex multipliers.
31
0 = 2 y6 + y5 0 = 5 y6 + y7 0 = 1 y4 + y7 0 = 2 y2 + y4
y7 y7
2 5
1
y3 y3
4
y4 y4
1
y5 y5
7
y6 y6
-1
-2
0 = 1 y3 + y4
32
4
y4 4 y5 y5
7
y6 6 y7 7
-1
-2
33
The algorithm continues until there is an optimum spanning tree flow or a proof of unboundedness. In this case, it ended with an optimum spanning tree flow.
1 5+
13+ 5
2+ 4
7+ +
If the basic cycle is directed, then the min cost flow is unbounded from below.
34
The proof of unboundedness is when there is a negative cost cycle in which one can send an infinite amount of flow. The solution will never be unbounded from below if each arc has a finite capacity. But we are assuming infinite capacities for this lecture.
The network simplex algorithm is the simplex algorithm, but without the tableaus Bases correspond to spanning trees The basic feasible solution is found by sending flow in arcs The reduced costs are found by finding the simplex multipliers explicitly. The leaving arc is found by sending flow around a cycle.
35
z z
Of course, this is the simplex algorithm. And so, the issues are how can we interpret the simplex algorithm in this case, and why are there computational differences?
How does one find an initial bfs? A property of flows in spanning trees A property of simplex multipliers A property of reduced costs
36
Put a high cost on artificial arcs, say 1000 in this example. The optimal flow will have no flow on artificial arcs, and so will be optimal for the original problem.
37
In the lecture on the simplex algorithm, we described the Phase 1 method in which one tries to obtain a basic feasible solution. If we carried out the Phase 1 method, we would put a cost of 1 on each of the artificial arcs and a cost of 0 on all other arcs. But in this case, we can put a high cost on all artificial arcs in the expectation that none of them would have flow in an optimum solution. In fact, if c* is the largest cost of an arc in the original network, and if one puts a cost of nc* on all of the artificial arcs, one can guarantee that no artificial arc will have positive flow in an optimum solution except in the case that there is no feasible flow.
3 6
4 -11
7 -7
Deleting arc (i, j) splits the tree into two subtrees, Ti and Tj. The flow on arc (i, j) is the net supply in Ti.
For a given spanning tree flow, one can compute the flow in each arc of the spanning tree iteratively. However, there is also a more direct method. For example, the flow on arc (1, 2) is the total supply of the red nodes of this diagram. This is because the only way to satisfy the supply constraints at the red nodes is to ship the supply via arc (1, 2). The red nodes are obtained by removing arc (1, 2) from the network and finding all nodes that are connected to node 1. If one wants to understand an algorithm, it helps to understand it in more than one way. In this case, one can understand the flow in an arc from a global perspective such as above, or by considering the algorithm itself and how flows are allocated.
cost = 2
The cost of the cycle is the sum of the costs in the forward direction of the cycle minus the sum of the costs in the reverse direction.
39
It is standard to interpret the cost of a backward arc as the negative of the cost of an arc going in the other direction. If this point is confusing, think of sending flow around the cycle. To send one unit of flow around the basic cycle, we would need to 1. increase the flow in (4, 7), (6, 7), (1, 2), and (2, 4) by one unit, and 2. decrease the flow in (6, 7) by one unit. The net impact will be to increase the cost by $7 because of the forward arcs of the cycle, and also to decrease the cost by $5 because we are decreasing the cost in (6, 7) by $5. So, the net increase is $2.
1 2 2 4 1
y4 4 4 -3
3 5
0 6 5 0
The reduced cost of a cycle is the same as the cost of the cycle
7 2
y5 5 5 -3 y6 6 6 3 y7 7 7 -2
y1 1 1 0
40
If we choose the prices as the simplex multipliers, then all basic arcs have a cost of 0. Then the reduced cost of the cycle containing any nontree arc (i, j) is also the reduced cost of the cycle. For example, the reduced cost of the cycle 4-7-6-1-2-4 is $2, which is the reduced
cost of (4, 7).
We claim here that this is also the cost of the cycle.
The simplex algorithm works by sending flow around negative cost cycles. Recall
that to send a flow around a cycle C is to send increase the flow by in the forward
arcs of C and to decrease the flow by in the backward arcs of C.
$4
$1
1 -$2
$3
$1 3 $0
The reduced cost of a directed cycle is equal to the cost of the cycle.
$3 - $4 + $1
$1 - $1 + $0 -$2 -$0 + $4 3
41
This diagram shows why the cost of a cycle is the same as the reduced cost of a cycle. If we increase the price of node 1 by $k, then the price of the arc entering node 1 increases by $k and the price of the arc leaving node 1 decreases by $k. So changing the price of node 1 (or any other node) does not change the reduced cost of the cycle.
Another method for finding simplex multipliers for spanning tree flows
1 3 2 2 3
y1 0
Assume the multiplier for node 1 is 0. The multiplier for node j is the length of the path from node j to node 1 in the tree. e.g., the length of the path from node 4 to node 1 is 5 - 4 = 1.
42
2 5
4
y3 2 y4 1 y5 1
y2 3
y6 3
y7 -2
We compute the simplex multiplier for each node iteratively. But there is also a direct method for computing the simplex multiplier for node j. It is the cost of the unique path in the tree from node j to node 1. (This assumes that the multiplier for node 1 is 0.) We can illustrate why this works by focusing on node 3. The path from node 3 to node 1 passes through node 4. If we let yj be the cost of the path from node j to node 1, then we can conclude that y3 = y4 + 1. This implies that the reduced cost of (3, 4) is 0. Similarly, the reduced cost of every other arc of the tree is 0. But since the simplex multipliers are the unique values that make the reduced costs of tree arcs equal to 0, it follows that vector y is the vector of simplex multipliers.
It is a lot faster than the usual simplex algorithm. The number of pivots is the same, but each pivot is much faster It gives another view of the simplex algorithm, and its operations. It shows how network algorithms can be much faster.
2.
3.
43
44