I'm trying to determine the least shipping cost when you have a number of items (each with a weight and a price) that can be combined into the same package. The constraints are as follows:
- There is a limit on the max price of the combined package (say $15)
- The cost of the package is determined using the following table:
- If total weight of package is < 30 grams, cost is 7.5
- If total weight of package is >= 30g and <80g, cost is 7.5 + (weight - 30)x0.075
- If total weight of package is >= 80g, cost is 7.5 + (weight - 30)x0.055
There is no limitation on the number of packages these items can be combined into as long they remain under the total price threshold.
I looked at the knapsack problem, but there are 2 major differences between the knapsack problem and my problem:
- One is that we are not maximizing the weight or price of the items combined, instead we want to minimize a calculated variable that can only be determined after the combination.
- Also, there isn't a direct correlation between weight and shipping cost.