10
Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a section devoted to setting up the networks and 8.2 as solving them, but only 8.2 has a homework section. Section 8.2 2. Use Dijkstra’s algorithm to find the shortest path from Figure 4. I’ll type asterisks in place of the boxes we used in class (easier to typeset). 1 2 3 4 5 1 0 * 2 1 8 1 2 2 * 1 7 2 6 2 14 2 4 7 2 6 * 2 14 2 3 7 * 2 14 2 5 14 * 2 The shortest path is 14, and the path is 1 - 2 - 5. 3. Repeat problem 2 as a transshipment problem. SOLUTION: Node 1 is the supply node, and node 5 is the demand node, and the other nodes are transshipment nodes. We set the supply equal to 1, which is also our “s”. Node 2 Node 3 Node 4 Node 5 Supply Node 1 2 8 M M 1 Node 2 0 5 4 12 1 Node 3 M 0 5 M 1 Node 4 M M 0 10 1 Demand 1 1 1 1 1

Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

  • Upload
    dinhtu

  • View
    224

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

Homework solutions, Chapter 8

NOTE: We might think of 8.1 as being a section devoted to setting up the networks and 8.2as solving them, but only 8.2 has a homework section.

Section 8.2

2. Use Dijkstra’s algorithm to find the shortest path from Figure 4. I’ll type asterisks inplace of the boxes we used in class (easier to typeset).

1 2 3 4 5

1 0∗ 21 81 ∞ ∞2 2∗

1 72 62 142

4 72 6∗2 142

3 7∗2 142

5 14∗2

The shortest path is 14, and the path is 1− 2− 5.

3. Repeat problem 2 as a transshipment problem.

SOLUTION: Node 1 is the supply node, and node 5 is the demand node, and the othernodes are transshipment nodes. We set the supply equal to 1, which is also our “s”.

Node 2 Node 3 Node 4 Node 5 Supply

Node 1

2 8 M M

1

Node 2

0 5 4 12

1

Node 3

M 0 5 M

1

Node 4

M M 0 10

1

Demand 1 1 1 1

1

Page 2: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

4. If we use Dijkstra’s algorithm, we get the path 1− 3− 4, but there is a shorter path,1 − 2 − 3 − 4. Dijkstra’s algorithm assumes that because node 3 is not connected tonode 1 by an arc, node 3 would have to go through node 2, which should make thedistance greater than 2. With a negative path, it made the distance zero-

Dijkstra’s algorithm only works for networks with positive edges.

5. Just as in Example 2, we let node 1 be the beginning of year 1, and node 7 to be theend of year 6/beginning of year 7.

Therefore, a table of our edges would be the following, where position (i, j) is Cij:

1 2 3 4 5 6 7

1 − 3300 4800 7600 9800 12400 15600

2 − 3300 4800 7600 9800 12400

3 − 3300 4800 7600 9800

4 − 3300 4800 7600

5 − 3300 4800

6 − 3300

Using Dijkstra’s algorithm, we have the following (in hundreds):

1 2 3 4 5 6 7

1 0∗ 331 481 761 981 1241 156

2 33∗1 481 761 981 1241 156

3 48∗1 761 963 1241 1463

4 76∗1 963 1241 1463

5 96∗3 1241 1445

6 124∗1 1445

7 144∗5

We see the best solution is 1− 3− 5− 7 with a value of 4800 + 4800 + 4800 = 14400.

6. Problem 6 is identical in flavor to 5 (and Example 2). Here are the costs involved (intens). We have nodes 1-7 for years beginning 1-6. Because we may only keep the phone

2

Page 3: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

for at most 5 years, then node 1 is not connected to node 6.

1 2 3 4 5 6 7

1 − 6 9 13 19 26 −2 − 6 9 13 19 26

3 − 6 9 13 19

4 − 6 9 13

5 − 6 9

6 6

1 2 3 4 5 6 7

1 0∗ 61 91 131 191 261 ∞2 6∗

1 91 131 191/2 252 322

3 9∗1 131 183 223 283

4 13∗1 183 223 264

5 18∗3 223 264

6 22∗3 264

7 26∗4

This tells us that 1 − 4 − 7 is the shortest path at $260. That is, we buy the phoneand keep it for three years, then buy another phone and keep it for three years to theend of year 6 (beginning of year 7).

7. Done in class (and solution posted to the class website).

8. Done in class.

9. The box factory. For this one, notice that there is a fixed cost of $1000 to produce anyparticular box. This is, in essence, a penalty on the number of different sizes we willuse.

We will assume that, for j > i, then xij will be the situation where we use box type iin place of box types i, i + 1, i + 2, · · · , j − 1. Therefore, for example,

x47 = Box type 4 in place of types 4 and 5

Here are a couple of sample computations:

C13 = 700× 33 + 1000 = 24100 C47 = 900× 24 + 1000 = 22600

And here is the cost matrix (in hundreds):

2 3 4 5 6 7 8

1 142 241 406 637 703 835 901

2 − 100 250 460 520 640 700

3 − − 140 322 374 478 530

4 − − − 178 226 322 370

5 − − − − 48 124 162

6 − − − − − 82 118

7 − − − − − − 44

1 2 3 4 5 6 7 8

