home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!newshost.uwo.ca!phobos.sscl.uwo.ca!john
- From: john@phobos.sscl.uwo.ca (John Tucker)
- Subject: Knapsack problem??
- Organization: University of Western Ontario
- Date: Thu, 17 Dec 1992 21:02:41 GMT
- Message-ID: <1992Dec17.210241.8948@julian.uwo.ca>
- Summary: C code for knapsack algorithm needed
- Sender: news@julian.uwo.ca (USENET News System)
- Nntp-Posting-Host: phobos.sscl.uwo.ca
- Lines: 24
-
- Here is my problem:
- 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, 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 know there is an excellent book (with code), but I can't remember
- the name or author ...and its probably already signed out of the library.
-
- So if you have any code (C C++ Pascal Modula-2) which can help me,
- or if you know of an ftp site. Please Help!!!
-
- E-mail me as :jtucker@uwo.ca
-
-
- --
- --
- jtucker@uwo.ca John Tucker
-
- A university is what a college becomes when the faculty loses interest
-