Пример #1
0
 public RandomGenesCrossover(IFitnessFun fitnessFun)
 {
     _fitnessFun = fitnessFun;
 }
Пример #2
0
        private static Species[] GenerateInitialSpecies(int speciesNumber, int itemCount, IFitnessFun fitnessFun)
        {
            var rnd = new Random();

            return(Enumerable.Range(1, speciesNumber)
                   .Select(_ =>
            {
                var vector = new BitArray(itemCount);
                for (var i = 0; i < vector.Count; i++)
                {
                    bool value = rnd.Next(0, 2) == 1;
                    vector[i] = value;
                }

                return vector;
            })
                   .Select(v => new Species(v, fitnessFun.Calculate(v)))
                   .ToArray());
        }
Пример #3
0
 public SimpleGenesCrossover(IFitnessFun fitnessFun, double betterParentGeneSelectionProbability)
 {
     _fitnessFun = fitnessFun;
     _betterParentGeneSelectionProbability = betterParentGeneSelectionProbability;
 }