Bugs: Browse | Submit New | Admin

[#15660] only ever creates a maximum of 2 children each generation

Date:
2007-11-15 22:54
Priority:
3
Submitted By:
Michael Hollins (mickh)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
only ever creates a maximum of 2 children each generation

Detailed description
Hi,
I've just been playing with the library and noticed that the code only ever creates a maximum of 2 children each generation.
The relevant code is shown below:

    new_childs = []
    new_generation.each_pair do |chromosome1, chromosome2|
      if rand > (1 - @p_combination)
        @logger.debug "Recombining" if @logger
        new_childs = chromosome1.recombine(chromosome2)
      end
    end
    
    new_generation + new_childs 

I believe the line:

    new_childs = chromosome1.recombine(chromosome2)

should say:

    new_childs.concat(chromosome1.recombine(chromosome2))

cheers,
mick

BTW: thanks for creating the library. Saved me some effort!

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item