The tramp steamer problem. You are the owner of a steamship that can apply between a group of port cities V . You make money at each port: a visit to city i earns you a profit of pi dollars. Meanwhile, the transportation cost from port i to port j is cij>0 .You want to find a cyclic route in which the ratio of profit to cost is maximized.

To this end, consider a directed graph G=(V,E) whose nodes are ports, and which has edges between each pair of ports. For any cycle C in this graph, the profit-to-cost ratio is

role="math" localid="1658920675878" r(c)=i,jicPiji,jicCij

Let r' be the maximum ratio achievable by a simple cycle. One way to determine r' is by binary search: by first guessing some ratio r , and then testing whether it is too large or too small. Consider any positive r>0 . Give each edge (i,j) a weight of wij=rcij-pj .

  1. Show that if there is a cycle of negative weight, then .
  2. Show that if all cycles in the graph have strictly positive weight, then r<r*.
  3. Give an efficient algorithm that takes as input a desired accuracy >0 and returns a simple cycle c for which r(C)3r*- Justify the correctness of your algorithm and analyze its running time in terms of |V|, and R=max(i,j)iE(PJCIJ) .

Short Answer

Expert verified

a) The cycle of negative weight is shown below.

b) If all cycles in the graph have strictly positive weight, then r>r*is proved.

c) An efficient algorithm that takes as input a desired accuracy>0 is proved.

Step by step solution

01

Step-by-Step Solution .  Cmax,Cnegative,r, 

Step-1: (a) proof of negative weight in cycle

Let Gr be the graph with edge weights wij=rcij-pj for a given r . Let's pretend there's a negative weight cycle in Gr. Consider a simple negative-weight cycle localid="1658921532977" Cnegative . The following Cnegative is the weight is given as: localid="1658921854625" rC<i,jCPiji,jcCIJ

weightcnegative=i,jI˙CnegativeWijweight(cnegative)=(i,j)I˙Cnegativercij-pj<0r<i,jCnegativePi,ji,jCnegtiveCij=Cnegative

Thus,

r<i,jCnegativePiji,jCnegativeCij=rCNegative

Since the highest possible ratio for any simple cycle

r<rCnegative<r*.

Therefore,

r<r*

02

 Step-2: proof of positive weight in cycle.

b).

Let's consider the basic cycle cmax with the highest profit-to-cost ratio, which is r'=rcmax .

Assume that no negative weight cycles exist in Gr. In the graph Gr, the weight of cmax is:

rC<i,jCPiji,jCCijweightcmax=i,jICmaxwijweightcmaxi,jiICmaxrcij=pj

Because the weight of all cycles in the graph is strictly larger than zero,

weightcmax=i,jICmaxrcij-pj

Thus,

r<i,jcmaxPiji,jcmaxCIJ=rcmax

Therefore,

The basic purpose of this challenge is to find a cycle with a ratio r that falls withinthe interval. It can be accomplished through the use of binary search and the conclusions in (a) and (b).

To begin with, it's simple to show upperbound and is a lowerbound for . Then choose a value that is in the middle of these two and test for the presence of negative weight cycles in Gr. Let be the new lowerbound if there is a negative cycle in Gr (which implies that r<r*). Otherwise, the new upperbound should be r . When the length of the interval (the distance between lowerbound and upperbound) is less than , the binary search operation ends.

03

Step-3: (c) Algorithm

The basic purpose of this challenge is to find a cycle with a ratio r that falls within the choose a value r that is in the middle of these two and test for the presence of negative weight cycles inGr. Let r be the new lowerbound if there is a negative cycle inGr. When the length of the interval (the distance between lowerbound and upperbound) is less than,, the binary search operation ends.

.Initialize lowest¬0,highest¬maxi,jI^Epjcij

.while highest-lowest> , do

rhighest+lowest2

If G has negative cycle then

lowestr

else

highestr

end if

end while

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

The kSPANNING TREE problem is the following.Input: An undirected graph G=(V,E) Output: A spanning tree of G in which each node has degree k, if such a tree exists.Show that for any k2:

  1. k SPANNING TREE is a search problem.
  2. k SPANNING TREE is NP-complete. (Hint: Start with k=2 and consider the relation between this problem and RUDRATA PATH.)

Consider the following game. A “dealer” produces a sequence s1···sn of “cards,” face up, where each card si has a value vi. Then two players take turns picking a card from the sequence, but can only pick the first or the last card of the (remaining) sequence. The goal is to collect cards of largest total value. (For example, you can think of the cards as bills of different denominations.) Assume n is even. (a) Show a sequence of cards such that it is not optimal for the first player to start by picking up the available card of larger value. That is, the natural greedy strategy is suboptimal. (b) Give an O(n2) algorithm to compute an optimal strategy for the first player. Given the initial sequence, your algorithm should precompute in O(n2) time some information, and then the first player should be able to make each move optimally in O(1) time by looking up the precomputed information.

Alice wants to throw a party and is deciding whom to call. She has n people to choose from, and she has made up a list of which pairs of these people know each other. She wants to pick as many people as possible, subject to two constraints: at the party, each person should have at least five other people whom they know and five other people whom they don’t know. Give an efficient algorithm that takes as input the list of n people and the list of pairs who know each other and outputs the best choice of party invitees. Give the running time in terms of n

Here’s a problem that occurs in automatic program analysis. For a set of variablesx1,......,xn, you are given some equality constraints, of the form “ xi=xj” and some disequality constraints, of the form “ xixj.” Is it possible to satisfy all of them?

For instance, the constraints.

x1=x2,x2=x3,x3=x4,x1x4

cannot be satisfied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satisfied.

How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free