- Timestamp:
- 03/08/10 11:37:24 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/LocalCrossover.cs
r2936 r2964 29 29 namespace HeuristicLab.Encodings.RealVector { 30 30 /// <summary> 31 /// Local crossover for real vectors: Takes for each element the allele of the first parent times a 32 /// always newly created randomly chosen factor and adds the allele of the second parent times (1 - the randomly chosen factor). 31 /// The local crossover for real vectors is similar to the <see cref="UniformAllPositionsArithmeticCrossover"/>, but where the factor alpha is chosen randomly in the interval [0;1) for each position. 33 32 /// </summary> 34 33 /// <remarks> 35 34 /// It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, p. 194. 36 35 /// </remarks> 37 [Item("LocalCrossover", "Local crossover for real vectors: Takes for each element the allele of the first parent times a always newly created randomly chosen factor and adds the allele of the second parent times (1 - the randomly chosen factor. " + 38 "It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL., p. 194.")] 36 [Item("LocalCrossover", @"The local crossover is similar to the arithmetic all positions crossover, but uses a random alpha for each position x = alpha * p1 + (1-alpha) * p2. It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL., p. 194.")] 39 37 [EmptyStorableClass] 40 38 public class LocalCrossover : RealVectorCrossover { … … 49 47 public static DoubleArrayData Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2) { 50 48 if (parent1.Length != parent2.Length) 51 throw new ArgumentException(" ERROR inLocalCrossover: the two parents are not of the same length");49 throw new ArgumentException("LocalCrossover: the two parents are not of the same length"); 52 50 53 51 double factor; … … 70 68 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 71 69 protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) { 72 if (parents.Length != 2) throw new ArgumentException(" ERROR inLocalCrossover: The number of parents is not equal to 2");70 if (parents.Length != 2) throw new ArgumentException("LocalCrossover: The number of parents is not equal to 2"); 73 71 return Apply(random, parents[0], parents[1]); 74 72 }
Note: See TracChangeset
for help on using the changeset viewer.