Balancing integer bins to have a certain summation Assume that we have bins
$$ B_1, B_2 ..., B_n $$
There exists integer bin values $$ V_1, V_2 ..., V_n $$
Let $$ Total_{V} =\sum_{i=1}^{n} V_i$$
There then exists weights (  $ W $) of each bin to its total  Where $$W_i = \frac{V_i}{Total_{v}} $$

Given a new total of bin values $Total_{new}$
I am trying to find the ideal values $$ V'_1, V'_2 ..., V'_n $$
Where $$ \sum_{i=1}^{n} V'_i = Total_{new}$$ and $$ \sum_{i=1}^{n} (W_i - W'_i)$$ is minimized as much as possible.
Put simply, I am trying to take an array of integers and balance them in such a way that their summation is equal to some new provided integer and their new values are as similar as possible to distribution as before. 
For example given integers 1,2,3,4 and a goal of 100 the new set of integers would be 10,20,30,40. This is an perfect/easy solution because the old ratios between $\frac{1}{10},\frac{2}{10},\frac{3}{10},\frac{4}{10}$ and $\frac{10}{100},\frac{20}{100},\frac{30}{100},\frac{40}{100}$ are identical.
A non-ideal solution would be given integers 100 and 101 and a goal of 200, the result would be 100 and 100. These ratios are not identical but are as close as possible $\frac{100}{201},\frac{101}{201}$ and $\frac{100}{200},\frac{100}{200}$
A more extreme example would be 10, 1, 10, 10, 15000 with an end goal of 17000. The new set of integers would be like 11, 1, 11, 11, 16966
The method I have devised so far goes through an iterative approach of finding remainders and distributing: https://dotnetfiddle.net/vP5rtN (This only works on an new total that is greater than the old total, that is, it only adds to the bin values and never subtracts)
I am interested in the mathematical ideal approach to this problem.
 A: I will assume the measure of "quality" was intended to be defined as $$\sum_{i=1}^n |W_i-W'_i|$$ (i.e. sum of absolute differences, rather than the differences; which is trivially equal to zero).

The quantity we are optimizing can be expressed as
$$\sum_{i=1}^n \left|\frac{V_i}{Total_v} - \frac{V'_i}{Total_{new}}\right| = \frac{1}{Total_{new}}\sum_{i=1}^n \left|\frac{Total_{new}}{Total_v}V_i - V'_i\right|$$
Since all the quantities other than $V'_i$ are fixed and minimality is not affected by multiplication by a fixed positive value, our problem is equivalent to the following one: Let $D_1,D_2,\ldots,D_n$ be positive real numbers whose sum is an integer. Find the sequence of integers $V_1,V_2,\ldots,V_n$ satisfying $$\sum_{i=1}^n V_i=\sum_{i=1}^n D_i$$ which minimizes the sum $$\sum_{i=1}^n \left|D_i-V_i\right|$$
If all the $D_i$ happen to be integers, the optimal solution is trivial. Otherwise, there are some indices $i$ for which $V_i<D_i$ and some indices $j$ for which $V_j>D_j$.
If we had $V_i\leq (D_i-1)$ for some index $i$, we could increase $V_i$ by one and decrease some $V_j$ by one. The value of $|D_i-V_i|$ would decrease by one, while the value of $|D_j-V_j|$ would change by less than one (even if it increases, it will only increase by less than $1$). But that means the full sum would decrease too and our sequence $V_1,V_2,\ldots,V_n$ could not have been optimal. The same kind of reasoning applies to the case when $V_j\geq (D_j+1)$ (decreasing $V_j$ by one and increasing $V_i$ by the same amount improves the sum). Thus, the optimal solution necessarily satisfies $|V_k-D_k|<1$ for all $k$.
This gives us at most two possibilities for each $V_k$: It can be equal to either $\lfloor D_k\rfloor$ or $\lceil D_k\rceil$. Put another way, the optimal solution must assign $\lfloor D_k\rfloor$ to every bin and whatever remains must be distributed among the bins, by adding $1$ to some of them (thus changing them into $\lceil D_k\rceil$).
The optimal choice is now easy enough: the best bins to add $1$ to are those for which $\lceil D_k\rceil - D_k$ is as small as possible; which is equivalent to requiring the so-called fractional part of $D_k$ (defined as $\{D_i\}:=D_i-\lfloor D_i\rfloor$) to be as large as possible. 

Put together, the optimal algorithm is quite simple:


*

*Set $D_i:=\frac{Total_{new}}{Total_v}V_i$.

*Let $K:=Total_{new}-\sum_{i=1}^n \lfloor D_i\rfloor$.

*Sort $(D_1,D_2,\ldots,D_n)$ according to the value of $\{D_i\}$ in descending order.

*Set first $K$ values of $V'_i$ equal to $\lceil D_i\rceil$ and the remaining $N-K$ ones to $\lfloor D_i\rfloor$.


For example, your case of $10, 1, 10, 10, 15000$ and $Total_{new}=17000$ would be best scaled as $12,1,11,11,16965$ ($K$ was equal to $2$).
