Visualization of a simulated annealing algorithm for laying out itineraries. Each rectangle contains an ordered set of stops (an “itinerary”) to be rendered. The algorithm searches for an appropriate layout by modifying the curvature of lines between consecutive stops and the positions of the stop labels. Layouts are penalized for intersections between elements, extending outside of the bounding rectangle, and violating other aesthetic criteria. A new layout is accepted if it is better than the previous layout or with some probability that tends to 0 if it is worse.
Simulated annealing avoids the cost of an exhaustive brute-force approach, while increasing the odds of finding the global optimum compared to a greedy solution.