41
1 Lecture 2 Lecture 2 Shortest-Path Problems Shortest-Path Problems Assignment Problems Assignment Problems Transportation Problems Transportation Problems

1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

Embed Size (px)

Citation preview

Page 1: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

1

Lecture 2 Lecture 2 Shortest-Path Problems Shortest-Path Problems

Assignment ProblemsAssignment ProblemsTransportation ProblemsTransportation Problems

Page 2: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

2

AgendaAgenda

shortest-path problems shortest-path problems

assignment problemsassignment problems

transportation problems transportation problems

transshipment problemstransshipment problems

Page 3: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

3

Yet Another Simple Concrete Yet Another Simple Concrete Numerical ExampleNumerical Example

obvious shortest path between node 1 and node 4

But how to formulate? What is the direction of flow in

the middle arc, upward or downward? Or any flow at

all?

1

2

5

6

3

1

2

4

3

min length of paths.t. a set of constraints representing a path

Page 4: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

4

Yet Another Simple Concrete Yet Another Simple Concrete Numerical ExampleNumerical Example

a route from the source to the sink = a collection of arcs from the source to the sink

some 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?

1

25

6

3

1

2

4

3 1

25

6

3

1

2

4

31

25

6

3

1

2

4

3 1

25

6

3

1

2

4

3

12

5

6

31

2

43

Page 5: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

5

Yet Another Simple Concrete Yet Another Simple Concrete Numerical ExampleNumerical 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: one arc out

sink: one arc in

intermediate node: one arc in and one arc out

1

25

6

3

1

2

4

3

1

25

6

3

1

2

4

31

25

6

3

1

2

4

3

1

25

6

3

1

2

4

3

Page 6: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

6

FormulationFormulation

min 3x12 + 6x13 + 2(x23+x32) + 5x24 + x34,

s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 = x23 + x24 (node 2)

x13 + x23 = x32 + x34 (node 3)

x24 + x34 = 1 (node 4, sink)

x12, x13, x32, x24, x34 {0, 1}

1

2

5

6

3

1

2

4

3

選最 node 1 到 node 4最短徑,就像將一單位( 1 unit)的水從 node 1送到 node 4,水流過的 arcs就是在路徑上的 arcs.

Page 7: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

7

Formulation - QuestionFormulation - Question

min 3x12 + 6x13 + 2(x23+x32) + 5x24 + x34,

s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 = x23 + x24 (node 2)

x13 + x23 = x32 + x34 (node 3)

x24 + x34 = 1 (node 4, sink)

x12, x13, x32, x24, x34 {0, 1}

Would both x23 and x32 be positive at minimum?

1

2

5

6

3

1

2

4

3

Page 8: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

8

FormulationFormulation tricks in our formulation

only outflow from source node only inflow to destination node variables x21, x31, x42, and x43 set to zero in the textbook

min 3(x12+x21) + 6(x13+x31) + 2(x23+x32) + 5(x24+x42) + (x34+x43),s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 + x42 = x21 + x23+x24 (node 2)

x13 + x23 + x43 = x31 + x32 + x34 (node 3)

x24 + x34 = 1 (node 4, destination)

x12, x13, x32, x24, x34 {0, 1}; x21 = x31 = x42 = x43 = 0

1

2

5

6

3

1

2

4

3

Page 9: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

9

Formulation - QuestionFormulation - Question Would the following formulation be all right?

min 3(x12+x21) + 6(x13+x31) + 2(x23+x32) + 5(x24+x42) + (x34+x43),s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 + x42 = x21 + x23+x24 (node 2)

x13 + x23 + x43 = x31 + x32 + x34 (node 3)

x24 + x34 = 1 (node 4, destination)

x12, x13, x32, x24, x34 , x21, x31, x42, x43 {0, 1}

1

2

5

6

3

1

2

4

3

Page 10: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

10

FormulationFormulation the formulation for the shortest distance between node 1 and node 6:

Min z = 5(x12+x21)+8(x13+x31)+7(x14+x41)+6(x23+x32)+1(x34+x43)+13(x25+x52) +7(x35+x53)+16(x46+x64)+6(x56+x65)

s.t. (i.e., subject to):

x12+x13+x14 = 1 (source node)

x12+x32+x52 = x21+x23+x25 (node 2)

x13+x23+x43+x53 = x31+x32+x34+x35 (node 3)

x14+x34+x64 = x41+x43+x46 (node 4)

x25+x35+x65 = x52+x53+x56 (node 5)

x56+x46 = 1 (node 6)

xij = 0 or 1 for all i, j combinations

Actually it is possible to drop the red variables.

Page 11: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

11

Assignment ProblemsAssignment Problems

