Professional Documents
Culture Documents
html
Introduction
The Hungarian Algorithm for the Transportation Problem is also a primal-dual Simplex method
Pseudo code:
Recall the Transportation Problem ships products from factories to the warehouses
Capacity of an edge in the Transportation Problem = residual capacity of the warehouse connected to that edge
Example:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 1/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Example:
Result:
Note:
When the capacity (demand) of a warehouse is reduced, the capacity of its attached edges are also reduced
Example:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 2/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
(We just apply the definition of the flow augmenting path to the Transportation bi-partite graph:
Cost Matrix:
| b1 b2 b3
----+------------------
A1 | 3 5 7
A2 | 6 4 3
Initial step:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 3/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
2. subtract its weight from all weights connected with that vertex.
You will get at least one 0-weight edges for each node.
Example:
Min. weight edge of each node ∈ X After subtracting cost from other edges
| b1 b2 b3 | b1 b2 b3
----+------------------ ----+------------------
A1 | 3 5 7 A1 | 0 2 4
A2 | 6 4 3 A2 | 3 1 0
2. subtract its weight from all weights connected with that vertex.
You may get more 0-weight edges (and you not get any more)
Example:
Min. weight edge of each node ∈ X After subtracting cost from other edges
| b1 b2 b3 | b1 b2 b3
----+------------------ ----+------------------
A1 | 0 2 4 A1 | 0 1 4
A2 | 3 1 0 A2 | 3 0 0
Consider the subgraph consisting only of the 0-weight edges after step 0:
Note:
Just as in the Assignment Problem, the 0-weight edges will provide the lowest possible cost if we can maximum flow
(satisfying all the supplies in set X
Important:
We are trying to find a maximal flow in the subgraph consisting only of the 0-weight edges
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 4/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Remember that:
A very simple way to find flow augmenting paths in the Transportation subgraph:
This is because a forward edge can always be part of a flow augmenting path:
If a forward edge is saturated, it can be part of a flow augmenting path by reducing the flow backwards
label all adjacent unlabeled vertices xi ∈ X with the label "yj" if edge (xi, yj) has flow > 0
Because we will use this edge only as a backward edge and as such, it can only be flow augmenting if flow > 0
Trace starting from vertex xi back to the "*" vertex to find the flow augmenting path
2. OR: after the labeling procedure terminates, there are no labeled vertices xi with demand > 0
We use the same algorithm as in the Assignment Problem to add new edges to the subgraph
Example:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 5/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
*
| b1 b2 b3
----+------------------
* A1 | 0 1 4
A2 | 3 0 0
Note:
The graph (in table form) includes the labels made by the last step of the max. flow algorithm
But in this case, we are not done (yet) and enter the iterative step
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 6/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Iterative step:
Add the "next least cost edge(s)" to the subgraph (it's more complex that just finding the smallest cost, because you have to
consider the effect of other nodes) and
Iterative step:
Iterative step (only doen when the matching is not maximum (complete)):
1. Look in the full bi-partite graph (with the label of the maximum flow algorithm added):
*
| b1 b2 b3
----+------------------
* A1 | 0 1 4
A2 | 3 0 0
2. Find all edges (with cost > 0) going from a labeled vertex ∈ X to an unlabeled vertex ∈ Y
*
| b1 b2 b3
----+------------------
* A1 | 0 1 4
A2 | 3 0 0
δ=1
3. For each edge with cost > 0 such that: labeled vertex ∈ X → unlabeled vertex ∈ Y:
For each edge with cost > 0 joining an unlabeled vertex ∈ X → labeled vertex ∈ Y :
(This addition and subtraction is actually a pivoting operation in the Simplex Algorithm !!)
Example:
Before any operations After the subtract step After the addition step
* * *
| b1 b2 b3 | b1 b2 b3 | b1 b2 b3
---+--------------- ---+--------------- ---+---------------
* A1 | 0 1 4 * A1 | 0 0 3 * A1 | 0 0 3
A2 | 3 0 0 A2 | 3 0 0 A2 | 4 0 0
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 7/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Find a Flow Augmenting Path After augmenting flow
Problem description:
| b1 b2 b3 b4
----+---------------------
a1 | 5 4 7 6
a2 | 2 5 3 2
a3 | 6 3 4 4
Solution:
Initialization:
1. Subtract the least cost of each vertex ∈ X from all weights connected to that vertex
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 8/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Subtract the smallest value in each row from all other values in that row
Result:
| b1 b2 b3 b4 | b1 b2 b3 b4
----+--------------------- ----+---------------------
a1 | 5 4 7 6 a1 | 1 0 3 2
a2 | 2 5 3 2 a2 | 0 3 1 0
a3 | 6 3 4 4 a3 | 3 0 1 1
2. Subtract the least cost of each vertex ∈ Y from all weights connected to that vertex
Subtract the smallest value in each column from all other values in that row
Result:
| b1 b2 b3 b4 | b1 b2 b3 b4
----+--------------------- ----+---------------------
a1 | 1 0 3 2 a1 | 1 0 2 2
a2 | 0 3 1 0 a2 | 0 3 0 0
a3 | 3 0 1 1 a3 | 3 0 0 1
Initial Subgraph:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 9/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
* *
| b1 b2 b3 b4
----+---------------------
* a1 | 1 0 2 2
a2 | 0 3 0 0
* a3 | 3 0 0 1
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 10/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Iteration 1:
* *
| b1 b2 b3 b4
----+---------------------
* a1 | 1 0 2 2
a2 | 0 3 0 0
* a3 | 3 0 0 1
δ = 1
Result: Result:
* * * *
| b1 b2 b3 b4 | b1 b2 b3 b4
----+--------------------- ----+---------------------
* a1 | 0 0 2 1 * a1 | 0 0 2 1
a2 | 0 3 0 0 a2 | 0 4 0 0
* a3 | 2 0 0 0 * a3 | 2 0 0 0
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 11/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 12/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 13/14
6/14/2019 www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html
Note:
www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Transportation/algorithm.html 14/14