title: How to fix "gp.generate tried to add a primitive but there is none available"?
body: <p>I'm trying to construct a typed genetic programming solution with <a href="http://deap.readthedocs.org/" rel="nofollow">DEAP</a>.  </p>
  
  <p>I start the program with a photo of a black &amp; white triangle and the 3 vertices of a different triangle.  The hope is for the program to come up with a program which moves the vertices of the given triangle closer to the one in the photo.  I provide it random constants, arithmetic primitives add, subtract, etc., if-then-else. and tests for is_black and is_white at given coordinates.</p>
  
  <p>I've set up all my primitives but I keep running into this error, which seems to be telling me to add more primitives which either provide or consume (not sure which?!) the photo.</p>
  
  <p>I find the error difficult because: </p>
  
  <ul>
  <li>I have primitives which use the photo as input.  </li>
  <li>I do <em>not</em> have primitives which produce the photo as output. </li>
  <li>I don't want to morph the photo, just consume it.  </li>
  </ul>
  
  <p>I'm thinking the winning program will be a long sequence of commands like "if (10,10) is black add (3,2) to vertex 1" repeated somewhat nauseatingly.</p>
  
  <p>But there is perhaps something I'm not understanding correctly about how deap works.  How do I overcome error messages like this?</p>
  
  <pre><code>  File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/random.py", line 255, in choice
      raise IndexError('Cannot choose from an empty sequence')
  IndexError: The gp.generate function tried to add a primitive of type '&lt;class 'triangles.Photo'&gt;', but there is none available.
  </code></pre>
  
  <p>This error typically fires from <code>gp.gengrow</code> when it is trying to generate the starting population.</p>
  
  <p>What may/may not be related is that I don't have much in the way of Terminals: I'm not clear how they apply to my problem.</p>
  
  <p>I expect to hear crickets, but if anyone actually takes an interest in this question and wants to see code, or at least the primitive set, I can tack it on or stick it somewhere.  Figured it was rambling enough already; whilst I've focused on a specific error message I expect it is moreso my general (un)appreciation of the workings of GP/DEAP that is at fault.</p>