math models of or: the boxes problem

28
Math Models of OR: The Boxes Problem John E. Mitchell Department of Mathematical Sciences RPI, Troy, NY 12180 USA December 2018 Mitchell The Boxes Problem 1 / 22

Upload: others

Post on 02-Oct-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Math Models of OR: The Boxes Problem

Math Models of OR:The Boxes Problem

John E. Mitchell

Department of Mathematical SciencesRPI, Troy, NY 12180 USA

December 2018

Mitchell The Boxes Problem 1 / 22

Page 2: Math Models of OR: The Boxes Problem

Mass production

Outline

1 Mass production

2 The Boxes Problem

3 Backward recursion equations

4 Solving the problem

5 Modeling as a shortest path problem

Mitchell The Boxes Problem 2 / 22

Page 3: Math Models of OR: The Boxes Problem

Mass production

Mass production

When we mass-produce something (eg, cars, telephones, computers,shirts, etc.), we are not usually able to exactly meet the demand ofevery customer.

We typically have to limit the number of different types of models weproduce.

For example, a particular line of cars comes with certain combinationsof color, number of cylinders, different configurations of theentertainment system, etc.

This saves money in production, but it has a cost in either potential lostdemand or in reduced prices to entice customers who wantedsomething slightly different.

Mitchell The Boxes Problem 3 / 22

Page 4: Math Models of OR: The Boxes Problem

The Boxes Problem

Outline

1 Mass production

2 The Boxes Problem

3 Backward recursion equations

4 Solving the problem

5 Modeling as a shortest path problem

Mitchell The Boxes Problem 4 / 22

Page 5: Math Models of OR: The Boxes Problem

The Boxes Problem

The boxes problem

The boxes problem is a variant on this.

We want to ship 6 packages of different sizes, but we can onlymanufacture 3 different sizes of box.

We assume item 1 is bigger than item 2, which in turn is bigger thanitem 3, and so on.

For example, a box that is large enough to contain item 3 would alsobe large enough to ship item 4 or item 5 or item 6.

The costs of manufacturing a single box of each size are in the table.

size k 1 2 3 4 5 6manufacturing cost ck 25 20 18 15 11 8

Mitchell The Boxes Problem 5 / 22

Page 6: Math Models of OR: The Boxes Problem

S i x items : I 7 2 7 3 7 4 > 5 7 6 .

Three b o x sires.

Boxofsi.c2.b.no/iiu4,boxcfsica#2 boxerof s i n 5 , 2 boxer c i r c 5

2 boxers i r . l , --

✓ item, item,i tems 5 8 6l o l 3 5 4

-

I box s i n 1 , I box i i i . 2 , 4 boxes i n 3

:.

Page 7: Math Models of OR: The Boxes Problem

The Boxes Problem

Stages and states

Our decision variables are

xk = number of boxes of size k that are manufactured, k = 1, . . . , 6

The STAGES are the indices k , so at stage k we decide the valueof xk .The STATE is the number of box sizes still available. Initially, we haves = 3. Every time we choose a positive value for xk , the value of sdecreases by one.

Mitchell The Boxes Problem 6 / 22

Page 8: Math Models of OR: The Boxes Problem

Backward recursion equations

Outline

1 Mass production

2 The Boxes Problem

3 Backward recursion equations

4 Solving the problem

5 Modeling as a shortest path problem

Mitchell The Boxes Problem 7 / 22

Page 9: Math Models of OR: The Boxes Problem

Backward recursion equations

Backward recursion

We use backward recursion to minimize the manufacturing costs. Wehave

fk (s) = manufacturing cost of optimal policy to ship items k , . . . , 6,given that we can use at most s different sizes

fk (s, xk ) = manufacturing cost of optimal policy to ship items k , . . . , 6,given that we can use at most s different sizeswith the decision xk

Mitchell The Boxes Problem 8 / 22

Eventually find f , (3).

Page 10: Math Models of OR: The Boxes Problem

falsixu) = c a n . + f (s-l)kexy

W ✓cost t o make

a boxer of futureS e c k :

cost

c o s t c µ e µEg: take k=3, s = 2 .I f X u = 3 : the 3 boxesof i c e 3 ship

item, 3 , 4,5.

Next consider boxesof s i n . 6.

Page 11: Math Models of OR: The Boxes Problem

Backward recursion equations

