math models of or: variants of transportation...
TRANSCRIPT
Math Models of OR:Variants of Transportation Problems
John E. Mitchell
Department of Mathematical SciencesRPI, Troy, NY 12180 USA
October 2018
Mitchell Variants of Transportation Problems 1 / 22
The assignment problem
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 2 / 22
The assignment problem
The assignment problemWe have n workers and n jobs.
Each worker is assigned to exactly one job.
There is a cost cij for assigning worker i to job j .
What is the minimum cost assignment?
Formulate as a binary integer program:
minx∈IRm×n∑m
i=1∑n
j=1 cijxij
subject to∑n
j=1 xij = 1 i = 1, . . . ,m(each worker has one job)∑m
i=1 xij = 1 j = 1, . . . ,n(each job has one worker)
xij binary i = 1, . . . ,m, j = 1, . . . ,n
Mitchell Variants of Transportation Problems 3 / 22
The assignment problem
Relax the binary requirementThe linear optimization relaxation of this problem is obtained byreplacing the restriction that each xij be binary by the constraints0 ≤ xij ≤ 1.
Further, the equality constraints force all xij ≤ 1, so these upper boundconstraints are redundant and can be omitted.
This gives the relaxation:
minx∈IRm×n∑m
i=1∑n
j=1 cijxij
subject to∑n
j=1 xij = 1 i = 1, . . . ,m∑mi=1 xij = 1 j = 1, . . . ,n
xij ≥ 0 i = 1, . . . ,m, j = 1, . . . ,n
This is a transportation problem.
Mitchell Variants of Transportation Problems 4 / 22
The assignment problem
It suffices to solve the relaxation
As we saw earlier, this problem can be solved by the simplex algorithm.
Further, because of the structure of the problem, all the basicfeasible solutions are integral when the supply ai and demand bjquantities are integral:the initial solution found by the northwest corner rule is integral,and all the updates are integral since they push an integral amount offlow around a cycle.
Thus, we can solve the assignment problem by solving itsrelaxation.
Mitchell Variants of Transportation Problems 5 / 22
An example assignment problem
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 6 / 22
An example assignment problem
An example problemOur example problem has costs
workers
jobs7 51 40 64 5 8 71
41 6 60 85 4 11 20
We used a greedy approach to find an initial feasible solution: pick thecheapest available job, until all the workers have jobs. So we make thefollowing assignments in order:
x43 = 1, x31 = 0, x12 = 1, x24 = 1.
We then obtain a basic feasible solution by adding three edges asbasic variables with xij = 0.
Mitchell Variants of Transportation Problems 7 / 22
An example assignment problem
An example problemOur example problem has costs
workers
jobs7 51 40 64 5 8 71
41 6 60 85 4 11 20
We used a greedy approach to find an initial feasible solution: pick thecheapest available job, until all the workers have jobs. So we make thefollowing assignments in order:
x43 = 1, x31 = 0, x12 = 1, x24 = 1.
We then obtain a basic feasible solution by adding three edges asbasic variables with xij = 0.
Mitchell Variants of Transportation Problems 7 / 22
An example assignment problem
An example problemOur example problem has costs
workers
jobs7 51 40 64 5 8 71
41 6 60 85 4 11 20
We used a greedy approach to find an initial feasible solution: pick thecheapest available job, until all the workers have jobs. So we make thefollowing assignments in order:
x43 = 1, x31 = 0, x12 = 1, x24 = 1.
We then obtain a basic feasible solution by adding three edges asbasic variables with xij = 0.
Mitchell Variants of Transportation Problems 7 / 22
An example assignment problem
An example problemOur example problem has costs
workers
jobs7 51 40 64 5 8 71
41 6 60 85 4 11 20
We used a greedy approach to find an initial feasible solution: pick thecheapest available job, until all the workers have jobs. So we make thefollowing assignments in order:
x43 = 1, x31 = 0, x12 = 1, x24 = 1.
We then obtain a basic feasible solution by adding three edges asbasic variables with xij = 0.
Mitchell Variants of Transportation Problems 7 / 22
An example assignment problem
An example problemOur example problem has costs
workers
jobs7 51 40 64 5 8 71
41 6 60 85 4 11 20
We used a greedy approach to find an initial feasible solution: pick thecheapest available job, until all the workers have jobs. So we make thefollowing assignments in order:
x43 = 1, x31 = 0, x12 = 1, x24 = 1.
We then obtain a basic feasible solution by adding three edges asbasic variables with xij = 0.
Mitchell Variants of Transportation Problems 7 / 22
An example assignment problem
Initial BFS
The initial basic feasible solution is illustrated below; note that itconstitutes a spanning tree. It has value 5 + 7 + 4 + 1 = 17.
s4
s3
s2
s1
d4
d3
d2
d1x12 = 1x13 = 0
x24 = 1
x31 = 1
x33 = 0
x43 = 1x44 = 0
workers jobs
Mitchell Variants of Transportation Problems 8 / 22
Solve the assignment problem example
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 9 / 22
Solve the assignment problem example First iteration
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 10 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find dual variablesWe first find the dual variables. We have dual variables u1, i = 1, . . . ,4for the workers, and dual variables vj , j = 1, . . . ,4 for the jobs. Thedual variables satisfy
ui + vj = cij for basic xij .
We set u1 = 0 and then determine the other dual variables through achain reaction.
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
Mitchell Variants of Transportation Problems 11 / 22
Solve the assignment problem example First iteration
Find reduced costs
workers
jobs7 51 40 6 u1 = 04 5 8 71 u2 = 241 6 60 8 u3 = 25 4 11 20 u4 = −3v1 = 2 v2 = 5 v3 = 4 v4 = 5
We can now find the reduced costs from
reduced cost is cij − ui − vj
workers
jobs5 01 00 10 −2 2 01
01 −1 00 16 2 01 00
Mitchell Variants of Transportation Problems 12 / 22
Solve the assignment problem example First iteration
Simplex directionThe nonbasic variable x22 has reduced cost −2, so we bring it into thebasis. The edge completes a unique cycle, with the other edges in thecycle being some of the current basic variables. The cycle is
s2 → d2 → s1 → d3 → s4 → d4 → s2.
We adjust flow around the cycle.
s4
s3
s2
s1
d4
d3
d2
d1x12 = 1−tx13 = 0+t
x22 = t
x24 = 1−t
x31 = 1
x33 = 0
x43 = 1−tx44 = 0+t
workers jobs
5 01−t 00+t 10 −2t 2 01−t
01 −1 00 16 2 01−t 00+t
Mitchell Variants of Transportation Problems 13 / 22
Solve the assignment problem example First iteration
PivotThe largest possible value of t is t = 1. We have a choice of variable toleave the basis: with t = 1, we get x12 = x24 = x43 = 0. We arbitrarilychoose x12 to become nonbasic. We can update the primal solutionand then update the dual solution.
s4
s3
s2
s1
d4
d3
d2
d1
x13 = 1
x22 = 1
x24 = 0
x31 = 1
x33 = 0
x43 = 0x44 = 1
workers jobs
Mitchell Variants of Transportation Problems 14 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Update reduced costs
workers
jobs5 0 01 1 u1 = 00 −21 2 00 u2 = 001 −1 00 1 u3 = 06 2 00 01 u4 = 0v1 = 0 v2 = −2 v3 = 0 v4 = 0
c̄ij ← c̄ij − ui − vj workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Mitchell Variants of Transportation Problems 15 / 22
Solve the assignment problem example First iteration
Optimal solution
workers
jobs5 2 01 10 01 2 00
01 1 00 16 4 00 01
Since all the reduced costs are nonnegative, we are optimal. Theoptimal assignment is:
worker 1 does job 3,worker 2 does job 2,worker 3 does job 1,worker 4 does job 4.Total cost is 4 + 5 + 4 + 2 = 15.
Mitchell Variants of Transportation Problems 16 / 22
Variants of the transportation problem
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 17 / 22
Variants of the transportation problem Unequal supply and demand
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 18 / 22
Variants of the transportation problem Unequal supply and demand
Unequal supply and demand
A transportation problem has m sources supplying ai for source i andn destinations with demands bj . So far, we’ve assumed total supplyand total demand are equal.
If they are not equal, we can introduce a dummy node, with costscij = 0 to ship in or out of the dummy node. For example
sources
destinations40 20 30
50 5 2 170 1 3 4
total supply: 120total demand: 90
Mitchell Variants of Transportation Problems 19 / 22
Variants of the transportation problem Unequal supply and demand
Introduce dummy node
We introduce a dummy demand node with demand 30.
sources
destinations40 20 30 30
50 5 2 1 070 1 3 4 0
total supply: 120total demand: 120
The excess supply is shipped to the dummy demand node.
Mitchell Variants of Transportation Problems 20 / 22
Variants of the transportation problem Unusable edges
Outline
1 The assignment problem
2 An example assignment problem
3 Solve the assignment problem exampleFirst iteration
4 Variants of the transportation problemUnequal supply and demandUnusable edges
Mitchell Variants of Transportation Problems 21 / 22
Variants of the transportation problem Unusable edges
Unusable edgesIt may be that some edges cannot be used. These edges can be giveninfinite cost. In an implementation, we need to choose a finite value,typically called a big-M value.
This should be large enough so that an optimal solution does not usethe edge.
One possibility is to choose the big-M to be at least as large as thesum of all the other edge costs.
40 40 2020 1 2 150 4 2 −30 2 5 3
Edge (2,3)not usable
40 40 2020 1 2 150 4 2 2530 2 5 3
Set c23 >∑
ofother edge weights
Mitchell Variants of Transportation Problems 22 / 22