Potential bug in example

12 views
Skip to first unread message

Rick Cromer

unread,
Jan 13, 2014, 12:01:57 AM1/13/14
to watch...@googlegroups.com
I'm trying to run the examples and when I run the geneticprogramming example program I get the following solution

((((((arg0 * arg0) > arg0) + (arg0 + arg0)) - ((9.0 > (arg0 * arg0)) - (arg0 * arg0))) + (arg0 + 4.0)) + (arg1 + arg1))

I wrote a quick application to take the results from the sample and use the data to calculate and verify the results.  If the solution doesn't have the ? operator or the > operator I get the expected results, but sometimes the answer produced includes a > operator. When I get a > operator I can't tell what it's trying to say for the condition or the result to be used in the calculation.

For cases where ? is the operator, for example (arg0 ? 5 : arg1)  I just change it to (arg0 ?= 0.0 ? 5 : arg1) and I get the expected results.

Can someone help me understand how to interpret > in the equation?

Thanks
Rick

Daniel Dyer

unread,
Jan 13, 2014, 10:40:01 AM1/13/14
to watch...@googlegroups.com
It's the IsGreater operator
(https://github.com/dwdyer/watchmaker/blob/master/examples/src/java/main/org/uncommons/watchmaker/examples/geneticprogramming/IsGreater.java).
It evaluates to 1 if the first argument is larger than the second and 0
otherwise. Along with the IfThenElse ternary operator (? :), it allows
for the evolution of trees that do a little bit more than simple
arithmetic. The GP example is basically the same as the Python one in the
book, Programming Collective Intelligence.

Dan.

--
Daniel Dyer

Rick Cromer

unread,
Jan 13, 2014, 10:15:14 PM1/13/14
to watch...@googlegroups.com
Daniel, thank you so much for the quick response.  I'm pretty sure I understand what you're saying, the solution

((((((arg0 * arg0) > arg0) + (arg0 + arg0)) - ((9.0 > (arg0 * arg0)) - (arg0 * arg0))) + (arg0 + 4.0)) + (arg1 + arg1))

if (arg0 * arg0) > arg0)  is true then the formula would be the same as the following

((((1 + (arg0 + arg0)) - ((9.0 > (arg0 * arg0)) - (arg0 * arg0))) + (arg0 + 4.0)) + (arg1 + arg1))

or written another way

(((((((arg0 * arg0) > arg0) ? 1 : 0) + (arg0 + arg0)) - ((9.0 > (arg0 * arg0)) - (arg0 * arg0))) + (arg0 + 4.0)) + (arg1 + arg1))



Thanks
Rick
Reply all
Reply to author
Forward
0 new messages