I have the following problem and would like an orientation on which algorithms I can try to adapt to solve it in the best possible way.
SCENARIO
A company has a warehouse where it stores several products. A product can be stored in several packages, for example:
1 box with 10 units
1 box with 3 boxes of 10 units
1 box with 30 units
1 box with 5 boxes of 30 units
Eventually these products need to be dispatched for consumption in the company's stores. Each store makes its own request for products according to their needs.
However, such requests do not take into account the available packaging, ie the quantity requested may or may not coincide with the quantity of a particular packaging.
Example:
1 box with 8 lunits
2 boxes with 2 units
1 box with 4 units
1 box with 6 units
The store could request 13 units of product, and thus there would be no packaging combination that could total exactly 13 units.
However, there would be the following options to meet the store order:
1 box of 8 units and 1 box of 4 units (total: 12)
1 box of 8 units and 2 boxes of 2 units (total: 12)
1 box of 8 units and 1 box of 6 units (total: 14)
1 box of 8 units, 1 box of 4 units and 1 box of 2 units (total: 14)
In a scenario like this I need an algorithm that might find the packaging combination to be closer to the exact value.
In the real scenario, there are dozens of possible combinations, where I need to find 3 possible combinations:
- The combination that meets the exact requested quantity (requested: 20, combination: 20)
- The combination that gets as close as possible through a lower value than requested (requested: 20, closest combination: 18)
- The combination that answers as close as possible through a value greater than requested (requested: 20, closest combination: 23)
Is there an algorithm already known that can fit well into this scenario where I can just adapt to my context?