computeHammingDistance method
Returns the degree to which this chromosome has dissimilar genes with the
other. If chromosomes are identical, returns 0.0
. If all genes are
different, returns 1.0
.
Genes are considered different when they are not equal. There is no half-different gene (which would make sense for num genes, for example). You should make sure genes have sane equality and hashCode.
Implementation
num computeHammingDistance(covariant Phenotype<G, R> other) {
var length = genes.length;
var similarCount = 0;
for (var i = 0; i < genes.length; i++) {
if (genes[i] == other.genes[i]) {
similarCount++;
}
}
return (1 - similarCount / length);
}