Grouping numeric data into efficient group/pool I have devices assigned with different data plan. But based on device behaviour amount of data used by device changes during the month. I need to put the device into appropriate data plan based on predicted data usages before end of the month to avoid data overage. 

There are 5MB,25MB,50MB,150MB,250MB data pool plans per device. If I put 2 devices into 25MB plan then both device can collectively use 50MB of total data among each, if there are 5 device in 25MB plan then all 5 devices collectively can use 125MB data.

My first simple approach was to based on total data usages of the device, put it into higher data plan. It was not effective because it's shared pool, and pool size varies based on how many devices are in the pool, I need to optimised the grouping of the devices into any particular data plan to optimised pool data usages. I can have any number of group/pool (Max 5 because there are 5 different data plans).

another way I tried was to cluster the device based on data usages and add them into particular group/pool, but with this cluster gets created based on how the usages data is distributed, which is not optimally close to data plan. 

Anyone know how to approach this problem to put the devices in a pool to optimally use the pools data limit and not go beyond it.
Sort all devices.

Take the first x elements until their average would be over 5 MB.

Then take the next x2 devices until their average would hit 25 MB.

Straightforward with sorted data. It's not the global optimum but will get you reasonably close.