Paintings from Polygons Improving the Cooling Schedule of Simulated Annealing
Total Page:16
File Type:pdf, Size:1020Kb
Paintings from Polygons Improving the Cooling Schedule of Simulated Annealing Redouane Dahmani Institute for Informatics, University of Amsterdam, Science Park 904, 1098XH Amsterdam, The Netherlands [email protected] Abstract. In an earlier study nature-inspired iterative optimization al- gorithms were used to reconstruct paintings from polygons. One of the used algorithms was simulated annealing, unfortunately this algorithm did not perform well. The simulated annealing is going to be adjusted in this study to try to achieve better performance. This will be done by making two kinds of changes in the cooling schedule. First, parameter settings of the original cooling schedule will be changed. Subsequently, there will be used new different cooling schedules. The cooling schedules that are new in this study are geometric, linear, cosine, linear reheat, sigmoid and staircase. There will be shown that all the cooling schedules used in this study are performing better than the cooling schedule in the earlier study. Keywords: Paintings · Polygons · Simulated annealing · Cooling sched- ules 1 Introduction Paauw and Van den Berg [11] researched the usage of three nature-inspired iterative optimization algorithms. The goal of their study was to approximate images of paintings, constructing these from stacked semi-transparent colored polygons. To achieve this goal, features of these polygons should be optimized, such as the location of the vertices, the color and the opacity of the polygon. The three algorithms used to optimize these features are the stochastic hillclimber, the simulated annealing and the plant propagation algorithm. The simulated annealing will be the center of attention in this study. The procedure of the simulated annealing of Paauw and Van den Berg looks like this: initially, a single random polygon constellation is initialized. This is done by randomly creating polygons and placing them on a black canvas. After the initialisation, a polygon will be mutated at every iteration. The mutation that will be done is chosen randomly, choosing from: move a vertex, transfer a vertex from one polygon to another, change the color of a polygon and change the drawing index of a polygon. After every iteration the mean squared error will be calculated over each pixel's color value. The calculated error value will be compared with the error value of the previous state. If the error value improves, 2 R. Dahmani the new state will be accepted. If the error value worsens, the new state can still be accepted, but with a probability which decreases as the difference in error value increases or as more iterations passes. The exact probability is calculated with a function which relies on the cooling schedule of Geman & Geman [6]. This research will face a challenge stated in the study of Paauw & Van den Berg: finding better results by changing parameter settings in the simulated annealing algorithm. Their simulated annealing led to poor results in comparison to the hillclimber. The believed cause of these poor results is the cooling schedule that the simulated annealing used. The rest of this paper is organized as follows: 8 different new cooling schedules will be tested to try to improve the results found in the original paper. The new cooling schedules will be found in two ways. First, literature about the simulated annealing algorithm and studies in which the simulated annealing algorithm are used will be researched. This research of the literature should lead to finding other frequently used cooling schedules. Second, the cooling schedule that had been used in the original research and the ones that have been found in the studied literature can be analysed and adjusted. The adjustments of these cooling schedules are new cooling schedules as well. All these new cooling schedules will be implemented in the simulated annealing algorithm to try to find better results. This first part will lead to the research question: Which parameter settings or cooling schedules will improve the results of the simulated annealing algorithm? In the second part of this research, the statistics of the final polygon constel- lations will be investigated. There will be looked at two different statistics. The first is the frequency of the number of vertices per polygon, so the number of triangles, squares, pentagons, etc. The second is the alpha value of the polygons per layer, so the opacity of the polygons per drawing index. These results on the number of vertices per polygon or the alpha value can have some interesting information for future studies. All the programmatic resources and algorithms that are used (programmed in Python 3.6.3) are publicly available [5]. 2 Related Work The introduction of the simulated annealing algorithm was done independently by Kirkpatrick, Gelatt & Vecchi in 1983 [7] and Cern´yinˇ 1985 [4]. This nature inspired algorithm derives from the research field of statistical mechanics, which is the central discipline of condensed matter physics. The origin of this algorithm is the simulating of an annealing process. The goal of an annealing process is to achieve a solid with a low energy state, which usually means a highly ordered state. This highly ordered state can be achieved by annealing the solid. Firstly, the material is heated so that the atoms in the material are permitted to rearrange much. After this the material is cooled slowly until the material freezes into a highly ordered material. Simulated annealing tries to imitate this method of slowly decreasing the temperature [10]. In simulated annealing the temperature represents the probability that a mutation that worsens the overall Paintings from Polygons 3 objective value will still be accepted. It is a burdensome process to obtain a perfect cooling schedule, as decreasing the temperature too rapidly might lead to local minima [12]. Simulated annealing has showed its worth in the science, as various combina- torial optimization problems have been solved with this algorithm. Problems as the travelling salesman problem [4], the chip routing problem [7], the scheduling problem [2] and the job shop scheduling problem [9] have been solved with good results. A great variety of cooling schedules have been used in different studies. Each cooling schedule varying from a linear temperature decrease to a cooling schedule that also allows reheating. Yet, the only cooling schedule that has theoretically been proven to find a global minimum as the iterations go to infinity, is the cooling schedule defined by Geman & Geman [6]. But there are other cooling schedules which might even work better for certain constraints as a limited time frame or a maximum amount of computing power. For example, a few cooling schedules are introduced by Abramson [2]. These cooling schedules are fairly simple, but they do have some practicality in comparison to the Geman & Geman cooling schedule. Even though that the simulated annealing analogy is derived from a com- plex physical subject, the algorithm is fairly simple to implement. The basics of the algorithm are simple, but there is enough space for adjustment within the algorithm. For example, using other cooling schedules might result in totally dif- ferent results. There is a large amount of cooling schedules, with a great variety as well. This all concludes that simulated annealing is a very versatile algorithm. 3 Paintings from Polygons For this study nine famous paintings are used. These are represented in bitmaps of the paintings. All of them are converted to a size of 240x180 pixels, either in landscape or portrait orientation. The used paintings (Fig 1.) are: Mona Lisa (1503) by Leonardo da Vinci, The Starry Night (1889) by Vincent van Gogh, The Kiss (1908) by Gustav Klimt, Composition with Red, Yellow and Blue (1930) by Piet Mondriaan, The Persistance of Memory (1931) by Salvador Dali, Convergence (1952) by Jackson Pollock, a portrait of Johann Sebastian Bach (1746) by Elias Gottlieb Haussman, Lady with an Ermine (around 1489 { 1490) by Leonardo da Vinci and Salvator Mundi (1500) by Leonardo da Vinci. Most of these paintings were used in the previous study of Paauw and Van den Berg (Salvator Mundi and Lady with an Ermine were added in this study), because together they span a wide range of ages, countries and artistic styles. All polygons have properties that influence the final constellation that is constructed by these polygons. First of all, every polygon has a color which is represented by 4 byte sized RGBA values: a red, green and blue channel and an alpha channel for the opacity of the polygon. Each of these channels have a value between 0 and 255. Second, every polygon holds coordinates for each vertex of the polygon. These coordinate values range between 0 and the maximum dimension 4 R. Dahmani Fig. 1. The paintings that are used in this study. From left to right and top to bottom: The Starry Night (1889) by Vincent van Gogh, a portrait of Johann Sebastian Bach (1746) by Elias Gottlieb Haussman, Salvator Mundi (1500) by Leonardo da Vinci, Lady with an Ermine (around 1489 { 1490) by Leonardo da Vinci, Composition with Red, Yellow and Blue (1930) by Piet Mondriaan, Convergence (1952) by Jackson Pollock, The Persistance of Memory (1931) by Salvador Dali, The Kiss (1908) by Gustav Klimt and Mona Lisa (1503) by Leonardo da Vinci. of the painting, which is either 180 or 240. The total number of vertices and polygons are predetermined, in this study a total number of v = 1000 vertices v are used and the total number of polygons are 4 , so 250. Every polygon has at v least 3 vertices and at most 4 +3 vertices (this happens when all but one polygons are triangles, that one non-triangle polygon has then 250 + 3 = 253 vertices). Lastly, all polygons have an index number, this number places the polygons in an order that determines the drawing order of the constellation.