# Homework1

Topics: Shortest path problem, Dijkstra's algorithm, Shortest path tree Pages: 7 (693 words) Published: April 28, 2015
﻿Homework Assignment 1

Due date: 21 Feb. 2010

A farmer wishes to transport a truckload of eggs from city 1 to city 2 through a road network as above. The truck will incur a certain amount of breakage on each road segment, where the % value shown on the network is the percentage of eggs broken if the truck passes the road arc. How should the truck be routed to minimize the total breakage? (1) Formulate the problem as a shortest path problem (showing the resulted shortest path problem such as drawing the network and specifying arc costs). (2) Solve the problem by Dijkstra’s algorithm.

************************************************************************ Optional Questions (no submission required)

Suppose that a shortest path from node 1 to node 2 has been found. Let the cost be C.

(1) If, for all arcs in the network, the cost is increased by k times, k>0, will the shortest path change? (2) If, for all arcs in the network, the cost is increased by a constant k, k>0, will the shortest path change? (3) If, for all arcs starting from node 1, the cost is increased by a constant k, k>0, will the shortest path change? (4) If, for one arc on the shortest path, the cost is increased by a constant k, k>0, will the new shortest path cost be C+k? (5) If, for one arc on the shortest path, the cost is decreased by a constant k, k>0, will the new shortest path cost be C-k?

Ans(1):

First convert the % lost into efficiency as below:

Then define the cost of each arc as –log(efficiency) as below:

Possible path 1: 1 -> 3 -> 2
{[-log(99%)]+[-log(95%)]} = 0.0044+0.0223 = 0.0267
Efficiency = (1-1%)*(1-5%) = 99%*95% = 94.05%

Possible path 2: 1 -> 3 -> 4 -> 2
{[-log(99%)]+[-log(97%)]+[-log(98%)]} = 0.0044+0.0132+0.0088 = 0.0264 Efficiency = (1-1%)*(1-3%)*(1-2%) = 99%*97%*98% = 94.11%

Possible path 3: 1 -> 3 -> 4 -> 6 -> 7-> 2
{[-log(99%)]+[-log(97%)]+[-log(98%)]+[-log(99%)]+[-log(99%)]} = 0.0044+0.0132+0.0088+0.0044+0.0044 = 0.0352
Efficiency = (1-1%)*(1-3%)*(1-2%)*(1-1%)*(1-1%) = 99%*97%*98%*99%*99% = 92.24%

Possible path 4: 1 -> 4 -> 2
{[-log(96%)]+[-log(98%)]} = 0.0177+0.0088 = 0.0265
Efficiency = (1-4%)*(1-2%) = 96%*98% = 94.08%

Possible path 5: 1 -> 4 -> 6 -> 7 -> 2
{[-log(97%)]+[-log(98%)]+[-log(99%)]+[-log(99%)]} = 0.0132+0.0088+0.0044+0.0044 = 0.0308 Efficiency = (1-4%)*(1-2%)*(1-1%)*(1-1%) = 96%*98%*99%*99% = 92.21%

Possible path 6: 1 -> 5 -> 4 -> 2
{[-log(98%)]+[-log(98%)]+[-log(98%)]} = 0.0088+0.0088+0.0088 = 0.0264 Efficiency = (1-2%)*(1-2%)*(1-2%) = 98%*98%*98% = 94.12%

Possible path 7: 1 -> 5 -> 4 -> 6-> 7 -> 2
{[-log(98%)]+[-log(98%)]+[-log(98%)]+[-log(99%)]+[-log(99%)]} = 0.0088+0.0088+0.0088+0.0044+0.0044 = 0.0352 Efficiency = (1-2%)*(1-2%)*(1-2%)*(1-1%)*(1-1%) = 98%*98%*98%*99%*99% = 92.25%

Possible path 8: 1 -> 5 -> 6 -> 7 -> 2
{[-log(98%)]+[-log(98%)]+[-log(99%)]+[-log(99%)]} = 0.0088+0.0088+0.0044+0.0044 = 0.0264 Efficiency = (1-2%)*(1-2%)*(1-1%)*(1-1%) = 98%*98%*99%*99% = 94.13%

The optimal path is 1 -> 5 -> 6 -> 7 -> 2 because the cost is min while the efficiency is max Ans(2):

First convert the % lost into efficiency as below:

Then define the cost of each arc as –log(efficiency) as below:

Iteration 1:
-node 1 is selected, S={1}
-distance update: d(3)=0.00436, d(4)=0.01773, d(5)=0.00877, pred(3)=1, pred(4)=1, pred(5)=1

Iteration 2:
-node 3 is selected, S={1,3}
-distance update: d(2)=0.02664, d(4)=0.01759, pred(2)=3, pred(4)=3

Iteration 3:
-node 5 is selected, S={1,3,5}
-distance update: d(6)=0.01754, d(4)=0.01754, pred(6)=5, pred(4)=5

Iteration 4:
-node 6 is selected, S={1,3,5,6}
-distance update: d(7)=0.0219, pred(7)=6

Iteration 5:
-node 4 is selected, S={1,3,5,6,4}
-distance update: d(2)=0.02631, pred(2)=4

Iteration 6:
-node 7 is selected, S={1,3,5,6,4,7}
-distance update: d(2)=0.02631, pred(2)=4

The shortest path tree is:

Please join StudyMode to read the full document