DESCRIPTION: Charlie is a library for genetic algorithms. It allows you to easily create and run genetic algorithms. You can choose selection, crossover or mutation strategies from either built-in options or simply write your own. It also includes methods that can be used to compare several of these strategies, generating reports with statistics that can be used to determine which one to use in future problems. == EXAMPLES: This example finds the binary representation of the number 512. require ‘rubygems’ require ‘charlie’ class Find512 < BitStringGenotype(10) # choose a genotype, in this case a list of 10 bits represents a solution # Define a fitness function. This one returns minus the offset to the best solution, so a higher number is better. # Usually, you won’t know the best solution, and will define this as some value that needs to be maximized. def fitness # Use the ‘genes’ function to retrieve the array of bits representing this solution. -(genes.map(&:to_s).join.to_i(2) - 512).abs end end # Finally, create an instance of a population (with the default size of 20) and let it run for the default number of 100 generations. Population.new(Find512).evolve_on_console