1 0∗ 142 241 406 637 703 835 901

2 142∗ 241 392 602 662 782 842

3 241∗ 381 563 615 719 771

4 381∗ 559 607 703 751

5 559∗ 607 683 721

6 607∗ 683 721

7 683∗ 721

8 721∗

3

Page 4: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

Therefore, the shortest path is 1−3−4−5−8, with costs C13+C34+C45+C58 = 72100.This means we use box type 1 in place of box types 1 and 2, box type 3 for its owndemand, box type 4 for its own, then box type 5 for the remainder (types 5, 6, 7).

Section 8.3

4.

5.

4

Page 5: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

6.

7.

5

Page 6: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

Section 8.4

5(a)

6. (a) One big thing to note. Once we separated activities C and D branching off ofnode 3, we had to bring them together again for activity E. The only way to dothat (without violating the rule about two nodes being connected by at most oneedge) is to create a dummy edge so that the two activities can be brought togetheragain at node 5.

(b) The linear program may be formulated a couple of different ways. We’ll showboth, although only the first one was used in class.

SOLUTION 1: Let xij = {0, 1}. Although this isn’t strictly a linear program, itturns out that the xij will take on the values either 0 or 1 in the optimal solution.

6

Page 7: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

We’ll have seven variables (one for each edge):

max z = 2x12 + 4x23 + 2x34 + 3x35 + 4x36 + 0x45 + 10x56

such that (each node has “outflow-inflow” expressions):

x12 = 1 Node 1 (Supply)

x23 −x12 = 0 Node 2

x34 + x35 + x36 −x23 = 0 Node 3

x45 −x34 = 0 Node 4

x56 −x45 − x35 = 0 Node 5

−x56 − x36 = −1 Node 6 (Demand)

with xij ≥ 0. For this problem, here is the output from LINDO. You might noticesomething interesting with the “Reduced Cost” column.

LP OPTIMUM FOUND AT STEP 2

OBJECTIVE FUNCTION VALUE

1) 19.00000

VARIABLE VALUE REDUCED COST

X12 1.000000 0.000000

X23 1.000000 0.000000

X34 0.000000 1.000000

X35 1.000000 0.000000

X36 0.000000 9.000000

X56 1.000000 0.000000

X45 0.000000 0.000000

ROW SLACK OR SURPLUS DUAL PRICES

2) 0.000000 6.000000

3) 0.000000 4.000000

4) 0.000000 0.000000

5) 0.000000 -3.000000

6) 0.000000 -3.000000

7) 0.000000 -13.000000

SOLUTION 2: Our textbook author suggests the following setup. Let xj be thetime at which event j will take place. These are relative times, so xj is URS. Then:

7

Page 8: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

min w = x6 − x1

st x2 ≥ x1 + 2

x3 ≥ x2 + 4

x4 ≥ x3 + 2

x5 ≥ x3 + 3

x5 ≥ x4

x6 ≥ x5 + 10

x6 ≥ x3 + x4

min x6-x1

st -x1+x2>2

-x2+x3>4

-x3+x4>2

-x3+x5>3

-x4+x5>0

x6-x5>10

-x3+x6>4

end

free x1

free x2

free x3

free x4

free x5

free x6Here is the LINDO output:

LP OPTIMUM FOUND AT STEP 5

OBJECTIVE FUNCTION VALUE

1) 19.00000

VARIABLE VALUE REDUCED COST

X6 10.000000 0.000000

X1 -9.000000 0.000000

X2 -7.000000 0.000000

X3 -3.000000 0.000000

X4 -1.000000 0.000000

X5 0.000000 0.000000

ROW SLACK OR SURPLUS DUAL PRICES

2) 0.000000 -1.000000

3) 0.000000 -1.000000

4) 0.000000 0.000000

5) 0.000000 -1.000000

6) 1.000000 0.000000

7) 0.000000 -1.000000

8) 9.000000 0.000000

7. For exercise 7, use the same techniques as exercise 6. What’s really new is buildingthe network model, so you might focus on that aspect, then build the linear program.

8

Page 9: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

The linear program is much like the one for Exercise 6 (Solution 1):

max z = 3x12 + 6x25 + 14x23 + 8x34 + 8x56 + 9x67

st x12 = 1

−x12 + x25 + x23 = 0

−x23 + x34 = 0

x34 + x45 = 0

−x25 − x45 + x56 = 0

−x56 + x67 = 0

−x67 = −1

with xij ≥ 0 (in the optimal path, they will be either 0 or 1).

9. Explain why the total float will always be bigger than the free float.

SOLUTION: Looking at how these are computed on activity (i, j):

FF (i, j) = ET (j)− ET (i)− tij

TF (i, j) = LT (j)− ET (i)− tij

And by definition, LT (j) is always larger than (or equal to) ET (j).

9

Page 10: Homework solutions, Chapter 8 - Whitman Collegepeople.whitman.edu/~hundledr/courses/M339F15/M339/Ch8All.pdf · Homework solutions, Chapter 8 NOTE: We might think of 8.1 as being a

10. Diagram is below. We needed a dummy edge to make it all work.

16. Basic set of computations. See below.

17. Same techniques as 16, you should find that the critical path has length 27.

10