Exemplo n.º 1
0
        public static Generation CreateRandomGeneration(ChihuahuaComponent comp, int numberOfIndividuals)
        {
            List <Individual> tempIndi = new List <Individual>();

            for (int i = 0; i < numberOfIndividuals; i++)
            {
                Individual ind = Chihuahua.CreateRandomIndividual(comp);
                tempIndi.Add(ind);
            }

            Generation gen = new Generation(tempIndi);

            return(gen);
        }
Exemplo n.º 2
0
        private void SolverClicked(object sender, EventArgs eventArgs)
        {
            Generation gen1 = Chihuahua.CreateRandomGeneration(this, 50);

            for (int i = 0; i < 22; i++)
            {
                Generation next = Chihuahua.EvolveGeneration(this, gen1, 5, 50, 0.1);
                gen1 = next;
            }

            Rhino.RhinoApp.WriteLine(string.Format("Best fitness: {0}", gen1.bestFitness));

            foreach (decimal gen in gen1.bestIndividual.Genome)
            {
                Rhino.RhinoApp.WriteLine(gen.ToString());
            }

            //Reinstate the best solution back the grasshopper canvas

            Chihuahua.ReinstateGenome(this, gen1.bestIndividual.NormalizeGenome);
        }