コード例 #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
ファイル: environment.cs プロジェクト: saveenr/saveenr
		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
ファイル: environment.cs プロジェクト: saveenr/saveenr
		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");
				}
			}
		}