public override double CompatibilityDistance(SpeciatedGenome <CPPNNEATGeneCollection, PType> genome) { var differences = new DifferenceAnalysis(this.GeneCollection, genome.GeneCollection); var totalExcess = differences.FirstCollection.Excess.Count + differences.SecondCollection.Excess.Count; var totalDisjoint = differences.FirstCollection.Disjoint.Count + differences.SecondCollection.Disjoint.Count; var averageWeightDifference = differences.Matches .Select(match => (match.FirstCollection.Weight - match.SecondCollection.Weight) .Magnitude) .Average(); var n = (double)Math.Max(this.GeneCollection.LinkGenes.Count(), genome.GeneCollection.LinkGenes.Count()); if (n <= SMALL_GENOME_THRESHOLD) { n = 1; } var parent = Parent as ICPPNNEATGA; var averageFunctionDifference = GetAverageFunctionDifference(this, (CPPNNEATGenome <PType>)genome); return(parent.ExcessGenesWeight * (totalExcess / n) + parent.DisjointGenesWeight * (totalDisjoint / n) + parent.MatchingGenesWeight * averageWeightDifference + parent.FunctionDifferenceWeight * averageFunctionDifference); }
public abstract double CompatibilityDistance(SpeciatedGenome <GType, PType> genome);