Index: /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/UniformLikeCrossover.cs
===================================================================
--- /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/UniformLikeCrossover.cs	(revision 6056)
+++ /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/UniformLikeCrossover.cs	(revision 6056)
@@ -0,0 +1,84 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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 HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.PermutationEncoding {
+  [Item("UniformLikeCrossover", "The ULX crossover tries to maintain the position in the permutation. It randomly chooses from left to right one of its parents' alleles at each position. Missing entries are then filled randomly later. It is described in Tate, D. M. and Smith, A. E. 1995. A genetic approach to the quadratic assignment problem. Computers & Operations Research, vol. 22, pp. 73-83.")]
+  [StorableClass]
+  public class UniformLikeCrossover : PermutationCrossover {
+    [StorableConstructor]
+    protected UniformLikeCrossover(bool deserializing) : base(deserializing) { }
+    protected UniformLikeCrossover(UniformLikeCrossover original, Cloner cloner) : base(original, cloner) { }
+    public UniformLikeCrossover() : base() { }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new UniformLikeCrossover(this, cloner);
+    }
+
+    public static Permutation Apply(IRandom random, Permutation parent1, Permutation parent2) {
+      if (parent1.Length != parent2.Length) throw new ArgumentException("parent1 and parent2 are of different length.");
+      int length = parent1.Length;
+      int[] child = new int[length];
+      bool[] numberCopied = new bool[length];
+      List<int> unoccupied = new List<int>();
+
+      for (int i = 0; i < length; i++) {
+        bool copied = true;
+        if (parent1[i] == parent2[i]) {
+          child[i] = parent1[i];
+        } else if (!numberCopied[parent1[i]] && !numberCopied[parent2[i]]) {
+          child[i] = (random.NextDouble() < 0.5) ? parent1[i] : parent2[i];
+        } else if (!numberCopied[parent1[i]]) {
+          child[i] = parent1[i];
+        } else if (!numberCopied[parent2[i]]) {
+          child[i] = parent2[i];
+        } else {
+          copied = false;
+          unoccupied.Add(i);
+        }
+        if (copied) numberCopied[child[i]] = true;
+      }
+
+      if (unoccupied.Count > 0) {
+        for (int i = 0; i < length; i++) {
+          if (!numberCopied[i]) {
+            int r = random.Next(unoccupied.Count);
+            child[unoccupied[r]] = i;
+            unoccupied.RemoveAt(r);
+          }
+          if (unoccupied.Count == 0) break;
+        }
+      }
+
+      return new Permutation(parent1.PermutationType, child);
+    }
+
+    protected override Permutation Cross(IRandom random, ItemArray<Permutation> parents) {
+      if (parents.Length != 2) throw new InvalidOperationException("UniformLikeCrossover: The number of parents is not equal to 2.");
+      return Apply(random, parents[0], parents[1]);
+    }
+  }
+}
Index: /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
===================================================================
--- /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj	(revision 6055)
+++ /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj	(revision 6056)
@@ -118,4 +118,5 @@
     <Compile Include="Crossovers\PartiallyMatchedCrossover.cs" />
     <Compile Include="Crossovers\PositionBasedCrossover.cs" />
+    <Compile Include="Crossovers\UniformLikeCrossover.cs" />
     <Compile Include="HeuristicLabEncodingsPermutationEncodingPlugin.cs" />
     <Compile Include="Interfaces\IPermutationMultiNeighborhoodShakingOperator.cs" />
@@ -179,4 +180,5 @@
     <Compile Include="Moves\TwoOpt\StochasticInversionMultiMoveGenerator.cs" />
     <Compile Include="Moves\TwoOpt\StochasticInversionSingleMoveGenerator.cs" />
+    <Compile Include="PermutationEqualityComparer.cs" />
     <Compile Include="PermutationManipulator.cs" />
     <Compile Include="PermutationCrossover.cs" />
Index: /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs
===================================================================
--- /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs	(revision 6056)
+++ /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs	(revision 6056)
@@ -0,0 +1,73 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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 HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Encodings.PermutationEncoding {
+  [NonDiscoverableType]
+  public class PermutationEqualityComparer : IEqualityComparer<Permutation> {
+    public bool Equals(Permutation x, Permutation y) {
+      if (x.PermutationType != y.PermutationType) return false;
+      if (x.Length != y.Length) return false;
+      switch (x.PermutationType) {
+        case PermutationTypes.Absolute:
+          return EqualsAbsolute(x, y);
+        case PermutationTypes.RelativeDirected:
+          return EqualsRelative(x, y, true);
+        case PermutationTypes.RelativeUndirected:
+          return EqualsRelative(x, y, false);
+        default:
+          throw new InvalidOperationException("unknown permutation type");
+      }
+    }
+
+    private bool EqualsAbsolute(Permutation x, Permutation y) {
+      for (int i = 0; i < x.Length; i++)
+        if (x[i] != y[i]) return false;
+      return true;
+    }
+
+    private bool EqualsRelative(Permutation x, Permutation y, bool directed) {
+      int[] edgesX = CalculateEdgesVector(x);
+      int[] edgesY = CalculateEdgesVector(y);
+      for (int i = 0; i < x.Length; i++)
+        if ((edgesX[i] != edgesY[i]) && (directed || edgesX[edgesY[i]] != i))
+          return false;
+      return true;
+    }
+
+    private int[] CalculateEdgesVector(Permutation permutation) {
+      // transform path representation into adjacency representation
+      int[] edgesVector = new int[permutation.Length];
+      for (int i = 0; i < permutation.Length - 1; i++)
+        edgesVector[permutation[i]] = permutation[i + 1];
+      edgesVector[permutation[permutation.Length - 1]] = permutation[0];
+      return edgesVector;
+    }
+
+    public int GetHashCode(Permutation obj) {
+      if (obj == null) return 0;
+      return obj.GetHashCode();
+    }
+  }
+}
Index: /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/HeuristicLab.Encodings.PermutationEncoding-3.3.Tests.csproj
===================================================================
--- /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/HeuristicLab.Encodings.PermutationEncoding-3.3.Tests.csproj	(revision 6055)
+++ /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/HeuristicLab.Encodings.PermutationEncoding-3.3.Tests.csproj	(revision 6056)
@@ -120,4 +120,5 @@
     <Compile Include="TranslocationInversionManipulatorTest.cs" />
     <Compile Include="TranslocationManipulatorTest.cs" />
