- Timestamp:
- 02/19/10 09:32:47 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Permutation/3.3/MaximalPreservativeCrossover.cs
r2830 r2835 29 29 /// Performs a crossover between two permuation arrays by preserving a large number of edges in both parents. 30 30 /// The operator also maintains the position in the arrays to some extent. 31 /// It is implemented as described in Mühlenbein, H. 1991. Evolution in time and space - the parallel genetic algorithm. FOUNDATIONS OF GENETIC ALGORITHMS, pp. 316-337. Morgan Kaufmann. 32 /// 33 /// The length of the segment copied from the first parent to the offspring is uniformly distributed in the interval [3, N/3) with N = length of the permutation. 31 /// It is implemented as described in Mühlenbein, H. 1991. Evolution in time and space - the parallel genetic algorithm. FOUNDATIONS OF GENETIC ALGORITHMS, pp. 316-337. Morgan Kaufmann.<br /><br /> 32 /// The length of the segment copied from the first parent to the offspring is uniformly distributed in the interval [3;N/3) with N = length of the permutation. 34 33 /// This recommendation is mentioned in Pohlheim, H. 1999. Evolutionäre Algorithmen: Verfahren, Operatoren und Hinweise für die Praxis, p. 44, Springer. 35 34 /// If the length of the permutation is smaller than 15, the size of the segment is always equal to 3. … … 44 43 /// </summary> 45 44 /// <exception cref="ArgumentException">Thrown when <paramref name="parent1"/> and <paramref name="parent2"/> are not of equal length or when the permutations are shorter than 4 elements.</exception> 46 /// <exception cref="InvalidOperationException">Thrown if the numbers in the permutation elements are not in the range [0 ,N) with N = length of the permutation.</exception>45 /// <exception cref="InvalidOperationException">Thrown if the numbers in the permutation elements are not in the range [0;N) with N = length of the permutation.</exception> 47 46 /// <remarks> 48 47 /// First one segment is copied from the first parent to the offspring in the same position. … … 56 55 /// <returns>The new permutation resulting from the crossover.</returns> 57 56 public static Permutation Apply(IRandom random, Permutation parent1, Permutation parent2) { 58 if (parent1.Length != parent2.Length) throw new ArgumentException("MaximalPreservativeCrossover: The parent permutations are of unequal length ");59 if (parent1.Length < 4) throw new ArgumentException("MaximalPreservativeCrossover: The parent permutation must be at least of size 4 ");57 if (parent1.Length != parent2.Length) throw new ArgumentException("MaximalPreservativeCrossover: The parent permutations are of unequal length."); 58 if (parent1.Length < 4) throw new ArgumentException("MaximalPreservativeCrossover: The parent permutation must be at least of size 4."); 60 59 int length = parent1.Length; 61 60 int[] result = new int[length]; … … 86 85 } 87 86 } catch (IndexOutOfRangeException) { 88 throw new InvalidOperationException("MaximalPreservativeCrossover: The permutation must consist of consecutive numbers from 0 to N-1 with N = length of the permutation");87 throw new InvalidOperationException("MaximalPreservativeCrossover: The permutation must consist of numbers in the interval [0;N) with N = length of the permutation."); 89 88 } 90 89
Note: See TracChangeset
for help on using the changeset viewer.