public void SetupForEvolution(Population the_population, FitnessDirection fd) { this.direction = fd; this.CurrentGeneration = new Generation(0); this.CurrentGeneration.population = the_population; if (this.CurrentGeneration.population.IsEmpty) { throw new GeneticError("Cannot start with empty population"); } }
public void SetupForEvolution(Population the_population, FitnessDirection fd ) { this.direction = fd; this.CurrentGeneration = new Generation(0); this.CurrentGeneration.population = the_population ; if ( this.CurrentGeneration.population.IsEmpty ) { throw new GeneticError("Cannot start with empty population"); } }
public void SortPopulation(Population p, FitnessDirection fd) { if (fd == FitnessDirection.Minimize) { p.Sort(Environment.m_min_comparer); // Double-check the sort if (p[0].Fitness > p[p.Size - 1].Fitness) { throw new GeneticError("Sort did not work"); } } else { p.Sort(Environment.m_max_comparer); // Double-check the sort if (p[0].Fitness < p[p.Size - 1].Fitness) { throw new GeneticError("Sort did not work"); } } }
public void SortPopulation( Population p, FitnessDirection fd ) { if ( fd==FitnessDirection.Minimize ) { p.Sort( Environment.m_min_comparer ); // Double-check the sort if (p[ 0 ].Fitness >p[ p.Size-1 ].Fitness ) { throw new GeneticError("Sort did not work"); } } else { p.Sort( Environment.m_max_comparer ); // Double-check the sort if (p[ 0 ].Fitness <p[ p.Size-1 ].Fitness ) { throw new GeneticError("Sort did not work"); } } }