I'm trying to construct a typed genetic programming solution with DEAP.
I start the program with a photo of a black & 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.
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.
I find the error difficult because:
- I have primitives which use the photo as input.
- I do not have primitives which produce the photo as output.
- I don't want to morph the photo, just consume it.
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.
But there is perhaps something I'm not understanding correctly about how deap works. How do I overcome error messages like this?
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 '<class 'triangles.Photo'>', but there is none available.
This error typically fires from gp.gengrow
when it is trying to generate the starting population.
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.
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.