Difference between revisions of "287: NP-Complete"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
m (Description)
Line 14: Line 14:
 
Another entry in the “My Hobby” series of cartoons; here, Cueball is embedding NP-complete problems in restaurant orders. Specifically, he is ordering appetizers not by explicitly stating the names of the appetizers, but by the total price of the chosen appetizers. This is a (simplified) example of the knapsack problem. The [[wikipedia:Knapsack_problem|knapsack]] (or rucksack) problem is a problem in combinatorial optimization, as follows: if you have a knapsack (or backpack, or rucksack, as your regional desire to call it may be) which can hold a specific amount of weight, and you have a set of items, each with its own assigned value and weight, can you select items to put into the knapsack so that (1) the weight does not exceed the capacity of the knapsack, and (2) the combined value of all the items is maximized. (The example in this cartoon is simplified, because we are not given the corresponding “value” of each item – like we would be if, for example, Cueball and his two friends assigned a perceived value of 7 on a scale of 1 to 10 for getting hot wings, but only a 2 out of 10 for a side salad. Another way to introduce complexity into the problem would be if the patrons were considering the calorie values of each appetizer on the menu.)
 
Another entry in the “My Hobby” series of cartoons; here, Cueball is embedding NP-complete problems in restaurant orders. Specifically, he is ordering appetizers not by explicitly stating the names of the appetizers, but by the total price of the chosen appetizers. This is a (simplified) example of the knapsack problem. The [[wikipedia:Knapsack_problem|knapsack]] (or rucksack) problem is a problem in combinatorial optimization, as follows: if you have a knapsack (or backpack, or rucksack, as your regional desire to call it may be) which can hold a specific amount of weight, and you have a set of items, each with its own assigned value and weight, can you select items to put into the knapsack so that (1) the weight does not exceed the capacity of the knapsack, and (2) the combined value of all the items is maximized. (The example in this cartoon is simplified, because we are not given the corresponding “value” of each item – like we would be if, for example, Cueball and his two friends assigned a perceived value of 7 on a scale of 1 to 10 for getting hot wings, but only a 2 out of 10 for a side salad. Another way to introduce complexity into the problem would be if the patrons were considering the calorie values of each appetizer on the menu.)
  
The knapsack problem is, as indicated by the title of the strip, [[wikipedia:NP_complete|NP-complete.]] In computational complexity theory, NP stands for “nondeterministic polynomial time.” Basically, for an NP-complete problem, there is no efficient way to find a solution, but it is relatively easy to verify that a solution works. Conceptually, for the problem posed in this comic, the most straightforward way to find a solution (not even knowing for certain if there is one) is to methodically start by first listing all the (6) ways of choosing one appetizer, and their totals (which of course are the prices of each appetizer), then list all the (15) ways of choosing two appetizers (allowing the same appetizer to be chosen twice, since we are assuming that the chef can create more than one sampler platter), and then list all the (56) ways of choosing three appetizers, and so forth. As any combination of eight appetizers would be more than $15.05, the process need not extend beyond listing all the (1709) ways of choosing seven appetizers.
+
The knapsack problem is, as indicated by the title of the strip, [[wikipedia:NP-complete|NP-complete.]] In computational complexity theory, NP stands for “nondeterministic polynomial time.” Basically, for an NP-complete problem, there is no efficient way to find a solution, but it is relatively easy to verify that a solution works. Conceptually, for the problem posed in this comic, the most straightforward way to find a solution (not even knowing for certain if there is one) is to methodically start by first listing all the (6) ways of choosing one appetizer, and their totals (which of course are the prices of each appetizer), then list all the (15) ways of choosing two appetizers (allowing the same appetizer to be chosen twice, since we are assuming that the chef can create more than one sampler platter), and then list all the (56) ways of choosing three appetizers, and so forth. As any combination of eight appetizers would be more than $15.05, the process need not extend beyond listing all the (1709) ways of choosing seven appetizers.
  
 
The image text refers to the fact that NP-complete problems have no known general solution. (A general solution would be the optimal solution to this problem generalized to allow any prices for the appetizers.) If the waiter can find an efficient general solution to this, or any NP-complete problem, he will have solved one of the most famous problems in computer science, whether or not P=NP. In other words, if every problem whose solution can be quickly verified by a computer can also be quickly solved by a computer. This problem is one of the seven [[wikipedia:Millennium_Prize_Problems|Millennium Prize Problems]] stated by the Clay Institute in 2000, six of which (including whether P=NP) are still unsolved, for which a correct solution is worth US$1,000,000.
 
