Skip to main content
3 of 5
added 192 characters in body

Here is a complete MIP (Mixed Integer Programming) model that should do the trick. I just use some random data (weights) with 100 widgets and 50 possible bins. When solved the variable NumUsedBins gives the maximum number of bins and the variable x gives the assignment. The equation 'order' is to make sure we use lower numbered bins first. The strange statement about optcr is to tell the solver to solve to optimality (for very difficult problems you may want to stop at 5% or so).

enter image description here

I don't think we need an equation that says: if y(i)=0 => x(i,j) = 0 but I am still pondering about this. It may be needed to prevent some left over widget to be assigned to an unused bin.