Page 12: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

12

An Assignment ProblemAn Assignment Problem

4 jobs, J1 to J4, are assigned to 4 machines, M1 to M4, 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

J1 J2 J3 J4

M1 9 M 13 8

M2 14 12 7 M

M3 M 5 M 6

M4 10 7 6 11

Page 13: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

13

An Assignment ProblemAn Assignment Problem

let xij = 1 if machine i takes up job j, and

= 0, otherwise, i = 1, 2, 3, 4, j = 1, 2, 3, 4J1 J2 J3 J4

M1 9 M 13 8

M2 14 12 7 M

M3 M 5 M 6

M4 10 7 6 11

4 4

1 1

4

1

4

1

min ,

. .

1, 1,...,4;

1, 1,...,4;

{0,1}, , 1,...,4

ij iji j

ijj

iji

ij

c x

s t

x i

x j

x i j

(each machine has one job)

(each job is assigned to one machine)

Page 14: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

14

CommentsComments

an assignment problem is easy to solve

if there are 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

1 1

1

1

min ,

. .

1, 1,..., ;

1, 1,..., ;

{0,1}, , 1,...,

n n

ij iji j

n

ijj

n

iji

ij

c x

s t

x i n

x j n

x i j n

Page 15: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

15

Exercise 1Exercise 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 zeroJ1 J2 J3 J4

M1 9 M 13 8

M2 14 12 7 M

M3 M 5 M 6

M4 10 7 6 11

Page 16: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

16

Exercise 2Exercise 2

Formulate a model for the 4-machine, 4-

job problem such that each machine can

take exact one job and jobs J1 and J2

must not be assigned to M4. J1 J2 J3 J4

M1 9 M 13 8

M2 14 12 7 M

M3 M 5 M 6

M4 10 7 6 11

Page 17: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

17

Exercise 2Exercise 2

Formulate a model for the 4-machine, 4-

job problem such that each machine can

take exact one job and jobs J1 and J2

must not be assigned to M4. J1 J2 J3 J4

M1 9 M 13 8

M2 14 12 7 M

M3 M 5 M 6

M4 10 7 6 11

Page 18: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

18

Exercise 3Exercise 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

exactly one job. J1 J2 J3 J4 J5

M1 9 4 13 8 21

M2 14 12 7 9 3

M3 7 5 5 6 14

M4 10 7 6 11 17

Page 19: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

19

Exercise 4Exercise 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. J1 J2 J3 J4 J5

M1 9 4 13 8 21

M2 14 12 7 9 3

M3 7 5 5 6 14

M4 10 7 6 11 17

Page 20: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

20

Exercise 5Exercise 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 M2 takes 2 jobs

and the other machines take one job. J1 J2 J3 J4 J5

M1 9 4 13 8 21

M2 14 12 7 9 3

M3 7 5 5 6 14

M4 10 7 6 11 17

Page 21: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

21

Exercise 6Exercise 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. J1 J2 J3 J4 J5

M1 9 4 13 8 21

M2 14 12 7 9 3

M3 7 5 5 6 14

M4 10 7 6 11 17

Page 22: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

22

Exercise 7 Exercise 7

Formulate a model that finds the shortest

paths from nodes 1 and 2 to node 6

457

8

9

11

1

2 4

3 5

6

6

3

14

Page 23: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

23

Transportation ProblemsTransportation Problems

Page 24: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

24

Transportation ProblemTransportation Problem

two suppliers, A and B 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

unit cost cij for unit flow from supplier i to customer j as labeled on diagram, e.g., $5 (= cAD) for each unit from A to D

objective: minimize the total cost to satisfy the requirement

6

1

25

8

3A

B

D

C

E

60

40

25

45

20

Page 25: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

25

Transportation ProblemTransportation Problem

steps of modeling define variables

express the objective function in terms of

the variables and parameters

express the constraints in terms of the

variables and parameters

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

Page 26: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

26

Transportation ProblemTransportation Problem

one trick to define variables: what

decisions are made?

answer: the amount of goods sent

from supplier i to customer j

let xij = amount of goods sent from

supplier i to customer j, i = A, B; j

= C, D, F

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

Page 27: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

27

Transportation ProblemTransportation Problem

objective min 3xAC + 5xAD + 2xAE

+ xBC + 8xAD + 6xAE

constraints supply from A: xAC + xAD + xAE ≤ 60

supply from B: xBC + xBD + xBE ≤ 40

demand of C: xAC + xBC = 20

demand of D: xAD + xBD = 45

demand of E: xAE + xBE = 25

non-negativity: xAC, xAD, xAE, xBC, xAD, xAE 0

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

Page 28: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

28

QuestionsQuestions

