Re: knapsack related question
- From: "Proginoskes" <proginoskes@xxxxxxxxxxxxx>
- Date: 22 Apr 2005 13:57:25 -0700
JoJo wrote:
> Hi all,
>
> I have the following question: suppose I have a set
> S of primes p (each prime can be present multiple
> times in the set), and I have a number X. If the
> product of all the primes in S is larger than X,
> then I should be able to select a subset T from S,
> such that the product of primes in T approaches the
> value X best.
>
> If we take the log of all values, then the problem
> is converted to the summation of a subset of values,
> this can be seen as the knapsack problem with binary
> weights applied to log(S) (I guess, I'm certainly
> not an expert here...).
You almost got there. 8-) "Binary weights" means that each prime could
only be included once. What you want are integer weights. (You may be
able to get a binary weight problem out of it by listing log(p) more
than once.)
> The problem now is: is there an algorithm that solves
> this problem (the original product-problem or the
> knapsack problem), described in such a way that it
> can be implemented in software? I did some searches
> on the Internet and could not find a good entry which
> helps me further to a good solution.
Being a knapsack problem, I doubt that there are any *short*
algorithms.
One paper that lists a couple of algorithms is:
Hifi, Mhand; Sadfi, Slim; Sbihi, Abdelkader. An efficient algorithm for
the knapsack sharing problem. Comput. Optim. Appl. 23 (2002), no. 1,
27--45.
(I got this paper by going to http://ams.rice.edu/mathscinet/search/
and searching for knapsack and algorithm*. If you have access, this
would be a recommended place to go. Approximat* would also be a good
search term, to approximate.)
One thing you didn't mention was whether there was anything special
about the primes or about X. If so, maybe that can be exploited.
--- Christopher Heckman
.
- References:
- knapsack related question
- From: JoJo
- knapsack related question
- Prev by Date: Re: (in-)homogeneous boundary conditions?
- Next by Date: Re: abundance of irrationals!)
- Previous by thread: knapsack related question
- Next by thread: Re: knapsack related question
- Index(es):
Relevant Pages
|