Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/AverageCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/AverageCrossover.cs	(revision 2964)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/AverageCrossover.cs	(revision 2964)
@@ -0,0 +1,76 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVector {
+  /// <summary>
+  /// The average crossover (intermediate recombination) calculates the average or centroid of a number of parent vectors.
+  /// </summary>
+  /// <remarks>
+  /// It is implemented as described by Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.
+  /// </remarks>
+  [Item("AverageCrossover", "The average crossover (intermediate recombination) produces a new offspring by calculating in each position the average of a number of parents. It is implemented as described by Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.")]
+  [EmptyStorableClass]
+  public class AverageCrossover : RealVectorCrossover {
+    /// <summary>
+    /// Performs the average crossover (intermediate recombination) on a list of parents.
+    /// </summary>
+    /// <exception cref="ArgumentException">Thrown when there is just one parent or when the parent vectors are of different length.</exception>
+    /// <remarks>
+    /// There can be more than two parents.
+    /// </remarks>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parents">The list of parents.</param>
+    /// <returns>The child vector (average) of the parents.</returns>
+    public static DoubleArrayData Apply(IRandom random, ItemArray<DoubleArrayData> parents) {
+      int length = parents[0].Length, parentsCount = parents.Length;
+      if (parents.Length < 2) throw new ArgumentException("AverageCrossover: The number of parents is less than 2.", "parents");
+      DoubleArrayData result = new DoubleArrayData(length);
+      try {
+        double avg;
+        for (int i = 0; i < length; i++) {
+          avg = 0;
+          for (int j = 0; j < parentsCount; j++)
+            avg += parents[j][i];
+          result[i] = avg / (double)parentsCount;
+        }
+      } catch (IndexOutOfRangeException) {
+        throw new ArgumentException("AverageCrossover: The parents' vectors are of different length.", "parents");
+      }
+
+      return result;
+    }
+
+    /// <summary>
+    /// Forwards the call to <see cref="Apply(IRandom, ItemArray<DoubleArrayData>)"/>.
+    /// </summary>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parents">The list of parents.</param>
+    /// <returns>The child vector (average) of the parents.</returns>
+    protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
+      return Apply(random, parents);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/CompleteContinuousCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/CompleteContinuousCrossover.cs	(revision 2936)
+++ 	(revision )
@@ -1,70 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Encodings.RealVector {
-  /// <summary>
-  /// Complete continuous crossover for real vectors: for each element of the new vector the average
-  /// of all parents is calculated.
-  /// </summary>
-  public class CompleteContinuousCrossover : RealVectorCrossoverBase {
-    /// <inheritdoc select="summary"/>
-    public override string Description {
-      get { return "Complete continuous crossover for real vectors."; }
-    }
-
-    /// <summary>
-    /// Performs a complete continuous crossover of multiple given real vectors.
-    /// </summary>
-    /// <param name="random">The random number generator.</param>
-    /// <param name="parents">An array containing the parents that should be crossed.</param>
-    /// <returns>The newly created real vector, resulting from the complete continuous crossover.</returns>
-    public static double[] Apply(IRandom random, double[][] parents) {
-      int length = parents[0].Length;
-      double[] result = new double[length];
-      for (int i = 0; i < length; i++) {
-        double sum = 0.0;
-        for (int j = 0; j < parents.Length; j++)
-          sum += parents[j][i];
-        result[i] = sum / parents.Length;
-      }
-      return result;
-    }
-
-    /// <summary>
-    /// Performs a complete continuous crossover operation for multiple given parent real vectors.
-    /// </summary>
-    /// <exception cref="InvalidOperationException">Thrown if there are less than two parents.</exception>
-    /// <param name="scope">The current scope.</param>
-    /// <param name="random">A random number generator.</param>
-    /// <param name="parents">An array containing the real vectors that should be crossed.</param>
-    /// <returns>The newly created real vector, resulting from the crossover operation.</returns>
-    protected override double[] Cross(IScope scope, IRandom random, double[][] parents) {
-      if (parents.Length < 2) throw new InvalidOperationException("ERROR in CompleteContinuousCrossover: The number of parents is less than 2");
-      return Apply(random, parents);
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/ContinuousCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/ContinuousCrossover.cs	(revision 2936)
+++ 	(revision )
@@ -1,75 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Encodings.RealVector {
-  /// <summary>
-  /// Continuous crossover for real vectors: for each element either the element of the first
-  /// parent or the average of all parents is selected randomly.
-  /// </summary>
-  public class ContinuousCrossover : RealVectorCrossoverBase {
-    /// <inheritdoc select="summary"/>
-    public override string Description {
-      get { return "Continuous crossover for real vectors."; }
-    }
-
-    /// <summary>
-    /// Performs a continuous crossover of multiple given real vectors.
-    /// </summary>
-    /// <param name="random">The random number generator.</param>
-    /// <param name="parents">An array containing the parents that should be crossed.</param>
-    /// <returns>The newly created real vector, resulting from the continuous crossover.</returns>
-    public static double[] Apply(IRandom random, double[][] parents) {
-      int length = parents[0].Length;
-      double[] result = new double[length];
-
-      for (int i = 0; i < length; i++) {
-        if (random.NextDouble() < 0.5) {
-          double sum = 0.0;
-          for (int j = 0; j < parents.Length; j++)
-            sum += parents[j][i];
-          result[i] = sum / parents.Length;
-        } else {
-          result[i] = parents[0][i];
-        }
-      }
-      return result;
-    }
-
-    /// <summary>
-    /// Performs a continuous crossover operation for multiple given parent real vectors.
-    /// </summary>
-    /// <exception cref="InvalidOperationException">Thrown if there are less than two parents.</exception>
-    /// <param name="scope">The current scope.</param>
-    /// <param name="random">A random number generator.</param>
-    /// <param name="parents">An array containing the real vectors that should be crossed.</param>
-    /// <returns>The newly created real vector, resulting from the crossover operation.</returns>
-    protected override double[] Cross(IScope scope, IRandom random, double[][] parents) {
-      if (parents.Length < 2) throw new InvalidOperationException("ERROR in ContinuousCrossover: The number of parents is less than 2");
-      return Apply(random, parents);
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs	(revision 2936)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs	(revision 2964)
@@ -30,11 +30,11 @@
 namespace HeuristicLab.Encodings.RealVector {
   /// <summary>
-  /// Heuristic crossover for real vectors: Takes for each position the better parent and adds the difference
-  /// of the two parents times a randomly chosen factor.
+  /// Heuristic crossover for real vectors: Calculates the vector from the worse to the better parent and adds that to the better parent weighted with a factor in the interval [0;1).
+  /// The idea is that going further in direction from the worse to the better leads to even better solutions (naturally this depends on the fitness landscape).
   /// </summary>
   /// <remarks>
   /// It is implemented as described in Wright, A.H. (1994), Genetic algorithms for real parameter optimization, Foundations of Genetic Algorithms, G.J.E. Rawlins (Ed.), Morgan Kaufmann, San Mateo, CA, 205-218.
   /// </remarks>
-  [Item("HeuristicCrossover", "Heuristic crossover for real vectors: Takes for each position the better parent and adds the difference. It is implemented as described in Wright, A.H. (1994), Genetic algorithms for real parameter optimization, Foundations of Genetic Algorithms, G.J.E. Rawlins (Ed.), Morgan Kaufmann, San Mateo, CA, 205-218.")]
+  [Item("HeuristicCrossover", "The heuristic crossover produces offspring that extend the better parent in direction from the worse to the better parent. It is implemented as described in Wright, A.H. (1994), Genetic algorithms for real parameter optimization, Foundations of Genetic Algorithms, G.J.E. Rawlins (Ed.), Morgan Kaufmann, San Mateo, CA, 205-218.")]
   [EmptyStorableClass]
   public class HeuristicCrossover : RealVectorCrossover {
@@ -72,5 +72,5 @@
     public static DoubleArrayData Apply(IRandom random, DoubleArrayData betterParent, DoubleArrayData worseParent) {
       if (betterParent.Length != worseParent.Length)
-        throw new ArgumentException("ERROR in HeuristicCrossover: the two parents are not of the same length");
+        throw new ArgumentException("HeuristicCrossover: the two parents are not of the same length");
       
       int length = betterParent.Length;
@@ -99,5 +99,5 @@
     /// <returns>The newly created real vector, resulting from the crossover operation.</returns>
     protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
-      if (parents.Length != 2) throw new ArgumentException("ERROR in HeuristicCrossover: The number of parents is not equal to 2");
+      if (parents.Length != 2) throw new ArgumentException("HeuristicCrossover: The number of parents is not equal to 2");
 
       if (MaximizationParameter.ActualValue == null) throw new InvalidOperationException("HeuristicCrossover: Parameter " + MaximizationParameter.ActualName + " could not be found.");
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/LocalCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/LocalCrossover.cs	(revision 2936)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/LocalCrossover.cs	(revision 2964)
@@ -29,12 +29,10 @@
 namespace HeuristicLab.Encodings.RealVector {
   /// <summary>
-  /// 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).
+  /// 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.
   /// </summary>
   /// <remarks>
   /// It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, p. 194.
   /// </remarks>
-  [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. " +
-    "It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL., p. 194.")]
+  [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.")]
   [EmptyStorableClass]
   public class LocalCrossover : RealVectorCrossover {
@@ -49,5 +47,5 @@
     public static DoubleArrayData Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2) {
       if (parent1.Length != parent2.Length)
-        throw new ArgumentException("ERROR in LocalCrossover: the two parents are not of the same length");
+        throw new ArgumentException("LocalCrossover: the two parents are not of the same length");
       
       double factor;
@@ -70,5 +68,5 @@
     /// <returns>The newly created real vector, resulting from the crossover operation.</returns>
     protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
-      if (parents.Length != 2) throw new ArgumentException("ERROR in LocalCrossover: The number of parents is not equal to 2");
+      if (parents.Length != 2) throw new ArgumentException("LocalCrossover: The number of parents is not equal to 2");
       return Apply(random, parents[0], parents[1]);
     }
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/RandomConvexCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/RandomConvexCrossover.cs	(revision 2936)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/RandomConvexCrossover.cs	(revision 2964)
@@ -29,13 +29,10 @@
 namespace HeuristicLab.Encodings.RealVector {
   /// <summary>
-  /// Random convex crossover for real vectors: Takes for each element the allele of the first parent times a 
-  /// once created randomly chosen factor and adds the allele of the second parent times 
-  /// (1 - the randomly chosen factor).
+  /// The random convex crossover is similar to the <see cref="LocalCrossover"/>, but chooses just one random alpha for all positions.
   /// </summary>
   /// <remarks>
   /// It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, pp. 193 - 194.
   /// </remarks>
-  [Item("RandomConvexCrossover", "Random convex crossover for real vectors: Takes for each element the allele of the first parent times a once created randomly chosen factor and adds the allele of the second parent times (1 - the randomly chosen factor). " +
-    "It is implementes as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, pp. 193 - 194.")]
+  [Item("RandomConvexCrossover", "The random convex crossover acts like the local crossover, but with just one randomly chosen alpha for all crossed positions. It is implementes as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, pp. 193 - 194.")]
   [EmptyStorableClass]
   public class RandomConvexCrossover : RealVectorCrossover {
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformAllPositionsArithmeticCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformAllPositionsArithmeticCrossover.cs	(revision 2964)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformAllPositionsArithmeticCrossover.cs	(revision 2964)
@@ -0,0 +1,88 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVector {
+  /// <summary>
+  /// The uniform all positions arithmetic crossover constructs an offspring by calculating x = alpha * p1 + (1-alpha) * p2 for every position x in the vector.
+  /// </summary>
+  /// <remarks>
+  /// By setting alpha = 0.5 it is the same as the <see cref="AverageCrossover"/>, but only on two parents.
+  /// It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.
+  /// </remarks>
+  [Item("UniformAllPositionsArithmeticCrossover", "The uniform all positions arithmetic crossover constructs an offspring by calculating x = alpha * p1 + (1-alpha) * p2 for every position x in the vector. Note that for alpha = 0.5 it is the same as the AverageCrossover. It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.")]
+  [EmptyStorableClass]
+  public class UniformAllPositionsArithmeticCrossover : RealVectorCrossover {
+    /// <summary>
+    /// The alpha parameter needs to be in the interval [0;1] and specifies how close the resulting offspring should be either to parent1 (alpha -> 0) or parent2 (alpha -> 1).
+    /// </summary>
+    public ValueLookupParameter<DoubleData> AlphaParameter {
+      get { return (ValueLookupParameter<DoubleData>)Parameters["Alpha"]; }
+    }
+
+    /// <summary>
+    /// Initializes a new instance with one parameter (<c>Alpha</c>).
+    /// </summary>
+    public UniformAllPositionsArithmeticCrossover()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<DoubleData>("Alpha", "The alpha value in the range [0;1]", new DoubleData(0.33)));
+    }
+
+    /// <summary>
+    /// Performs the arithmetic crossover on all positions by calculating x = alpha * p1 + (1 - alpha) * p2.
+    /// </summary>
+    /// <exception cref="ArgumentException">Thrown when the parent vectors are of different length or alpha is outside the range [0;1].</exception>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parent1">The first parent vector.</param>
+    /// <param name="parent2">The second parent vector.</param>
+    /// <param name="alpha">The alpha parameter (<see cref="AlphaParameter"/>).</param>
+    /// <returns>The vector resulting from the crossover.</returns>
+    public static DoubleArrayData Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleData alpha) {
+      int length = parent1.Length;
+      if (length != parent2.Length) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: The parent vectors are of different length.", "parent1");
+      if (alpha.Value < 0 || alpha.Value > 1) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: Parameter alpha must be in the range [0;1]", "alpha");
+      DoubleArrayData result = new DoubleArrayData(length);
+      for (int i = 0; i < length; i++) {
+        result[i] = alpha.Value * parent1[i] + (1 - alpha.Value) * parent2[i];
+      }
+      return result;
+    }
+
+    /// <summary>
+    /// Checks that there are exactly 2 parents, that the alpha parameter is not null and fowards the call to <see cref="Apply(IRandom, DoubleArrayData, DoubleArrrayData, DoubleData)"/>.
+    /// </summary>
+    /// <exception cref="ArgumentException">Thrown when there are not exactly two parents.</exception>
+    /// <exception cref="InvalidOperationException">Thrown when the alpha parmeter could not be found.</exception>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parents">The collection of parents (must be of size 2).</param>
+    /// <returns>The vector resulting from the crossover.</returns>
+    protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
+ 	    if (parents.Length != 2) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: There must be exactly two parents.", "parents");
+      if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformAllPositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found.");
+      return Apply(random, parents[0], parents[1], AlphaParameter.ActualValue);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs	(revision 2964)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs	(revision 2964)
@@ -0,0 +1,99 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVector {
+  /// <summary>
+  /// The uniform all positions arithmetic crossover (continuous recombination) constructs an offspring by calculating x = alpha * p1 + (1-alpha) * p2 for a position x in the vector with a given probability (otherwise p1 is taken at this position).
+  /// </summary>
+  /// <remarks>
+  /// It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, p. 191.<br />
+  /// Note that the implementation is a bit more general than the operator described by Dumitrescu et al. There the alpha parameter was defined to be fixed at 0.5 and thus calculating the average at some positions.
+  /// </remarks>
+  [Item("UniformSomePositionsArithmeticCrossover", "The uniform some positions arithmetic crossover (continuous recombination) constructs an offspring by calculating x = alpha * p1 + (1-alpha) * p2 for a position x in the vector with a given probability (otherwise p1 is taken at this position). It is implemented as described in Dumitrescu, D. et al. (2000), Evolutionary computation, CRC Press, Boca Raton, FL, p. 191. Note that Dumitrescu et al. specify the alpha to be 0.5.")]
+  class UniformSomePositionsArithmeticCrossover : RealVectorCrossover {
+    /// <summary>
+    /// The alpha parameter needs to be in the interval [0;1] and specifies how close the resulting offspring should be either to parent1 (alpha -> 0) or parent2 (alpha -> 1).
+    /// </summary>
+    public ValueLookupParameter<DoubleData> AlphaParameter {
+      get { return (ValueLookupParameter<DoubleData>)Parameters["Alpha"]; }
+    }
+    /// <summary>
+    /// The probability in the range [0;1] for each position in the vector to be crossed.
+    /// </summary>
+    public ValueLookupParameter<DoubleData> ProbabilityParameter {
+      get { return (ValueLookupParameter<DoubleData>)Parameters["Probability"]; }
+    }
+
+    /// <summary>
+    /// Initializes a new instance with two parameters (<c>Alpha</c> and <c>Probability</c>).
+    /// </summary>
+    public UniformSomePositionsArithmeticCrossover()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<DoubleData>("Alpha", "The alpha value in the range [0;1]", new DoubleData(0.5)));
+      Parameters.Add(new ValueLookupParameter<DoubleData>("Probability", "The probability for crossing a position in the range [0;1]", new DoubleData(0.5)));
+    }
+
+    /// <summary>
+    /// Performs the arithmetic crossover on some positions by taking either x = alpha * p1 + (1 - alpha) * p2 or x = p1 depending on the probability for a gene to be crossed.
+    /// </summary>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parent1">The first parent vector.</param>
+    /// <param name="parent2">The second parent vector.</param>
+    /// <param name="alpha">The alpha parameter (<see cref="AlphaParameter"/>).</param>
+    /// <param name="probability">The probability parameter (<see cref="ProbabilityParameter"/>).</param>
+    /// <returns>The vector resulting from the crossover.</returns>
+    public static DoubleArrayData Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleData alpha, DoubleData probability) {
+      int length = parent1.Length;
+      if (length != parent2.Length) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: The parent vectors are of different length.", "parent1");
+      if (alpha.Value < 0 || alpha.Value > 1) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: Parameter alpha must be in the range [0;1]", "alpha");
+      if (probability.Value < 0 || probability.Value > 1) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: Parameter probability must be in the range [0;1]", "probability");
+      
+      DoubleArrayData result = new DoubleArrayData(length);
+      for (int i = 0; i < length; i++) {
+        if (random.NextDouble() < probability.Value)
+          result[i] = alpha.Value * parent1[i] + (1 - alpha.Value) * parent2[i];
+        else result[i] = parent1[i];
+      }
+      return result;
+    }
+
+    /// <summary>
+    /// Checks that there are exactly 2 parents, that the alpha and the probability parameter are not null and fowards the call to <see cref="Apply(IRandom, DoubleArrayData, DoubleArrrayData, DoubleData)"/>.
+    /// </summary>
+    /// <exception cref="ArgumentException">Thrown when there are not exactly two parents.</exception>
+    /// <exception cref="InvalidOperationException">Thrown when either the alpha parmeter or the probability parameter could not be found.</exception>
+    /// <param name="random">The random number generator.</param>
+    /// <param name="parents">The collection of parents (must be of size 2).</param>
+    /// <returns>The vector resulting from the crossover.</returns>
+    protected override DoubleArrayData  Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
+      if (parents.Length != 2) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: There must be exactly two parents.", "parents");
+      if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformSomePositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found.");
+      if (ProbabilityParameter.ActualValue == null) throw new InvalidOperationException("UniformSomePositionsArithmeticCrossover: Parameter " + ProbabilityParameter.ActualName + " could not be found.");
+      return Apply(random, parents[0], parents[1], AlphaParameter.ActualValue, ProbabilityParameter.ActualValue);
+    }
+  }
+}
