/// <summary> /// /// </summary> /// <param name="individual">not null > 0</param> private void InversionMutate(Genotype individual) { var count = individual.Count; var inversionSize = Math.Min(count, GetMutationSize(2, count * MutationSizeStdevFactor)); var inversionStart = random.Next(0, count - inversionSize + 1); var mutationSubset = individual.GetRange(inversionStart, inversionSize); var afterSubset = individual.GetRange(inversionStart + inversionSize, count - (inversionStart + inversionSize)); // remove everything after inversionStart individual.RemoveRange(inversionStart, count - inversionStart); // add reverse again mutationSubset.Reverse(); individual.AddRange(mutationSubset); // add subset after mutation again individual.AddRange(afterSubset); }