Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help me with this algorithm prog

Name: The Masked Poopy 2012-05-07 18:13

Alright /prog/, I'm coming here for help with an algorithm I've been trying to solve but I think the problem may be intractable.

Essentially, I have n unique thing I want to buy in a market with m sellers. Not all of the m sellers sell each items. I want to construct a set of purchases so that I buy all n items the cheapest way possible. This problem, in its current form, is quite easy and can be solved by greedily buying from the cheapest offer for each item.

Here is the hard part: for these items, transactions can only be made in whole units, however items are priced to 3 decimals. Therefor if I buy something for 1.550, I end up paying 2 for it. If I buy 2 items for 1.550 and 1.300 from a seller however, I end up paying only 3 for them. How can I compute the most efficient way to buy all the items? Keep in mind my input size may be up to 200 items and 20 (possibly) unique sellers per item?

Name: Anonymous 2012-05-07 21:59

OP here, I have implemented the greedy solution and brute force solution, however the brute force solution takes >10 minutes on n=8 things to buy and it has been running for 3 hours so far on n=15. On problems with n<=8, it produces the exact same answer as the greedy solution however I'm assuming with more input this will not be the case. My goal now is to develop a heuristic to come close to the optimal solution within a reasonable time frame. My current idea is to start with the greedy solution, then try to minimize seller "waste". What do you guys think?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List