is the formulation correct?

can we use xAC + xBC 20, xAD + xBD 45, xAE

+ xBE 25 instead?

what does it mean by can or cannot?

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

min 3xAC + 5xAD + 2xAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE ≤ 60,

xBC + xBD + xBE ≤ 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAC, xAD, xAE, xBC, xAD, xAE 0.

Page 29: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

29

QuestionsQuestions

can we use

can we use

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

min 3xAC + 5xAD + 2xAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE = 60,

xBC + xBD + xBE = 40,

xAC + xBC 20,

xAD + xBD 45,

xAE + xBE 25,

xAC, xAD, xAE, xBC, xAD, xAE 0.

min 3xAC + 5xAD + 2xAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE = 60,

xBC + xBD + xBE = 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAC, xAD, xAE, xBC, xAD, xAE 0.

Page 30: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

30

QuestionsQuestions

how to model: impossible to send goods from A

to E

setting cAE to

numerically cAE = M, a large positive number

6

1

M

5

8

3A

B

D

C

E

60

40

25

45

20min 3xAC + 5xAD + MxAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE ≤ 60,

xBC + xBD + xBE ≤ 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAC, xAD, xAE, xBC, xAD, xAE 0.

6

1

5

8

3A

B

D

C

E

60

40

25

45

20

Page 31: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

31

QuestionsQuestions

how to model: impossible to send goods from A

to E

omitting xAE (i.e., setting to xAE = 0)

min 3xAC + 5xAD + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD ≤ 60,

xBC + xBD + xBE ≤ 40,

xAC + xBC = 20,

xAD + xBD = 45,

xBE = 25,

xAC, xAD, xAE, xBC, xAD, xAE 0.

6

1

5

8

3A

B

D

C

E

60

40

25

45

20

Page 32: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

32

Balanced Transportation ProblemsBalanced Transportation Problems

a balanced transportation problem:

total supply = total demand

computational advantages for a balanced

transportation problem

possible to transform any imbalanced

transportation problem to a balanced one

Page 33: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

total supply = 100 90 = total demand

adding a dummy customer T what is bT?

what is cAT?

what is cBT?

33

To Transform into To Transform into a Balanced Transportation Problema Balanced Transportation Problem

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

cATcBT

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

TbT

Page 34: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

bT = 10090 = 10

can cAT = 0 and cBT = 0?

what does it mean by can or cannot?

can cAT = 19 and cBT = 19?

can cAT = 19 and cBT = 31?

the same trick for total supply total demand

34

To Transform into To Transform into a Balanced Transportation Problema Balanced Transportation Problem

cATcBT

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

TbT

Page 35: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

35

CommentsComments

00

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

T10

min 3xAC + 5xAD + 2xAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE + xAT = 60,

xBC + xBD + xBE + xBT = 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAT + xBT = 10,

xAC, xAD, xAE, xBC, xAD, xAE, xAT, xBT 0.

Page 36: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

36

A General Transportation ProblemA 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

Page 37: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

37

Special Structure Special Structure for the Set of Constraintsfor 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

xAC xAD xAE xAT = 60,

xBC xBD xBE xBT = 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAT + xBT = 10,

xAC, xAD, xAE, xBC, xAD, xAE, xAT, xBT 0.

cATcBT

6

1

2

5

8

3A

B

D

C

E

60

40

25

45

20

TbT

Page 38: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

38

Solution of Solution of a Transportation Problema 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

network flow algorithm, Ford and Fulkerson (1956, 1962)

min 3xAC + 5xAD + 2xAE + xBC + 8xAD + 6xAE,

s.t.

xAC + xAD + xAE + xAT = 60,

xBC + xBD + xBE + xBT = 40,

xAC + xBC = 20,

xAD + xBD = 45,

xAE + xBE = 25,

xAT + xBT = 10,

xAC, xAD, xAE, xBC, xAD, xAE, xAT, xBT 0.

Page 39: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

39

Example 5.3 of [7]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

Page 40: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

40

Example 5.3 of [7]Example 5.3 of [7]

possible to model as a transportation problem

Jan Feb March April

Jan Regular 1 1.3 1.6 1.9

Overtime 1.5 1.8 2.1 2.4

Feb Regular 1 1.3 1.6

Overtime 1.5 1.8 2.1

March Regular 1 1.3

Overtime 1.5 1.8

April Regular 1

Overtime 1.5

Page 41: 1 Lecture 2 Shortest-Path Problems Assignment Problems Transportation Problems

41

Capacitated Capacitated Transportation ProblemsTransportation Problems

lower and upper bounds for xij

0 ≤ lij ≤ xij ≤ uij

solved by extensions of the specialized

algorithms