Example #1
0
        public bool InitRandomPopulation(List <string> selectedTraces)
        {
            ConfigurationGenerator cg = new ConfigurationGenerator();

            for (int i = 0; i < populationSize; i++)
            {
                population.Add(cg.RandomConfig(individualID.ToString()));
            }
            allConfigurations.AddRange(population);

            var results = sim.Run(population, selectedTraces);

            for (int i = 0; i < population.Count; i++)
            {
                population[i] = new GeneticIndividual(population[i], 0.0, 0.0, 0.0);

                for (int j = 0; j < selectedTraces.Count; j++)
                {
                    ((GeneticIndividual)population[i]).Ipc    += 1.0 / results[i + population.Count * j].ipc;
                    ((GeneticIndividual)population[i]).Power  += results[i + population.Count * j].power;
                    ((GeneticIndividual)population[i]).Energy += results[i + population.Count * j].energy;
                }
                if (selectedTraces.Count > 1)
                {
                    ((GeneticIndividual)population[i]).Ipc    /= selectedTraces.Count;
                    ((GeneticIndividual)population[i]).Power  /= selectedTraces.Count;
                    ((GeneticIndividual)population[i]).Energy /= selectedTraces.Count;
                }
                nsgaPopulation.Add(new GeneticIndividual(population[i], ((GeneticIndividual)population[i]).Ipc, ((GeneticIndividual)population[i]).Power, ((GeneticIndividual)population[i]).Energy));
            }
            return(true);
        }
Example #2
0
        private List <Configuration> CreateRandomConfigurations(int count)
        {
            int configurationIndex = 0;
            ConfigurationGenerator configurationGenerator = new ConfigurationGenerator();
            var result = new List <Configuration>();

            for (int i = 0; i < count; i++)
            {
                result.Add(configurationGenerator.RandomConfig(string.Format("configuration-{0}", configurationIndex++)));
            }
            return(result);
        }
Example #3
0
        public void InitRandomPopulation(List <string> selectedTraces)
        {
            this.selectedTraces = selectedTraces;

            for (int i = 0; i < populationSize; i++)
            {
                population.Add(cg.RandomConfig(individualID.ToString()));
            }

            CalculateObjectives();

            var v = Crossover(population[1], population[2]);
            var m = Mutate(v[0]);
        }