What algorithm would pair parcels with a high proportion of property x to a parcel with a low proportion of property x so that the weighted average of the two parcels falls within an upper and lower bound? The algorithm needs to pair a set of parcels to maximise the quantity that fall into the given range. The parcels are of differing size.
For example, suppose I have a table of data that has tonnes of each block and percentage iron in each block. I can process two blocks at the same time to create an average iron percentage. I want to change the sequence of each block to maximise the tonnes that fall inside a percentage iron range.
2
Create a list of all the parcels sort the list of parcels by weight.
Remove parcels from either the head or the tail of the list until the average weight falls within an acceptable range.
Pair each parcel at the head with a parcel at the tail, moving inwards, to get your pairs of parcels.