test/genetic_algorithm.rb
def replace_worst_ranked(offsprings)
        size = offsprings.length

        @population.sort!() # Make sure population is sorted so we replace the worst 

        raise "@population.first.fitness() >= @population.last.fitness()" unless @population.first.fitness() >= @population.last.fitness()

        @population = @population [0..((-1*size)-1)] + offsprings
      end
# Replace worst ranked part of population with offspring
Replace worst ranked part of population with offspring
Replace worst ranked part of population with offspring
def replace_worst_ranked(offsprings)
        size = offsprings.length
        @population.sort!() 
        raise "@population.first.fitness() >= @population.last.fitness()" unless @population.first.fitness() >= @population.last.fitness()
        @population = @population [0..((-1*size)-1)] + offsprings
      end
def replace_worst_ranked ( offsprings ) size = offsprings . length @population . sort! ( ) raise "@population.first.fitness() >= @population.last.fitness()" unless @population . first . fitness ( ) >= @population . last . fitness ( ) @population = @population [ 0 .. ( ( - 1 * size ) - 1 ) ] + offsprings end
Replace worst ranked part of population with offspring
Replace worst ranked part of population with offspring
# Make sure population is sorted so we replace the worst 
offsprings