The image text refers to the fact that NP-complete problems have no known general solution. (A general solution would be the optimal solution to this problem generalized to allow any prices for the appetizers.) If the waiter can find an efficient general solution to this, or any NP-complete problem, he will have solved one of the most famous problems in computer science, whether or not P=NP. In other words, if every problem whose solution can be quickly verified by a computer can also be quickly solved by a computer. This problem is one of the seven [[wikipedia:Millennium_Prize_Problems|Millennium Prize Problems]] stated by the Clay Institute in 2000, six of which (including whether P=NP) are still unsolved, for which a correct solution is worth US$1,000,000.

Revision as of 19:33, 7 August 2012

NP-Complete
General solutions get you a 50% tip.
Title text: General solutions get you a 50% tip.

Image Text

General solutions get you a 50% tip.

Description

Another entry in the “My Hobby” series of cartoons; here, Cueball is embedding NP-complete problems in restaurant orders. Specifically, he is ordering appetizers not by explicitly stating the names of the appetizers, but by the total price of the chosen appetizers. This is a (simplified) example of the knapsack problem. The knapsack (or rucksack) problem is a problem in combinatorial optimization, as follows: if you have a knapsack (or backpack, or rucksack, as your regional desire to call it may be) which can hold a specific amount of weight, and you have a set of items, each with its own assigned value and weight, can you select items to put into the knapsack so that (1) the weight does not exceed the capacity of the knapsack, and (2) the combined value of all the items is maximized. (The example in this cartoon is simplified, because we are not given the corresponding “value” of each item – like we would be if, for example, Cueball and his two friends assigned a perceived value of 7 on a scale of 1 to 10 for getting hot wings, but only a 2 out of 10 for a side salad. Another way to introduce complexity into the problem would be if the patrons were considering the calorie values of each appetizer on the menu.)

The knapsack problem is, as indicated by the title of the strip, NP-complete. In computational complexity theory, NP stands for “nondeterministic polynomial time.” Basically, for an NP-complete problem, there is no efficient way to find a solution, but it is relatively easy to verify that a solution works. Conceptually, for the problem posed in this comic, the most straightforward way to find a solution (not even knowing for certain if there is one) is to methodically start by first listing all the (6) ways of choosing one appetizer, and their totals (which of course are the prices of each appetizer), then list all the (15) ways of choosing two appetizers (allowing the same appetizer to be chosen twice, since we are assuming that the chef can create more than one sampler platter), and then list all the (56) ways of choosing three appetizers, and so forth. As any combination of eight appetizers would be more than $15.05, the process need not extend beyond listing all the (1709) ways of choosing seven appetizers.

The image text refers to the fact that NP-complete problems have no known general solution. (A general solution would be the optimal solution to this problem generalized to allow any prices for the appetizers.) If the waiter can find an efficient general solution to this, or any NP-complete problem, he will have solved one of the most famous problems in computer science, whether or not P=NP. In other words, if every problem whose solution can be quickly verified by a computer can also be quickly solved by a computer. This problem is one of the seven Millennium Prize Problems stated by the Clay Institute in 2000, six of which (including whether P=NP) are still unsolved, for which a correct solution is worth US$1,000,000.

Another famous NP-complete problem is the Travelling Salesman problem, also mentioned in the strip. An example: suppose a traveling salesman has to visit ten cities and then return home, and it is possible to directly travel from any city to any other city (by plane, for example.) What is the minimum distance (or time, or cost) necessary for the trip? Like the knapsack problem, it is (usually) difficult to find the best solution without trying a very large number of combinations. Cueball mentions this problem after the waiter states he has to tend to six other tables.

A film reference is embedded in the menu in the first panel: the restaurant is called “Chotchkies,” a fictional restaurant featured in the film Office Space. (In that film, the character Joanna, played by Jennifer Aniston, quits her job at Chotchkies, a typical family-oriented chain restaurant, over their policy that she wear a large number of “flair” items – tacky pins, buttons, or other adornments to a worker’s uniform which can often be seen on waiters and waitresses at chain family restaurants, as well as those who work at movie theaters or large retail chain stores.

Solution

There are exactly two solutions to the problem posed in the comic strip, combinations of appetizers which total $15.05: either (1) seven mixed fruit orders, or (2) a combination of two orders of hot wings, one order of mixed fruit, and one sampler plate.