home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!yale.edu!yale!gumby!destroyer!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.programming
- Subject: Re: Knapsack problem??
- Message-ID: <1992Dec21.191234.17727@organpipe.uug.arizona.edu>
- Date: 21 Dec 92 19:12:34 GMT
- References: <1992Dec17.210241.8948@julian.uwo.ca>
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Organization: University of Arizona
- Lines: 24
- In-Reply-To: john@phobos.sscl.uwo.ca (John Tucker)
-
- In article <1992Dec17.210241.8948@julian.uwo.ca>, john@phobos (John Tucker) writes:
- > I have N items with an associated cost of Cn. I want to select
- >the best subset of these items where TotalCost-Tolerance < Sum(Cn) <
- >TotalCost.
- >
- > I know it is a form of a knapsack problem
-
- Yup.
-
- >but I can't recollect the
- >elegant way of coding this. I'm using a brute force algorithm based on
- >2^n possible combinations of n objects taken 0..n at a time. This limits
- >me to a max of 32 items and is slow (micro) to acceptable (DECstation 5000).
-
- I hate to break this to you, but the Knapsack problem is NP-complete.
- That means if someone does find a polynomial-time algorithm to solve it,
- they'll gain fame (well, at least within CS circles) as well as the
- satisfaction of having solved a long-standing open question in CS theory.
-
- On the other hand, there could very well be a polynomial time algorithm
- for a special case which is useful for your purposes.
-
- --
- Dave Schaumann dave@cs.arizona.edu
-