620-261 Solved Problems: DP CHAPTER 9: DYNAMIC PROGRAMMING 1. Consider the Towers of Hanoi problem in which it takes 2 seconds to move one disc from one peg to another. How long (days) would it take to implement the dynamic programming solution in the case of a problem involving 10 discs ? Solution: The DP solution to this problem is discussed in the lecture notes (pp. 9.23-9.28). It is also mentioned (in fact, given in the 1993 Exam) that the DP solution requires 2n-1 moves. Thus, for n=10 discs, we shall need 210-1 moves, which in turn will require 211-2 seconds, or (211-2)/(60x60x24) days to complete. 2. Write down the dynamic programming functional equation that we used in class to solve the knapsack problem and give the formal definition of f(s) as well as its physical interpretation. Then solve the following knapsack problem using this functional equation. z* : max 6x1 11x2 10x3 x s.t. x1 2x 2 1.5x3 3 x1 ,x 2 , x3 {0,1,2,3, } You are expected to determine the value of z* as well as the optimal values of x1,x2 and x3. Solution: The DP functional equation that we discussed in class is as follows: f (s) max wn f (s vn , s 1,2, ,V with n vn s f (0) 0, where f (s): max N n1 wn x n , s 0,1, 2, ,V s.t x N v x s n1 n n xn {0,1,2,3, } Thus, by definition f(s) is equal to the maximum weight of a knapsack of volume s given the unit weights and volumes specified by the vectors w and v respectively. To use this functional equation we need an item whose volume is equal to 1. If no such (real) item exits, we introduce a dummy item with 1 unit of volume and 0 unit of weight. Since we also rely on the vector v to consist of positive integers, we multiply the functional constraint by 2 to obtain v=(2,4,3). In our case we have: n vn wn 1 2 6 2 4 11 3 3 10 4 1 0 Solved Problems: 9.1 620-261 Solved Problems: DP Solving the functional equation for s=0,1,2,...,6, in this order, we obtain. f(0)=0 f(1)=max {wn+f(1-vn): vn1}= max {w4+f(1-v4)}=0 (Hence N(1)={4}). f(2)=max {wn+f(2-vn): vn2}= max {w1+f(2-v1),w4+f(2-v4)} = max {6+f(2-2),0+f(2-1)}= max {6+0,0+0}= 6 (Hence N(2)={1}). f(3)=max {wn+f(3-vn): vn3}= max {w1+f(3-v1),w3+f(3-v3),w4+f(3-v4)} = max {6+f(3-2),10+f(3-3),0+f(3-1)} = max {6+0,10+0,0+6} =10 (Hence N(3)={3}). f(4)=max {wn+f(4-vn): vn4} = max {w1+f(4-v1),w2+f(4-v2),w3+f(4v3),w4+f(4-v4)} = max {6+f(4-2),11+f(4-4),10+f(4-3),0+f(4-1)} = max {6+6,11+0,10+0,0+10} =12 (Hence N(4)={1}). f(5)=max {wn+f(5-vn): vn5} = max {w1+f(5-v1),w2+f(5-v2),w3+f(5v3),w4+f(5-v4)} = max {6+f(5-2),11+f(5-4),10+f(5-3),0+f(5-1)} = max {6+10,11+0,10+6,0+12} =16 (Hence N(5)={1,3}). f(6)=max {wn+f(6-vn): vn6} = max {w1+f(6-v1),w2+f(6-v2),w3+f(6v3),w4+f(6-v4)} = max {6+f(6-2),11+f(6-4),10+f(6-3),0+f(6-1)} = max {6+12,11+6,10+10,0+16} =20 (Hence N(6)={3}). The recovery procedure yields the following: s=6 x=(0,0,0,0) N(6)={3} x=(0,0,1,0) Solved Problems: 9. 620-261 Solved Problems: DP s=s-v3=6-3=3 N(3)={3} x=(0,0,2) s=s-v3=3-3=0 Stop. Thus, the optimal solution is x=(0,0,2,0), yielding z*=20 units of weight. 3. Write down the dynamic programming functional equation for generic knapsack problems of the form: * z := max z = 6x1 +11x 2 + 7x3 x s.t. 2 1 x1 + 2x2 + x3 £ 4 3 3 x1 , x2 ,x 3Œ{0,1,2,3, } Then, write down the functional equation for problems where the functional constraint is an equality constraint and solve this functional equation for the data given above. You are expected to determine the optimal value of z as well as the optimal values of x1, x2 and x3. Solution: The functional equation for a generic knapsack problem with "less than" constraint is as follows: f (s) = max { wn + f (s - vn )} , s = 1,2,...,V vn £ s observing that by definition f(0)=0. This formulation relies on vn =1 for at least one item n. For the "=" constraint problem, the functional equation is as follows: f (s) max wn f (s vn ) , s min {vn } vn s f (s): , 0 s min {vn} f (0): 0 This equation does not rely on vn =1 for at least one item n. We interpret f(s)=- as "the problem does not have a feasible solution". It is convenient to have integer coefficients in the constraint, so we can multiply it by 3 and use 3x1 + 6x 2 + 2x 3 =13 instead. Solving this equation for s=0,1,2,...,13, in this order yields the following: s 0 1 2 3 f(s) 0 - 7 6 Optimal n 3 1 Solved Problems: 9.3 620-261 Solved Problems: DP 4 5 6 7 8 9 10 11 12 13 14 13 21 20 28 27 35 34 42 41 3 1,3 3 1,3 3 1,3 3 1,3 3 1,3 Thus, for s=13 the maximum weight is z=41 and the optimal solution is: x=(1,0,5). 4. . Write down a dynamic programming functional equation for generic knapsack problems of the form: z* : max z 28x1 11x 2 6x 3 x s.t. 4x1 6x 2 3x3 V x1 ,x 2 , x 3 {0,1,2,3, } where V is a given positive number. Then use the functional equation to compute optimal solutions for V=5 and V=7. In each case you are expected to determine the optimal value of z as well as the optimal values of x 1, x2 and x3. Solution: Let f(s) = max weight of knapsack of volume s (completely full), s =0,1,2,...,V. Then, assuming that we have an item with vj=1, the DP functional equation is as follows: f(s) = max {wj + f(s-vj): vj<=s} , s=1,2,3,…,V with f(0)=0. Since we do not have an item with vj=1, we add an artificial variable, recalling that we have an “=” constraint. Thus, we set N=4, with v4=1 and w4=-M, where M is a very large number. Thus, the full range of items is as follows: j wj vj 1 28 4 2 11 6 3 6 3 4 -M 1 Solving for s=1,2,3, …, 7, - in this order - yields the following results: f(1) = max {wj + f(1-vj): vj <= 1} = max {w4 + f(1-v4)} = max {w4+f(1-1)} = max {w4 + f(0)} = max {-M+0} = -M , N(1)={4} f(2) = max {wj + f(2-vj): vj <= 2} = max {w4 + f(2-v4)} = max {w4+f(2-1)} = max {w4 + f(1)} = max {-M+(-M)} = -2M , N(1)={4} Solved Problems: 9. 620-261 Solved Problems: DP f(3) = max {wj + f(3-vj): vj <= 3} = max { w3 + f(3-v3) , w4 + f(3-v4)} = max { w3+f(3-3) , w4+f(3-1) } = max { w3 + f(0) , w4 + f(2) } = max { 6 + f(0) , -M+(-2M)} = max {6+0, -3M} = 6 , N(3)={3} f(4) = max {wj + f(4-vj): vj <= 4} = max { w1 + f(4-v1) , w3 + f(4-v3) , w4 + f(4-v4)} = max { w1+f(4-4) , w3+f(4-3) , w4+f(4-1) } = max { w1 + f(0) , w3 + f(1) , w4 + f(3) } = max { w1 + f(0) , w3 + f(1) , w4 + f(3) } = max { w1 + 0 , w3 + (-M) , w4 + 6 } = max { 28 + 0 , 6 + (-M) , -M + 6 } = max { 28 , -M+6, -M+6} = 28, N(4)={1} f(5) = max {wj + f(5-vj): vj <= 5} = max { w1 + f(5-v1) , w3 + f(5-v3) , w4 + f(5-v4)} = max { w1+f(5-4) , w3+f(5-3) , w4+f(5-1) } = max { w1 + f(1) , w3 + f(2) , w4 + f(4) } = max { w1 + (-M) , w3 + (-2M) , w4 + 6 } = max { 28-M, 6-M , -M+ 6 } = 28-M, N(5)={1} f(6) = max {wj + f(6-vj): vj <= 6} = max { w1 + f(6-v1) , w2 + f(6-v2) , w3 + f(6-v3) , w4 + f(6-v4)} = max { w1+f(6-4) , w2+f(6-6) , w3+f(6-3) , w4+f(6-1) } = max { w1 + f(2) , w2+f(0) , w3 + f(3) , w4 + f(5) } = max { w1 + (-2M) , w2+0 , w3 + 6 , w4 + 28-M } = max { 28-2M, 11+0 , 6+6, -M+28-M } = max {28-2M, 11 , 12, 28-2M} = 12 , N(5)={3} f(7) = max {wj + f(7-vj): vj <= 7} = max { w1 + f(7-v1) , w2 + f(7-v2) , w3 + f(7-v3) , w4 + f(7-v4)} = max { w1+f(7-4) , w2+f(7-6) , w3+f(7-3) , w4+f(7-1) } = max { w1 + f(3) , w2+f(1) , w3 + f(4) , w4 + f(6) } = max { w1 + 6 , w2-M , w3 + 28 , w4 + 12 } = max { 28+6, 11-M , 6+28, -M+12} = max {34,11-M,34,-M+12}= 34, N(7)={1,3} We therefore conclude that for V=5 there is no feasible solution (a positive artificial variable), and that for V=7 the optimal weight is equal to f(7)=34. Recovery procedure: X(0) =(0,0,0,0), s=7, N(7)={1,3) (we shall use j=1) X(1) =(1,0,0,0), s=s-v1=7-4=3, N(3)={3} X(2) =(1,0,1,0), s=s-v3 =3-3=0 Thus, the optimal solution is x=(1,0,1,0). This indeed yield a total weight equal to w1+w3=28+6=34. This mixture also satisfies the volume constraint: v1+v3 = 4+3=7. Remark: Solved Problems: 9.5 620-261 Solved Problems: DP Give the relationship between the weights and volumes of items of Type 2 and Type 3, it is obvious that the later is superior to the former. Thus, it is clear that an optimal knapsack will never include items of Type 2. We could have therefore ignored items if Type altogether at the outset 5. Write down a dynamic programming functional equation for generic knapsack problems of the form: z* : max z j 1 wi xi n x s.t. n vx V j 1 i i x j {0,1,2,3, } , j 1,2,...,n Then use the functional equation to compute optimal solution(s) for z* : max z 28x1 11x 2 6x3 x s.t. 4x1 6x2 3x3 10 x1 ,x 2 , x 3 {0,1,2,3, } You are expected to determine the optimal value of z as well as the optimal values of x 1, x2 and x3. Also, determine (without elaborate computation) the optimal solution should an additional item type with v 4=5 and w4=27 be available. Solution: The functional equation for the knapsack problem is as follows: f(s) = max {wn + f(s-vn): vn<=s, n=1,2,...,N}, for s > 0 with f(0) = 0 (assuming vn=1 for some n.) or equivalently f(s) = 0, s < min {vn} f(s) = max {wn + f(s-vn): vn<=s, n=1,2,...,N}, s >= min {vn} Thus, for the specific instance given, we have ` f(s) = 0, s = 0,1,2 ; K(s) = empty f(3) = 6 , K(3)={3} f(4) = 28 , K(4)={1} f(5) = 28 , K(5)={1} f(6) = 28 , K(6)={1} f(7) = 34 , K(7)={1,3} f(8) = 56 , K(8)={1} f(9) = 56 , K(9)={1} f(10) = 56 , K(10)={1} eg: f(10) = max {wn + f(10-vn): vn<=10, n=1,2,...,N} = max {wn + f(10-vn): n=1,2,3} = max {28 + f(10-4), 11 + f(10-6) , 6 + f(10-3)} = max {28 + f(6), 11 + f(4) , 6 + f(7)} = max {28 + 28, 11 + 28 , 6 + 34} = max {56, 39, 40} Solved Problems: 9. 620-261 Solved Problems: DP = 56 Recovery of optimal solution: x(0) = (0,0,0) , s(0) = 10 , K(10) = {1} x(1) = (1,0,0) , s(1) = 6 , K(6) = {1} x(2) = (2,0,0) , s(2) = 2 , K(2) = empty Thus, the optimal solution is: x = (2,0,0) yielding z*=56. The additional item type is dominated by the first item type so its availability will have no impact on the optimal solution. 6. Write down the generic knapsack problem we used in class and the dynamic programming functional equation associated with it. Modify this functional equation to handle the case where opt=min and use it to solve the following knapsack problem: z* : min z 6x1 11x 2 10x3 x s.t. x1 2x2 1.5x3 3 x1 ,x 2 , x 3 {0,1,2,3, } You are expected to determine the optimal value of z as well as the optimal values of x1, x2 and x3. Solution: The generic knapsack problem studied in class is as follows: n z* : max w j x j j 1 s.t n v x j j V j 1 x j {0,1,2,...} The functional equation is: f (s) max {w j f (s v j )},s 1,2,3,...,V j v j s with f(s):=0. To cope with opt=min, we simply change max to min in the functional equation. We shall multiply the volume constraint by 2 to make all the coefficients integers. The constraint is thus, 2x1 + 4x2 + 3x3 = 6 so that v=(2,4,3) and v=(6,11,10). Because of the equality constraint, we first set f(0)=0, and f(s) = M, for s< volume of smallest item. In our case, f(1)=M. Hence we start with Solved Problems: 9.7 620-261 Solved Problems: DP f(0) =0 f(1)= M and then we solve the functional equation for s=2,3,4,5,6. The results are as follows: f(2) =min {w(j)+f(2-v(j): j=1} = w(1) + f(2-v(1) ) = 6 + f(0)=6, K(2)={1} f(3) =min {w(j)+f(3-v(j): j=1,3} = min {w(1) + f(3-v(1) ), w(3)+f(3-v(3)} = min{ 6 + M, 10+0} = 10, K(3)={3} f(4) =min {w(j)+f(4-v(j): j=1,2,3} = min {w(1) + f(4-v(1), w(2)+f(4-w(2), w(3)+f(4-v(3)} = min{ 6 + 6, 11 + 0, 10+M} = 11, K(4)={2} f(5) =min {w(j)+f(5-v(j): j=1,2,3} = min {w(1) + f(5-v(1)), w(2)+f(5-w(2)), w(3)+f(5-v(3))} = min{ 6 + 10, 11 + M, 10+6} = 16, K(5)={1,3} f(6) =min {w(j)+f(6-v(j): j=1,2,3} = min {w(1) + f(6-v(1)), w(2)+f(6-w(2)), w(3)+f(6-v(3))} = min{ 6 + 11, 11 + 6, 10+10} = 17, K(6)={1,2} Recovery: x(0) =(0,0,0), s=6, K(6)={1,2}, 6-v1=4 x(1) =(0,1,0), s=4, K(4)={2}, 2-v2=0 x(2) =(1,1,0) Thus, x*=(1,1,0) and z*=w(1)+w(2)=6 + 11 = 17. 7. Write down the generic dynamic programming functional equation for the Towers of Hanoi problem (2%) and then solve it for the case where there are 4 discs that must be moved from right to left (3%). Solution: The generic dynamic programming functional equation for the towers of Hanoi problem is as follows: S(n,x,y) = S(n-1,x,not(x,y)),S(1,x,y),S(n-1,not(x,y),y) Where S(n,x,y) is the solution to a problem requiring moving n discs from platform x to platform y and not(x,y) is the third platform (neither x nor y). Thus, for our problem, n=4, x=R, y = L, so S(4,R,L) = S(3,R,C),S(1,R,L),S(3,C,L) Similarly, S(3,R,C) = S(2,R,L),S(1,R,C),S(2,L,C) S(3,C,L) = S(2,C,R),S(1,C,L),S(2,R,L) S(2,R,L) = S(1,R,C),S(1,R,L),S(1,C,L) Solved Problems: 9. 620-261 Solved Problems: DP S(2,L,C) = S(1,L,R),S(1,L,C),S(1,R,C) S(2,C,R) = S(1,C,L),S(1,C,R),S(1,L,R) S(2,C,L) = S(1,C,R),S(1,C,L),S(1,R,L) Hence, S(3,R,C) = S(1,R,C),S(1,R,L),S(1,C,L), S(1,R,C) , S(1,L,R),S(1,L,C),S(1,R,C) S(3,C,L) = S(1,C,L),S(1,C,R),S(1,L,R), S(1,C,L) , S(1,R,C),S(1,R,L),S(1,C,L) Therefore, S(4,R,L) = S(1,R,C),S(1,R,L),S(1,C,L), S(1,R,C) , S(1,L,R),S(1,L,C),S(1,R,C) S(1,R,L), S(1,C,L),S(1,C,R),S(1,L,R), S(1,C,L) , S(1,R,C),S(1,R,L),S(1,C,L) 8. Write down the generic dynamic programming functional equation for the travelling salesman problem (5%) and then solve it for the problem whose distance matrix is as follows (10%): City City City City City A --3 4 3 A B C D City B 2 --3 2 City C 4 2 --1 City D 3 4 2 --- Solution: The generic dynamic programming functional equation for the TSP is based on the following definition: f(i,s) := shortest sub-tour given that we are at city i and still have to visit the cities in s (and return to home city). Here s is any subset of the given set of cities. Let S={1,2,...,N) be the set of cities and for simplicity assume that the home city is city A. We are interested then in the value of f(A,S\{A}). The DP functional equation is as follows: f (i,s) min d(i, j) f (j,s \ {j}) j S with f(i,)=d(i,A). We solve the functional equation by enumerating the sets s S according to their size (cardinality). The following is a summary of the results; |s| = 0: f(A, ) = 0; f(B, ) = d(B,A) =3; f(C, ) = d(C,A) = 4; f(D, ) = d(D,A) = 3 |s| = 1: Solved Problems: 9.9 620-261 Solved Problems: DP i=B f(B, {C}) = min {d(B,C) + f(C,)} = d(B,C) + d(C,A) = 2 + 4 = 6 f(B, {D}) = min {d(B,D) + f(D,)} = d(B,D) + d(D,A) = 4 + 3 = 7 i=C f(C, {B}) = min {d(C,B) + f(B,)} = d(C,B) + d(B,A) = 3 + 3 = 6 f(C, {D}) = min {d(C,D) + f(D,)} = d(C,D) + d(D,A) = 2 + 3 = 5 i=D f(D, {B}) = min {d(D,B) + f(B,)} = d(D,B) + d(B,A) = 2 + 3 = 5 f(D, {C}) = min {d(D,C) + f(C,)} = d(D,C) + d(C,A) = 1 + 4 = 5 |s| =2: i=B f(B,{C,D}) = min {d(B,C) + f(C,{D}), d(B,D) + f(D,{C})} = min {2+5, 4+5} = 7 f(C,{B,D}) = min {d(C,B) + f(B,{D}), d(C,D) + f(D,{B})} = min{3+7,2+5} = 7 f(D,{B,C}) = min {d(D,B) + f(B,{C}), d(D,C) + f(C,{B})} =min {2+6,1+6}=7 i=C i=D |s| = 3 f(A;{B,C,D}) = min {d(A,B)+f(B,{C,D} , d(A,C)+f(C,{B,D} , d(A,D)+f(D,{B,C}} = min {2+7 , 4+7, 3+ 7} = 9 Hence, the shortest tour (A,B,C,D) is of length 9. 9. Write down the generic functional equation of dynamic programming for the Towers of Hanoi problem (3%). Then use it to show that the solution it yields requires 2n-1 moves (where n is the number of discs). Solution: The generic DP functional equation of the Tower of Hanoi problems is as follows: S(n,x,y) = S(n-1,x,xy), S(1,x,y), S(n-1,xy,y) , (xy := neither x nor y). Thus, if we let f(n):= number of moves required for the solution of a problem with n discs, we have f(n) = f(n-1)+ 1 + f(n-1) = 1 + 2f(n-1) (1) Since f(1) =1, it follows that f(2) = 3, and therefore f(3) = 1+6 = 7. We can show, by induction on j that f(j) = 2j-1. Clearly, the inductive hypothesis is true for j=1 and j=2. So suppose that it is true for j=1,2,…,k. In particular, assume that f(k) = 2k-1. Then it follows from (1) and the inductive hypothesis that f(k+1) = 1 + 2(2k-1) = 1 + 2k+1 - 2 = 2k+1 - 1. Hence, the inductive hypothesis holds for j=k+1 as well and therefore it holds for all j=1,2,…. Solved Problems: 9. 620-261 Solved Problems: DP 10. Write down the generic dynamic programming functional equation for the standard knapsack problem . Then solve it for the following specific knapsack problem: z* : max 7x1 15x2 10x3 x s.t. 4x1 8x 2 6x3 13 x1 ,x 2 , x 3 {0,1,2,...} You are expected to determine the value of z* as well as the optimal values of the decision variables x1 , x2 and x3 . What would be the functional equation if the functional constraint is changed to 4x1 8x 2 6x3 13 and max is changed to min ? Solution. The generic dynamic programming functional equation for the knapsack problem is f (s) max {v j f (s w j )},w s W 1 j k with f(0) = 0, s<w where w is the weight of the lightest item and W is the total (weight) capacity of the knapsack, and f(s) is the maximum value of a knapsack of total weight capacity of s. Solving this functional equation for the problem under consideration yields the following results: s 0 1 2 3 4 5 6 7 8 9 10 11 12 13 f(s) 0 0 0 0 7 7 10 10 15 15 17 17 22 22 D*(s) {1} {1} {3} {3} {2} {2} {1,3} {1,3} {1,2} {1,2} For example, consider s=13: f(13) = max {v1 + f(13-w1), v2 + f(13-w2) , v3 + f(13-w3) } = max {7+f(13-4),15+f(13-8),10+f(13-6)} Solved Problems: 9.11 620-261 Solved Problems: DP = max{7 + 15, 15 + 7 , 10 + 10} = 22 , D*(13) = {1,2} If we start with s=W=13, and select say item 1 as an optimal solution from D*(13), we shall be left with s'=134=9 units of weight. If we then select one item of type 2 from D*(9) we are left with s''=0 units of weight. According to this, the optimal solution is equal to x*=(1,1,0,0). This solution is consistent with the value of f(13)=22 as v1+v2 = 7+15=22. If we change the constraint to an equality constraint and max to min, the functional equation will be as follows: f (s) min {vj f (s w j )},w s W 1 j k f(s) = M, s<w (where M is a large positive number.) 11. Write down the generic dynamic programming functional equation for the travelling salesman problem and then solve it for the problem whose travel times are as follows: City City City City 1 2 3 4 City 1 --3 4 5 City 2 2 --4 3 City 3 4 2 --1 City 4 3 4 1 --- Solution. The generic DP functional equation for the travelling salesman problem is as follows: f (i, ) d(i,0), empty set f (i,s) min d(i, j) f (j,s \ {j}), s j S s \ A : {k s,k A}. where i denotes the current city, s denotes the set of cities yet to be visited, f(i,s) is the shortest distance from city i to the home city given that we still have to visit the cities in s, denotes the empty set and d(i,j) denotes the travel time from city i to city j (along the direct route). Solving this problem yields the following results (using 1 as the home city): f(2,{3}) = min { d(2,x) + f(x,{3}\{x}): x in {3}} = min { d(2,3) + f(3,{}) } = min { 2 + 4 } =6 f(2,{4}) = min { d(2,x) + f(x,{4}\{x}): x in {4}} = min { d(2,4) + f(4,{}) } Solved Problems: 9. 620-261 Solved Problems: DP = min { 4 + 5 } =9 f(3,{2}) = min { d(3,x) + f(x,{2}\{x}): x in {2}} = min { d(3,2) + f(2,{}) } = min { 4 + 3 } =7 f(3,{4}) = min { d(3,x) + f(x,{4}\{x}): x in {4}} = min { d(3,4) + f(4,{}) } = min { 1 + 5 } =6 f(4,{2}) = min { d(4,x) + f(x,{2}\{x}): x in {2}} = min { d(4,2) + f(2,{}) } = min { 3 + 3 } =6 f(4,{3}) = min { d(4,x) + f(x,{3}\{x}): x in {3}} = min { d(4,3) + f(3,{}) } = min { 1 + 4 } =5 f(2,{3,4}) = min { d(2,x) + f(x,{3,4}\{x}): x in {3,4}} = min { d(2,3) + f(3,{4}) , d(2,4) + f(4,{3}) } = min { 2 + 6 , 4 + 5 } =8 f(3,{2,4}) = min { d(3,x) + f(x,{2,4}\{x}): x in {2,4}} = min { d(3,2) + f(2,{4}) , d(3,4) + f(4,{2}) } = min { 4 + 9 , 1 + 6 } =7 f(4,{2,3}) = min { d(4,x) + f(x,{2,3}\{x}): x in {2,3}} = min { d(4,2) + f(2,{3}) , d(4,3) + f(3,{2}) } = min { 3 + 6 , 1 + 7 } =8 f(1,{2,3,4}) = min { d(1,2) + f(2,{,3,4}) , d(1,3) + f(3,{2,4}) , d(1,4) + f(4,{2,3}) } = min { 2 + 8 , 4 + 7 , 3 + 8 } = min { 10,11,11 } = 10 so the shortest tour takes 10 units of time. Recovering the optimal decisions we obtain the optimal tour (1,2,3,4,1). Checking the length of this tour yields 2 + 2 + 1 + 5 =10 which is consistent with the value of f(1,{2,3,4})=10. Solved Problems: 9.13