public IDNA <CSingleAssignment> CoinCrossover(IDNA <CSingleAssignment> objPartner) { CTaamAssignment Child = new CTaamAssignment(false); for (int i = 0; i < this.Genes.Length; i++) { CTaamAssignment Selected = Shared.Coin() ? this : objPartner as CTaamAssignment; Child[i] = Selected[i].Clone() as CSingleAssignment; } return(Child); }
public override IDNA <CSingleAssignment> Clone() { CTaamAssignment Copy = new CTaamAssignment(false); Copy.Fitness = this.Fitness; for (int i = 0; i < this.Genes.Length; i++) { Copy[i] = this[i].Clone() as CSingleAssignment; } return(Copy); }
public IDNA <CSingleAssignment> PartialGenomeCrossover(IDNA <CSingleAssignment> objPartner) { CTaamAssignment child = new CTaamAssignment(false); CTaamAssignment partner = (CTaamAssignment)objPartner; int nStart = Shared.Next(this.Genes.Length / 2) + 1; int nEnd = nStart + Shared.Next(this.Genes.Length / 2); List <int> colPassedGenesUIDs = new List <int>(); for (int i = nStart; i < nEnd; i++) { child[i] = partner[i].Clone(); colPassedGenesUIDs.Add(partner[i].UID); } int nGeneInsertionPos = 0; for (int i = 0; i < this.Genes.Length; i++) { if (nGeneInsertionPos == nStart) { nGeneInsertionPos = nEnd; } if (colPassedGenesUIDs.Contains(this.Genes[i].UID)) { continue; } child[nGeneInsertionPos] = this.Genes[i].Clone(); nGeneInsertionPos++; } child.Mutate(); return(child); }