kstaats / karoo_gp

A Genetic Programming platform for Python with TensorFlow for wicked-fast CPU and GPU support.
Other
157 stars 61 forks source link

'Full' trees are not actually full #52

Closed granawkins closed 2 years ago

granawkins commented 2 years ago

(This issue affects the current branch but is not recent. It also affects 4154711866485b876a1f1f4112d9044b76863145, which is from March 20)

Karoo supports 3 tree generation methods:

In the full method, all of the trees are 15 nodes long as expected. However, in the ramped method (the default) with a population 100 (the default), <20 are 15 nodes (out of expected 50), and the rest shorter - I believe this is a bug.

To see for yourself: Run the default simulation, look at the logs in runs/[date]/population_a.csv, look at the size of the first generation. This issue affects the current branch, but it also affects 4154711866485b876a1f1f4112d9044b76863145 which is from March 20 (as far back as I checked)

My latest update has a different api for generating trees, so the logic on making populations is new, so 50/100 are actually 15 nodes long. For this reason, the outputs are different, and the test doesn't pass.

granawkins commented 2 years ago

I misunderstood, it's right. From the user manual, "Ramped Half/Half initialises the first population with a 50/50 split of Full/Grow methods, and a spread of depths from min to max."

Here's the code that does it. A simplified version for (population=100, depth=3):

n_cycles = int(population/2/depth)
for i in range(n_cycles):
   for d in range(depth):
      tree.generate(type='full', depth=d)
      tree.generate(type='grow', depth=d)

False alarm! Will update my code accordingly.

kstaats commented 2 years ago

Correct.

On 5/19/22 16:30, Grant wrote:

I misunderstood, it's right. From the user manual, "Ramped Half/Half initialises the first population with a 50/50 split of Full/Grow methods, and a spread of depths from min to max."

Here's the code that does it. A simplified version for (population=100, depth=3):

n_cycles = int(population/2/depth)
for i in range(n_cycles):
    for d in range(depth):
       tree.generate(type='full', depth=d)
       tree.generate(type='grow', depth=d)

False alarm! Will update my code accordingly.