<?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/"
	>

<channel>
	<title>Pragmatic Genetic Programming</title>
	<atom:link href="http://www.vagueinnovation.com/pragmatic_gp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vagueinnovation.com/pragmatic_gp</link>
	<description>Engineering Useful Surprises</description>
	<lastBuildDate>Wed, 23 Jan 2013 14:48:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Everybody loves a puzzle</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/everybody-loves-a-puzzle/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/everybody-loves-a-puzzle/#comments</comments>
		<pubDate>Wed, 23 Jan 2013 12:14:07 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[genetic programming]]></category>
		<category><![CDATA[puzzles]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=250</guid>
		<description><![CDATA[A few months back Zee Spencer started thinking about using evolutionary algorithms of various sorts (notably GP) to solve Sudoku puzzles—and more particularly to evolve solvers. Interesting idea, not least because Sudoku solving is a “solved problem”, and nothing sets &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/everybody-loves-a-puzzle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A few months back <a href="http://zeespencer.com">Zee Spencer</a> started thinking about using evolutionary algorithms of various sorts (notably GP) to solve <a href="http://en.wikipedia.org/wiki/Sudoku">Sudoku puzzles</a>—and more particularly to evolve <em>solvers</em>.</p>

<p>Interesting idea, not least because Sudoku solving is a “solved problem”, and nothing sets me off like one of those. There are well-known constraint-satisfaction methods for constructing and solving Sudoku grids; there are branch-and-bound and integer programming approaches; you can even <a href="http://www.ctan.org/tex-archive/macros/latex/contrib/sudokubundle">create, solve and <em>typeset</em> Sudoku grids by just typing a little LaTeX code</a>. And of course <a href="http://norvig.com/sudoku.html">Peter Norvig has shown us all how to do it</a> in his excellent and clear pedagogic essay.</p>

<p>But of course all of those approaches <em>make sense</em>. Which is to say they’re elegant and no doubt ever so efficient and rational, but… well, they’re <em>boring</em>, for lack of a better term.</p>

<p>Zee and I paired a few months back on a preliminary experiment he’d designed, in which he was evolving <em>solutions</em> to fixed Sudoku puzzles. And something he said reminded me of an old unexplored notebook question regarding constraint-satisfaction puzzles generally, which I brought up. This week I’m in Cleveland working with him on his interpretation of that approach.</p>

<h2>Cellular Sudoku</h2>

<p>All the extant Sudoku solver algorithms I’m aware of rely on what you might call “serial attention” and a traditional dynamic programming architecture. That is, they scan over the initial grid in some way looking for any of a number of patterns: a block or row or column that has almost everything filled in, or a cell where two or three constraints overlap to make a number choice <em>certain</em>, and they fill those numbers in and start looking at the consequences. The fancy ones keep a little “stack” of what-if explorations in mind, looking not merely at the currently-obvious constraint-overlaps but also checking for conflicts and effects two or more steps into “the future”. This is in some sense the way many people actually <em>work</em> Sudoku: a cycle of scanning for patterns, making judicious assertions, and maybe backing out if those assertions are “tricky” (as they can be in difficult puzzle examples). And—at least in my case—probably there’s some guessing.</p>

<p>Very nice. We’re not doing that.</p>

<p>In this experiment we’re looking for <em>distributed</em> algorithms, a lot more like cellular automata rules, that simultaneously update the <em>choices</em> available to every cell in the Sudoku grid according to an (undiscovered) deterministic rule.</p>

<p>Here’s the way our hypothetical alien cellular fellows will “solve” a given puzzle:</p>

<ol>
<li>Every cell in the grid is assigned a <code>choice vector</code>, which indicates which of the available digits (1–4 for <a href="http://sudokuplace.com/4x4.asp">small Sudoku</a>, 1–9 for standard grids, and so on) that given cell <em>might</em> be at any given instant. The vectors aren’t probabilistic, just Boolean values indicating whether a cell <em>could</em> take a given value. If I represent these Booleans with <code>1</code> and <code>0</code> for brevity, then for example in a 9x9 grid the initial <code>choice vector</code> for any empty cell will be <code>111111111</code>, and if the cell is a known hint (say a <code>5</code>) the <code>choice vector</code> is <code>000010000</code>—that is, that given cell’s choices are limited to being <code>5</code>.</li>
<li>An <code>Answer</code> is a script of any number of lines, each line containing exactly one <code>command</code>. Commands have two parts: an <code>argument</code> and an <code>operator</code>.</li>
<li>The <code>argument</code> is a string that refers to the relative position of some other cell within the Sudoku <em>grid</em>: <code>left</code>, <code>right</code>, <code>up</code>, <code>down</code>, and also <code>clockwise</code> (<code>cw</code>) and <code>counterclockwise</code> (<code>ccw</code>). A cell’s <code>left</code> neighbor is the cell in the same row, one step to the left, modulo the grid width; that is, the <code>left</code> neighbor of a cell in the left column is the cell in the same row on the right column. Similar toroidal conditions apply to <code>right</code>, <code>up</code> and <code>down</code>. The <code>clockwise</code> neighbor of any cell in the grid is its preceding neighbor <em>within its block</em>, numbering in top-left-to-lower-right positional order, row-first. So for example, in a standard 3x3 block within a 9x9 Sudoku puzzle, the <code>cw</code> neighbor of the cell in the upper right corner is the leftmost cell in the next row. The <code>cw</code> neighbor of the cell in the lower right corner is the first block in the upper left, as well.</li>
<li>The <code>operator</code> represents a bitwise boolean operation to be carried out between the <code>choice vector</code> of the cell in question and that of the indicated <code>argument</code> cell. For example the command <code>"left and"</code> applied to a given cell in the grid will replace that cell’s <code>choice vector</code> with the result of applying bitwise <code>AND</code> to its current <code>choice vector</code> and that of its <code>left</code> neighbor.</li>
<li>For each line in an <code>Answer</code>, the <code>choice vector</code> of every cell in the grid is <em>synchronously</em> updated based on the current values, starting from the initial setup.</li>
<li>After the last command in the <code>Answer</code> has been applied, the resulting grid is <em>interrogated</em>. That is, every cell is sent a <code>decide!</code> message, and emits (with uniform probability) one of the choices encoded in its final <code>choice vector</code>. Cells that have ended up with no remaining choices emit a <code>?</code> or <code>0</code> answer, indicating they’re unable to respond.</li>
</ol>

<p>Needless to say by this time, this is an exploratory project, not an “optimization” problem. It’s not a case of “find the most efficient algorithm to do that”, but rather “is it even feasible that this might get closer to a solution”? Our <em>suspicion</em> is that it might, but aside from a bit of hand-wavy discussion of “information propagating across the grid” we have no fracking idea <em>how</em> a general-purpose Sudoku solver might work, if it can.</p>

<p>We’ll see.</p>

<p>In the meantime, you might already sense a few places where this scheme can be relaxed or expanded. Yes, we thought about probability vectors instead of choice vectors. Yes, we’ll start with a simple suite of <code>operators</code> like <code>and</code>, <code>or</code>, <code>not</code>, but we could get fancy with all 16 possible binary operators, or spread out into multiple arguments. Yes, we’re starting with a local neighborhood around each cell to begin with, but we could let the <code>argument</code> of any command be a <em>phrase</em> of consecutive moves like <code>"left up left ccw"</code>. We could include access to the <em>past</em> state of a cell in the neighborhood definition as well. We could apply different rules to different cells at each time-step.</p>

<p>We have no clear idea what <em>might</em> happen until we give it a shot. Which will probably be the next thing we talk about.</p>

<p>How do we know what’s <em>happening</em>, and whether we think it’s good or bad?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/everybody-loves-a-puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pizza Eating Strategies, Part 2</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-2/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-2/#comments</comments>
		<pubDate>Thu, 23 Aug 2012 11:04:25 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[genetic programming]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=247</guid>
		<description><![CDATA[In the previous episode, I spent a few minutes jotting down some stories that describe what I’m interested in learning in this project: I’m using GP to develop players of Peter Winkler’s “Pizza Eating Game”, and the algorithmic part of &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In the <a href="http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-1/">previous episode</a>, I spent a few minutes jotting down some stories that describe what I’m interested in learning in this project: I’m using GP to develop players of Peter Winkler’s “Pizza Eating Game”, and the algorithmic part of those GP Answers will use a novel architecture called <a href="http://hampedia.org/wiki/File:Tsm.pdf">Tag Space Machines</a> from Lee Spector. And as a kata for myself (and a bit of a tutorial for the occasional person I encounter who hasn’t done test-driven design before) I’ll be using <a href="http://en.wikipedia.org/wiki/Behavior-driven_development">rigorous BDD</a>, recording all the little messy details here.</p>

<p>So. I think I’ll start with some low-hanging fruit, not least because I’m wrestling with learning a <a href="http://www.sublimetext.com">new text editor</a>, and <a href="http://rubenlaguna.com/wp/2012/02/01/sublime-text-2-rvm-rspec/">trying to get all the fiddly bits hooked up</a> is proving challenging. So I think I’ll build a Pizza class first.</p>

<p>Looking over the stories, I’m going to assume the pizza is just some kind of wrapper around an Array of slice sizes, with some fancy methods that permit initialization/reset and “eating”.  Let’s start with initialization/reset.</p>

<pre><code># pizza.feature
Feature: Pizza

  Background:
    Given I have a new pizza

  Scenario: pizza slicing
    Given a list of slice sizes [1,0,7,9,3,12,33,0,0,0,2.88,2.12]
    When I slice the pizza
    Then there should be 12 slices
    And the pizza should weigh 70
    And the pizza should be whole
</code></pre>

<p>The pizza is “whole” because Alice hasn’t eaten the first slice, and it’s going to be treated as an array with “wrapping” boundaries by her yumminess function(s).</p>

<p>Cucumber reports that the first pending spec is <code>Given I have a new pizza</code>, so I create the appropriate step definition.</p>

<pre><code># pizza_steps.rb
Given /^I have a new pizza$/ do
  @pizza = Pizza.new
end
</code></pre>

<p>This fails, since I have no Pizza class.</p>

<pre><code>#pizza.rb
class Pizza
end
</code></pre>

<p>And it passes. The next pending step is <code>Given a list of slice sizes [1,0,7,9,3,12,33,0,0,0,2.88,2.12]</code>.</p>

<pre><code># pizza_steps.rb
Given /^a list of slice sizes (\[.+\])$/ do |slices|
  @slice_list = eval(slices)
end
</code></pre>

<p>That passes, since it’s not invoking the library at all, just setting a variable within the scope of the test. <code>When I slice the pizza</code> is next.</p>

<pre><code># pizza_steps.rb
When /^I slice the pizza$/ do
  @pizza.slice(@slice_list)
end
</code></pre>

<p>This calls for a tiny bit more structure in the <code>Pizza</code> class, but not too much.</p>

<pre><code>#pizza.rb
class Pizza
  attr_accessor :slices

  def slice(size_array)
    @slices = size_array
  end
end
</code></pre>

<p>Next pending step is <code>Then there should be 12 slices</code>.</p>

<pre><code># pizza_steps.rb
Then /^there should be (\d+) slices$/ do |count|
  @pizza.slices.length.should == count.to_i
end
</code></pre>

<p>Which passes already. <code>And the pizza should weigh 70</code></p>

<pre><code># pizza_steps.rb
Then /^the pizza should weigh (\d+)$/ do |weight|
  @pizza.weight.should == weight.to_f
end
</code></pre>

<p>That calls for another bit if <code>Pizza</code> structure. But is it an attribute, or a method? I’m thinking method; the slice weight array itself is already stored, and I assume the players will have some sort of <code>#eat(left_slice)</code> method that modifies that Array directly on each turn. I’ll return the sum of all slice values.</p>

<pre><code>#pizza.rb
class Pizza
...
  def weight
    @slices.inject(0) {|sum,w| sum+w}
  end
end
</code></pre>

<p>Last step is <code>And the pizza should be whole</code>.</p>

<pre><code># pizza_steps.rb
Then /^the pizza should be whole$/ do
  @pizza.should be_whole
end
</code></pre>

<p>Interesting question: when is <code>Pizza#whole?</code> going to be true? As soon as my pizza is first sliced, surely. But maybe also when it’s initialized (“baked”)? Then again, the initialization method (which I haven’t needed yet) might be more useful to set up partially-eaten un-whole pizzas for testing or training. I’m all for postponing.</p>

<pre><code>#pizza.rb
class Pizza
  attr_accessor :whole
  ...
  def slice(size_array)
    @slices = size_array
    @whole = true
  end

  def whole?
    whole
  end
end
</code></pre>

<p>All steps pass.</p>

<p>So Alice and Bob will be eating particular elements of  <code>Pizza#slices</code>. And the stories make it clear there are two modes: the first slice, and then the <code>left_slice</code> vs <code>right_slice</code>. I suppose I should start with the first slice. In addition to making the pizza no longer <code>whole?</code>, this ought to “unwrap” the circle to create the <code>left_slice</code> and <code>right_slice</code> linearity.</p>

<pre><code># pizza.feature
...
Scenario: eating the first slice unfolds the circle
  Given the pizza is sliced into [1,2,3,4,5,6,7,8]
  When I take out piece 6
  Then the pizza should not be whole
  And the left slice should weigh 7
  And the right slice should weigh 5
</code></pre>

<p>I’ve made a new step here.</p>

<pre><code># pizza_steps.rb
Given /^the pizza is sliced into (\[.+\])$/ do |slices|
  @pizza.slice eval(slices)
end
</code></pre>

<p>That passes already, from work done in the previous scenario. Now <code>When I take out piece 6</code> is the next pending step.</p>

<pre><code># pizza_steps.rb
When /^I take out piece (\d+)$/ do |which|
  @pizza.eat_first_slice(which.to_i-1)
end
</code></pre>

<p>I need to add <code>Pizza#eat_first_slice</code> to the library, though this step doesn’t actually call for it to do anything.</p>

<pre><code>#pizza.rb
class Pizza
...
  def eat_first_slice(which)
  end
...
</code></pre>

<p><code>Then the pizza should not be whole</code></p>

<pre><code># pizza_steps.rb
Then /^the pizza should not be whole$/ do
  @pizza.should_not be_whole
end
</code></pre>

<p>Seems a simple thing to make that pass.</p>

<pre><code>#pizza.rb
class Pizza
...
  def eat_first_slice(which)
    @whole = false
  end
...
</code></pre>

<p><code>And the left slice should weigh 7</code>. Basically the “left” slice is the stub-end of the unwrapped circle I get when I snip out the eaten piece, and the “right” slice is the piece remaining to its left. First the steps I need (both at once, just because the symmetry is so clear):</p>

<pre><code># pizza_steps.rb
Then /^the left slice should weigh (\d+)$/ do |weight|
  @pizza.left_slice.should == weight.to_f
end

Then /^the right slice should weigh (\d+)$/ do |weight|
  @pizza.right_slice.should == weight.to_f
end
</code></pre>

<p>And the library code to make these pass. I fiddle a bit with the bounds-checking, but I think this will do.</p>

<pre><code>#pizza.rb
class Pizza
...
  def eat_first_slice(which)
    open_circle = @slices[which+1..-1] + @slices[0...which]
    @slices = open_circle
    @whole = false
  end
...
</code></pre>

<p>And that seems to have done the trick.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pizza Eating Strategies, part 1</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-1/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-1/#comments</comments>
		<pubDate>Sat, 18 Aug 2012 13:10:17 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[genetic programming]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=234</guid>
		<description><![CDATA[This is the first in a (hopefully short) series in which I’m practicing my BDD in a Ruby-based experiment where I want: to use GP to develop strategies in Peter Winkler’s Pizza Eating Game; to use Lee Spector’s Tag Space &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is the first in a (hopefully short) series in which I’m practicing my BDD in a Ruby-based experiment where I want:</p>

<ul>
<li>to <a href="http://www.vagueinnovation.com/pragmatic_gp/applying-gp-to-winklers-pizza-eating-game/">use GP to develop strategies in Peter Winkler’s Pizza Eating Game</a>;</li>
<li>to use <a href="https://hampedia.org/wiki/File:Tsm.pdf">Lee Spector’s Tag Space Machine</a> system as an architecture in my <a href="http://www.vagueinnovation.com/pragmatic_gp/the-three-languages-of-gp/">Answer Language
</a>;</li>
<li>to use a trivial Answer Factory architecture (random sampling of Answers plus some basic metaheuristic moves) to explore whether there anything like the known <a href="http://arxiv.org/abs/0812.2870">optimal strategies</a> crop up</li>
</ul>

<h3>Some stories</h3>

<p>I’m starting from an empty canvas: I’ll need to think about the representation of the problem domain, not just the architecture of the TSM answers and GP system. I spend some time reading over the <a href="http://arxiv.org/abs/0812.2870">arXiv paper that sparked my curiosity</a> and <a href="http://hampedia.org/wiki/File:Tsm.pdf">Lee’s description of TSMs</a>. I come up with a few stories, and some notes as I jot them down.</p>

<blockquote>
  <dl>
  <dt>Eating the first piece isn’t like later pieces:</dt>
  <dd>Before the first game move (when the pizza is whole), Alice can pick any piece at all. After she does, Bob and Alice can only pick one of the two neighbors of the growing gap.</dd>
  </dl>
</blockquote>

<p>As I mentioned when I launched this side-project, I’m thinking about the way these agents play the game as being some kind of “field generation” process. Their calculations impose some kind of “yumminess field” on the (current) set of pizza slices, and then when that calculation is done they eat the slice with the highest yumminess value. Further, I think I want to try a <em>local</em> process, a single calculation conducted with “this piece of pizza” as the focus, with references to the traits of other pieces being spatially relative.</p>

<p>The interesting thing of course is the topological difference between the whole pizza and the partially-eaten one. The whole is circular, with “left” and “right” being well-defined all the way around. But once a piece is eaten, the thing becomes “linear”, and the only choice before the agents is between the two “end” pieces of that ordered set of pieces.</p>

<p>In determining the “yumminess field”, this feels like it might be important. But it’s also limiting the set of agent behaviors: the first move is some kind of <code>eat_first_piece</code>, and all subsequent moves are <code>eat_left_piece</code> or <code>eat_right_piece</code>.</p>

<blockquote>
  <dl>
  <dt>Pizza slices have weights:</dt>
  <dd>every pizza slice has a numerical weight, which can be 0</dd>
  </dl>
</blockquote>

<p>This seems pretty straightforward: the goal of the players is to consume a maximum proportion of the total pizza, and “weight” seems as good as anything for tallying this up. Better than “crust”, surely… though of course they will sort in the same order.</p>

<blockquote>
  <dl>
  <dt>Agent decision-making:</dt>
  <dd>Agents have two <code>yumminess</code> functions, one for picking the first piece, and the other for later moves. The <code>yumminess</code> function is invoked with a reference to a specific index of the current pizza, and returns a float value. One yumminess value is calculated (in parallel) for each slice.</dd>
  </dl>
</blockquote>

<p>I’m thinking the basic <code>yumminess</code> calculations might include some boolean logic and arithmetic; we’ll work our way up from there as needed. The index of a slice is the input, but the algorithm can have instructions to interrogate the attributes of slices, things like its index, its weight, that sort of thing. Heck, maybe the <code>yumminess</code> of one slice can refer to the <code>yumminess</code> of its neighbors… but that may end up being complicated.</p>

<p>Because of the clear topological (and strategic) difference between the first slice and the later ones, I’m willing to start with a little extra complexity and have two separate functions. This seems to imply I’m thinking that every agent can play “Alice” or “Bob” roles in whatever scoring tournament I come up with. Why not? Let’s see what happens.</p>

<blockquote>
  <dl>
  <dt>Yumminess ties are broken randomly:</dt>
  <dd>When the maximum <code>yumminess</code> is assigned to multiple available slices, one is picked at random with uniform probability.</dd>
  </dl>
</blockquote>

<p>In other words: when in doubt, flip a coin or draw straws.</p>

<blockquote>
  <dl>
  <dt>Yumminess functions are Tag Space Machines:</dt>
  <dd>One for each. The appropriate references to external values are set up based on the slice index, the TSM is run, and then the topmost [number] is emitted as the output.</dd>
  </dl>
</blockquote>

<p>I’m not sure which “number” this might be. Do I need to differentiate between <code>int</code> and <code>float</code>? Really? I don’t have a lot of information yet about what the TSM language is going to be like. Maybe this will become more apparent as I work on that.</p>

<blockquote>
  <dl>
  <dt>TSM math instructions:</dt>
  <dd>The TSM should recognize <code>float</code> values, and have basic math instructions: <code>add</code>, <code>subtract</code>, <code>divide</code>, <code>multiply</code>, <code>min</code>, <code>max</code>, maybe a few more.</dd>
  </dl>
</blockquote>

<p>Do I really need <code>integer</code> as a type? After all, the notion of an “index” in the tag space itself depends on the mathematical “floor” function. Why not use floats for indices as well, taking the floor (or ceiling) as needed? Maybe this is just <code>reals</code>, and we’ll skip the difference until we need it.</p>

<blockquote>
  <dl>
  <dt>TSM pizza instructions:</dt>
  <dd>The TSM should be able to get the <code>index</code> and <code>weight</code> of the slice on which it’s applied. It can use <code>weight_of</code> and <code>index_of</code> with a numeric argument (positive or negative) to obtain values of neighboring slices.</dd>
  </dl>
</blockquote>

<p>I have an intuition this may not be enough. But we’ll see. It’s not that hard to imagine running the calculations for each slice in lock-step, and letting one TSM interrogate its neighboring TSM’s state, like with <code>real_of</code> to copy over a <code>real</code> from a neighboring slice’s stack into its own. But no need to over-design yet.</p>

<blockquote>
  <dl>
  <dt>TSM logical instructions:</dt>
  <dd>The TSM should have basic Boolean logician functions: <code>and</code>, <code>or</code>, <code>not</code>, that sort of thing.</dd>
  </dl>
</blockquote>

<p>Makes sense, because we’ll have comparisons to make.…</p>

<blockquote>
  <dl>
  <dt>TSM comparison instructions:</dt>
  <dd>The TSM should have comparisons like <code>less_than</code>, <code>greater_than</code>, <code>equal</code> and so on for <code>real</code>s and any other types for which they make sense.</dd>
  </dl>
</blockquote>

<p>These will create <code>bool</code> outputs.</p>

<blockquote>
  <dl>
  <dt>TSM dynamics:</dt>
  <dd>When the TSM is activated, it pops one item from its <code>x</code> stack; if it’s a constant it’s pushed to the appropriate stack, and if it’s an instruction it executes that instruction immediately. This continues until the <code>x</code> stack is empty.</dd>
  </dl>
</blockquote>

<p>This is just the definition of how TSMs run. But it does raise the question (from experience): Will there ever be TSM “programs” that don’t terminate? Will I need a step counter, and some sort of deadline? We’ll see, I guess.</p>

<blockquote>
  <dl>
  <dt>TSM tag spaces:</dt>
  <dd>The <code>tag_space</code> stack holds <code>tag_space</code> instances. TSM instructions for storage and lookup exist, and refer to the top <code>tag_space</code> in the stack based on numeric index. Each <code>tag_space</code> is a key-value pair store, sorted by numeric key. Lookup is <em>inexact</em>, returning the value for the smallest key larger than the search tag, or the first key of no key is larger. No value is returned if the <code>tag_space</code> is empty.</dd>
  </dl>
</blockquote>

<p>Feels as though I’ll need to create a subclass of Ruby’s <code>Hash</code> for this, maintaining the sort order and dealing with the inexact lookup. Shouldn’t be too complicated, but will demand some careful checks.</p>

<blockquote>
  <dl>
  <dt>TSM tagging instructions:</dt>
  <dd><strike>There are instructions <code>store</code>, <code>store_pair</code> and <code>lookup</code> for writing and reading from the top <code>tag_space</code>.</strike> (see update below)</dd>
  </dl>
</blockquote>

<p><strike>Based on Lee’s description, it sounds as though his <code>ts_tag</code> imaps arise somehow from the “genome” of a TSM: that is, they appear fully-formed in the <code>x</code> stack before we start running the code. This feels strange but intentional, and so I’ve asked him if I’m missing something.</strike></p>

<p><strike>In the meantime, I’m more comfortable having instructions that <em>make</em> those associations from arguments just like other instructions would use, except that the arguments for <code>store</code> and <code>store_pair</code> come from the <code>x</code> stack rather than the typed stacks. For instance, I’m imagining <code>store</code> pulls a “tag key” from the <code>reals</code> stack, and the next item from the <code>x</code> stack, and stores the item as a value associated with that key in the topmost <code>tag_space</code>.</strike></p>

<h3>What am I missing?</h3>

<p>Well, of course I’ve not defined anything about how these supposed pizza-eating experts are going to be scored, nor how many and what kind of pizza they’ll be asked to eat, or any of that. But it feels like enough to get started with, especially as I’m waiting for <a href="http://people.cs.umass.edu/~etosch/Emma_Tosch.html">Emma Tosch</a> and Lee to help me out of the confusing bits.</p>

<p>In the meantime, I’ll start on the pizza first….</p>

<p><strong>Update (later that day):</strong></p>

<p>After a couple of clarifications from Lee, I’ve got a better handle on how the tags and tagging instructions should work.</p>

<blockquote>
  <dl>
  <dt>TSM tagging instructions:</dt>
  <dd>There are three kinds of what I’ll call <em>macro instructions</em>: <code>store_at(N)</code>, <code>lookup_at(N)</code> and <code>store_pair_at(N)</code>, where <code>(N)</code> is a fixed floating-point number, <em>not an argument</em>. These numerical values can (and probably will) vary between instances of these instructions, but not over the “life” of the individual instruction instances.</dd>
  </dl>
</blockquote>

<p>So basically what’s happening here is that the storage and retrieval of items in a <code>tag_space</code> always includes a particular address, not a numeric argument. This is a design decision from Lee, and seems perfectly valid to work with.</p>

<p>I think I can get away with a bit of abbreviation when writing TSM code, and use <code>>8.2</code> to indicate the macro instruction <code>store_at(8.2)</code>, use <code><-3.9</code> to indicate <code>lookup_at(-3.9)</code>, and <code>>>991.55</code> to indicate the macro <code>store_pair_at(991.55)</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/pizza-eating-strategies-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Applying GP to Winkler’s Pizza Eating Game</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/applying-gp-to-winklers-pizza-eating-game/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/applying-gp-to-winklers-pizza-eating-game/#comments</comments>
		<pubDate>Fri, 17 Aug 2012 10:15:53 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[GECCO]]></category>
		<category><![CDATA[genetic programming]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=226</guid>
		<description><![CDATA[(Code to be posted at github as I move forward) A recent arXiv preprint entitled “How to eat 4/9 of a Pizza” caught my eye. It’s an interesting little answer to a challenge from game theory (and geometry, I suppose) &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/applying-gp-to-winklers-pizza-eating-game/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>(Code to be posted at <a href="https://github.com/Vaguery/GP_pizza_eaters">github</a> as I move forward)</p>

<p>A recent <a href="http://arxiv.org/abs/0812.2870">arXiv preprint entitled “How to eat 4/9 of a Pizza”</a> caught my eye. It’s an interesting little answer to a challenge from game theory (and geometry, I suppose) posed by <a href="http://www.math.dartmouth.edu/~pw/">Peter Winkler</a>, who’s a constant source of inspiration.</p>

<h2>Hungry, Hungry Alice &amp; Bob</h2>

<p>Suppose we have a circular pizza, already cut into wedge-shaped slices (from the center to the crust). These are <em>extremely</em> precise slices, and in fact they can have “0 width”, or some small epsilon close enough to 0 to be entertaining.</p>

<p>There are two hungry players, Alice and Bob. Alice chooses a piece to eat first. Bob and Alice alternate eating pieces of pizza after that, until it’s gone, but they must both <em>always</em> choose one of the two pieces adjacent to the growing gap.</p>

<p>The <a href="http://arxiv.org/abs/0812.2870">arXiv preprint</a> describes a strategy by which Alice can eat at least 4/9 of the pizza, regardless of the slices or how smart Bob’s strategy is. She may be able to eat more than 4/9, depending on the slices and Bob’s mistakes. And of course she’s only <em>guaranteed</em> to get that much if she’s following a provably optimal strategy.</p>

<h2>Agents: Represent</h2>

<p>See, I’ve been writing <a href="https://leanpub.com/pragmaticGP">this book</a>, and there are a number of little side-projects like this one that have come up, but probably won’t make the cut for the final edit. The six large-scale projects I’m working on keep me busy enough, but at the same time I’m trying to polish and refine my “simplified” approach to GP project management.</p>

<p>So this is me thinking in Ruby about one of those little side-projects.</p>

<p>I’ve also recently been watching <a href="https://hampedia.org/wiki/File:Tsm.pdf">Lee Spector’s explanations of Tag Space Machines</a> unfold. Tag Space Machines (TSMs) are a representation scheme for GP languages he’s implemented in his lab’s work. I think I may work with TSMs here.</p>

<h2>Pizza</h2>

<p>The pizza is modeled as an Array of “slice weights”. An uneaten pizza is considered to be circular, and the first player (“Alice”) can eat any piece she wants. Eating the first piece “unfolds” the pizza, restructuring the array so that the start and end values are the pieces on the “right” and “left” of the gap. After that, players can only choose to eat one of the two end pieces.</p>

<p>In other words, the player agents have only three actions (besides “planning”): <code>eat_first_piece</code>, <code>eat_left_piece</code> and <code>eat_right_piece</code>. And they don’t even get free choice among those three, since the first is mutually exclusive with the last two.</p>

<h2>How to think about eating pizza</h2>

<p>The big design question here is, how do players <em>think</em> about the pizza?</p>

<p>A slightly more traditional approach might have them handling arrays and iterating and stuff. But having modeled game-play before, I know there’s also more distributed (if less intuitive) approach I’m wondering about here: since there are so few choices in the game, what if a “thinking” or “strategy” were a <em>scalar field</em> calculated locally for each of the pizza slices individually, and which slice is chosen by a given agent was determined by the highest-scoring pizza slice according to that agent’s slice field algorithm?</p>

<p>In other words, suppose Alice has <code>eat_first_slice</code> field definition that is a function applied to each element of the pizza slice array (treating it as circular). The arguments are the weight of “this” slice, and weights and distances of slices to the relative left and right of “this” slice, and the number of slices overall. Maybe her <code>eat_first_slice</code> field is the weight of a slice plus the average weight of its six neighbors on either side.</p>

<p>Alice’s first turn begins with her calculation of this field for the given pizza, and then she selects the highest-scoring slice. If Bob and Alice then have a (possibly different) function for scoring the slices of the non-circular pizza, the same dynamics can apply to their subsequent choices of <code>left_slice</code> over <code>right_slice</code>. In cases of ties, we pick at random.</p>

<p>Might this approach work? I have no idea. It <em>feels</em> as though it has some flexibility. We’ll see.</p>

<p>I’ll post updates as I make progress.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/applying-gp-to-winklers-pizza-eating-game/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/update/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/update/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 21:54:57 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[leanpub]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=223</guid>
		<description><![CDATA[[cross-posted to Notional Slurry] I realize I’ve turned quiet as far as the blogs are concerned. I’ve been working on translating the draft content for the Answer Factories book into published manuscript. Markdown is lovely, but talking in detail about &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/update/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>[cross-posted to <a href="http://williamtozier.com/slurry/">Notional Slurry</a>]</p>

<p>I realize I’ve turned quiet as far as the blogs are concerned. I’ve been working on translating the draft content for the  <a href="https://leanpub.com/pragmaticGP">Answer Factories</a> book into published manuscript. Markdown is lovely, but talking in detail about the process of software development still requires an awful lot of cutting-and-pasting, it turns out….</p>

<p>I recently updated the published draft; if you’re behind, feel free to go <a href="https://leanpub.com/pragmaticGP">update your copy now</a>. New content includes a description of the iPad game <a href="http://twolivesleft.com/CargoBot/">Cargo-bot</a>, and a detailed test-driven re-implementation of the game logic in an emulator we’ll use for GP in forthcoming chapters. I spent a lot of time on the test-driven development, so I’d like some feedback if you’re willing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Help me pick the programming language for the second project?</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/help-me-pick-the-programming-language-for-the-second-project/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/help-me-pick-the-programming-language-for-the-second-project/#comments</comments>
		<pubDate>Mon, 30 Jul 2012 15:24:17 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[google-group]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=216</guid>
		<description><![CDATA[Over at the Google group I’m soliciting advice on what programming language I should use to implement the second project for the book. Also: Do you prefer the blog or the Google group for this sort of thing? One of &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/help-me-pick-the-programming-language-for-the-second-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="https://groups.google.com/forum/?fromgroups#!topic/pragmatic-gp/rvIw0C2rGJA">Over at the Google group</a> I’m soliciting advice on what programming language I should use to implement the second project for <a href="https://leanpub.com/pragmaticGP">the book</a>.</p>

<p>Also: Do you prefer the blog or the Google group for this sort of thing?</p>

<blockquote>
<p>One of the deepest philosophical qualms I’ve had about the structure of the book is the necessity to show code in some particular programming language, without implying that if an algorithm were written in some other language it would be “better” or “worse” or in any sense functionally different. If I pick Ruby, things not only devolve into “Genetic Programming in Ruby” (which is misleading), but Python and Clojure and J programmers are left unable to follow along.</p>

<p>Traditionally computer scientists have use pseudocode as a solution to this problem, but to be blunt pseudocode sucks: the acceptability of runnable code should not be driven by structural features pseudocode enforces (loops, branches, arguments) but the behavior it exhibits. As far as I’m concerned it’s not only misleading but dangerous to hand out pseudocode, if nothing else because I’ve watched people treat the text as if it were a form to fill out, replacing every line of the pseudocode with an “equivalent” line of code-in-some-language, expecting the result to run as intended.
</p>
<p>Of course in a big chunk of the readership, those familiar with test-driven and behavior-driven development, tests do the trick handily. But in the other big chunk of readers, that sensibility and suite of habits is missing, and even alien.
</p>
<p>So here’s what I decided: I’ll write code myself, and in the beginning project show all the code I write, but only in a behavior-driven way. The Cucumber tests will be there for readers to use (or kludge along with) in their own language of choice. I’ll be working in Ruby for the first project because people who are comfortable with Ruby are the first audience I hope to reach.
</p>
<p>But there are six projects planned, and so I’d like to gradually set the explicit code aside, and come to rely more gradually on the Cucumber features and stories, or perhaps “more generic” (?!) statements of acceptance tests the reader’s libraries should pass.
</p>
<p>So the programming language I use in the second project is up for grabs. Clojure? Python? Javascript? Objective-C? In any case it must be something with a stable and usable acceptance testing framework on hand; I’m not scheduling any time to write my own testing libraries here.
</p>
<p>The second project’s subject matter will either be “evolving geometric algorithms and proofs” or “data-mining and stock-trading and related crap”. So any language I’ve listed will work fine, and perhaps a few others I could learn relatively easily. (But not Java.)
</p>
<p>Your input would be appreciated!
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/help-me-pick-the-programming-language-for-the-second-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First release</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/first-release/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/first-release/#comments</comments>
		<pubDate>Sun, 29 Jul 2012 21:14:30 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[leanpub]]></category>
		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=213</guid>
		<description><![CDATA[… Well… there it is.]]></description>
				<content:encoded><![CDATA[<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/E7TGlcHy3ug?rel=0" frameborder="0" allowfullscreen></iframe>

<p><a href="http://leanpub.com/pragmaticGP">… Well… there it is.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/first-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On sensibility</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/the-sensibility-of-the-multi-track-conference/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/the-sensibility-of-the-multi-track-conference/#comments</comments>
		<pubDate>Sun, 08 Jul 2012 11:44:39 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[GECCO]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=196</guid>
		<description><![CDATA[GECCO is one of the largest conferences in the field of evolutionary algorithms, and I’m told there are something over 400 people attending this year in sultry Philadelphia. The first two days are often the calmest, broken up into a &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/the-sensibility-of-the-multi-track-conference/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sigevo.org/gecco-2012/">GECCO</a> is one of the largest conferences in the field of evolutionary algorithms, and I’m told there are something over 400 people attending this year in sultry Philadelphia. The first two days are often the calmest, broken up into a “mere” seven or eight simultaneous tracks, about equally workshops where a half-dozen topic-specific papers are presented and discussed, and tutorials in which introductory and advanced techniques are reviewed. Before the early starts, during the two-hour lunch break (if there is one), and after hours we participants self-assort and chat and catch up, like any technical conference I suppose.</p>

<p>It’s an interesting thing to watch from the inside. The social networks, the cliques and components forming and re-forming. I can’t help but feel I’m watching turf wars on the ground: all of us old influencers with our various Schools of Martial Arts vying for attention, revisiting old scores and reminiscing about which thing happened when, joking about In the Old Days at the same time we eye the young bloods keenly and try to steer them towards or away from Right Thought and Practice.</p>

<p>This is a dilute field, if it’s a field at all. One or two people in each institution, with a couple-three graduate students each. In the old days, there was still a defensive air about it, like we used to hear at Complex Systems research conferences. We’ve moved (a bit) past that stage of justifying the approach as such, convinced ourselves and our peers there’s something useful to be done with “biased random guessing”, so now the tribes are splitting along not-unexpected lines as they think about what they should <em>seem like</em>. Should this thing I’m doing sound like Operations Research, clad in formal provable correctness and rigorous theoretical justification? Should it sound like Artificial Intelligence, with agents believing and intending and desiring to move blocks and identify spam? Should it be a form of generative art, a way of inspiring and provoking me to new works? Should we consolidate our resources, like the Machine Learning people did, and start benchmarking so we can “better compare” results, or build tools that make it “easier” for “non-technical people” to “solve problems”?</p>

<p>And of course the lumping and splitting goes on, as ever: But <em>this</em> is just another example of <em>that</em>, a special case. This is new (it must be, if you’re presenting it); this is old (it must be, if you are to be given credit); that is this (it should be, if we’re to understand one another); this is not that—nothing is ever anything else. Where “this” and “that” are works, techniques, experiences, guidelines, rules, habits, terms.</p>

<p>Nobody talks about the <em>community</em> in which they work. Not <em>this</em> community of conference-goers, but the community of people who might someday actually want their cancer cured, or their stocks traded. The academic habits of the Cold War—deep resource deprivation, the Artificial Intelligence paradigms, the rampant cultivation of Lone Genius as the one route to greatness—they drive so many into their own work and away from helpful collaborations. There are collaborations within the families (the MIT family, the Virginia family, the Illinois family, the Stanford family, the Michigan family with its wide-ranging limbs), but still I never see people talking about <em>how</em> a problem becomes a  project, nor <em>how</em> a “result” becomes a useful furthering of some conversation.</p>

<p>There’s discussion of <em>subjective</em> experience, of course. Some nice ones. But even these lie <em>within</em> the boundaries of the Technical Works: I was surprised to see it doing this; I tried X but eventually Y was better.</p>

<p>For whom?</p>

<p>What I’ve found so far is that my old colleagues work as though providing self-contained software were of use to anybody. They talk as though publishing self-contained repositories of data and algorithms were of use to anybody. They think, I’m afraid, that the places human beings interact with their work should be limited to the production of “requirements” and the acceptance of “results”.</p>

<p>They do not speak of human context.</p>

<p>I hope they get over it. I would like them to find something outside themselves and their particular School of Martial Arts and their own turf that brings them together in a “track”. How do we cope with fear? With hubris? How does one work, when one is working <strong>in service</strong> of some other person’s aim?</p>

<p>I have standard questions I ask in almost every talk I attend: Why do you ignore the other objectives? Why do you use that habit, that library? Why do you measure that thing, and not the real thing you’re doing?</p>

<p>I don’t ask these questions to find out their technical justification. I’m not quizzing them on how well they’ve learned to write a multiobjective non-domination algorithm, or read and write from a database. I’m asking them because I’m still waiting for one to say, “Because when we discussed it with our colleagues, the people whose question this is, they wanted to try this. It was best at the time. It was something so we could deliver results and learn together.”</p>

<p>I want somebody to say, “The customer saw value in it.”</p>

<p>But so far I fear the “customer” is represented in this work as a mere tradesman, or worse a “layman”. Somebody you help only after taking their problem away from them, Being Very Smart, and giving the Right Answer back to them so they can use it.</p>

<p>Such a Waterfall world. So confident, even in the face of hundreds of hours of talks discussing why things are <em>hard</em> and <em>complicated</em> and <em>slow</em>.</p>

<p>These are excuses for failing to deliver something to a person who can use it. Of course they’re cultural excuses, Cold War excuses, Academic excuses based on “significantly advancing the field”. But they justify a view in which work is <em>yours</em>, and problems belong to other people.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/the-sensibility-of-the-multi-track-conference/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>102°F in Philadelphia</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/102f-in-philadelphia/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/102f-in-philadelphia/#comments</comments>
		<pubDate>Fri, 06 Jul 2012 20:34:13 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[GECCO]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=193</guid>
		<description><![CDATA[I’m here for GECCO 2012. And yes, I’m editing the first release of the book furiously.]]></description>
				<content:encoded><![CDATA[<p>I’m here for <a href="http://www.sigevo.org/gecco-2012/calendar.html">GECCO 2012</a>. And yes, I’m editing the first release of the book furiously.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/102f-in-philadelphia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sketch of an “artificial scientist” project</title>
		<link>http://www.vagueinnovation.com/pragmatic_gp/sketch-of-an-artificial-scientist-project/</link>
		<comments>http://www.vagueinnovation.com/pragmatic_gp/sketch-of-an-artificial-scientist-project/#comments</comments>
		<pubDate>Fri, 29 Jun 2012 16:03:47 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[genetic programming]]></category>
		<category><![CDATA[prospects]]></category>

		<guid isPermaLink="false">http://www.vagueinnovation.com/pragmatic_gp/?p=166</guid>
		<description><![CDATA[One of the things you realize after a while is that projects drop into your lap faster than they can be completed. Some sources of inspiration are things you encounter all the time: your work (I know a lot about &#8230; <a href="http://www.vagueinnovation.com/pragmatic_gp/sketch-of-an-artificial-scientist-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>One of the things you realize after a while is that projects drop into your lap faster than they can be completed. Some sources of inspiration are things you encounter all the time: your work (I know a lot about molecular design and pharmaceutical lead compound discovery), your hobbies (I know a lot about image recognition and segmentation for OCR of digitized books), and things you see other folks doing and just want to try (I’ve enjoyed my years doing Symbolic Regression because so many other people have paved the way, while leaving other paths less traveled and thus more interesting).</p>

<p>I’m finding that writing the introductory material for <a href="http://leanpub.com/pragmaticGP">the book</a> is difficult. In fact I’ll probably postpone releasing the intro until more of the core guts are written. Mainly the introductory material has been about that perennial question, “How do I find and pursue ideas?” My core argument is that GP is useful for <em>accelerating</em> the fruitful investigation of your ideas, but the challenge for many folks is recognizing the heuristics I personally take for granted. Some of this means I’m revisiting Polya’s <a href="http://www.amazon.com/gp/product/4871878309/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=4871878309">How To Solve It: A New Aspect of Mathematical Method</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=4871878309" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, but I find that it’s not philosophically compatible with the agile stance I personally prefer, so I’m actually finding Andrew Abbott’s <a href="http://www.amazon.com/gp/product/0393978141/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0393978141">Methods of Discovery: Heuristics for the Social Sciences</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=0393978141" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> more useful, not least because he suggests <a href="http://en.wikipedia.org/wiki/Four_causes">Aristotle’s four causes</a> and <a href="http://en.wikipedia.org/wiki/Schema_(Kant)">Kant’s schema</a> as interesting “kicks to the head”. And there’s Michalewicz and Fogel’s excellent <a href="http://www.amazon.com/gp/product/B000SEKUUS/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=B000SEKUUS">How to Solve It: Modern Heuristics</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=B000SEKUUS" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, which goes in a more technical direction (and closer to GP) tan Polya was able to do.</p>

<p>But I look over all that good advice, and I find it troubling. So I’m up in the air about it.</p>

<p>I decided more than a month back to change something important in the book. I still think Learning by Doing is crucial and important. But I can’t see a way to provide <em>acceptance tests alone</em> (with no pseudocode or worked-out examples) in an enticing-enough way that provokes reasonable responses from the readers. That is, I got a lot of pushback from potential audience members who <em>don’t actually know how to write their own code</em> based on acceptance tests.</p>

<p><em>Le sigh.</em></p>

<p>So I’m trying what Ron Jeffries did in his <a href="http://www.amazon.com/gp/product/B004OR1Y0U/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=B004OR1Y0U">Extreme Programming Adventures in C#</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=B004OR1Y0U" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />: describing what <em>I</em> am thinking, what motivates <em>me</em>, what I actually <em>do</em>, and as a result I hope to make the process itself more transparent, not just the externally visible steps. As Ron pointed out a few weeks back when we chatted about it, this smacks of arrogance. Who am I to think other people care about the mistakes I’m making, or want to be <em>misled</em> by watching me do stuff I subsequently undo? Just to prove I “learn something” from it?</p>

<p>Them’s the breaks. The alternative would be the crap one already has: pseudocode presented as if it were the one “right” way to do stuff, and the inclusion of idiomatic (or worse, generic) libraries that the reader <em>should</em> re-create themselves for every project, not borrow and re-use indiscriminately just because it happened to be in a book. In other words, better sorry than unsafe.</p>

<p>So inspiration is a thing I’ll set aside and talk about <em>subjectively</em>, not in terms of heuristics which (as Abbott points out in his excellent account) can quickly become fossilized and ritualized as though they were “correct” instead of <em>useful</em>.</p>

<h3>So I picked up a book</h3>

<p>I seem to like mathematical recreations. <a href="http://www.vagueinnovation.com/pragmatic_gp/sketch-of-a-2-player-connection-game/">Just the other day</a> I sketched a little game thing that somebody should pick up and run with. If it sits around long enough, maybe I’ll do it myself, but not until the book is farther along.</p>

<p>In the pile of interlibrary loans that I picked up the other day was a treasure trove in one volume: <a href="http://www.amazon.com/gp/product/0521857570/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0521857570">Geometric Folding Algorithms: Linkages, Origami, Polyhedra</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=0521857570" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. Now the mathematics of origami and stuff is all modern and weird and “advanced” to my generation; most of the actual mathematical results came after I graduated from University, and appeared in fancy esoteric mathematics journals even then. But there’s a constant chorus in <em>New Scientist</em> and <em>Science News</em> and stuff about new results, and there’s this <a href="http://en.wikipedia.org/wiki/Protein_structure_prediction">other thing I used to do</a> when I was a structural biologist that involves folding and abstractions of physical reality surprisingly similar to those in origami. Which is the Holy Grail of a multi-trillion dollar industry at the moment, by the way.</p>

<p>I’m trying to put my finger on what it is about some books—<a href="http://www.amazon.com/gp/product/0521735246/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0521735246"> Martin Gardner’s</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=0521735246" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
 or <a href="http://www.amazon.com/gp/product/0312107439/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0312107439">Cliff Pickover’s</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=0312107439" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
or <a href="http://www.amazon.com/gp/product/0761134662/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=billtoziersho-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0761134662">Ivan Moscovitch’s</a><img src="http://www.assoc-amazon.com/e/ir?t=billtoziersho-20&#038;l=as2&#038;o=1&#038;a=0761134662" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, for example—that makes them so inspiring. Is it the density of open questions? A tone that makes you wonder before disclosing anything? Something inherent in this semi-abstracted recreational game stuff that makes it clear how to write a simple computer program but unclear how to <em>solve a problem</em>? Something about puzzles? I have no idea.</p>

<p>At any rate, this one has that same stuff on it. It’s <em>fun</em>.</p>

<p>I picked it up from the stack this morning, opened to a random page, and started reading about one-dimensional origami. Now this is a book that’s framing new work in <em>modeling</em> physical systems like folded paper (and proteins) by setting up the mathematical constructs and abstractions in a traditional way. But there’s a <em>heuristic</em> I find myself adding to the other handy “kicks to the head”, especially useful for GP work: <em>What would it take to build a software system that “did” this?</em></p>

<p>So let’s think about one-dimensional origami for a second.</p>

<h3>Does it fold?</h3>

<p>Before they even get very far in the formal mathematics of paper-folding, Demaine and O’Rourke talk a bit about <em>representing</em> one-dimensional folded structures. You know, the traditional necessary and sufficient conditions for determining whether a thing is what you call it or not. Those core concepts, the stuff hanging off the “trivial” parts of traditional science and engineering that you often elide because you’re just <em>defining your terms</em>, that’s where there’s often low-hanging fruit for GP projects.</p>

<p>I recommend a browse through the excellent book, or just peek at <a href="http://courses.csail.mit.edu/6.885/fall04/erik_notes/100dpi/L6-1.html">Erik Demaine’s lecture notes on the subject</a>. We’re talking about what <em>starts out</em> as a line segment, which we <em>crease</em> at certain (arbitrary) points, and then <em>press flat</em> so that it produces a sort of accordioned stack of squiggles. Think of a cross-section through a piece of folded paper.</p>

<p>Let’s use paper, for a minute, and just assume for now we are folding it only in the vertical direction. Just to get a slightly more visceral sense of it.</p>

<p>Plop a (big) sheet of paper down on the table in front of your mind’s eye for me, OK?</p>

<p>We can make “mountain” or “valley” folds.  Think of a “valley” fold as taking either the left or right edge of the paper and folding it upwards and across towards the opposite; think of “mountain” folds as tucking the right or left edge down underneath the stack. You can make these mountain or valley folds anywhere between the edges of the paper, and as long as the creases are parallel with the left and right sides you’re mimicking one-dimensional folding. Just peek at the end of the sheet to lose the extra dimension.</p>

<p>There’s a tricky bit of mathematics hidden inside this simple-seeming physical model, though: how do we capture the physical <em>constraint</em> that keeps paper from passing through itself?</p>

<p>Demaine and O’Rourke’s contributions are eminent and interesting and well-considered. There are cunningly-crafted constraints that capture the physicality of paper’s inability to cross itself, and identify feasible flat foldings (and implicitly foldings that aren’t “flat” at all), while maintaining the integrity of the paper itself. In other words, you carry on that direction, and you have a formal representation that lets you do some fascinating mathematics and modeling.</p>

<p>But <em>what would it take to build a software system that “did” this?</em></p>

<p>By “this” I mean the work of establishing necessary and sufficient conditions for realistic folded lines. The implicit and tacit stuff a human being takes for granted when they have some notion of “crossing” or even “folding” in their heads already.</p>

<h3>Does this make sense?</h3>

<p>So let’s ask a GP system to look at a stack of line segments of various lengths and “merely” say whether there is any way a single line segment could have been folded that way, without crossing itself. Heck, there are probably long-range situations in which a partially-folded crumple would interfere with itself; let’s ignore those.</p>

<p>So here’s a quick sketch to help out:</p>

<div style="text-align:center;"><img src="http://www.vagueinnovation.com/pragmatic_gp/wp-content/uploads/2012/06/1D-origami1.png" alt="1D-origami.png" border="0" width="547" height="421" /></div>

<p>The top two squiggles are actual folded line segments.</p>

<p>The first is definitely <em>feasible</em>, in the sense that you can imagine crunching up a pipe cleaner or folding the edges-only paper I mentioned above and making the cross section look like that.</p>

<p>The second it <em>infeasible</em>, because the middle leaf is too big for the space it’s in, and protrudes <em>through</em> the crease.</p>

<p>But I think we need to go farther for this to be reasonably interesting. Think about how you would represent these objects or situations in your GP system. What is a “folded stack”? Do you start from a line segment and introduce mountain and valley folds at certain positions in some order? Or do you start from the folded stack and represent it as a series of orders in certain positions, like those I’ve shown below?</p>

<p>I’ve sketched five little situations down there in the bottom, indicating with the dotted green lines where the nominal “crease” points are. Which of those five <em>might</em> be feasible? Which of them are feasible but represent a line segment that’s not the same size as the original shown in the top two? Which if them is infeasible even when you allow the raw material to be any size at all?</p>

<p>See how this works? Those are all reasonably interesting questions. I can totally see a set of a few hundred (or thousand) examples and counterexamples for each category. Some examples (I assume) from every combination of feasible/infeasible, same/different, congruent/incongruent, single/multiple pieces. It’s an interesting algorithmic exercise to fill in that chart with diagrammatic examples. Training and test data are yours for the taking then.</p>

<p>But what this sort of project wants from us, as GP folks, is a bit of <em>ontological</em> work.</p>

<p>I’m the one who does this for a living, so let me preempt your versions now:</p>

<ul>
<li>a <code>Diagram</code> is a list of <code>Stretches</code></li>
<li>each <code>Stretch</code> has a numeric <code>length</code> attribute, and a list <code>Segments</code> attribute</li>
<li>each <code>Segments</code> list contains integers representing the segments present, in top-to-bottom order, numbered from 1 at the top and increasing downwards</li>
</ul>

<p>So for the five examples I’ve shown, each would have three <code>Stretches</code>. Say their lengths are 4, 11, and 5 respectively. And the <code>Stretches</code> would contain these <code>Segments</code> lists, respectively:</p>

<ol>
<li>[1],[1,2,3],[2]</li>
<li>[1],[1,2,3],[3]</li>
<li>[1,2],[1,2],[1,3]</li>
<li>[1,3],[1,2,3],[3]</li>
<li>[1,2],[2,3],[2]</li>
</ol>

<p>Notice that the only difference between the feasible and infeasible examples (the first two) is the third <code>Segment</code>. What sort of “thinking work” does your GP-developed algorithm need to do in order to differentiate usefully between these?</p>

<p>Notice that the first and third are both feasible, but that the third doesn’t add up to the same amount of material. Again, what does your GP-developed algorithm need to “know” to be able to identify which diagrams might and which might not be the same line? On the other hand, if we think of the <code>Segment</code> lengths as <em>proportions</em> rather than explicit measurements, we’re suddenly allowing the third diagram as well; in some sense it’s <em>congruent</em> to the first, but not identical.</p>

<p>And so on.</p>

<p>What sort of manipulations of these input structures might a general-purpose classification algorithm do? What, in other words, is the Answer Language like?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vagueinnovation.com/pragmatic_gp/sketch-of-an-artificial-scientist-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
