Example #1
0
        public void GenerateInitPopulation()
        {
            object loadedData = LoadData("PongLearningData");

            if (loadedData != null)
            {
                LearningData = new ObservableCollection <LearningData>(loadedData as List <LearningData>);
            }

            CurrentPopulation = new List <Chromosome>(PopulationCount);
            GenerationNumber  = 1;

            int    seed   = (int)DateTime.Now.Ticks;
            Random random = new Random(seed);

            for (int i = 0; i < PopulationCount; i++)
            {
                Chromosome c = new Chromosome(ChromosomeLength, random);
                CurrentPopulation.Add(c);
            }

            EvaluatePopulation(CurrentPopulation);
            MeanValue = 0.0;
            MeanValue = GetMeanValue(CurrentPopulation);

            if (this.GeneratedNewPopulation != null)
            {
                GeneratedNewPopulation.Invoke(CurrentPopulation, new EventArgs());
            }

            if (this.ResetPopulation != null)
            {
                ResetPopulation.Invoke(CurrentPopulation, new EventArgs());
            }
        }
Example #2
0
        public void NextPopulationGeneration()
        {
            CurrentPopulation = Selection(CurrentPopulation); // embed pe un tip de date.. populatie

            CurrentPopulation = Crossover(CurrentPopulation);

            CurrentPopulation = Mutation(CurrentPopulation);

            CurrentPopulation = GenerateNewPopulation(CurrentPopulation); // TODO remove

            EvaluatePopulation(CurrentPopulation);
            MeanValue = GetMeanValue(CurrentPopulation);

            if (this.GeneratedNewPopulation != null)
            {
                GeneratedNewPopulation.Invoke(CurrentPopulation, new EventArgs());
            }

            GenerationNumber++;
        }