0

Here is the scenario:

There are n boxes with various capacity at the beginning of each box before assigning.

I want to fit x parcels into the boxes, letting the capacity after assigning for each boxes are as even as possible.

The solution I have thought of is:

score = 0
for i in range(len(result)):
    capacity_left = boxes["box"]["capacity"] - sum(result[i])
    score += capacity_left ** 2
model.Maximize(score)

where result is a matrix:

[[1,0,0,1],
 [0,0,1,0],
 [0,1,0,0]]

meaning the first and fourth parcel is assigned to the first box, the third parcel is assigned to the second box, and the second parcel is assigned to the third box.

2
  • That would make the model a MIQP (Mixed-Integer Quadratic Programming) model. This typically requires a high-end solver. You may be able to achieve something similar by just maximizing the minimum of the capacity left. Commented Nov 18, 2021 at 20:39
  • Does this answer help? Commented Dec 13, 2021 at 2:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.