How can I distribute weights knowing what's inside the box

124 Views Asked by At

I have this problem and I think that I'm gonna need a mathematical solution.

I have some boxes. Of these, I only know their total weight and what is inside each one. I have to calculate each one's weight.

For example I have:

Total weight: 100
Number of boxes: 5
Number of items: 14

Stock:
Type1: 2 items
Type2: 1 items
Type3: 7 items
Type4: 4 items

Box #1: 
Type1: 2 items
Type2: 1 items

Box #2: 
Type4: 3 items

Box #3: 
Type3: 3 items

Box #4: 
Type3: 2 items
Type4: 1 items

Box #5: 
Type3: 2 items

Each box can potentially have n types of items, so how can I distribute the total weight?

I cannot divide the total weight by the number of boxes because the result would be equal for all boxes and this is not a real case.

1

There are 1 best solutions below

1
On

You have:

  • Four variables - the weight of each item type
  • One linear equation 2A + B + 7C + 4D = 100 - what you know about the total weight.
  • Some linear inequalities - you know that A, B, C and D are all positive.

There's an infinite number of possible solutions. For example A=B=C=2,D=20 or A=B=C=4,D=15 and everything in between.