Setting up the recursion

The maximum number of boxes we need to build at size k is equal tothe number of items still to be shipped, which is 6 � k + 1. We cannottake xk = 0 in the recursion, since we have to ship item k . Then

fk (s) = maxxk=1,...,6�k+1

{fk (s, xk )}

If we make the decision xk > 0 then the state decreases by one. Theimmediate cost is ckxk .

Further, these k boxes are used to ship items k , . . . , k + xk � 1, so thefuture costs depend on fk+xk (s � 1).

Notice in this example that the stage has changed by an amountthat may well be different from one.

Mitchell The Boxes Problem 9 / 22

m i n A l lremaining item, shipped:← 6=ktxu.- I

K k i ka...tt#?kexu?X u : I 2 . . . x ,

Page 12: Math Models of OR: The Boxes Problem

Backward recursion equations

Setting up the recursion

The maximum number of boxes we need to build at size k is equal tothe number of items still to be shipped, which is 6 � k + 1. We cannottake xk = 0 in the recursion, since we have to ship item k . Then

fk (s) = maxxk=1,...,6�k+1

{fk (s, xk )}

If we make the decision xk > 0 then the state decreases by one. Theimmediate cost is ckxk .

Further, these k boxes are used to ship items k , . . . , k + xk � 1, so thefuture costs depend on fk+xk (s � 1).

Notice in this example that the stage has changed by an amountthat may well be different from one.

Mitchell The Boxes Problem 9 / 22

Page 13: Math Models of OR: The Boxes Problem

Backward recursion equations

The recursion

Combining the immediate costs with the future costs, we obtain theformula

fk (s, xk ) =

⇢ckxk + fk+xk (s � 1) if 1 k + xk 6ckxk if k + xk > 6

In the end, we need to determine f1(3).

Mitchell The Boxes Problem 10 / 22

Page 14: Math Models of OR: The Boxes Problem

Solving the problem

Outline

1 Mass production

2 The Boxes Problem

3 Backward recursion equations

4 Solving the problem

5 Modeling as a shortest path problem

Mitchell The Boxes Problem 11 / 22

Page 15: Math Models of OR: The Boxes Problem

Solving the problem

The posible states and decisions

At optimality, we are going to build three different sizes of boxes.

Thus, the only state we need to consider when k = 6 is s = 1.

We must build at least one of size 1.

Thus, the only possible states for stages 3, . . . , 5 are s = 1 or s = 2.

At stage 2, the only possible state is s = 2: we used up one size onitem 1.

When s = 1, we must choose xk = 6 � k + 1 so we ship all theremaining items.

When s = 2, we can choose xk = 1, . . . , 6 � k , so we don’t ship item 6in a box of size k .

Mitchell The Boxes Problem 12 / 22

Page 16: Math Models of OR: The Boxes Problem

l e t 4 - s e ei f n o tenough^ earlierboxer:I ✓ build1 boxo f a i r . G

'ai:÷÷÷÷:)

1st.".".im.1 o r 2

Must have5 = 2 :could only have used u p 1 r i c e

previously

Page 17: Math Models of OR: The Boxes Problem

m a t eD D D 0 D o✓ ÷¥¥÷¥...

I f s = 1 : choose a ⇐ 4

Page 18: Math Models of OR: The Boxes Problem

Solving the problem

Find f6(s)

We have f6(1) = c6 = 8, since the optimal solution to the subproblemwould be to build one box to ship item 6.

Mitchell The Boxes Problem 13 / 22

Page 19: Math Models of OR: The Boxes Problem

Solving the problem

Find f5(s)

We have f6(1) = 8 and c5 = 11.

state s f5(s, x5) f5(s) x⇤5

x5 = 1 x5 = 21 — 2c5 = 22 22 22 c5 + f6(1) = 19 — 19 1

Mitchell The Boxes Problem 14 / 22

I F h e

0

Page 20: Math Models of OR: The Boxes Problem

Solving the problem

Find f4(s)

We have f5(1) = 22, f6(1) = 8 and c4 = 15.

state s f4(s, x4) f4(s) x⇤4

x4 = 1 x4 = 2 x4 = 31 — — 3c4 = 45 45 32 c4 + f5(1) = 37 2c4 + f6(1) = 38 — 37 1

Mitchell The Boxes Problem 15 / 22

ME i n D 8

