jnaithani / genetic-programming

A Genetic Programming Environment (SEIS 610/Fall 2013)
2 stars 2 forks source link

Generate Initial Population #8

Open jnaithani opened 11 years ago

jnaithani commented 11 years ago

Randomly generate and initialize an initial population of solutions.

generate initial population

jnaithani commented 11 years ago

gps--dfd - level 1

jnaithani commented 11 years ago

All, @warsamebashir @rkg11gupta @KBenderaa @mohammedalkhiat

Pushed code that randomly generates trees of specified depth.

The TreeTest.testGenerateTree() displays information about the randomly generated tree. This method is similar to what is shown here: http://geneticprogramming.us/The_Initial_Population.html.

There is also an alternate implementation of a binary Tree with Operand and Operator Nodes - very similar to what we have already. We have both in the repo for now - we should review, discuss, and consolidate the two today.

-Jayesh

wbashir commented 11 years ago

Okay, i just pulled and will take a look. Earliest i can meet online today is around 5:00pm

wbashir commented 11 years ago

I was talking to one of the classmates about ignoring the operand '0' since it adds no value to our fitness evaluation and causes alot of problems with 'divide by zero' check and constantly needing to keep a pointer of a node's particular parent. We can put it in our requirements to justify it

jnaithani commented 11 years ago

Warsame, @warsamebashir

Good suggestion. Evaluating the tree results in a "NaN" (not a number) error when dividing by 0. Multiplying by 0 sometimes results in the tree evaluating to 0.

The generated trees - with depth 3 - don't have always have an "X" node. That is because an arbitrary algorithm is being used to randomly generate the operand value for the node - and sometimes the generated tree only has constants (0..9). Also, a tree of depth 1 (single operand node) is possible currently, even when the max depth is specified to be greater than 1.

-Jayesh

cc: @mohammedalkhiat @KBenderaa @rkg11gupta

wbashir commented 11 years ago

I think we can always make sure an 'x' node is present if we run two random generators and keep them in cycles, is the goal to always have at least 1 'x' node in the tree ? If so, we should specify it in our settings and run a test just for this catch

wbashir commented 11 years ago

To clarify what i meant, we would store an 'x' probability and use the depth of the tree to determine when to generate the node.

jnaithani commented 11 years ago

Warsame, @warsamebashir

I modified the code to use the depth of the tree to generate GP trees with a greater probability of the 'x' node in them. Also, if trees are still being generated w/o 'x' nodes, then the the generate method re-issues a request for a new tree.

Did you and Rajesh @rkg11gupta meet online today? We need to consolidate/cleanup the tree data structures, and should try to figure how we want to mutate and cross-over the trees.

-Jayesh

cc: @mohammedalkhiat @KBenderaa

wbashir commented 11 years ago

We didn't meet today and should try to figure out if we can meet either tomorrow or early next week. @jnaithani does the tree generator you have created have an option to increase/decrease the size of the tree or is it something that is fixed. To answer your question about mutation/cross over, I think this being a critical part of the selection process we should consolidate and implement together. I will take a deeper look at the data structure you have and remove our existing one since there is a great deal of duplicate work

jnaithani commented 11 years ago

Warsame, @warsamebashir

The tree generator can randomly generate initial population trees that will not exceed the max depth settings. It will need additional methods to support mutation and crossover.

I could meet online tomorrow later in the evening (after 5pm). Let me know if there is specific capability we need for tree creation/generation, and I can work on that. Otherwise, I will try to keep pushing ahead and work on reproduction/crossover/mutation use cases in order to build the necessary support required from the Tree/Node data structure to perform these functions.

Rajesh @rkg11gupta , Kholoud @KBenderaa , Mohammed @mohammedalkhiat - if you haven't yet, you may want to check out the source and review what we have so far. Also call or email or if you all have any questions or need help with building and executing the project code.

-Jayesh

wbashir commented 11 years ago

Okay, I may be available at 5pm as well. Let me send an email to the team and see if anyone is available at that time.

rkg11gupta commented 11 years ago

I will be available @ 5

Rajesh

Sent from my iPhone

On Nov 17, 2013, at 2:03 PM, warsamebashir notifications@github.com wrote:

Okay, I may be available at 5pm as well. Let me send an email to the team and see if anyone is available at that time.

— Reply to this email directly or view it on GitHub.

jnaithani commented 11 years ago

All, @warsamebashir @rkg11gupta @mohammedalkhiat @KBenderaa

One way to resolve the divide by zero problem is suggested by John R. Koza, http://www.genetic-programming.com/johnkoza.html, in his book on Genetic Programming.

The solution is to perform a protected division function which returns a value of 1 when division by 0 is attempted (including 0 divided by 0), but otherwise returns the quotient of its two arguments. For now, we can try this approach.

-Jayesh

http://books.google.com/books?id=Bhtxo60BV0EC&pg=PA82&lpg=PA82&dq=The+protected+division+function+%25+returns+a+value+of+1+when+division+by+0+is+attempted+genetic+programming&source=bl&ots=9oiRjwg-MN&sig=y5LB1tRPjWwtorVGVgg6Gdi9c1Q&hl=en&sa=X&ei=WiiKUo7zJe3lsASf8YHYCA&ved=0CDYQ6AEwAQ#v=onepage&q=The%20protected%20division%20function%20%25%20returns%20a%20value%20of%201%20when%20division%20by%200%20is%20attempted%20genetic%20programming&f=false

closure

rkg11gupta commented 11 years ago

Yes, this way we can prevent infinite value returns.

Rajesh

Sent from my iPhone

On Nov 18, 2013, at 11:01 AM, jnaithani notifications@github.com wrote:

All, @warsamebashir @rkg11gupta @mohammedalkhiat @KBenderaa

One way to resolve the divide by zero problem is suggested by John R. Koza, http://www.genetic-programming.com/johnkoza.html, in his book on Genetic Programming.

The solution is to perform a protected division function which returns a value of 1 when division by 0 is attempted (including 0 divided by 0), but otherwise returns the quotient of its two arguments. For now, we can try this approach.

-Jayesh

http://books.google.com/books?id=Bhtxo60BV0EC&pg=PA82&lpg=PA82&dq=The+protected+division+function+%25+returns+a+value+of+1+when+division+by+0+is+attempted+genetic+programming&source=bl&ots=9oiRjwg-MN&sig=y5LB1tRPjWwtorVGVgg6Gdi9c1Q&hl=en&sa=X&ei=WiiKUo7zJe3lsASf8YHYCA&ved=0CDYQ6AEwAQ#v=onepage&q=The%20protected%20division%20function%20%25%20returns%20a%20value%20of%201%20when%20division%20by%200%20is%20attempted%20genetic%20programming&f =false

— Reply to this email directly or view it on GitHub.

wbashir commented 11 years ago

I think the first approach is better, instead of explictly checking for undefined and returning undefined, we should check if right node is a 0 and return numerator