Minimal Input Set ================================================================================ This is the hypothetical minimal "ideal" input set for a genetic algorithm. The purpose of this document is to stimulate thinking about how general we want to make the package, and force us to think it about it now before implementation begins. Below is an example of what the properties file might contain -------------------------------------------------------------------------------- # General specifications ------------------------------------------------------- number_of_environments = 1 number_of_populations = 2 # per environment population_size = 100 # per population max_generations = 500 # the maximum number of generations to evolve (nil if undefined) stop_if_goal_found = false # useful if you want more than 1 solution, and you want to let the other populations continue to evolve # Environment sepcifications --------------------------------------------------- mutation_rate = .2 double_mutation_rate = .1 crossover_rate = .2 double_crossover_rate = .01 catastrophy_rate = .001 # catastrophy = extremely high lvl mutation rate goal_fitness = 1 # specify nil if goal is unknown # Gene information ( Agent specific )------------------------------------------- chromosome_size = 10 # 10 "base pairs" unique_bases = false # True if a base pair can only occur once in chromosome valid_bases = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # Problem: I want an array of length ten, whose elements are limited to numbers # 0-9, which has a sum of 50 when added together AND is ALSO palindromic, I # shall weight it such that each of these attributes contributes .5/1 to the score def fitness( agentA ) # Sum = 50? sum = 0.0 agentA.chromosome.each{ |i| sum += i } sum > 50 ? sum_score = (sum - 50)/50.0 * 0.5 : sum_score = sum/50.0 * 0.5 # Palindromic? p_val = 0.0 chr1 = agentA.chromosome[0,5] chr2 = agentA.chromosome[5,5] chr1.each_index{ |i| p_val += 1 if chr1[i] == chr2[i] } sum_score + p_val/5.0 end