|Just another Perl shrine|
Re: Bag uniform distribution algorithmsby LanX (Canon)
|on Oct 28, 2013 at 17:09 UTC||Need Help??|
I'd say this is an (discrete) optimization problem, which kind depends on the distance function to minimize (i.e. distance from idealized optimal solution)
One possibility is to measure the integer distances between elements of one bag and to sum up the deltas to the idealized real number distance. You can also sum up the quadratic deltas and take the square root (Norm_(mathematics)#Euclidean_norm). Which "norm" to take depends on your intuitive understanding of "uniformity".
I think you can get very good results with heuristic approaches involving some random elements, but w/o guaranty of being optimal.
Maybe of interest, the following algorithm will calculate all >12000 combinations of your bags, you can use the output to test different distance functions (or norms) to refine your understanding of "uniformely distributed".
Please note the flag '$MODULO_ROTATION' which allows to limit to the subset of solutions which can generate all other solutions by rotating the bytes, this might facilitate calculation of the distance.
Of course you could already combine this slow branching approach with a distance function which avoids walking thru inefficient sub-tree for a branch-and-bound solution... (i.e. bound if the distance so far already exceeds the known local minimum)
But I doubt you would want to use this in praxis...
( addicted to the Perl Programming Language)