Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs	(revision 2918)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs	(revision 2918)
@@ -0,0 +1,97 @@
+﻿#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>
+  /// Performs the simulated binary crossover (SBX) on a vector of real values such that each position is either crossed contracted or expanded with a certain probability.
+  /// The probability distribution is designed such that the children will lie closer to their parents as is the case with the single point binary crossover.
+  /// </summary>
+  /// <remarks>
+  /// It is implemented as described in Deb, K. and Agrawal, R. B. 1995. Simulated binary crossover for continuous search space. Complex Systems, 9, pp. 115-148.
+  /// </remarks>
+  [Item("SimulatedBinaryCrossover", "The simulated binary crossover (SBX) is implemented as described in Deb, K. and Agrawal, R. B. 1995. Simulated binary crossover for continuous search space. Complex Systems, 9, pp. 115-148.")]
+  [EmptyStorableClass]
+  public class SimulatedBinaryCrossover : RealVectorCrossover {
+    /// <summary>
+    /// The parameter must be greater or equal than 0. Common values are in the range [0;5] and more often just [2;5].
+    /// </summary>
+    public ValueLookupParameter<DoubleData> ContiguityParameter {
+      get { return (ValueLookupParameter<DoubleData>)Parameters["Contiguity"]; }
+    }
+
+    public SimulatedBinaryCrossover()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<DoubleData>("Contiguity", "Specifies whether the crossover should produce very different (small value) or very similar (large value) children. Valid values must be greater or equal to 0.", new DoubleData(2)));
+    }
+
+    /// <summary>
+    /// Performs the simulated binary crossover on a real vector. Each position is crossed with a probability of 50% and if crossed either a contracting crossover or an expanding crossover is performed, again with equal probability.
+    /// For more details refer to the paper by Deb and Agrawal.
+    /// </summary>
+    /// <exception cref="ArgumentException">Thrown when the parents' vectors are of unequal length or when <paramref name="contiguity"/> is smaller than 0.</exception>
+    /// <param name="random">The random number generator to use.</param>
+    /// <param name="parent1">The first parent vector.</param>
+    /// <param name="parent2">The second parent vector.</param>
+    /// <param name="contiguity">The contiguity value that specifies how close a child should be to its parents (larger value means closer). The value must be greater or equal than 0. Typical values are in the range [2;5].</param>
+    /// <returns>The vector resulting from the crossover.</returns>
+    public static DoubleArrayData Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleData contiguity) {
+      if (parent1.Length != parent2.Length) throw new ArgumentException("SinglePointCrossover: Parents are of unequal length");
+      if (contiguity.Value < 0) throw new ArgumentException("SimulatedBinaryCrossover: Contiguity value is smaller than 0", "contiguity");
+      int length = parent1.Length;
+      DoubleArrayData result = new DoubleArrayData(length);
+      for (int i = 0; i < length; i++) {
+        if (random.NextDouble() < 0.5) { // cross this variable
+          double u = random.NextDouble();
+          double beta = 0;
+          if (u < 0.5) { // if u is smaller than 0.5 perform a contracting crossover
+            beta = Math.Pow(2 * u, 1.0 / (contiguity.Value + 1));
+          } else { // otherwise perform an expanding crossover
+            beta = Math.Pow(1.0 / (2 - 2 * u), (contiguity.Value + 1));
+          }
+          if (random.NextDouble() < 0.5)
+            result[i] = ((parent1[i] + parent2[i]) / 2.0) - beta * 0.5 * Math.Abs(parent1[i] - parent2[i]);
+          else
+            result[i] = ((parent1[i] + parent2[i]) / 2.0) + beta * 0.5 * Math.Abs(parent1[i] - parent2[i]);
+        }
+      }
+      return result;
+    }
+
+    /// <summary>
+    /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArrayData, DoubleArrayData, DoubleData)"/>.
+    /// </summary>
+    /// <exception cref="InvalidOperationException">Thrown when there are not exactly 2 parents or when the contiguity 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 real vector resulting from the crossover.</returns>
+    protected override DoubleArrayData Cross(IRandom random, ItemArray<DoubleArrayData> parents) {
+      if (parents.Length != 2) throw new InvalidOperationException("SinglePointCrossover: The number of parents is not equal to 2");
+      if (ContiguityParameter.ActualValue == null) throw new InvalidOperationException("SimulatedBinaryCrossover: Parameter " + ContiguityParameter.ActualName + " could not be found.");
+      return Apply(random, parents[0], parents[1], ContiguityParameter.ActualValue);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Encodings.RealVector/3.3/HeuristicLab.Encodings.RealVector-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVector/3.3/HeuristicLab.Encodings.RealVector-3.3.csproj	(revision 2916)
+++ trunk/sources/HeuristicLab.Encodings.RealVector/3.3/HeuristicLab.Encodings.RealVector-3.3.csproj	(revision 2918)
@@ -92,4 +92,5 @@
   <ItemGroup>
     <Compile Include="Crossovers\BlendAlphaCrossover.cs" />
+    <Compile Include="Crossovers\SimulatedBinaryCrossover.cs" />
     <Compile Include="Crossovers\SinglePointCrossover.cs">
       <SubType>Code</SubType>
