If I understand the problem correctly, you want to create the maximum and most uniform distance array possible.
Brute force
Unfortunately I believe this problem is NP-hard, meaning if it absolutely has to be the optimal solution, you may be better off cycling through all possible permutations of the array and picking the best. If you have a relatively small array, this may, in effect, be your best bet.
The pseudocode for finding the best solution using brute force would be something like:
var max = MIN; for each permutation of array var score = getScore(permutation) if(score > max) max = score; end
getScore represents how you determine what makes up a "best array". I saw that in your best solution for what you provided, there was a "2" among the other distance values of 1, which means you tolerate solutions with non-uniform answers. My suggestion would be something along the lines of adding up all distances and subtracting a penalty for each distance which varies from the most common. How much you subtract will determine how important it is that they are all uniform (perform some trial and error to understand what works best).
Genetic algorithms
If you want a really good solution, but not necessarily the best, then you should consider using genetic algorithms.
If you're new to Java, I apologize! This is definitely not the best thing to start off with if you're new to Java.
The idea behind genetic algorithms is that you create a population of list orderings (could be a list of indexes). It doesn't have to hold every possible combination, just around 50 or so. With each turn of the algorithm, you evaluate each solution's "score" (equivalent of getScore mentioned above). Then, 50/2 times, you randomly select two solutions with weighted probability favoring those solutions which had a higher score and you create two new solutions from the two parent solutions. You then have a new population which you can then perform another turn, and so forth and so on.
If you continue in this way, often the trend emerges that you will see scores improve in the population and if done properly, these solutions will improve as well. Consider always directly including the solution with the best score in each turn, or you risk to lose your very best solution at each turn.
Simulated annealing
Simulated annealing is the process of modifying a solution slightly in order to improve or worsen a solution. If it worsens, then you keep the solution you had before. If it improves, you keep the new solution. In either case, you continue to modify the solution until no change to the solution brings a better one. This is a very simple algorithm, but it is guaranteed to find you at least a local maximum.
In your case, the changes you would be making would be the list ordering. Say rather than use list ordering 0,1,2,3, you try 0,2,1,3 and you find its score is better. You keep 0,2,1,3, and you try to modify something else.
I hope that helps!
|d| = 10, u = 3or|d| = 12, u = 7? (Thereby:|d|is the length of the distance vector,uis the variance in the distance vector). Or do you have some formula which makes the pair measurable?|d|will be minimal. Now if you take the highest value in the vector and put it in the middle of a new vector. Then you take the two smallest values and put those each on one side of the first value. Next you take the two highest values and then again the lowest values. And so on. That should give a quite maximized|d|. It might even be the absolute maximum. But the variance will be horrible. Without a rule for a trade off, I'm pretty stuck now.