Index: /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
===================================================================
--- /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs	(revision 10742)
+++ /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs	(revision 10743)
@@ -30,4 +30,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Random;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
@@ -140,15 +141,5 @@
       if (checkedOperators.Count() > 0) {
         // select a random operator from the checked operators
-        double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
-        if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
-        double r = random.NextDouble() * sum;
-        sum = 0;
-        foreach (var indexedItem in checkedOperators) {
-          sum += probabilities[indexedItem.Index];
-          if (sum > r) {
-            successor = indexedItem.Value;
-            break;
-          }
-        }
+        successor = checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value;
       }
 
Index: /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
===================================================================
--- /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs	(revision 10742)
+++ /stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs	(revision 10743)
@@ -30,4 +30,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Random;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
@@ -140,15 +141,6 @@
       if (checkedOperators.Count() > 0) {
         // select a random operator from the checked operators
-        double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
-        if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
-        double r = random.NextDouble() * sum;
-        sum = 0;
-        foreach (var indexedItem in checkedOperators) {
-          sum += probabilities[indexedItem.Index];
-          if (sum > r) {
-            successor = indexedItem.Value;
-            break;
-          }
-        }
+        successor =
+          checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value;
       }
 
Index: /stable/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
===================================================================
--- /stable/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj	(revision 10742)
+++ /stable/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj	(revision 10743)
@@ -465,4 +465,8 @@
       <Private>False</Private>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
+      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
+      <Name>HeuristicLab.Random-3.3</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Index: /stable/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame
===================================================================
--- /stable/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame	(revision 10742)
+++ /stable/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame	(revision 10743)
@@ -41,4 +41,5 @@
   [PluginDependency("HeuristicLab.Persistence", "3.3")]
   [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
+  [PluginDependency("HeuristicLab.Random", "3.3")]
   public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase {
   }
Index: /stable/HeuristicLab.Random/3.3/RandomEnumerable.cs
===================================================================
--- /stable/HeuristicLab.Random/3.3/RandomEnumerable.cs	(revision 10742)
+++ /stable/HeuristicLab.Random/3.3/RandomEnumerable.cs	(revision 10743)
@@ -36,5 +36,5 @@
 
     //algorithm taken from progamming pearls page 127
-    //IMPORTANT because IEnumerables with yield are used the seed must best be specified to return always 
+    //IMPORTANT because IEnumerables with yield are used the seed must be specified to return always 
     //the same sequence of numbers without caching the values.
     public static IEnumerable<int> SampleRandomNumbers(int seed, int start, int end, int count) {
@@ -166,4 +166,6 @@
     /// 
     /// The method internally holds two arrays: One that is the sequence itself and another one for the values.
+    /// 
+    /// The method does not check if the number of elements in source and weights are the same.
     /// </remarks>
     /// <typeparam name="T">The type of the items to be selected.</typeparam>
@@ -173,6 +175,6 @@
     /// <param name="weights">The weight values for the items.</param>
     /// <param name="windowing">Whether to scale the proportional values or not.</param>
-    /// <param name="maximization">Determines whether to choose proportionally (true) or inverse-proportionally (false).</param>
-    /// <returns>A sequence of selected items.</returns>
+    /// <param name="inverseProportional">Determines whether to choose proportionally (true) or inverse-proportionally (false).</param>
+    /// <returns>A sequence of selected items. Might actually be shorter than <paramref name="count"/> elements if source has less than <paramref name="count"/> elements.</returns>
     public static IEnumerable<T> SampleProportionalWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, int count, IEnumerable<double> weights, bool windowing = true, bool inverseProportional = false) {
       return source.SampleProportionalWithoutRepetition(random, weights, windowing, inverseProportional).Take(count);
@@ -181,5 +183,5 @@
     private static IEnumerable<T> SampleProportional<T>(this IEnumerable<T> source, IRandom random, IEnumerable<double> weights, bool windowing, bool inverseProportional) {
       var sourceArray = source.ToArray();
-      var valueArray = PrepareProportional<T>(sourceArray, weights, windowing, inverseProportional);
+      var valueArray = PrepareProportional(sourceArray, weights, windowing, inverseProportional);
       double total = valueArray.Sum();
 
@@ -193,22 +195,21 @@
     }
     private static IEnumerable<T> SampleProportionalWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, IEnumerable<double> weights, bool windowing, bool inverseProportional) {
-      var sourceArray = source.ToArray();
-      var valueArray = PrepareProportional<T>(sourceArray, weights, windowing, inverseProportional);
+      var valueArray = PrepareProportional(source.ToArray(), weights, windowing, inverseProportional);
+      var list = new LinkedList<Tuple<T, double>>(source.Zip(valueArray, Tuple.Create));
       double total = valueArray.Sum();
 
-      HashSet<int> chosenIndices = new HashSet<int>();
-      while (chosenIndices.Count < sourceArray.Length) {
-        int index = 0;
-        double ball = valueArray[index], sum = random.NextDouble() * total;
+      while (list.Count > 0) {        
+        var cur = list.First;        
+        double ball = cur.Value.Item2, sum = random.NextDouble() * total; // assert: sum < total. When there is only one item remaining: sum < ball
         while (ball < sum) {
-          index++;
-          if (!chosenIndices.Contains(index))
-            ball += valueArray[++index];
-        }
-        yield return sourceArray[index];
-        chosenIndices.Add(index);
-        total -= valueArray[index];
-      }
-    }
+          cur = cur.Next;
+          ball += cur.Value.Item2;
+        }
+        yield return cur.Value.Item1;
+        list.Remove(cur);
+        total -= cur.Value.Item2;
+      }
+    }
+
     private static double[] PrepareProportional<T>(IList<T> sourceArray, IEnumerable<double> weights, bool windowing, bool inverseProportional) {
       double maxValue = double.MinValue, minValue = double.MaxValue;
@@ -274,2 +275,3 @@
   }
 }
