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

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”.

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.

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.

This entry was posted in General and tagged , . Bookmark the permalink.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值