I'm trying to find the name of this problem, and with it a reasonable algorithmic solution.
Setup: There are $n$ items with weights $w_1,\dots,w_n$, and $m<n$ buckets with target weights $a_1,\dots,a_m$, satisfying $\sum_iw_i=\sum_ja_j=1$. The goal is to find an assignment $f:\{1,\dots,n\}\to\{1,\dots,m\}$ of the weights to the buckets such that $f$ is nondecreasing (the weights have to be in the same order as the buckets) and the sum of the weights in each bucket is "close" to the target for that bucket.
The sense of "closeness" is up to the implementation (whatever is easiest to model), but for concreteness let's suppose this is least-squares error; then we can define the error of a given assignment as $\varepsilon(f)=\sum_{i=1}^m(\sum_{j:f(j)=i}w_j-a_i)^2$, and the goal is to find the $f$ that minimizes $\varepsilon(f)$.
This problem seems similar to the knapsack problem, but there are some differences in the constraints and I don't know if this is also NP-complete. Does this problem have a name or reduce to a named problem?