Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The first thing you need to do is to precisely define the result you want.</p> <p>You do this by defining how good a result is, so that you know which is the best one. Mathematically you do this by a <em>cost function</em>. In this case one would typically choose the sum of the distances between related elements, the sum of the squares of these distances, or the maximal distance. Then a list with a small value of the cost function is the desired result.</p> <p>It is not clear whether in this case it is feasible to compute the best solution by some special method (maybe if you choose the maximal distance or the sum of the distances as the cost function).</p> <p>In any case it should be easy to find a good approximation by standard methods.</p> <p>A simple <a href="http://en.wikipedia.org/wiki/Greedy_algorithm" rel="nofollow">greedy approach</a> would be to insert each element in the position where the resulting cost function for the whole list is minimal.</p> <p>Once you have a good starting point you can try to improve it further by modifying the list towards better solutions, for example by swapping elements or rotating parts of the list (<a href="http://en.wikipedia.org/wiki/Local_search_%28optimization%29" rel="nofollow">local search</a>, <a href="http://en.wikipedia.org/wiki/Hill_climbing" rel="nofollow">hill climbing</a>, <a href="http://en.wikipedia.org/wiki/Simulated_annealing" rel="nofollow">simulated annealing</a>, <a href="http://en.wikipedia.org/wiki/Metaheuristic" rel="nofollow">other</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload