Channels ▼
RSS

Tools

Tough Apps: Pretty Good at Half the Speed


Solutions

1. Why is the heuristic of doing the most expensive job first not optimal? Well, suppose that there are 5 jobs: 45 min, 40 min, 15 min, 11 min, 9 min and two machines. According to the heuristic, they should be scheduled this way m1: 45 min, 11 min m2: 40 min 15 min, 9 min But it would be better for m2 to do 11 and 9 when it's finished with the 40 minute job. Then all jobs would complete in 60 minutes rather than 64 minutes.

2. Order the items from longest to shortest. Put the trucks in a line. For each item, put it on the first truck on which it will fit. All trucks but one will be at least half full. Here is why: if any two trucks A and B are less than half full and A precedes B in line, then all the items on B would have gone on A or onto some other truck. So this is within a factor of two of the minimum possible number of trucks (possibly with one extra truck). In practice, it will usually be much better.

3. Go up and down the minimum spanning tree edges as shown in Figure 3. Since the minimum spanning tree costs no more than the optimal route, traversing every edge both ways cannot cost more than twice the optimal route. This can be improved by taking shortcuts as shown in Figure 4.

[Click image to view at full size]
Figure 3.

[Click image to view at full size]
Figure 4.

Further Reading

How to Solve It: Modern Heuristics by Z. Michaelewicz and D. Fogel, Springer Verlag, ISBN 3642061346.

Approximation Algorithms for NP-Hard Problems by Dorit Hochbaum, Brooks/Cole Pub Co; ISBN: 0534949681; 1st edition (July 26, 1996).


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video