Created
July 20, 2012 15:58
-
-
Save Poincare/3151534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chromosome | |
... | |
def self.produce_new(chrs) | |
roulette(chrs) | |
newchrs = [] | |
chrs.each do |c| | |
newchrs.push(roulette(chrs)) | |
end | |
fitnesses(newchrs) | |
return newchrs | |
end | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code as written in gistfile1.rb produced 2 errors when I tried to run it using v2.3.0. The first is on line 5. I had to add to_i as follows:
def fitness
@Fitness = @bitstring.to_i^0b0101
end
The second is on line 100 which reads: chrs = Chromosome.produce_new(chrs). This had to be changed to: chrs = Chromosome.produceNew(chrs), to match the definition of self.produceNew(chrs).
All in all I really enjoyed the articles. I'm am learning Ruby as a first language (not counting fortran in college) and I want to also learn how to program algorithms. I'm looking forward to your follow on article to Graph Algorithms in Ruby. I think it should be very interesting. Thank you very much for taking the time write the articles.