1

I'm looking for an algorithm for the following problem:

I have a set of x distinct components and a set of y supplier for those components. I know the price p(x,y) for each component from each supplier. I also know the shipping cost s(y) for each supplier, which is obviously cheaper if you just buy from just a few suppliers. Not all suppliers have each component available. I want to buy all components once, but need to get the cheapest total price or at least a very closed small value.

The straight forward approach would be to try each combination, which could take some time if x and y get very large, although it could be parallelized. Any suggestions are appreciated.

For simplicity let's say x = 100, y = 1000.

Andibioticum
  • 305
  • 2
  • 10
  • 1
    Why not simply by each component from the supplier with the lowest price? Or do you need to by everything form the same supplier? – MrSmith42 Nov 30 '21 at 10:10
  • Good point, thanks for pointing this out! I completely forgot to mention the advantage of lower shipping costs if you order from just one supplier. Editing my post. – Andibioticum Nov 30 '21 at 10:14
  • 2
    Wow, the edit took the question to a fully new level. It was a simple greedy algorithm first. Now it's a dp problem. Please add constraints as this would have a major impact on the implementation/approach. – user1984 Nov 30 '21 at 10:20
  • Thank you for the remarks and sorry for missing that point – Andibioticum Nov 30 '21 at 10:58
  • 2
    Not much detail here. This may well be easy to formulate as a Mixed-Integer Programming model. Of course, this depends on what "very large" means. It may be useful anyway in order to compare against some heuristic (to get a feeling of how good the heuristic is). – Erwin Kalvelagen Nov 30 '21 at 11:48
  • Added example values for x and y – Andibioticum Nov 30 '21 at 13:35
  • 2
    This looks like a fixed-charge problem (shipping costs look like a fixed cost). As not all component/supplier combinations are allowed this is a sparse problem. If modeled correctly, this results in a large but quite doable MIP problem. With a good MIP solver, I suspect this takes a couple of minutes. – Erwin Kalvelagen Nov 30 '21 at 14:51

1 Answers1

1

Thanks for all the comments. They pointed me in the right direction, to formulate the problem like displayed below.

Minimize the sum of all items plus shipping costs:

p(0,0)*x00 + p(0,2)*x02 + p(1,2)*x12 + ... + ship(0)*y0 + ship(1)*y1 + ...

with x and y in [0,1], p(n,m) is the price of item n for supplier m and ship(m) is the shipping cost for supplier m

Subject to:

  1. Retrieve each item exactly one time, like this:
p00 + p01 = 1
p12 + p13 + p15 = 1
p20 + p21 = 1
...
  1. Shipping cost is taken into account if one item is bought from this supplier
y0 >= x00
y0 >= x10
y1 >= x01
...
Andibioticum
  • 305
  • 2
  • 10