예제 #1
0
        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");
            }
        }
예제 #2
0
		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");
			}
		}
예제 #3
0
        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");
                }
            }
        }
예제 #4
0
		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");
				}
			}
		}