private static double CalculateDistance(Chromosome chromosome) { var distanceToTravel = 0.0; Destino previousDestino = null; //run through each Destino in the order specified in the chromosome foreach (var gene in chromosome.Genes) { var currentDestino = _cities[(int)gene.RealValue]; if (previousDestino != null) { var distance = previousDestino.GetDistanceFromPosition(currentDestino.Latitude, currentDestino.Longitude); distanceToTravel += distance; } previousDestino = currentDestino; } return(distanceToTravel); }
protected bool Equals(Destino other) { return(string.Equals(Name, other.Name) && Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude)); }