Lecture 2 ShortestPath Problems Assignment Problems Transportation Problems
Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems 1
Agenda èshortest-path problems èassignment problems ètransportation problems ètransshipment problems 2
Yet Another Simple Concrete Numerical Example è obvious shortest path between node 1 and node 4 2 3 2 1 6 è 5 3 4 1 But how to formulate? What is the direction of flow in the middle arc, upward or downward? Or any flow at all? min length of path s. t. a set of constraints representing a path 3
Yet Another Simple Concrete Numerical Example è a route from the source to the sink = a collection of arcs from the source to the sink 2 3 2 5 2 1 6 3 3 4 1 è some 2 5 2 1 6 3 3 4 1 5 2 1 6 3 4 1 restriction on the choice of arcs in to form a path è question: How to define the values of a group of xij such that xijs form a route from the source to the sink? 2 3 5 2 1 4 6 3 1 4
Yet Another Simple Concrete Numerical Example è properties of a route from the source to the sink: èeach route represented by a collection of xij = 1, with the other off-route variables = 0 èsource: èsink: 2 one arc out one arc in èintermediate 3 6 6 3 4 2 1 6 1 5 3 4 1 2 5 2 1 3 3 node: one arc in and one arc out 2 3 5 2 1 2 3 4 1 5 2 1 6 3 4 1 5
Formulation 2 3 2 1 6 è min 5 3 x 12 + 6 x 13 + 2(x 23+x 32) + 5 x 24 + x 34, 3 4 1 s. t. x 12 + x 13 = 1 (node 1, source) x 12 + x 32 = x 23 + x 24 (node 2) x 13 + x 23 = x 32 + x 34 (node 3) x 24 + x 34 = 1 (node 4, sink) x 12, x 13, x 32, x 24, x 34 {0, 1} 選最node 1到node 4最短徑,就像將一單位 (1 unit)的水從node 1送到node 4,水流 過的arcs就是在路徑上的arcs. 6
Formulation - Question è min 3 x 12 + 6 x 13 + 2(x 23+x 32) + 5 x 24 + x 34, s. t. x 12 + x 13 = 1 (node 1, source) 3 x 12 + x 32 = x 23 + x 24 (node 2) 1 x 13 + x 23 = x 32 + x 34 (node 3) 6 x 24 + x 34 = 1 (node 4, sink) x 12, x 13, x 32, x 24, x 34 {0, 1} both x 23 and x 32 be positive at minimum? 2 5 2 3 4 1 è Would 7
Formulation è 3 tricks in our formulation only outflow from source node è only inflow to destination node è è 2 5 2 1 6 3 4 1 variables x 21, x 31, x 42, and x 43 set to zero in the textbook è min 3(x 12+x 21) + 6(x 13+x 31) + 2(x 23+x 32) + 5(x 24+x 42) + (x 34+x 43), s. t. x 12 + x 13 = 1 (node 1, source) x 12 + x 32 + x 42 = x 21 + x 23+x 24 (node 2) x 13 + x 23 + x 43 = x 31 + x 32 + x 34 (node 3) x 24 + x 34 = 1 (node 4, destination) x 12, x 13, x 32, x 24, x 34 {0, 1}; x 21 = x 31 = x 42 = x 43 = 0 8
Formulation - Question è Would the following formulation be all right? è min 3(x 12+x 21) + 6(x 13+x 31) + 2(x 23+x 32) + 5(x 24+x 42) + (x 34+x 43), s. t. x 12 + x 13 = 1 (node 1, source) x 12 + x 32 + x 42 = x 21 + x 23+x 24 (node 2) x 13 + x 23 + x 43 = x 31 + x 32 + x 34 (node 3) x 24 + x 34 = 1 (node 4, destination) 2 3 5 2 1 6 3 4 1 x 12, x 13, x 32, x 24, x 34 , x 21, x 31, x 42, x 43 {0, 1} 9
Formulation è the formulation for the shortest distance between node 1 and node 6: è Min z = 5(x 12+x 21)+8(x 13+x 31)+7(x 14+x 41)+6(x 23+x 32)+1(x 34+x 43)+13(x 25+x 52) +7(x 35+x 53)+16(x 46+x 64)+6(x 56+x 65) s. t. (i. e. , subject to): x 12+x 13+x 14 = 1 (source node) x 12+x 32+x 52 = x 21+x 23+x 25 (node 2) x 13+x 23+x 43+x 53 = x 31+x 32+x 34+x 35 (node 3) x 14+x 34+x 64 = x 41+x 43+x 46 (node 4) x 25+x 35+x 65 = x 52+x 53+x 56 (node 5) x 56+x 46 = 1 (node 6) xij = 0 or 1 for all i, j combinations Actually it is possible to drop the red variables. 10
Assignment Problems 11
An Assignment Problem è 4 jobs, J 1 to J 4, are assigned to 4 machines, M 1 to M 4, such that each machine can handle exactly 1 job è è è implicitly each job is assigned only to one machine the costs of assigning machine i to job j are shown in the RHS matrix, where M denotes a feasible but expensive assignment find the assignment that minimizes the total assignment cost J 1 J 2 J 3 J 4 M 1 9 M 13 8 M 2 14 12 7 M M 3 M 5 M 6 M 4 10 7 6 11 12
An Assignment Problem èlet xij = 1 if machine i takes up job j, and = 0, otherwise, i = 1, 2, 3, 4, j = 1, 2, 3, 4 J 1 J 2 J 3 J 4 M 1 9 M 13 8 M 2 14 12 7 M M 3 M 5 M 6 M 4 10 7 6 11 (each machine has one job) (each job is assigned to one machine) 13
Comments è an assignment problem is easy to solve è if there any additional constraints other than those shown in a standard assignment model, the resulted model is no longer an assignment problem, which may be difficult to solve 14
Exercise 1 èCan we omit variables xij if the corresponding cij = M, where M is a large positive number practically representing infinity? èphysical meaning: setting such xij to zero J 1 J 2 J 3 J 4 M 1 9 M 13 8 M 2 14 12 7 M M 3 M 5 M 6 M 4 10 7 6 11 15
Exercise 2 èFormulate a model for the 4 -machine, 4 job problem such that each machine can take exact one job and jobs J 1 and J 2 must not be assigned to M 4. J 1 J 2 J 3 J 4 M 1 9 M 13 8 M 2 14 12 7 M M 3 M 5 M 6 M 4 10 7 6 11 16
Exercise 2 èFormulate a model for the 4 -machine, 4 job problem such that each machine can take exact one job and jobs J 1 and J 2 must not be assigned to M 4. J 1 J 2 J 3 J 4 M 1 9 M 13 8 M 2 14 12 7 M M 3 M 5 M 6 M 4 10 7 6 11 17
Exercise 3 èSuppose that there are 5 jobs and 4 machines. Formulate an assignment model that finds the cheapest way to assign 4 out of the 5 jobs to the 4 machines, with each machine taking J 1 J 2 J 3 J 4 J 5 exactly one job. M 1 9 4 13 8 21 M 2 14 12 7 9 3 M 3 7 5 5 6 14 M 4 10 7 6 11 17 18
Exercise 4 èSuppose that there are 5 jobs and 4 machines. Formulate a model that finds the cheapest way to assign all 5 jobs to the 4 machines such that only one of the 4 machines takes 2 jobs. J 1 J 2 J 3 J 4 J 5 M 1 9 4 13 8 21 M 2 14 12 7 9 3 M 3 7 5 5 6 14 M 4 10 7 6 11 17 19
Exercise 5 èSuppose that there are 5 jobs and 4 machines. Formulate a model that finds the cheapest way to assign all 5 jobs to the 4 machines such that M 2 takes 2 jobs and the other machines take one job. J 1 J 2 J 3 J 4 J 5 M 1 9 4 13 8 21 M 2 14 12 7 9 3 M 3 7 5 5 6 14 M 4 10 7 6 11 17 20
Exercise 6 èSuppose that there are 5 jobs and 4 machines. Formulate a model that finds the cheapest way to assign all 5 jobs to the 4 machines such that each machine can take at most 2 jobs. J 1 J 2 J 3 J 4 J 5 M 1 9 4 13 8 21 M 2 14 12 7 9 3 M 3 7 5 5 6 14 M 4 10 7 6 11 17 21
Exercise 7 èFormulate a model that finds the shortest paths from nodes 1 and 2 to node 6 2 11 7 1 9 3 8 14 4 5 4 6 6 3 5 22
Transportation Problems 23
Transportation Problem è two suppliers, A and B 60 60 units from A è 40 units from B è è three customers, C, D, and E 20 units for C è 45 units for D è 25 units for E è è è 3 5 A C 2 40 D 1 20 45 8 B 6 E 25 unit cost cij for unit flow from supplier i to customer j as labeled on diagram, e. g. , $5 (= c. AD) for each unit from A to D objective: minimize the total cost to satisfy the requirement 24
Transportation Problem 60 è steps 2 of modeling è define variables 3 5 A C 40 è express D 1 20 45 8 B 6 the objective function in terms of the variables and parameters E 25 è express the constraints in terms of the variables and parameters 25
Transportation Problem 60 trick to define variables: what decisions are made? 3 5 A C 2 è one 40 è answer: the amount of goods sent from supplier i to customer j D 1 20 45 8 B 6 E 25 è let xij = amount of goods sent from supplier i to customer j, i = A, B; j = C, D, F 26
Transportation Problem è objective è min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE è constraints è supply 60 3 5 A C 2 40 from A: x. AC + x. AD + x. AE ≤ 60 è supply from B: x. BC + x. BD + x. BE ≤ 40 è demand of C: x. AC + x. BC = 20 è demand of D: x. AD + x. BD = 45 è demand of E: x. AE + x. BE = 25 è non-negativity: x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0 D 1 20 45 8 B 6 E 25 27
Questions 60 2 40 è is the formulation correct? ècan 3 5 A 20 C 45 D 1 8 B 6 25 E we use x. AC + x. BC 20, x. AD + x. BD 45, x. AE + x. BE 25 instead? è what does it mean by can or cannot? min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE, s. t. x. AC + x. AD + x. AE ≤ 60, x. BC + x. BD + x. BE ≤ 40, x. AC + x. BC = 20, x. AD + x. BD = 45, x. AE + x. BE = 25, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0. 28
Questions min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE, s. t. x. AC + x. AD + x. AE = 60, è can we use x. BC + x. BD + x. BE = 40, 60 3 5 A C 2 40 D 1 20 45 8 B 6 E 25 x. AC + x. BC 20, x. AD + x. BD 45, x. AE + x. BE 25, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0. min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE, s. t. è can we use x. AC + x. AD + x. AE = 60, x. BC + x. BD + x. BE = 40, x. AC + x. BC = 20, x. AD + x. BD = 45, x. AE + x. BE = 25, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0. 29
60 Questions A B 45 D 1 40 20 C 3 5 8 6 25 E è how to model: impossible to send goods from A to E è setting c. AE to è numerically c. AE = M, a large positive number min 3 x. AC + 5 x. AD + Mx. AE + x. BC + 8 x. AD + 6 x. AE, s. t. 60 x. AC + x. AD + x. AE ≤ 60, M x. BC + x. BD + x. BE ≤ 40, x. AC + x. BC = 20, x. AD + x. BD = 45, x. AE + x. BE = 25, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0. 3 5 A C 40 D 1 20 45 8 B 6 E 25 30
Questions è how to model: impossible to send goods from A to E è omitting x. AE (i. e. , setting to x. AE = 0) min 3 x. AC + 5 x. AD + x. BC + 8 x. AD + 6 x. AE, s. t. x. AC + x. AD ≤ 60, x. BC + x. BD + x. BE ≤ 40, 60 3 5 A x. AC + x. BC = 20, x. AD + x. BD = 45, x. BE = 25, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE 0. 40 D 1 B C 20 45 8 6 E 25 31
Balanced Transportation Problems èa balanced transportation problem: supply = total demand total è computational advantages for a balanced transportation problem è possible to transform any imbalanced transportation problem to a balanced one 32
To Transform into a Balanced Transportation Problem è total supply = 100 90 = total demand è adding a dummy customer T è what is b. T? è what is c. AT? è what 60 2 40 60 C 3 5 A 40 D 1 B 20 D 1 45 6 c. BT 25 c. AT T 45 6 8 E 20 8 B E 2 is c. BT? 3 5 A C b. T 33 25
To Transform into a Balanced Transportation Problem è b. T = 100 90 = 10 è can c. AT è what è can c. AT è the = 0 and c. BT = 0? does it mean by can or cannot? = 19 and c. BT = 19? 60 C 3 5 A 2 40 D 1 B 20 45 8 6 E c. BT = 19 and c. BT = 31? 25 c. AT T b. T same trick for total supply total demand 34
Comments min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE, s. t. 60 x. BC + x. BD + x. BE + x. BT = 40, x. AC + x. BC = 20, 3 5 A x. AC + x. AD + x. AE + x. AT = 60, C 2 40 D 1 B 45 8 6 E x. AD + x. BD = 45, x. AE + x. BE = 25, 20 0 25 0 T 10 x. AT + x. BT = 10, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE, x. AT, x. BT 0. 35
A General Transportation Problem èm suppliers èn customers è quantity supplied by supplier i, ai è quantity demanded by customer j, bj è cost of unit flow from supplier i to customer j, cij è objective: minimize the total shipment cost 36
Special Structure for the Set of Constraints è very special property: as long as all ai and bj are integral, the minimum solution is integral è no need to use integer programming x. AC x. AD x. AE x. AT = 60, x. BC x. BD x. BE x. BT x. AC + x. BC x. AD x. AE = 45, + x. BE x. AT = 25, + x. BT x. AC, x. AD, x. AE, x. BC, x. AD, x. AE, x. AT, x. BT 0. = 10, 3 5 A 2 = 40, = 20, + x. BD 60 C 40 D 1 B 20 45 8 6 E c. BT 25 c. AT T 37 b. T
Solution of a Transportation Problem è at least three approaches è linear programming, Simplex method by CPLEX, Gurobi è special transportation Simplex by Dantzig (1951) (for balanced transportation problems) è basically Simplex, but specialized steps because of the special structure of the problem min 3 x. AC + 5 x. AD + 2 x. AE + x. BC + 8 x. AD + 6 x. AE, s. t. x. AC + x. AD + x. AE + x. AT = 60, x. BC + x. BD + x. BE + x. BT = 40, x. AC + x. BC = 20, x. AD + x. BD = 45, x. AE + x. BE = 25, x. AT + x. BT = 10, x. AC, x. AD, x. AE, x. BC, x. AD, x. AE, x. AT, x. BT 0. è network flow algorithm, Ford and Fulkerson (1956, 1962) 38
Example 5. 3 of [7] è transportation problems occurring in many contexts, not necessarily transportation è production capacities and demands in the next four months è unit cost of production at regular time = $1 è unit cost of production at overtime = $1. 5 è storage cost = $0. 3 per month per unit è how to produce to satisfy the demands in the four months with minimum total cost Jan Feb March April Capacity in Regular Time (pcs) 100 150 140 160 Capacity in Overtime (pcs) 50 75 70 80 Demand (pcs) 80 200 300 200 39
Example 5. 3 of [7] è possible Jan Feb March April to model as a transportation problem Jan Feb March April Regular 1 1. 3 1. 6 1. 9 Overtime 1. 5 1. 8 2. 1 2. 4 Regular 1 1. 3 1. 6 Overtime 1. 5 1. 8 2. 1 Regular 1 1. 3 Overtime 1. 5 1. 8 Regular 1 Overtime 1. 5 40
Capacitated Transportation Problems è lower è 0 and upper bounds for xij ≤ lij ≤ xij ≤ uij è solved by extensions of the specialized algorithms 41
- Slides: 41