+    <Compile Include="UniformLikeCrossoverTest.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -129,4 +130,8 @@
       <Name>HeuristicLab.Collections-3.3</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
+      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
+      <Name>HeuristicLab.Common.Resources-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
@@ -144,4 +149,8 @@
       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
       <Name>HeuristicLab.Operators-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
+      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
+      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     </ProjectReference>
     <ProjectReference Include="..\..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
Index: /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/UniformLikeCrossoverTest.cs
===================================================================
--- /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/UniformLikeCrossoverTest.cs	(revision 6056)
+++ /branches/histogram/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/UniformLikeCrossoverTest.cs	(revision 6056)
@@ -0,0 +1,103 @@
+﻿using HeuristicLab.Core;
+using HeuristicLab.Encodings.PermutationEncoding;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Encodings.PermutationEncoding_33.Tests {
+
+
+  /// <summary>
+  ///This is a test class for UniformLikeCrossoverTest and is intended
+  ///to contain all UniformLikeCrossoverTest Unit Tests
+  ///</summary>
+  [TestClass()]
+  public class UniformLikeCrossoverTest {
+
+
+    private TestContext testContextInstance;
+
+    /// <summary>
+    ///Gets or sets the test context which provides
+    ///information about and functionality for the current test run.
+    ///</summary>
+    public TestContext TestContext {
+      get {
+        return testContextInstance;
+      }
+      set {
+        testContextInstance = value;
+      }
+    }
+
+    #region Additional test attributes
+    // 
+    //You can use the following additional attributes as you write your tests:
+    //
+    //Use ClassInitialize to run code before running the first test in the class
+    //[ClassInitialize()]
+    //public static void MyClassInitialize(TestContext testContext)
+    //{
+    //}
+    //
+    //Use ClassCleanup to run code after all tests in a class have run
+    //[ClassCleanup()]
+    //public static void MyClassCleanup()
+    //{
+    //}
+    //
+    //Use TestInitialize to run code before running each test
+    //[TestInitialize()]
+    //public void MyTestInitialize()
+    //{
+    //}
+    //
+    //Use TestCleanup to run code after each test has run
+    //[TestCleanup()]
+    //public void MyTestCleanup()
+    //{
+    //}
+    //
+    #endregion
+
+
+    /// <summary>
+    ///A test for Apply
+    ///</summary>
+    [TestMethod()]
+    public void UniformLikeCrossoverApplyTest() {
+      // test from the paper
+      IRandom random = new TestRandom(new int[] { 0 }, new double[] { 0.2, 0.7, 0.2, 0.2 }); // TODO: Initialize to an appropriate value
+      Permutation parent1 = new Permutation(PermutationTypes.Absolute,
+        new int[] { 3, 2, 0, 7, 5, 4, 1, 6 });
+      Assert.IsTrue(parent1.Validate());
+      Permutation parent2 = new Permutation(PermutationTypes.Absolute,
+        new int[] { 5, 0, 4, 7, 1, 3, 2, 6 });
+      Assert.IsTrue(parent2.Validate());
+      Permutation expected = new Permutation(PermutationTypes.Absolute,
+        new int[] { 3, 0, 4, 7, 5, 2, 1, 6 });
+      Assert.IsTrue(expected.Validate());
+      Permutation actual;
+      actual = UniformLikeCrossover.Apply(random, parent1, parent2);
+      Assert.IsTrue(actual.Validate());
+      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
+    }
+
+    /// <summary>
+    ///A test for Cross
+    ///</summary>
+    [TestMethod()]
+    [DeploymentItem("HeuristicLab.Encodings.PermutationEncoding-3.3.dll")]
+    public void UniformLikeCrossoverCrossTest() {
+      UniformLikeCrossover_Accessor target = new UniformLikeCrossover_Accessor();
+      IRandom random = new TestRandom(new int[] { }, new double[] { 0.1, 0.2, 0.3, 0.4 });
+      random.Reset();
+      bool exceptionFired = false;
+      try {
+        target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 
+          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
+      } catch (System.InvalidOperationException) {
+        exceptionFired = true;
+      }
+      Assert.IsTrue(exceptionFired);
+    }
+  }
+}
