示例#1
0
        public static DNA SelectByCO2(this List <DNA> population, double demandPower)
        {
            var validPopulation = population.Where(x => x.GetTotalPower() >= demandPower).ToList();
            var reciprocal      = validPopulation.Select(x => 1 / x.GetAverageCO2(demandPower));
            var sum             = reciprocal.Sum();
            var probablities    = reciprocal.Select(x => x / sum).ToList();
            var selected        = RandomSelector.RandomSelect(probablities);

            return(validPopulation.ElementAt(selected));
        }
示例#2
0
        public static DNA SelectByLoadRate(this List <DNA> population, double demandPower)
        {
            var validPopulation = population.Where(x => x.GetTotalPower() >= demandPower).ToList();
            var loadRates       = validPopulation.Select(x => x.GetLoadRate(demandPower));
            var sum             = loadRates.Sum();
            var probablities    = loadRates.Select(x => x / sum).ToList();
            var selected        = RandomSelector.RandomSelect(probablities);

            return(validPopulation.ElementAt(selected));
        }