<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Tackling the travelling salesman problem: simulated annealing</title>
	<atom:link href="http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/</link>
	<description>folding with my brain</description>
	<pubDate>Tue, 06 Jan 2009 10:10:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Simulated annealing in OCaml &#171; khi&#8217;s life with an ech</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-9910</link>
		<dc:creator>Simulated annealing in OCaml &#171; khi&#8217;s life with an ech</dc:creator>
		<pubDate>Wed, 11 Jun 2008 14:34:40 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-9910</guid>
		<description>[...] Simulated annealing in&#160;OCaml Posted by khigia under ocaml &#160;  I&#8217;ve been using this python implementation of simulated annealing to deduce Singapore bus service from a database of bus stops (see previous [...]</description>
		<content:encoded><![CDATA[<p>[...] Simulated annealing in&nbsp;OCaml Posted by khigia under ocaml &nbsp;  I&#8217;ve been using this python implementation of simulated annealing to deduce Singapore bus service from a database of bus stops (see previous [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7879</link>
		<dc:creator>William</dc:creator>
		<pubDate>Wed, 16 Apr 2008 02:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7879</guid>
		<description>Perfect solution!  It works perfectly now!  Thank you very much for all of your help, and your great python script!</description>
		<content:encoded><![CDATA[<p>Perfect solution!  It works perfectly now!  Thank you very much for all of your help, and your great python script!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7810</link>
		<dc:creator>john</dc:creator>
		<pubDate>Mon, 14 Apr 2008 08:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7810</guid>
		<description>It is really strange.  I hope you have some more luck.

Hmmm.  Maybe that line range I gave you was invalid.  Basically I meant for you to try removing the code that actually renders the lines (from about where the Draw object is made to where it's del'ed).  That way you could then maybe isolate what's being done wrong.  If you still get an invalid image I'd guess that something isn't quite right with your install, but as to what...

Have you tried using pil to make a small blank image and save it to file?

No scratch that!  Just thing I've realised what's wrong!  I've been using this on OS X and just opening the file.  As you're on windows you'll need to open the file in binary mode when you save to it!!

So change:

write_tour_to_img(coords,best,'%s: %f'%(city_file,score),file(out_file_name,'w'))

to:

write_tour_to_img(coords,best,'%s: %f'%(city_file,score),file(out_file_name,'wb'))

(note the extra b)

Hope that helps.  Total oversight on my part, but easy enough to fix.</description>
		<content:encoded><![CDATA[<p>It is really strange.  I hope you have some more luck.</p>
<p>Hmmm.  Maybe that line range I gave you was invalid.  Basically I meant for you to try removing the code that actually renders the lines (from about where the Draw object is made to where it&#8217;s del&#8217;ed).  That way you could then maybe isolate what&#8217;s being done wrong.  If you still get an invalid image I&#8217;d guess that something isn&#8217;t quite right with your install, but as to what&#8230;</p>
<p>Have you tried using pil to make a small blank image and save it to file?</p>
<p>No scratch that!  Just thing I&#8217;ve realised what&#8217;s wrong!  I&#8217;ve been using this on OS X and just opening the file.  As you&#8217;re on windows you&#8217;ll need to open the file in binary mode when you save to it!!</p>
<p>So change:</p>
<p>write_tour_to_img(coords,best,&#8217;%s: %f&#8217;%(city_file,score),file(out_file_name,&#8217;w'))</p>
<p>to:</p>
<p>write_tour_to_img(coords,best,&#8217;%s: %f&#8217;%(city_file,score),file(out_file_name,&#8217;wb&#8217;))</p>
<p>(note the extra b)</p>
<p>Hope that helps.  Total oversight on my part, but easy enough to fix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7793</link>
		<dc:creator>William</dc:creator>
		<pubDate>Mon, 14 Apr 2008 01:18:28 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7793</guid>
		<description>I tried running the program with Python 2.4 and with the 1.1.5 and 1.1.6 versions of PIL.  To install PIL I just used the standard windows installer that they distribute, so I assume that it works.

Do I comment those lines in tsp.py?  In tsp.py it looks like those lines haves something to do with argument parsing.

The only thing that I could find that was strange was the header of the .png file.  When I compared it to http://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header it looks slightly different.  I don't know if that is correct, or if maybe there is something wrong with my system.  When I get a chance, I will install Python and PIL on a bare system and see if I get the same problems. 

I really want to use this script since it is something that can be easily understood because of the comments and easy readability of python.  I just wish that I could find out what was wrong with it!  Thanks!</description>
		<content:encoded><![CDATA[<p>I tried running the program with Python 2.4 and with the 1.1.5 and 1.1.6 versions of PIL.  To install PIL I just used the standard windows installer that they distribute, so I assume that it works.</p>
<p>Do I comment those lines in tsp.py?  In tsp.py it looks like those lines haves something to do with argument parsing.</p>
<p>The only thing that I could find that was strange was the header of the .png file.  When I compared it to <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/en.wikipedia.org');">http://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header</a> it looks slightly different.  I don&#8217;t know if that is correct, or if maybe there is something wrong with my system.  When I get a chance, I will install Python and PIL on a bare system and see if I get the same problems. </p>
<p>I really want to use this script since it is something that can be easily understood because of the comments and easy readability of python.  I just wish that I could find out what was wrong with it!  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7752</link>
		<dc:creator>john</dc:creator>
		<pubDate>Sat, 12 Apr 2008 22:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7752</guid>
		<description>Hmm.  Well it looks like it it should be an image, but I can't quite see why it's not working.  I can see in a hex editor that it seems to have the right header etc.  It might be the version of Python, but I'd be very surprised.  It should work and I can't see any reason it shouldn't.  Do you know if your install of PIL works properly?

Failing that maybe see if commenting out the code that does the actual drawing (line 156-175) gives you a valid, but empty image.</description>
		<content:encoded><![CDATA[<p>Hmm.  Well it looks like it it should be an image, but I can&#8217;t quite see why it&#8217;s not working.  I can see in a hex editor that it seems to have the right header etc.  It might be the version of Python, but I&#8217;d be very surprised.  It should work and I can&#8217;t see any reason it shouldn&#8217;t.  Do you know if your install of PIL works properly?</p>
<p>Failing that maybe see if commenting out the code that does the actual drawing (line 156-175) gives you a valid, but empty image.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7750</link>
		<dc:creator>William</dc:creator>
		<pubDate>Sat, 12 Apr 2008 21:55:23 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7750</guid>
		<description>The image is 20.9kb after it is written.  I uploaded the image to http://www.silliam.com/test.png</description>
		<content:encoded><![CDATA[<p>The image is 20.9kb after it is written.  I uploaded the image to <a href="http://www.silliam.com/test.png" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/www.silliam.com');">http://www.silliam.com/test.png</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7731</link>
		<dc:creator>john</dc:creator>
		<pubDate>Sat, 12 Apr 2008 10:44:44 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7731</guid>
		<description>Not sure why the image isn't outputting right.  I ran all of this stuff with Python2.4 on OS X (10.4), so it could be some sort of incompatibility I guess...

How big is the image file after the script has run?  Maybe it's just not getting written to disk properly?</description>
		<content:encoded><![CDATA[<p>Not sure why the image isn&#8217;t outputting right.  I ran all of this stuff with Python2.4 on OS X (10.4), so it could be some sort of incompatibility I guess&#8230;</p>
<p>How big is the image file after the script has run?  Maybe it&#8217;s just not getting written to disk properly?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7722</link>
		<dc:creator>William</dc:creator>
		<pubDate>Sat, 12 Apr 2008 06:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-7722</guid>
		<description>Excellent group of posts on the TSP!  The code looks excellent and is very easy to understand.

However, I ran the program on my windows machine with Python 2.5 and PIL 1.1.6, It ran fine and output what looked to be the correct answer, but, the image is corrupt and I am not able to open it with anything.  Did I do something wrong, or is the code possibly not designed for Python 2.5?

I ran this command:
"C:\Python25\python.exe" "C:\part_three\tsp.py" -o "C:\part_three\test.png" -v -n 100000 "C:\part_three\city100.txt" &#62; "C:\part_three\tsp.log"

This was the contents of tsp.log:
100000 -4206.38222041 [11, 49, 74, 43, 38, 8, 14, 79, 20, 82, 87, 60, 69, 77, 44, 66, 92, 5, 68, 0, 35, 39, 56, 73, 86, 9, 30, 50, 99, 31, 19, 96, 10, 21, 34, 88, 67, 22, 18, 36, 16, 61, 41, 63, 23, 1, 90, 97, 78, 26, 54, 84, 3, 51, 48, 65, 47, 71, 53, 15, 32, 94, 55, 76, 95, 72, 58, 37, 45, 6, 93, 12, 2, 25, 98, 40, 91, 17, 29, 89, 27, 70, 33, 24, 46, 81, 7, 57, 59, 28, 85, 83, 80, 4, 42, 75, 62, 64, 13, 52]</description>
		<content:encoded><![CDATA[<p>Excellent group of posts on the TSP!  The code looks excellent and is very easy to understand.</p>
<p>However, I ran the program on my windows machine with Python 2.5 and PIL 1.1.6, It ran fine and output what looked to be the correct answer, but, the image is corrupt and I am not able to open it with anything.  Did I do something wrong, or is the code possibly not designed for Python 2.5?</p>
<p>I ran this command:<br />
&#8220;C:\Python25\python.exe&#8221; &#8220;C:\part_three\tsp.py&#8221; -o &#8220;C:\part_three\test.png&#8221; -v -n 100000 &#8220;C:\part_three\city100.txt&#8221; &gt; &#8220;C:\part_three\tsp.log&#8221;</p>
<p>This was the contents of tsp.log:<br />
100000 -4206.38222041 [11, 49, 74, 43, 38, 8, 14, 79, 20, 82, 87, 60, 69, 77, 44, 66, 92, 5, 68, 0, 35, 39, 56, 73, 86, 9, 30, 50, 99, 31, 19, 96, 10, 21, 34, 88, 67, 22, 18, 36, 16, 61, 41, 63, 23, 1, 90, 97, 78, 26, 54, 84, 3, 51, 48, 65, 47, 71, 53, 15, 32, 94, 55, 76, 95, 72, 58, 37, 45, 6, 93, 12, 2, 25, 98, 40, 91, 17, 29, 89, 27, 70, 33, 24, 46, 81, 7, 57, 59, 28, 85, 83, 80, 4, 42, 75, 62, 64, 13, 52]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Psychic Origami &#187; Blog Archive &#187; Tackling the travelling salesman problem: hill-climbing</title>
		<link>http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-100</link>
		<dc:creator>Psychic Origami &#187; Blog Archive &#187; Tackling the travelling salesman problem: hill-climbing</dc:creator>
		<pubDate>Thu, 28 Jun 2007 13:24:35 +0000</pubDate>
		<guid isPermaLink="false">http://psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/#comment-100</guid>
		<description>[...] of the other algorithms I will discuss later attempt to counter this weakness in hill-climbing. The next algorithm I will discuss (simulated annealing) is actually a pretty simple modification of hill-climbing, but [...]</description>
		<content:encoded><![CDATA[<p>[...] of the other algorithms I will discuss later attempt to counter this weakness in hill-climbing. The next algorithm I will discuss (simulated annealing) is actually a pretty simple modification of hill-climbing, but [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
