public Genome Clone() { Genome clonedGenome = new Genome(_genes.Length); List <bool> genes = Genes.ToList(); for (int i = 0; i < _genes.Length; i++) { clonedGenome._genes[i] = genes[i]; } return(clonedGenome); }
public DNA CrossOver(DNA dna, int splitPoint, int[,] distances) { var c = Genes[splitPoint]; var lst = new List <int>(); var p1 = Genes.ToList(); var p2 = dna.Genes.ToList(); lst.Add(c); while (p1.Count() > 1) { var id1 = p1.IndexOf(c); var c1 = p1[(id1 + 1) % p1.Count()]; var id2 = p2.IndexOf(c); var c2 = p2[(id2 + 1) % p2.Count()]; p1.Remove(c); p2.Remove(c); c = distances[c, c1] < distances[c, c2] ? c1 : c2; lst.Add(c); } return(new DNA(lst.ToArray())); }
public int Size() { return(Genes.ToList().Count()); }