用旅行商算法制作艺术图像

Making art with the Travelling Salesman Problem

The Travelling Salesman Problem is a classic problem in math­em­atics. The objective of the problem is to find the shortest pos­sible route between a number of cities that visits each city only once and returns to the starting point.

Below is a ren­dering of the text “MrReid.org” created by solving the Travelling Salesman Problem. If you look care­fully you can see that in each case the text is com­posed of one single line, drawn “without lifting the pen from the page”.

用旅行商算法制作艺术图像_第1张图片

用旅行商算法制作艺术图像_第2张图片

Top to bottom: “MrReid.org” rendered using 1000, 2000, and 5000 nodes. Click to enlarge.

By taking a grey­scale image, and turning it into a weighted Voronoi diagram (using Adrian Secord’s algorithm) it is pos­sible to create a “map” in which the “cities” are placed closer together in dark areas and further apart in light ones.

用旅行商算法制作艺术图像_第3张图片

Top: the ori­ginal panda image. Bottom: weighted Voronoi diagram of panda image (10000 nodes).

By solving the Travelling Salesman Problem for this “map” (using the Nearest Neighbour algorithm for the first pass and and the 2-opt algorithm for sub­sequent optim­isa­tion) the fol­lowing “route” is produced.

There isn’t really enough con­trast between the back­ground and fore­ground in the ori­ginal panda image, but it works if you squint a little bit.

用旅行商算法制作艺术图像_第4张图片

Tweet

This entry was posted in General and tagged art, mathematics. Bookmark the permalink.

你可能感兴趣的:(用旅行商算法制作艺术图像)