-

I!÷:{''I:#think.I box ofair. G .

Page 21: Math Models of OR: The Boxes Problem

Solving the problem

Find f3(s)

We have f4(1) = 45, f5(1) = 22, f6(1) = 8 and c3 = 18.

state s f3(s, x3) f3(s) x⇤3

x3 = 1 x3 = 2 x3 = 3 x3 = 41 — — — 4c3 = 72 72 42 c3 + f4(1) = 63 2c3 + f5(1) = 58 3c3 + f6(1) = 62 — 58 2

Mitchell The Boxes Problem 16 / 22

T I F I I I I 183

3! I21¥'s' + HE's

Page 22: Math Models of OR: The Boxes Problem

Solving the problem

Find f2(s)

We only need to consider s = 2 for f2(s), since we can only use onesize that is larger than size 2.

We have f3(1) = 72, f4(1) = 45, f5(1) = 22, f6(1) = 8 and c3 = 20.

state s f2(s, x2) f2(s) x⇤2

x2 = 1 x2 = 2 x2 = 3 x2 = 42 c2 + f3(1) = 92 2c2 + f4(1) = 85 3c2 + f5(1) = 82 4c2 + f6(1) = 88 82 3

Hence f2(2) = 82 with x⇤2 = 3.

Mitchell The Boxes Problem 17 / 22

§ MyFit I D D8

O'boi:{+ !!:::'s

Page 23: Math Models of OR: The Boxes Problem

Solving the problem

Find f1(3)

It is not optimal to take x1 � 5, since then we’d only make at most 2different sizes.

We have f2(2) = 82, f3(2) = 58, f4(2) = 37, f5(2) = 19, and c1 = 25.

state s f1(s, x1) f1(s) x⇤1

x1 = 1 x1 = 2 x1 = 3 x1 = 43 c1 + f2(2) = 107 2c1 + f3(2) = 108 3c1 + f4(2) = 112 4c1 + f5(2) = 119 107 1

Thus, f1(3) = 107 and x⇤1 = 1.

Mitchell The Boxes Problem 18 / 22

M¥122128115 D i d

a

Page 24: Math Models of OR: The Boxes Problem

Solving the problem

Backtracking to get the optimal solution

The optimal value is 107.

Backtracking through the tables, we see that x1 = 1, x2 = 3, andx5 = 2.

Checking the cost, we have 1 ⇥ 25 + 3 ⇥ 20 + 2 ⇥ 11 = 107,confirming the value we found in the tables.

Mitchell The Boxes Problem 19 / 22

Page 25: Math Models of OR: The Boxes Problem

Modeling as a shortest path problem

Outline

1 Mass production

2 The Boxes Problem

3 Backward recursion equations

4 Solving the problem

5 Modeling as a shortest path problem

Mitchell The Boxes Problem 20 / 22

Page 26: Math Models of OR: The Boxes Problem

Modeling as a shortest path problem

Modeling as a shortest path problem

Each (stage,state) combination is a node.

An edge goes from one node (k , s) to another if there is a decision xkthat leads from one node to the other;

the edge is labelled with the immediate cost of that decision, namelyckxk .

Mitchell The Boxes Problem 21 / 22

Page 27: Math Models of OR: The Boxes Problem

Modeling as a shortest path problem

The network

1, 3

2, 2 3, 2 4, 2 5, 2

3, 1 4, 1 5, 1 6, 1

end

25

5075

100

20

40

60

80

18

36 54

15 30

11

72

4522

8

The optimal solution x1 = 1, x2 = 3, x5 = 2 has value 107 andcorresponds to the path (1, 3) ! (2, 2) ! (5, 1) ! end.

Mitchell The Boxes Problem 22 / 22

0 ¥ ,O O O O

states] 1 2 30 ok E § e n d

0

state= 2

state= I

Page 28: Math Models of OR: The Boxes Problem

Modeling as a shortest path problem

The network

1, 3

2, 2 3, 2 4, 2 5, 2

3, 1 4, 1 5, 1 6, 1

end

25

5075

100

20

40

60

80

18

36 54

15 30

11

72

4522

825

60

22

The optimal solution x1 = 1, x2 = 3, x5 = 2 has value 107 andcorresponds to the path (1, 3) ! (2, 2) ! (5, 1) ! end.

Mitchell The Boxes Problem 22 / 22