<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>I Eat Bugs For Breakfast</title>
	<atom:link href="http://ieatbugsforbreakfast.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ieatbugsforbreakfast.wordpress.com</link>
	<description>Programming, Graphics and The End Of Civilisation As We Know It</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:54:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ieatbugsforbreakfast.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>I Eat Bugs For Breakfast</title>
		<link>http://ieatbugsforbreakfast.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ieatbugsforbreakfast.wordpress.com/osd.xml" title="I Eat Bugs For Breakfast" />
	<atom:link rel='hub' href='http://ieatbugsforbreakfast.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Battlefield 3</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2012/02/01/battlefield-3/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2012/02/01/battlefield-3/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 20:48:40 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=292</guid>
		<description><![CDATA[A while ago I purchased Red Dead Redemption by RockStar, mostly because of a YouTube video by TheCheese00. It wasn&#8217;t a particularly cheap buy, as I also had to get an Xbox 360 to put the disc somewhere and a TV so I could see what I was doing. There are many things I don&#8217;t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=292&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I purchased Red Dead Redemption by <a title="RockStar Games homepage" href="http://www.rockstargames.com/" target="_blank">RockStar</a>, mostly because of a <a title="The Essence of Red Dead Redemption" href="http://youtu.be/_4t81aqMyZk" target="_blank">YouTube video</a> by TheCheese00. It wasn&#8217;t a particularly cheap buy, as I also had to get an Xbox 360 to put the disc somewhere and a TV so I could see what I was doing. There are many things I don&#8217;t like about RDR, but all in all I had (and still have) a lot of fun playing it. I can wholeheartedly recommend it to anyone. Among the things I&#8217;d like to see improved most in any upcoming sequel is a more detailed environment and better destructibility of objects. I was therefore impressed by the quality of the visuals in many BattleField 3 videos, which seems to deliver on these aspects. BattleField was developed by <a title="DICE homepage" href="http://www.dice.se/" target="_blank">Dice</a>, the people who brought us Mirror&#8217;s Edge.</p>
<p>If I had to pick three words to describe my experience with BattleField 3, it would have to be; annoyance, disappointment &amp; frustration. Some might argue that annoyance and frustration have a large overlap, but I thought it important to properly cover the extent of my bile.</p>
<p>Not only is the game extremely short –I finished it within a little more than 6 hours– it is also extremely boring. The story is ludicrously unsophisticated and focuses on stolen nuclear bombs to be detonated by terrorists in Paris and New York. Really Dice? Stolen fucking nuclear fucking bombs? How very 1980 of you. The story is presented as a sequence of flash-back missions of the main character, Sergeant Blackburn, who is being drilled by civilians (?) about having shot his CO and his potential involvement with terrorist attacks. Every mission is basically the same; lots of people firing back and forth, follow the blue diamond and follow the instructions on the screen. Press A when you&#8217;re told to. Press B when you&#8217;re told to. Press RT when you&#8217;re told to. Thrilling.</p>
<p>There&#8217;s almost no lead-in, no time to get comfortable with the controls or the weaponry. There&#8217;s also very little freedom. Wander but a little from the preset mission path and the mission fails, at which point you&#8217;ll be awarded with the loading screen and you get to try again. And again. And again. And again, until you figured out the correct sequence of buttons to press to get you through the mission.</p>
<p>The graphics and physics of BattleField 3 are fantastic. Too bad there&#8217;s no time whatsoever to enjoy them as the game-play and the story are amongst the worst I&#8217;ve ever seen in any game.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/292/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=292&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2012/02/01/battlefield-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>
	</item>
		<item>
		<title>An alternative to New Year&#8217;s Resolutions</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/12/29/an-alternative-to-new-years-resolutions/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/12/29/an-alternative-to-new-years-resolutions/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 23:07:39 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=286</guid>
		<description><![CDATA[Instead of a bunch of New Year&#8217;s Resolutions I thought I&#8217;d mention four of my childhood mistakes. Without further ado: Ascension. I used to think that Ascension was to celebrate the 1969 moon landing. The error is somewhat less obvious in Dutch, as &#8220;Hemelvaart&#8221; —as it is known there— translates to &#8220;Heaven/Sky Flight&#8221;. Kissing. When actors [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=286&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Instead of a bunch of New Year&#8217;s Resolutions I thought I&#8217;d mention four of my childhood mistakes. Without further ado:</p>
<ol>
<li><em><strong>Ascension.</strong></em> I used to think that Ascension was to celebrate the 1969 moon landing. The error is somewhat less obvious in Dutch, as &#8220;Hemelvaart&#8221; —as it is known there— translates to &#8220;Heaven/Sky Flight&#8221;.</li>
<li><em><strong>Kissing.</strong></em> When actors kiss in movies, it surely must be some sort of visual trick because only people who are in love could possibly want to kiss each other and the odds that two professional actors randomly thrown together are in fact in love is diminishingly small.</li>
<li><em><strong>Adulthood.</strong></em> The best thing about being an adult is not —as I used to think— being allowed to do adult stuff. Turns out adult stuff is major league boring and frustrating. The best thing about being an adult is that you can do all the kids stuff you want and nobody is going to tell you to stop.</li>
<li><em><strong>Lasers.</strong></em> The only mechanism by which I could imagine lasers to work was for them to be funnels made of reflective material. I knew there was a mirror involved, just got the geometry wrong, after all, if it works for water, why can&#8217;t it work for photons? These days I do understand how the electron states are perturbed by passing photons, though I still have major problems understanding the basic principles of holograms.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/286/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=286&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/12/29/an-alternative-to-new-years-resolutions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>
	</item>
		<item>
		<title>Multiple Local Optima</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/12/01/multiple-local-optima/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/12/01/multiple-local-optima/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:06:17 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=258</guid>
		<description><![CDATA[In this post I&#8217;ll present one of the examples I used in my lecture at the Design Modelling Symposium in Berlin in October/2011. This particular example shows how the Simulated Annealing solver handles fitness landscapes with multiple local optima. I&#8217;ll also talk briefly about how to set up the test-case in Grasshopper+Galapagos. Most problems have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=258&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll present one of the examples I used in my lecture at the Design Modelling Symposium in Berlin in October/2011. This particular example shows how the <a title="Simulated Annealing on IEatBugsForBreakfast" href="http://ieatbugsforbreakfast.wordpress.com/2011/10/14/simulated-annealing-a-brief-introduction/">Simulated Annealing</a> solver handles fitness landscapes with multiple local optima. I&#8217;ll also talk briefly about how to set up the test-case in Grasshopper+Galapagos.</p>
<p><span id="more-258"></span></p>
<p>Most problems have multiple local optima, sometimes these optima represent very similar fitnesses and sometimes they represent very different fitnesses. A good solver should not allow itself to get stuck in a low-quality optimum.</p>
<p>Let&#8217;s consider the problem of fitting a circle to a collection of points in the 2D plane so that the distance between the circle and the points is minimized. There are good algorithms available for finding such a circle so we don&#8217;t have to rely on a generic solver such as Simulated Annealing, but it is a good example because it&#8217;s both easy to set up and see whether or not the answer we&#8217;re given is correct.</p>
<p>Our problem is three-dimensional while we&#8217;re limited to the 2D plane because the least amount of variables we need to define any circle equals three; x, y and radius. Every unique combination of {x,y,R} results in a unique circle, and every possible circle can be represented by picking the appropriate {x,y,R}. So the question basically becomes; &#8220;which values for x, y and R result in the best fitting circle?&#8221;</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariablex2.png"><img class="alignnone size-thumbnail wp-image-272" title="CircleFittingVariableX" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariablex2.png?w=150&#038;h=124" alt="" width="150" height="124" /></a><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabley2.png"><img class="alignnone size-thumbnail wp-image-273" title="CircleFittingVariableY" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabley2.png?w=150&#038;h=124" alt="" width="150" height="124" /></a><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabler2.png"><img class="alignnone size-thumbnail wp-image-271" title="CircleFittingVariableR" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabler2.png?w=150&#038;h=124" alt="" width="150" height="124" /></a></p>
<p style="text-align:left;">The Grasshopper <a title="Download the gh file." href="http://s3.amazonaws.com/files.na.mcneel.com/grasshopper/1.0/samples/en/BasinsOfAttraction.gh">file</a> that represents both this problem and the fitness function looks as follows:</p>
<p style="text-align:left;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/basinsofattraction00.png"><img class="aligncenter size-full wp-image-275" title="BasinsOfAttraction00" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/basinsofattraction00.png?w=480&#038;h=171" alt="" width="480" height="171" /></a></p>
<p style="text-align:left;">We have a collection of target points stored in the red point parameter. Our three variables are represented by the three sliders. The green group contains the two components that create a circle from the three variables and the blue group contains the components that measure the distance (i.e. fitness) from the points to the circle. As you can see I&#8217;m actually measuring the <a title="Least Squares Fitting on MathWorld" href="http://mathworld.wolfram.com/LeastSquaresFitting.html">square of the distance</a> rather than distance itself. Most fitting operations minimize the square of the distances as that&#8217;s a more useful mathematical concept. I explain why this is needed in the <a title="Define “Fitness”…." href="http://ieatbugsforbreakfast.wordpress.com/2011/03/07/define-fitness/">Define Fitness</a> and <a title="Fitness Pressure" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/09/fitness-pressure/">Fitness Pressure</a> blog posts.</p>
<p style="text-align:left;">The title of this post is &#8220;Multiple Local Optima&#8221; and it might surprise you to learn that the fitness landscape associated with this problem does indeed have multiple optima. There&#8217;s the obvious fitness peak at the {x,y,R} state which represents the best fit, but there&#8217;s an additional peak hiding along the edges of the landscape. To see why this is so have a look at the following two cases:</p>
<p style="text-align:left;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingextremes.png"><img class="aligncenter size-full wp-image-278" title="CircleFittingExtremes" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingextremes.png?w=480" alt=""   /></a></p>
<p style="text-align:left;">The green curve represents a circle which is obviously far too large to be a good fit. We&#8217;d expect a somewhat smaller circle to have a higher fitness, but unfortunately it doesn&#8217;t. Or rather, it doesn&#8217;t up to a certain size. The much larger red circle is actually more &#8220;fit&#8221; by our definition than the green one because even though it is farther away from the points in the upper left, it is closer to the points in the lower right. And due to the square root in our fitness definition, a somewhat smaller large distance is to be preferred over a somewhat larger small distance. When we actually plot the real fitness landscape this double peak characteristic becomes visible:</p>
<p style="text-align:left;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/multipleoptimalandscape.png"><img class="aligncenter size-full wp-image-279" title="MultipleOptimaLandscape" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/multipleoptimalandscape.png?w=480" alt=""   /></a></p>
<p style="text-align:left;">I had to collapse the x and y variables into a single axis called &#8216;Position&#8217; because it&#8217;s difficult to display a four-dimensional landscape on a two-dimensional computer screen, but otherwise this graphic is synonymous with the real fitness landscape. In the lower left hand corner you can see a high peak that corresponds with the ideal circle. However towards the upper right corner there is a gradual slope. This slope never gets anywhere near as high as the green peak, but it does continue to get higher and higher the further you go (in a fashion similar to the <a title="ArcTangent on MathWorld" href="http://mathworld.wolfram.com/InverseTangent.html">ArcTangent</a> function).</p>
<p style="text-align:left;">When we plot the path of steepest ascent for every point in this landscape and assign a colour to the point based on which peak we found, we end up with two regions; green and red. One leads to the ideal solution, the other leads to the wrong solution. These two regions are called &#8216;Basins of Attraction&#8217; and every peak has a basin around it by definition*. The larger the basin of attraction the easier it becomes to &#8216;find&#8217; a peak. Ideally we&#8217;d like our solvers to be able to find peaks according to their height, not by the size of their respective basins. So when we ask the Simulated Annealing solver to tackle this problem, we expect to end up at the green peak <em>more often</em> than the red one.</p>
<p style="text-align:left;">Download the <a title="Download the gh file." href="http://s3.amazonaws.com/files.na.mcneel.com/grasshopper/1.0/samples/en/BasinsOfAttraction.gh">file</a> and find out!</p>
<p><em>* Actually this is not true for some Fractal landscapes, but then fractal fitness landscapes are near impossible to solve anyway.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/258/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=258&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/12/01/multiple-local-optima/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariablex2.png?w=150" medium="image">
			<media:title type="html">CircleFittingVariableX</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabley2.png?w=150" medium="image">
			<media:title type="html">CircleFittingVariableY</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingvariabler2.png?w=150" medium="image">
			<media:title type="html">CircleFittingVariableR</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/basinsofattraction00.png" medium="image">
			<media:title type="html">BasinsOfAttraction00</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/circlefittingextremes.png" medium="image">
			<media:title type="html">CircleFittingExtremes</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/12/multipleoptimalandscape.png" medium="image">
			<media:title type="html">MultipleOptimaLandscape</media:title>
		</media:content>
	</item>
		<item>
		<title>Simulated Annealing, a brief introduction</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/10/14/simulated-annealing-a-brief-introduction/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/10/14/simulated-annealing-a-brief-introduction/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 10:15:48 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Heuristics]]></category>
		<category><![CDATA[SA]]></category>
		<category><![CDATA[Simulated Annealing]]></category>
		<category><![CDATA[Solver]]></category>
		<category><![CDATA[Stochastics]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=248</guid>
		<description><![CDATA[Ever since version 0.8.0051 of Grasshopper, there is a second solver available from within Galapagos which implements the Simulated Annealing algorithm. Like the existing Evolutionary solver, Simulated Annealing is also a meta-heuristic technique, but works in a fundamentally different fashion. Having access to both solvers makes it easier to circumvent some of the shortcomings of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=248&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever since version 0.8.0051 of Grasshopper, there is a second solver available from within Galapagos which implements the Simulated Annealing algorithm. Like the existing Evolutionary solver, Simulated Annealing is also a meta-heuristic technique, but works in a fundamentally different fashion. Having access to both solvers makes it easier to circumvent some of the shortcomings of each. Ironically, Simulated Annealing is a much simpler process than Simulated Evolution but may be harder to understand since the real-world analogy is more abstract and based on a less well known process.</p>
<p>In metallurgy, annealing is the process of controlled heating and cooling of metal to achieve certain material properties. At first, the metal is heated up to melting point so it can be cast or formed. At an atomic level, heat is nothing more than particle velocity. The particles (atoms &amp; molecules alike) in a hot substrate move faster than the same particles in a cold substrate. At some point the velocity of two particles will be so high that they cannot succeed in forming a persistent bond between them. When this happens the substrate loses internal structure and turns liquid.</p>
<div id="attachment_250" class="wp-caption aligncenter" style="width: 210px"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_001.png"><img class="size-full wp-image-250" title="SA_CoolingSchedule_00" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_001.png?w=480" alt=""   /></a><p class="wp-caption-text">Atoms in liquid metal</p></div>
<p><span id="more-248"></span></p>
<p>Similarly, when a substrate is liquid but starts to cool down, there will come a point where the atoms <em>can</em> form lasting bonds and the internal structure of the substrate is resurrected, turning the liquid into a solid. These two processes are of course colloquially known as &#8220;melting&#8221; and &#8220;freezing&#8221;. However it&#8217;s not quite as simple as all this. In 1866 <a title="Maxwell on Wikipedia" href="http://en.wikipedia.org/wiki/James_Clerk_Maxwell#Kinetic_theory_and_thermodynamics">James Clerk Maxwell</a> formulated the equations that described the distribution of particle velocities in a gas of constant macro temperature. For example, when you have a litre of helium gas at room-temperature it contains roughly 3 × 10<sup>22</sup> atoms and the <em>most probable</em> speed of these atoms is a little over a 1000 meters per second. However there will be a lot of very slow atoms as well as a few much faster ones. This same phenomenon holds for liquids too, although the velocity distributions are not as well defined nor do they cover quite so large a range.</p>
<p>The upshot of all this is that when a substrate is allowed to cool, some atoms will cross the liquid|solid threshold before others. In other words, a substrate doesn&#8217;t freeze everywhere at once, small clumps of relatively slow atoms group together and form the freezing &#8216;seeds&#8217;. Especially when we&#8217;re talking about metals this is important because when metal atoms freeze, they like to form a regular lattice, or crystal.</p>
<div id="attachment_251" class="wp-caption aligncenter" style="width: 210px"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_01.png"><img class="size-full wp-image-251" title="SA_CoolingSchedule_01" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_01.png?w=480" alt=""   /></a><p class="wp-caption-text">Crystal seeds in semi-liquid metal</p></div>
<p>These small islands of glued together atoms grow over time as more and more slow atoms attach themselves to the seeds, allowing the micro-crystals to expand. When the cooling takes a long time, atoms are allowed to find the optimal (minimal energy) distribution. If on the other hand the cooling is very quick —for example by dumping the hot metal into water— there is no time to form large crystals and the substrate becomes amorphous.</p>
<div id="attachment_252" class="wp-caption aligncenter" style="width: 210px"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_03.png"><img class="size-full wp-image-252" title="SA_CoolingSchedule_03" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_03.png?w=480" alt=""   /></a><p class="wp-caption-text">Regular atomic lattice</p></div>
<p>So how does this help us find solutions in Galapagos? To be sure, the analogy is fairly tenuous but the simple fact remains that treating all the parameters in a problem as an atomic thermodynamic system allows us to find relatively good answers relatively quickly. Basically, with Simulated Annealing, we seek to crystallize the parameters into the lowest energy state.</p>
<p>A typical annealing run consists of a number of successive jumps in the problem phase-space, where the amplitude of each jump <em>and</em> it&#8217;s legitimacy are affected by the temperature of the system. When the temperature of the system is high, large jumps are allowed and there is a significant likelihood that a worse answer is adopted despite being a setback. The graph below shows a typical annealing track.</p>
<div id="attachment_253" class="wp-caption aligncenter" style="width: 490px"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_jumpbehaviour.png"><img class="size-full wp-image-253" title="SA_JumpBehaviour" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_jumpbehaviour.png?w=480&#038;h=286" alt="" width="480" height="286" /></a><p class="wp-caption-text">A schematic annealing track</p></div>
<p>Along the horizontal axis all possible states of the problem are collected. If the problem phase-space is one-dimensional (i.e. only a single Grasshopper slider), then this is an exact representation, but since this is a schematic representation the graph x-axis can represent any number of parameter dimensions. The vertical axis represents the fitness of each distinct state, so the thick black curve represents the entire fitness landscape. This particular landscape has 4 local optima with varying degrees of quality.</p>
<p>The first annealing jump must start at a random location because nothing is known about the landscape so no informed decision can be made. In this particular example, the annealing track starts along the left edge of the landscape at location (1). At this point in time the temperature is very high, so large jumps across phase-space are allowed. A jump from (1) to (2) would indeed qualify as large as it spans almost the entire phase-space. Since (2) is higher than (1), we automatically accept the new solution. Now we need to jump again, but there is less energy available as the entire system is cooling down. So the jump from (2) to (3) is most likely going to be shorter than the jump from (1) to (2). The fitness at (3) happens to be lower than (2), so the second jump actually represents a worse answer. However, since the temperature is still relatively high, we&#8217;re sometimes (where &#8220;sometimes&#8221; is in accordance with thermodynamic stochastics) forced to accept a worse case. This is not as stupid as it sounds though, as this characteristic makes the solver less prone to getting &#8216;stuck&#8217; to a local optimum.</p>
<p>As time goes on, the temperature of the system drops and smaller and smaller jumps are possible. Also, at low temperatures the chance that a worse case is adopted over a better one becomes insignificant. Eventually the temperature has dropped far enough for the entire system to be frozen, at which point the best answer from the run is cached and a second run is started, once again at high temperature.</p>
<p>Because of the cooling schedule, it means that every annealing run only has a limited number of steps and therefore terminates in a limited time-span. Simulated Evolution does not have this characteristic; it will happily churn away for all eternity without ever looking back. This fundamental difference between the two algorithms makes Simulated Annealing a good candidate for finding many promising optima, while Simulated Evolution is much better at refining a single solution.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=248&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/10/14/simulated-annealing-a-brief-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_001.png" medium="image">
			<media:title type="html">SA_CoolingSchedule_00</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_01.png" medium="image">
			<media:title type="html">SA_CoolingSchedule_01</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_coolingschedule_03.png" medium="image">
			<media:title type="html">SA_CoolingSchedule_03</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/sa_jumpbehaviour.png" medium="image">
			<media:title type="html">SA_JumpBehaviour</media:title>
		</media:content>
	</item>
		<item>
		<title>Sugar and Spice</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/10/08/sugar-and-spice/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/10/08/sugar-and-spice/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 09:20:16 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[food]]></category>
		<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=243</guid>
		<description><![CDATA[And now for something completely different. With the imminent arrival of girlfriend coming to stay with me until Christmas, I figured I&#8217;d better beef up my pastry skills as she&#8217;s way better at that than I am, and we obviously can&#8217;t have that. I&#8217;ve always been partial to cinnamon (up to the point of making [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=243&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>And now for something completely different. With the imminent arrival of girlfriend coming to stay with me until Christmas, I figured I&#8217;d better beef up my pastry skills as she&#8217;s <em>way</em> better at that than I am, and we obviously can&#8217;t have that. I&#8217;ve always been partial to cinnamon (up to the point of making cinnamon sauce for tenderloin) and found an absolutely fantastic recipe. It takes a bit of preparation, but most of that is spend leaving the dough alone so as long as you start baking in the morning you can have a lovely afternoon tea. Only down-side I found is that it does tend to get stale pretty quick, so ideally make it when you have guests.</p>
<p>I&#8217;m not going to reproduce the recipe here as it has already been documented to the point of perfection by<a title="Recipe for pull-apart cinnamon bread" href="http://www.joythebaker.com/blog/2011/03/cinnamon-sugar-pull-apart-bread/" target="_blank"> Joy the Baker</a> and here&#8217;s an alternate recipe by <a title="Cinnamon pull-apart alternate recipe" href="http://zoomyummy.com/2011/07/23/cinnamon-sugar-pull-apart-bread/" target="_blank">Zoom Yummy</a>.</p>
<p>These pictures were taken three days ago, since then summer has disappeared and has been replaced swiftly and without error by snow.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadincontext.jpg"><img class="aligncenter size-full wp-image-244" title="Cinnamon bread in context" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadincontext.jpg?w=480&#038;h=355" alt="Still life with pastry, tea and cat (cat's not moving much so it's technically a still life)" width="480" height="355" /></a></p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadcloseup.jpg"><img class="aligncenter size-full wp-image-245" title="Cinnamon bread close-up" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadcloseup.jpg?w=480&#038;h=360" alt="" width="480" height="360" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=243&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/10/08/sugar-and-spice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadincontext.jpg" medium="image">
			<media:title type="html">Cinnamon bread in context</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/cinnamonbreadcloseup.jpg" medium="image">
			<media:title type="html">Cinnamon bread close-up</media:title>
		</media:content>
	</item>
		<item>
		<title>Obfuscation, fear and loathing.</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/10/03/obfuscation-fear-and-loathing/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/10/03/obfuscation-fear-and-loathing/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 22:09:31 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[decompilation]]></category>
		<category><![CDATA[disassemble]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[paranoia]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=226</guid>
		<description><![CDATA[Warning; legal and moral clap-trap ahead. First, a bit of history. You might be surprised to learn that programming pre-dates computers by about a century and a half. The two are so synonymous these days that it&#8217;s hard to imagine a computer without programs or a program without a computer. But machines have been controlled [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=226&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:right;"><em>Warning; legal and moral clap-trap ahead.</em></p>
<p>First, a bit of history. You might be surprised to learn that programming pre-dates computers by about a century and a half. The two are so synonymous these days that it&#8217;s hard to imagine a computer without programs or a program without a computer. But machines have been controlled using honest-to-goodness code from the early 1800&#8242;s (think of automated looms and pianolas). Most commonly the program was stored on punch cards that were fed into a machine which executed the instructions. But even a hand-cranked music box is an example of programming.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/handcrankmusicbox.jpg"><img class="aligncenter size-full wp-image-231" title="HandCrankMusicBox" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/handcrankmusicbox.jpg?w=480" alt=""   /></a></p>
<p>With the advent of the modern (read: electronic) computer in the 1940&#8242;s, programming as we understand it today makes its first appearance. Basically a program is a series of instructions. Some instructions pertain to reading or writing bits in memory, others are concerned with computational steps such as addition of two numbers. The main reason computers became so popular is that they are unwaveringly consistent in the application of their programs. You can always trust a computer to do as it&#8217;s told*.</p>
<p><span id="more-226"></span></p>
<p>Originally computer programs were stored on punch cards using machine code, which was quickly superseded by Assembler type languages. The last 2~3 decades have witnessed an amazing evolution in terms of programming languages <em>and</em> programming platforms. Languages have become both more human-centric and more versatile. And programming platforms like <a title="Microsoft Foundation Class Library" href="http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library">MFC</a>, <a title="Cocoa API" href="http://en.wikipedia.org/wiki/Cocoa_api">Cocoa</a>, <a title=".NET Framework" href="http://en.wikipedia.org/wiki/.net">.NET</a> or <a title="Google App Engine" href="http://en.wikipedia.org/wiki/Google_App_Engine">Google Apps</a> provide a plethora of useful functions that allow programmers to create new applications in a matter of minutes.</p>
<p>Programs these days are often distributed, meaning the instructions are given to the end-user, whose computer will then execute them. Of course there are exceptions; a lot of programs run server-side, meaning they are executed elsewhere and only the output of the program is pumped to the end-user machine, but in my business the bulk of programs run client-side. There has been an on-going debate about ownership and patents and rights and how they pertain to software and while that discussion is both interesting and frustrating, it is not the focus of this post.</p>
<p>When one writes a piece of software one typically owns copyright on the source code**, just as one would own copyright on any other piece of text. When someone else uses your source code to make a different application they are guilty of copyright infringement, essentially theft. Though I find &#8216;plagiarizing&#8217; a better parallel. This is not legal, but depending on the code stolen it can be very difficult to detect, let alone prove. This is the first legal problem I want to highlight.</p>
<p>It is also usually up to you whether or not you want to sell your software***. If you choose to sell your software, only people who have paid you money are allowed to use it. If someone is using your software without payment or explicit permission, they are breaking the law and are liable to prosecution. This is also often referred to as theft and it is the second legal problem pertinent to the topic at hand.</p>
<p>Both issues outlined above have the potential to reduce income for the original developer, which is why sentiments run so high over this. A good case can be made that illegal copies have positive as well as negative consequences for the author, but that, too, is not the focus of this post. It is not difficult to see that access to source code is the single most valuable asset to anyone looking to infringe copyright or circumvent license agreements. When one can read source code, algorithms can be extracted and license protection can be punctured.</p>
<p>Up until recently practically all large scale applications were distributed to users as machine code instructions. Source code was written by the developer on her computer, then turned into a collection of assembly-level calls by her compiler. The result is a set of instructions that can be executed very efficiently by the client machine since it is stripped from all human-centric content. Basically a compiler is a translator that converts code written by humans into instructions readable by machines. Compilers often use tricks to increase performance or reduce memory usage, so instead of just removing all superfluous content they also modify the logic of source code. Compiling is quite difficult and those who write compilers are often lionized by their fellow programmers. The opposite of a compiler is a <em>de</em>compiler, which takes machine instructions and translates it back into a human-readable language. This process is even more difficult as a lot of the &#8216;squishy&#8217; stuff needs to be put back in.</p>
<p>I said &#8220;up until recently&#8221; because when you write .NET code this is not what happens. .NET programs are no longer fully compiled by the developer and then distributed to users. Rather, the compilation process has been broken up into two parts, one to be performed by the developer machine and the other by the client machine. Text-based, human-readable source code is converted to a language called IL (Intermediate Language). This process validates the code (which is a time consuming process) and turns it into a form which is more easily parsable by computers. You can think of it as binary source instead of textual source if you want. It is this binary code that is given to users and only when they <em>run</em> the program does it get fully compiled to machine code. There are a lot of really big benefits to this approach, but there&#8217;s also a down-side; it makes it much easier to decompile the program into high-quality source. This worries a fair few developers for reasons that are <em>almost</em> always, in my opinion, misguided.</p>
<p>There is a process called <em>obfuscation</em> which changes compiled (or semi-compiled in the case of .NET) code and in so doing makes it harder for a decompiler to make sense of the instructions. This is a very effective defense against the casual &#8216;code thief&#8217; as it can fool most commercial decompilers. Although I agree that there do exist valid reasons in favour of obfuscating code, these reasons are few and far between.</p>
<p>My main objection is an idealogical one. It seems to me obfuscation is often used because &#8220;the competition is catching up&#8221;. Competition is always catching up, that&#8217;s its job. You won&#8217;t defeat the competition by flailing around and yelling &#8220;Mine!&#8221;. The only way to get on top is to write better code than the competition and the only way to stay on top is to <em>keep</em> writing better code than the competition (yes, I know there are marketing and legal departments involved as well, I concede the world is not quite as neat as portrayed here). Time and effort spend securing code can no longer be spend improving code. This applies to obfuscation, but also to elaborate licensing mechanisms such as on-line validation and (shiver) dongles.</p>
<p>Another objection is that obfuscation removes any possibility of useful exploration. &#8220;Useful&#8221; to legit users and authors that is. It can allow power-users to track down bugs and come up with work-arounds without the need for the official developer to fix, re-compile and re-release. It helps plug-in developers to see what&#8217;s going on when they rely on your code. It helps other programmers to see what&#8217;s going on when you run into problems and need help. These are real benefits and you might be sacrificing them in favour of imaginary ones when you decide to obfuscate.</p>
<div id="attachment_234" class="wp-caption aligncenter" style="width: 490px"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/xkcd_code_talkers.png"><img class="size-full wp-image-234" title="xkcd_code_talkers" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/xkcd_code_talkers.png?w=480&#038;h=381" alt="" width="480" height="381" /></a><p class="wp-caption-text">Source: xkcd comics</p></div>
<p>* With the exception of hard-ware failures such as corrupt storage of course.<br />
** I am not a lawyer and this is not legal advice.<br />
*** Again, I am not a lawyer. If you make legal decisions based on this post I will sue you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/226/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=226&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/10/03/obfuscation-fear-and-loathing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/handcrankmusicbox.jpg" medium="image">
			<media:title type="html">HandCrankMusicBox</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/10/xkcd_code_talkers.png" medium="image">
			<media:title type="html">xkcd_code_talkers</media:title>
		</media:content>
	</item>
		<item>
		<title>On getting lucky in higher dimensions</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/07/31/on-getting-lucky-in-higher-dimensions/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/07/31/on-getting-lucky-in-higher-dimensions/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 22:07:51 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=204</guid>
		<description><![CDATA[Pin the Tail on the Donkey is an all time favourite for children&#8217;s parties. For those of you not familiar with the game, a player is blindfolded and spun around until thoroughly disoriented. Then, cheered on by her friends, she must attempt to stick the &#8216;tail&#8217; as close as possible to the proper location on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=204&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Pin the Tail on the Donkey</em> is an all time favourite for children&#8217;s parties. For those of you not familiar with the game, a player is blindfolded and spun around until thoroughly disoriented. Then, cheered on by her friends, she must attempt to stick the &#8216;tail&#8217; as close as possible to the proper location on the picture of a donkey on the wall. It&#8217;s not difficult to calculate the odds that a certain blind pick will yield a result close enough to win the game. If we assume that only picks within the boundary of the donkey image are allowed, the odds of making a winning pick are the area of the image, divided by the area of the winning region (drawn in red)</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/pinthetailonthedonkey.png"><img class="aligncenter size-full wp-image-205" title="PinTheTailOnTheDonkey" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/pinthetailonthedonkey.png?w=480" alt=""   /></a></p>
<p>We can simplify this by choosing sensible dimensions for both the boundary and the winning region. Let&#8217;s say the boundary is a square with an edge length of one units, while the winning region is a circle with a radius of half a unit. This means the boundary has an area of 1 units<sup>2</sup>, while the winning region has an area of pi × 0.5<sup>2 </sup> ≈ 0.785 units<sup>2</sup>. Thus the chances of making a winning pick are roughly 80% in this simplified case.</p>
<p>But what are our chances if we&#8217;re supposed to pick a single point in three-dimensional space? Instead of dividing areas, we must now divide volumes. And instead of a square with a circle, we&#8217;re now dealing with a cube and a sphere.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/2sphere3sphere.png"><img class="aligncenter size-full wp-image-206" title="2Sphere+3Sphere" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/2sphere3sphere.png?w=480" alt=""   /></a></p>
<p>Now, the volume of a unit cube is <em>always</em> 1.0, no matter how high the dimensionality. This is of course why it is a sensible value. The volume of a sphere in three dimensions is defined as (4/3) × pi × r<sup>3</sup> which for a radius of 0.5 roughly equals 0.524 units<sup>3</sup>. So the volume of a sphere is much smaller compared to the volume of the containing cube than is the area of a circle compared to the area of the containing square.  In other words, there&#8217;s a lot more left-over space. What happens if we go even higher than 3 dimensions?</p>
<p><span id="more-204"></span></p>
<p>This:</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/hyperspherevolumegraph.png"><img class="aligncenter size-full wp-image-207" title="HyperSphereVolumeGraph" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/hyperspherevolumegraph.png?w=480&#038;h=339" alt="" width="480" height="339" /></a></p>
<p>Here you see for the first 12 spatial dimensions the ratio of volume of the (hyper)sphere* as a percentage of the volume of the (hyper)cube. With every additional dimension, the ratio is nearly halved. The tilted numbers next to the graph represent the volume of the hyper-sphere rounded to three decimal places and it doesn&#8217;t take many dimensions for the hyper-sphere to become utterly insignificant compared to the hyper-cube. This is probably somewhat counter-intuitive as the cube is <em>still</em> a tight fit around the sphere, but then things tend to get counter-intuitive with gay alacrity when more than 3 dimensions are involved.</p>
<p>The purpose of this post is not to tell you that you should pick a lower-dimensional reality from your opponents when playing Pin the Tail on the Donkey. Rather, Pin the Tail on the Donkey is an excellent analogy for computational random search algorithms. You don&#8217;t have to blindfold and spin computers, being ignorant and disoriented is their default state. It is actually removing the blindfold that typically requires an awful lot of difficult programming.</p>
<p>When an Evolutionary Solver (such as Galapagos) starts, it has absolutely nothing to go on. Eventually new generations are created from previous generations using a combination of <a title="Evolutionary Solvers: Coupling" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/04/coupling-algorithms/">breeding</a> and <a title="Evolutionary Solvers: Selection" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/04/selection-mechanisms/">selection</a> and <a title="Evolutionary Solver: Mutations" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/05/evolutionary-solver-mutations/">mutation</a> algorithms, but the first generation has to be magicked into existence out of thin air. A common strategy is to completely randomize the individuals in the first generation, basically pinning tails onto the hyper-donkey. Since the dimensionality of the search-space equals the number of variables, there is a vanishing —indeed, rapidly vanishing— chance that any individual in Generation 1 is going to get lucky.</p>
<p>Thankfully only the first generation suffers from this problem, as subsequent generations use a far more directed (as opposed to random) search, but it is important that you allow for sufficient individuals in Generation 1, so that the chances of getting immediately stuck in a local optimum are small. This is why Galapagos has an Initial Boost factor setting, which multiplies the number of individuals in Generation 1.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/galapagosinitialboostfactor.png"><img class="aligncenter size-full wp-image-211" title="GalapagosInitialBoostFactor" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/galapagosinitialboostfactor.png?w=480" alt=""   /></a></p>
<p>* The formulas for hyper-sphere volumes are:</p>
<p>R<sup>2</sup>  → π · r<sup>2</sup><br />
R<sup>3</sup>  → (4/3) · π · r<sup>3</sup><br />
R<sup>4</sup>  → (1/2) · π<sup>2</sup> · r<sup>4</sup><br />
R<sup>5</sup>  → (8/15) · π<sup>2</sup> · r<sup>5</sup><br />
R<sup>6</sup>  → (1/6) · π<sup>3</sup> · r<sup>6</sup><br />
R<sup>7</sup>  → (16/105) · π<sup>3</sup> · r<sup>7</sup><br />
R<sup>8</sup>  → (32/945) · π<sup>4</sup> · r<sup>8</sup><br />
R<sup>9</sup>  → (1/24) · π<sup>4</sup> · r<sup>9</sup><br />
R<sup>10</sup>  → (1/120) · π<sup>5</sup> · r<sup>10</sup><br />
R<sup>11</sup>  → (64/10395) · π<sup>5</sup> · r<sup>11</sup><br />
R<sup>12</sup>  → (1/720) · π<sup>6</sup> · r<sup>12</sup></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=204&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/07/31/on-getting-lucky-in-higher-dimensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/pinthetailonthedonkey.png" medium="image">
			<media:title type="html">PinTheTailOnTheDonkey</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/2sphere3sphere.png" medium="image">
			<media:title type="html">2Sphere+3Sphere</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/hyperspherevolumegraph.png" medium="image">
			<media:title type="html">HyperSphereVolumeGraph</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/07/galapagosinitialboostfactor.png" medium="image">
			<media:title type="html">GalapagosInitialBoostFactor</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8220;Is it just me, or do my balls itch?&#8221;</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/03/27/is-it-just-me-or-do-my-balls-itch/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/03/27/is-it-just-me-or-do-my-balls-itch/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 11:49:05 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[movie]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[science fiction]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=182</guid>
		<description><![CDATA[A little departure from the realm of coding in favour of the realm of fiction. I like Science Fiction. Really I do. It&#8217;s just that I don&#8217;t consider many things to be Science Fiction that are typically gathered under this banner. Star Wars isn&#8217;t SF, it&#8217;s cowboys, knights and wizards in space. Star Trek couldn&#8217;t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=182&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">A little departure from the realm of coding in favour of the realm of fiction. I like Science Fiction. Really I do. It&#8217;s just that I don&#8217;t consider many things to <em>be</em> Science Fiction that are typically gathered under this banner. <em>Star Wars</em> isn&#8217;t SF, it&#8217;s cowboys, knights and wizards in space. <em>Star Trek</em> couldn&#8217;t possibly be more pathetic from a purely scientific point of view. <em>Planet Of The Apes</em>? Darwin would spin in his grave so quickly it would destabilize the orbit of the Earth (to loosely borrow from Douglas Adams). <em>Independence Day.</em> Fun? Sure. Science? Bollocks.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/john-berkey-ii_sf.jpg"><img class="aligncenter size-full wp-image-183" title="John-Berkey-II_SF" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/john-berkey-ii_sf.jpg?w=480&#038;h=325" alt="" width="480" height="325" /></a></p>
<p style="text-align:center;"><span style="color:#999999;"><em>source: John Berkey</em></span></p>
<p><span id="more-182"></span></p>
<p style="text-align:justify;">These are of course all examples of Science Fiction made for the silver screen, print has produced far more worthwhile SF to date. I can count the number of good SF movies I&#8217;ve seen without risking double digits, while the number of good SF authors alone runs in the dozens. So what makes good Science Fiction? Well, since the term is composed of two words, let&#8217;s tackle them in order.</p>
<p style="text-align:justify;"><em>Good science</em>. We know an awful lot about an awful lot four centuries after the start of the Scientific Revolution. Sure, we also know that what we know is only a very small part of all the things we could possibly know and we know that some of the things we know are wrong or at least partially incomplete. The science part of any SF story does not need to adhere to what we currently know, I&#8217;m not arguing that at all. But being blatantly at odds with what we know today requires at the very least a decent explanation and/or justification. Faster-Than-Light travel for example is a common theme in many SF sagas, and it is a perfectly valid fictional concept. Though I have to admit that the best movies and books (in my humble opinion) do not break this tenet of current scientific orthodoxy. It is not beyond imagining that one day we&#8217;ll figure out that it <em>is</em> possible to beat those darn photons.</p>
<p style="text-align:justify;">A lovely example of being blatantly at odds with what we know is the common idea in earlier SF works that a gas lighter than Hydrogen could be used to solve all the lifting and travel needs of humanity. One author (who shall remain unnamed, I&#8217;m not on a vendetta here) even went as far as to suggest that the higher the pressure of this magical gas, the more lift it generated!</p>
<p style="text-align:justify;">Greg Bear is an example of an author who is exceptionally good at the hard science part of SF. The science in his work tends to be novel and unexpected, yet almost never unbelievable. In <a title="Eon on Amazon" href="http://www.amazon.co.uk/Eon-S-F-Masterworks-Greg-Bear/dp/0575073160/ref=sr_1_1?ie=UTF8&amp;qid=1301221074&amp;sr=8-1-spell">Eon</a> he describes a group of humans who have left Earth in search of another planet. They travel there inside a hollowed out asteroid where they&#8217;ve build cities and landscapes against the rotating inner walls. Since it takes such a long time to get to their destination (generations, centuries) their own grasp of technology advances as they travel, enabling them eventually to construct a secondary universe inside the asteroid. Take <em>that</em> magical gas! There&#8217;s a lot more to the story of course, but you&#8217;ll have to read it to find out, and I highly recommend you do. <a title="Moving Mars on Amazon" href="http://www.amazon.co.uk/Moving-Mars-Greg-Bear/dp/1423353110/ref=sr_1_10?s=books&amp;ie=UTF8&amp;qid=1301221390&amp;sr=1-10">Moving Mars</a> and <a title="Blood Music on Amazon" href="http://www.amazon.co.uk/Blood-Music-Gollancz-S-F-Greg/dp/0575081090/ref=sr_1_2?ie=UTF8&amp;qid=1301223382&amp;sr=8-2">Blood Music</a> are other examples of Greg Bear books that shatter all of today&#8217;s scientific understanding but do so in a highly believable fashion.</p>
<p style="text-align:justify;"><em>Good fiction</em>. By this I don&#8217;t mean good story telling. Obviously that is an important factor in <em>any</em> book or movie in <em>any</em> genre. By &#8216;good fiction&#8217; I mean that the created reality is internally consistent. It does not need to be realistic, just believable. The society we live in today is profoundly affected by scientific and technological advances. We are not just medieval people with cell-phones and fire-arms. The way we spend our days, the way we see the world and even ourselves is in large part due to the shifting scientific perspective. So when one introduces new science into an imaginary world, one must also take the indirect effects into account. This is one of my main complaints with Star Trek; for all this cool new technology (warp drives, transporters, universal translators) the humans (and even the aliens!) are basically the same as we are today.</p>
<p style="text-align:justify;">Isaac Asimov was a master at making believable societies. The science employed in his stories was rarely explained in great detail, but the effects of that science on societies at large were always brilliant. The same goes for many Arthur C. Clarke stories.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/2001-a-space-odyssey.jpg"><img class="aligncenter size-full wp-image-184" title="2001 A Space Odyssey" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/2001-a-space-odyssey.jpg?w=480&#038;h=263" alt="" width="480" height="263" /></a></p>
<p style="text-align:center;"><span style="color:#999999;"><em>source: 2001, A Space Odyssey</em></span></p>
<p style="text-align:center;">
<p style="text-align:center;"><span style="color:#999999;"><em><br />
</em></span></p>
<p style="text-align:justify;">I mention all this because I just watched <a title="Movie website" href="http://www.corymcabee.com/americanastronaut/">The American Astronaut</a> by Cory McAbee. If you haven&#8217;t seen it, I&#8217;m not surprised. It&#8217;s particularly difficult to get a hold of. As far as I know there are no DVDs on sale for Region 2. The American Astronaut is a fantastically clever and well made movie and it&#8217;s the first time I&#8217;ve been left in confusion as to whether I consider this Science Fiction or not. The story itself is wonderfully ludicrous: Samuel Curtis —an inter-planetary trucker and roughneck— is on a mission to get rich. In order to achieve this he must return to Earth with the mortal remains of Johnny R, which are currently being held hostage on the planet Venus —the planet of beautiful women— until a suitable replacement breeding male is delivered. This new boy can be found on Jupiter —a mining planet inhabited by men only— where he is currently employed as a morale booster since he&#8217;s the only one who has ever seen a women&#8217;s breast. The man in charge of Jupiter will trade the boy for a &#8216;Real Live Girl&#8217;, who is apparently still in the process of being cloned as we never see her, but only the suitcase in which she grows. Through it all, Curtis is hunted by Professor Hess, who wants to kill him. Professor Hess is a psychopathic murderer who kills for no reason. But the catch is he <em>only</em> kills for no reason. If he&#8217;s got a reason to kill you, he won&#8217;t.</p>
<p style="text-align:justify;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/americanastronautposter.jpg"><img class="aligncenter size-full wp-image-198" title="AmericanAstronautPoster" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/americanastronautposter.jpg?w=480" alt=""   /></a></p>
<p style="text-align:justify;">The movie is littered with musical pieces (the director and author is a professional musician) that only add to the bizarre atmosphere. It also contains <a title="The Bad Joke on YouTube" href="http://www.youtube.com/watch?v=HLZ9rTzLURw">the world longest bad joke</a>, which is surprisingly funny because the audience consistently manages to laugh at the inappropriate times.</p>
<p style="text-align:justify;">In summary; ten years ago, a crack unit of creative artists made a surrealistic sci-fi/western/musical movie. If you want to watch something that pushes the boundaries of weird, if no-one else can help, and if you can find it, maybe you can watch&#8230; The American Astronaut.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/182/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=182&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/03/27/is-it-just-me-or-do-my-balls-itch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/john-berkey-ii_sf.jpg" medium="image">
			<media:title type="html">John-Berkey-II_SF</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/2001-a-space-odyssey.jpg" medium="image">
			<media:title type="html">2001 A Space Odyssey</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/americanastronautposter.jpg" medium="image">
			<media:title type="html">AmericanAstronautPoster</media:title>
		</media:content>
	</item>
		<item>
		<title>Colours Everywhere</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/03/19/colours-everywhere/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/03/19/colours-everywhere/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 13:07:49 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[biology]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[psychology]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=130</guid>
		<description><![CDATA[Colour is a tricky subject. From pretty much every angle you look at it. From a chemical point of view we get to deal mostly with pigments, which is to say how molecules (or rather, the electron clouds of molecules) interact with photons. It would be difficult enough to predict the result of mixing two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=130&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Colour is a tricky subject. From pretty much every angle you look at it. From a chemical point of view we get to deal mostly with pigments, which is to say how molecules (or rather, the electron clouds of molecules) interact with photons. It would be difficult enough to predict the result of mixing two pigments if you didn&#8217;t have to take chemical reactions into account. Chemical reactions due to pigments interacting, or due to pigments falling apart as a function of half-life or light or temperature or humidity.</p>
<p style="text-align:justify;">From a physics point of view colour is usually approached from the photon-wave-length direction. Every photon has a wave-length and some of these wave-lengths translate into visible light. Lasers tend to emit light of only a single wavelength (mono chromatic), but most natural light sources emit a continuous range of wavelengths. It&#8217;s easy enough to predict the result when mixing two light sources of known wavelength and intensity, but there&#8217;s a difference between the harsh numeric wavelength approach and the soft human biological approach. Just because you know the exact mixture of wavelengths in a certain light beam doesn&#8217;t mean you know how that colour will be experienced by living creatures. The <a href="http://en.wikipedia.org/wiki/Spectral_sensitivity">rods and cones in our eyes</a> do not measure all wavelengths equally well. The following graph shows how, <em>on average</em>, human cones respond to photons of specific wave-lengths:</p>
<p style="text-align:center;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/humanlightsensitivity.png"><img class="aligncenter size-full wp-image-131" title="Human Colour Sensitivity" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/humanlightsensitivity.png?w=480" alt=""   /></a></p>
<p style="text-align:justify;"><span id="more-130"></span></p>
<p style="text-align:justify;">The three curves each represent one of the types of cones humans typically have. They&#8217;re usually referred to as Blue, Green and Red cones, though it&#8217;s clear from the graph that it&#8217;s actually closer to Blue, Yellow and Red. When photons with a wavelength of 400~500 fall on our retinas, it&#8217;s mostly the blue cones that fire, for larger wavelengths it&#8217;s a ratio of Green and Red cones. Anything over 700 is &#8216;too red&#8217; for us to see (infrared), as is everything under 400 (ultra-violet). Note that a larger wave-length equals less energy, hence &#8216;infra&#8217; for red and &#8216;ultra&#8217; for violet instead of the other way around.</p>
<p style="text-align:justify;">Then there&#8217;s the natural variation in the population at large, Rhodopsin after all is subject to evolutionary forces, so we expect this graph to differ from person to person. Also a lot of people are colour blind and there are reports of women who have a fourth kind of cone, making them <a title="tetrachromats" href="http://en.wikipedia.org/wiki/Tetrachromacy#Possibility_of_human_tetrachromats">tetrachromats</a>.</p>
<p style="text-align:justify;">But physics (specifically optics) tells us that colour can also be the result of processes other than photon-pigment interaction. Structural colours for example arise due to quantum effects when light is reflected from thin layers. We see this effect in a lot of bird-feathers, which makes them appear somewhat metallic. Then there&#8217;s good old fashioned dispersion due to the index of refraction, as first properly investigated by Newton. All in all biology has found seven ways to generate colour, all of which are treated in Andrew Parker&#8217;s excellent book &#8216;<a title="Seven Deadly Colours" href="http://www.amazon.co.uk/Seven-Deadly-Colours-Natures-Palette/dp/0743259394/ref=sr_1_1?ie=UTF8&amp;qid=1300538808&amp;sr=8-1">Seven Deadly Colours</a>&#8216;, a worthwhile read.</p>
<p style="text-align:center;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/dsotm.png"><img class="aligncenter size-full wp-image-132" title="The Dark Side Of The Moon" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/dsotm.png?w=480" alt=""   /></a></p>
<p style="text-align:center;"><em>(source: Hipgnosis Design)</em></p>
<p style="text-align:justify;"><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:13px;line-height:19px;white-space:normal;">But by far the most complex facet of colours is the cultural/linguistic aspect. How people experience and recognize colour is in large parts a function of their own personal history. Not only does colour perception differ between cultures, it also differs from time to time (which is of course not that surprising, British culture today is not the same as British culture a century ago). Pink for example wasn&#8217;t always a colour. Sometime in the 14th century the verb <em>to pink</em> changed meaning and is today exclusively used to identify photons of a specific wave-length and extrovert singer-songwriters. There is no equivalent word in Dutch or German or French or Slavic languages for pink, this particular shade is called &#8216;roze&#8217; or &#8216;rose&#8217; or some other variation. (Finnish does have &#8216;pinkki&#8217;, but it&#8217;s a loan word. Anyone who&#8217;s ever been to Finland will tell you that particular hue is not present anywhere in the country, which explains why they had to borrow it from elsewhere).</span></p>
<p style="text-align:justify;">Whether or not you&#8217;ll be able to distinguish Indigo as a colour distinct from Purple depends on large parts on whether you&#8217;re familiar with Indigo. It is not a function of our cones or nerves, but rather our memory. The popular web-comic author xkcd performed a large scale <a title="colour survey" href="http://blag.xkcd.com/2010/05/03/color-survey-results/">colour survey</a> where people were asked to name a random colour. The results of which he graciously published for anyone to play with.</p>
<p style="text-align:justify;">Which brings us finally to the relationship between wavelength and word, which is what this blog post is about. Most modern computer screens are able to display 16,777,216 unique colours (256 variations for red, green &amp; blue each), but we are only able to distinguish a few as truly distinct colours. This means there is a very limited amount of colour names needed to identify any combination of red, green &amp; blue. Or, put another way, it is very easy to write an algorithm that matches a name to any given colour. All you need is a database of a few dozen to maybe a few hundred colour|name combinations and a way to measure distances between two colours. xkcd provided such a map of the fully saturated faces of the RGB colour cube with the regions that fall within a specific colour name:</p>
<p style="text-align:center;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/xkcd_sat_map.png"><img class="aligncenter size-full wp-image-135" title="XKCD Colour Name Map" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/xkcd_sat_map.png?w=480" alt=""   /></a><em>(source: xkcd)</em></p>
<p style="text-align:justify;">But what about going the other way? What if we want to write an algorithm that takes a textual description of a colour and returns an RGB value? Now we&#8217;re in trouble. Sure, we can just invert the aforementioned algorithm and whenever people happen to type a colour name like &#8216;Blue&#8217; or &#8216;Pink&#8217; or &#8216;Brown&#8217; we can return a representative hue of that particular colour. But whenever we&#8217;re confronted with something like &#8216;Darkish Teal&#8217; or &#8216;Pinkish Yellow&#8217; or &#8216;Boring Maroon&#8217; there&#8217;s nothing we can do. If we&#8217;re serious about writing an algorithm that can &#8216;reverse-engineer&#8217; colours from colour names, we first need a large database of colour names. There are several official palettes that define a collection of named colours such as the <a title="X11 table" href="http://en.wikipedia.org/wiki/X11_color_names">X11 table</a>, or the <a title="Pantone Space" href="http://en.wikipedia.org/wiki/Pantone">Pantone Space</a>. Then there&#8217;s a large database of human-centric colour names as collected by the xkcd Colour Survey. When we put it all together we get the large image below. A lot of the entries are duplicates though since this table was created using several sources. Then there&#8217;s a large abundance of colours that we would ideally like to be able to generate directly with an algorithm such as &#8216;Dark Green&#8217; or &#8216;Yellow Green&#8217;. When these unnecessary and redundant entries are filtered out, we end up with the thin images on the right:</p>
<p style="text-align:center;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_all.png"><br />
</a> <a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_all.png"><img class="alignnone size-full wp-image-136" title="colours_all_small" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_all_small.png?w=480" alt=""   /></a> <a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_name.png"><img class="alignnone size-full wp-image-142" title="Sorted by name" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_name_small.png?w=480" alt=""   /></a> <a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_lum.png"><img class="alignnone size-full wp-image-144" title="Sorted by luminance" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_lum_small.png?w=480" alt=""   /></a> <a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_hue.png"><img class="alignnone size-full wp-image-143" title="Sorted by hue" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_hue_small.png?w=480" alt=""   /></a></p>
<p style="text-align:center;"><em>(click for large versions)</em></p>
<p style="text-align:justify;">If we map the reduced palette to an RGB cube, we get the following distribution:</p>
<p style="text-align:justify;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_vp_full_01.png"><img class="aligncenter size-full wp-image-165" title="Reduced Palette RGB Cube" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_vp_full_01.png?w=480&#038;h=468" alt="" width="480" height="468" /></a></p>
<p style="text-align:justify;">As is already visible, the cube does not have uniform density. This is not terribly surprising, as I can think of a lot of names for whitish colours, but only a few for purplish colours. What I did find surprising is the exact shape of the density distribution. We can remove the most isolated colours from the set (those whose distance to the nearest other colour in the set is largest) and thus highlight the boundary between high and low density areas. The following two images are two different views of the entire set with the 50% most isolated colours removed:</p>
<p style="text-align:justify;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective01.png"><img class="aligncenter size-full wp-image-168" title="Dense Areas RGB Cube" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective01_small.png?w=480&#038;h=480" alt="" width="480" height="480" /></a><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective02.png"><img class="aligncenter size-full wp-image-169" title="Dense Areas RGB Cube 2" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective02_small.png?w=480&#038;h=480" alt="" width="480" height="480" /></a></p>
<p style="text-align:justify;">As these images show, the bulk of colour names cluster around the black-white diagonal. We basically have lots of words for colours that are very greyish, but few words for colours that are saturated. A possible explanation for this would be that we experience colours in an imaginary context of nearby colours. After all, if you start to modify Barbie Pink, it takes a lot of modification to really get away from that specific colour, whereas even a little change to a very faint pink will already push it to a different hue. But this is pure conjecture, I have no evidence for this hypothesis.</p>
<p style="text-align:justify;">Next up, how to parse compound colour names and end up with a decent result.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=130&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/03/19/colours-everywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/humanlightsensitivity.png" medium="image">
			<media:title type="html">Human Colour Sensitivity</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/dsotm.png" medium="image">
			<media:title type="html">The Dark Side Of The Moon</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/xkcd_sat_map.png" medium="image">
			<media:title type="html">XKCD Colour Name Map</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_all_small.png" medium="image">
			<media:title type="html">colours_all_small</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_name_small.png" medium="image">
			<media:title type="html">Sorted by name</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_lum_small.png" medium="image">
			<media:title type="html">Sorted by luminance</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_merged_simplified_hue_small.png" medium="image">
			<media:title type="html">Sorted by hue</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colours_vp_full_01.png" medium="image">
			<media:title type="html">Reduced Palette RGB Cube</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective01_small.png" medium="image">
			<media:title type="html">Dense Areas RGB Cube</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/colournamecubeperspective02_small.png" medium="image">
			<media:title type="html">Dense Areas RGB Cube 2</media:title>
		</media:content>
	</item>
		<item>
		<title>Fitness Pressure</title>
		<link>http://ieatbugsforbreakfast.wordpress.com/2011/03/09/fitness-pressure/</link>
		<comments>http://ieatbugsforbreakfast.wordpress.com/2011/03/09/fitness-pressure/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 08:43:51 +0000</pubDate>
		<dc:creator>David Rutten</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Evolution]]></category>
		<category><![CDATA[Fitness]]></category>
		<category><![CDATA[Galapagos]]></category>
		<category><![CDATA[Solver]]></category>

		<guid isPermaLink="false">http://ieatbugsforbreakfast.wordpress.com/?p=108</guid>
		<description><![CDATA[This is the second post on how to define your own Fitness Functions. In the first post we discussed how to combine Fitness variables with different units and ranges. Today we&#8217;ll talk about how we can write a Fitness Function that always points the solver in the right direction. I&#8217;ll use a simpler example this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=108&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">This is the second post on how to define your own Fitness Functions. In the <a title="first post" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/07/define-fitness/">first post</a> we discussed how to combine Fitness variables with different units and ranges. Today we&#8217;ll talk about how we can write a Fitness Function that always points the solver in the right direction. I&#8217;ll use a simpler example this time, where all the Fitness Variables are of the same type as well as the same range.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea001.png"><img class="aligncenter size-full wp-image-114" title="floorarea00" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea001.png?w=480" alt=""   /></a></p>
<p style="text-align:justify;"><span id="more-108"></span>Imagine we want to divide a certain floor area into a fixed number of equally large spaces. Not equally shaped, merely equal surface area. So if the total floor area equals 100 m<sup>2</sup> and we want to create two rooms, they each need to be 50 m<sup>2</sup>. Of course there is an infinite number of ways in which we could divide these spaces and end up with a perfect solution, but even if the system we&#8217;re solving only allows for one perfect solution (or maybe even none!), the ideal Fitness Function would still look the same.</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea011.png"><img class="aligncenter size-full wp-image-115" title="floorarea01" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea011.png?w=480" alt=""   /></a></p>
<p style="text-align:justify;">There are a number of approaches that spring immediately to mind, each with its own benefits and drawbacks:</p>
<ol style="text-align:justify;">
<li>Compute the difference between the individual sub-space areas.</li>
<li>Compute the difference between each sub-space and the equal portion of the total area.</li>
</ol>
<p style="text-align:justify;">If we want both sub-spaces to have the same size, we can simply minimize the difference in area. This is an extremely simple Fitness Function that always converges on the correct answer and which always ends up at <em>zero</em> when the solution is ideal. The function and the associated fitness graph look like:</p>
<p style="text-align:center;"><em><strong>Abs(A &#8211; B)</strong></em></p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/surfaceareafitness_aminusb.png"><img class="aligncenter size-full wp-image-116" title="surfaceareafitness_aminusb" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/surfaceareafitness_aminusb.png?w=480" alt=""   /></a></p>
<p style="text-align:justify;">The problem with this approach though is that it doesn&#8217;t scale very well to a more complex problem. What if we wanted to insert 3 sub-spaces into the master space? Then the fitness function will have to be expanded to:</p>
<p style="text-align:center;"><em><strong>Abs(A &#8211; B) + Abs(A &#8211; C) + Abs(B &#8211; C)</strong></em></p>
<p style="text-align:justify;">And the complexity of this function grows exponentially with the number of sub-spaces. For 5 subspaces we&#8217;re already looking at:</p>
<p style="text-align:center;"><strong><em>Abs(A &#8211; B) + Abs(A &#8211; C) + Abs(A &#8211; D) + Abs(A &#8211; E) + </em></strong></p>
<p style="text-align:center;"><strong><em>Abs(B &#8211; C) + Abs(B &#8211; D) + Abs(B &#8211; E) + </em></strong></p>
<p style="text-align:center;"><strong><em>Abs(C &#8211; D) + Abs(C &#8211; E) + </em></strong></p>
<p style="text-align:center;"><strong><em>Abs(D &#8211; E)</em></strong></p>
<p style="text-align:justify;">which is clearly getting out of hand. So what about option #2? What if we were to compute the difference between each sub-space area and the desired area? We now have a function which grows in a linear fashion. In fact we can write it as a simple sequence:</p>
<p style="text-align:center;"><strong><em>Abs(A &#8211; A<sub>D</sub>) + Abs(B &#8211; <strong><em>A<sub>D</sub></em></strong>) + &#8230; + Abs(Z &#8211; <strong><em>A<sub>D</sub></em></strong>)</em></strong></p>
<p style="text-align:justify;">Where <em><em>A<sub>D</sub></em></em> is the Desired Area, basically the area of the master space divided by the number of sub-spaces. At first glance this function appears to behave just as well as the first one, but there&#8217;s a problem with selection <em>pressure</em>. The pressure of  fitness graph is an indication of how strongly it pushes the Solver into a specific direction. The higher the pressure, the quicker a solver will run across the fitness landscape. A very high pressure is not necessarily a good thing as it tends to reduce the diversity of the gene-pool. All individuals are channelled into a narrow path from here to the summit of the fitness gradient. A very low pressure can also be problematic as it allows the population to spread out, and the random drift starts to counteract the progress of the solver. A pressure of zero is definitely very bad as the Solver doesn&#8217;t know in what direction to progress. The Fitness Function as written above, has zero pressure under certain circumstances. For example, imagine we have three rooms, each of which has an ideal area of 30 m<sup>2</sup>. However, we are at a stage in the solution where this ideal is very far off. Room C is far too big (50 m<sup>2</sup>) whereas Rooms A &amp; B are both too small (20 m<sup>2 </sup>each). If we insert these values into the Fitness Function, we end up with:</p>
<p style="text-align:justify;">&nbsp;</p>
<p><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea02.png"><img class="aligncenter size-full wp-image-122" title="floorarea02" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea02.png?w=480" alt=""   /></a></p>
<p style="text-align:center;"><em><strong>Abs(20 &#8211; 30) + Abs(20 &#8211; 30) + Abs(50 &#8211; 30) = 40</strong></em></p>
<p style="text-align:center;"><em><strong><br />
</strong></em></p>
<p style="text-align:justify;">Now the Solver mutates or recombines the genes and it comes up with a different answer, namely:</p>
<p>&nbsp;</p>
<p style="text-align:center;"><a href="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea03.png"><img class="aligncenter size-full wp-image-123" title="floorarea03" src="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea03.png?w=480" alt=""   /></a><em><strong> </strong></em></p>
<p style="text-align:center;"><em><strong>Abs(25 &#8211; 30) + Abs(15 &#8211; 30) + Abs(50 &#8211; 30) = 40</strong></em></p>
<p>&nbsp;</p>
<p style="text-align:justify;">Even though the result is different, the fitness is the same. Equal fitness means equal worth means the Solver doesn&#8217;t know where to go from here. We need to decide which of these two cases better suits our goals and adjust the Fitness Function to reflect this set of preferences. Let&#8217;s assume for the time being that we prefer the former case, as it better represents our ultimate goal of identically sized rooms. How can we convert this preference into maths?</p>
<p style="text-align:justify;">The easiest solution is to add penalty clauses, just like in the <a title="previous post" href="http://ieatbugsforbreakfast.wordpress.com/2011/03/07/define-fitness/">previous post</a>. But instead of dampening the Fitness factors with a square root, we need to amplify them. The larger the departure from the ideal area, the more severe the penalty should be. We can amplify the components of the Fitness Function by squaring them, giving us:</p>
<p style="text-align:center;"><strong><em>Abs(A &#8211; A<sub>D</sub>)<sup>2</sup> + Abs(B - <strong><em>A<sub>D</sub></em></strong>)<sup>2</sup> + &#8230; + Abs(Z - <strong><em>A<sub>D</sub></em></strong>)<sup>2</sup></em></strong></p>
<p style="text-align:left;">&nbsp;</p>
<p style="text-align:justify;">If we now insert the areas of the two cases we get different results:</p>
<p style="text-align:center;"><em><strong>Abs(20 &#8211; 30)<strong><em><sup>2</sup></em></strong> + Abs(20 &#8211; 30)<strong><em><sup>2</sup></em></strong> + Abs(50 &#8211; 30)<strong><em><sup>2</sup></em></strong> = 600</strong></em></p>
<p style="text-align:center;"><em><strong><em><strong>Abs(25 &#8211; 30)<strong><em><sup>2</sup></em></strong> + Abs(15 &#8211; 30)<strong><em><sup>2</sup></em></strong> + Abs(50 &#8211; 30)<strong><em><sup>2</sup></em></strong> = 650</strong></em></strong></em></p>
<p style="text-align:center;"><em><strong><em><strong><br />
</strong></em></strong></em></p>
<p style="text-align:justify;">with the former case giving a lower fitness value, which is exactly what we want since we&#8217;re trying to minimize this value.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ieatbugsforbreakfast.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ieatbugsforbreakfast.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ieatbugsforbreakfast.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ieatbugsforbreakfast.wordpress.com&amp;blog=20810556&amp;post=108&amp;subd=ieatbugsforbreakfast&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ieatbugsforbreakfast.wordpress.com/2011/03/09/fitness-pressure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4e3addf5eebb3af61ab4104eabb499f?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">davidrutten</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea001.png" medium="image">
			<media:title type="html">floorarea00</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea011.png" medium="image">
			<media:title type="html">floorarea01</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/surfaceareafitness_aminusb.png" medium="image">
			<media:title type="html">surfaceareafitness_aminusb</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea02.png" medium="image">
			<media:title type="html">floorarea02</media:title>
		</media:content>

		<media:content url="http://ieatbugsforbreakfast.files.wordpress.com/2011/03/floorarea03.png" medium="image">
			<media:title type="html">floorarea03</media:title>
		</media:content>
	</item>
	</channel>
</rss>
