Esempio n. 1
0
        public Population nextPopulation(Population parent)
        {
            var parents = selection(parent.individuals);
            var children = crossover(parents);
            children = mutate(children);

            var childrenPopulation = new Population() { individuals = children.OrderByDescending(o => getIndividualFitness(o)).ToList() };

            return childrenPopulation;
        }
Esempio n. 2
0
File: Island.cs Progetto: jswk/GA-BO
        private void run()
        {
            currentPopulation = factory.createPopulation();
            bestIndividual = currentPopulation.individuals[0].duplicate();
            while (keepGoing)
            {
               IIndividual outResult = null;
               while(arrivingIndividuals.TryDequeue(out outResult))
               {
                   swapPopulation(outResult);
               } // change individuals for new

               List<IIndividual> bestsToExchange = getBestsToExchange();
               supervisor.exchangeIndividuals(this,bestsToExchange);
                // sending a best part of population to supervisior
               lock (currentPopulation)
               {
                   currentPopulation = factory.nextPopulation(currentPopulation);
               }
               actualizeBest();
                // it produces start population first, then tries to rechange population using indiviudals from queue.
               // then produce next generation of population
                // produce new populations using factory, exchange best individuals with supervisor, add arriving individuals to population...
            }
        }