+
Index: /stable/HeuristicLab.Tests/HeuristicLab.Random-3.3/RandomEnumerableSampleTest.cs
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.Random-3.3/RandomEnumerableSampleTest.cs	(revision 10743)
+++ /stable/HeuristicLab.Tests/HeuristicLab.Random-3.3/RandomEnumerableSampleTest.cs	(revision 10743)
@@ -0,0 +1,161 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2013 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.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+namespace HeuristicLab.Random.Tests {
+
+  [TestClass()]
+  public class RandomEnumerableSampleTest {
+    [TestMethod]
+    [TestCategory("Problems.Random")]
+    [TestProperty("Time", "short")]
+    public void SampleProportionalWithoutRepetitionTest() {
+      {
+        // select 1 of 100 uniformly (weights = 0)
+        var items = Enumerable.Range(0, 100);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(0.0, 100);
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 1, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 1);
+          Assert.AreEqual(sample.Distinct().Count(), 1);
+        }
+      }
+      {
+        // select 1 of 1 uniformly (weights = 0)
+        var items = Enumerable.Range(0, 1);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(0.0, 1);
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 1, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 1);
+          Assert.AreEqual(sample.Distinct().Count(), 1);
+        }
+      }
+      {
+        // select 1 of 2 non-uniformly (weights = 1, 2)
+        var items = Enumerable.Range(0, 2);
+        var random = new MersenneTwister(31415);
+        var weights = new double[] { 1.0, 2.0 };
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 1, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 1);
+          Assert.AreEqual(sample.Distinct().Count(), 1);
+        }
+      }
+      {
+        // select 2 of 2 non-uniformly (weights = 1, 1000)
+        var items = Enumerable.Range(0, 2);
+        var random = new MersenneTwister(31415);
+        var weights = new double[] { 1.0, 1000.0 };
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 1, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 1);
+          Assert.AreEqual(sample.Distinct().Count(), 1);
+        }
+      }
+      {
+        // select 2 from 1 uniformly (weights = 0), this does not throw an exception but instead returns a sample with 1 element!
+        var items = Enumerable.Range(0, 1);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(0.0, 1);
+        var sample =
+          RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 2, weights, false, false).ToArray();
+        Assert.AreEqual(sample.Count(), 1);
+      }
+
+      {
+        // select 10 of 100 uniformly (weights = 0)
+        var items = Enumerable.Range(0, 100);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(0.0, 100);
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 10, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 10);
+          Assert.AreEqual(sample.Distinct().Count(), 10);
+        }
+      }
+
+      {
+        // select 100 of 100 uniformly (weights = 0)
+        var items = Enumerable.Range(0, 100);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(0.0, 100);
+        for (int i = 0; i < 1000; i++) {
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 100, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 100);
+          Assert.AreEqual(sample.Distinct().Count(), 100);
+        }
+      }
+
+      {
+        // select 10 of 10 uniformly (weights = 1)
+        var items = Enumerable.Range(0, 10);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(1.0, 10);
+        for (int i = 0; i < 1000; i++) {
+
+          var sample =
+            RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 10, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 10);
+          Assert.AreEqual(sample.Distinct().Count(), 10);
+        }
+      }
+
+      {
+        // select 10 of 10 uniformly (weights = 1)
+        // repeat 1000000 times and calculate statistics
+        var items = Enumerable.Range(0, 100);
+        var random = new MersenneTwister(31415);
+        var weights = Enumerable.Repeat(1.0, 100);
+        var selectionCount = new int[100, 100]; // frequency of selecting item at pos
+        for (int i = 0; i < 1000000; i++) {
+          var sample = RandomEnumerable.SampleProportionalWithoutRepetition(items, random, 100, weights, false, false).ToArray();
+          Assert.AreEqual(sample.Count(), 100);
+          Assert.AreEqual(sample.Distinct().Count(), 100);
+
+          int pos = 0;
+          foreach (var item in sample) {
+            selectionCount[item, pos]++;
+            pos++;
+          }
+        }
+        var sb = new StringBuilder();
+        for (int item = 0; item < 100; item++) {
+          for (int pos = 0; pos < 100; pos++) {
+            sb.AppendFormat("{0} ", selectionCount[item, pos]);
+          }
+          sb.AppendLine();
+        }
+        Console.WriteLine(sb.ToString());
+      }
+    }
+  }
+}
Index: /stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 10742)
+++ /stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 10743)
@@ -464,4 +464,5 @@
     <Compile Include="HeuristicLab.Problems.TravelingSalesman-3.3\TSPMoveEvaluatorTest.cs" />
     <Compile Include="HeuristicLab.Problems.LinearAssignment-3.3\LinearAssignmentProblemSolverTest.cs" />
+    <Compile Include="HeuristicLab.Random-3.3\RandomEnumerableSampleTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="TestRandom.cs" />
