I'm searching for the generic name of an algorithm/method that would allow me to solve this type of problem efficiently.
I have a continuous line which I traverse, from one side to the other. Along that line are buckets, placed at various positions which have a given size. Along the line are also items that I have to pick up, and place in buckets. I want to optimise placing the items in the buckets to minimise the distance between items and buckets. The combined size of all buckets is always larger than the number of total items.
I cannot only use "shortest distance", because it may very well be that my bucket fills up too fast and the neighbouring items end up having to end in a bucket far away.
Is there a generic method to help me solve that kind of problem, or do you have some pointers in the right direction at least? I can find an algorithm by myself but I'd like to expand my knowledge list as well 😊.
Here is an illustration of what I mean :
--x----x-----x-----x-------x-x----x----x-x-x-x-----------x-x-x----x----> 2 5 3 9
In that case, what is an efficient way to place items in buckets to optimize "distance to buckets"?