I have a population which consist of n customers, each of them has an associated rate r and an annual purchase volume apv. Rate and volume are negative correlated to some extent:
The average weighted rate of the population is P. I want to define 5 volume buckets (defined by boundaries APV1, APV2, APV3, APV4) and apply a different rate (R1, ..., R5) to each volume bucket (but the same to all customers within the same bucket as opposed to today where it is different for each individual) with the condition that 1) the average weighted rate of the population is still P and that 2) it is optimized so the sum of the absolute rate variation of each customer is minimal
In other words, I want to find the constants for the function:

Such that:
and
is as small as possible.
I thought about using some basic ML clustering algorithms which I am familiar with such as KMeans but I think that would not work here. Any help is highly appreciated.strong text
Thanks!
