public RandomGenesCrossover(IFitnessFun fitnessFun) { _fitnessFun = fitnessFun; }
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()); }
public SimpleGenesCrossover(IFitnessFun fitnessFun, double betterParentGeneSelectionProbability) { _fitnessFun = fitnessFun; _betterParentGeneSelectionProbability = betterParentGeneSelectionProbability; }