/// <summary> /// Cross the specified parents generating the children. /// </summary> /// <param name="parents">The parents.</param> /// <returns>The offspring (children) of the parents.</returns> public override IList <IIndividual> Cross(IList <IIndividual> parents) { // This xover need same length if (parents[0].Length != parents[1].Length) { return(parents); } // minimal parents lenght if (parents[0].Length <= minParentSize) { return(parents); } // cross points var crossPoints = RandomizationRnd.GetUniqueInts(2, 1, parents[0].Length - 2); // new individuals int firstIndex = crossPoints[0]; int secondIndex = crossPoints[1]; if (secondIndex < firstIndex) { secondIndex = crossPoints[0]; firstIndex = crossPoints[1]; } var firstChild = CreateChild(parents[0], parents[1], firstIndex, secondIndex); var secondChild = CreateChild(parents[1], parents[0], firstIndex, secondIndex); return(new List <IIndividual>() { firstChild, secondChild }); }