Perhaps this is a little redundant for what you are looking for.
You can use the Simulated Annealing algorithm, which is usually used in electronics, to find the optimal layout for all tiny electronic components inside a microchip in a limited area, which is basically the same problem as finding the best layout for a set of images inside a browser window.
Basically, this algorithm gives you a good solution, but does not guarantee that it will be the best. Read the Wikipedia article carefully as it explains it better than me.
You can also check out this Simulated Annealing applet for a problem with the seller. Test the temperature of 500 and watch what happens when it freezes.
Hope this helps.
source share