Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs	(revision 6449)
@@ -48,20 +48,24 @@
 
     protected override AlbaEncoding Crossover(IRandom random, AlbaEncoding parent1, AlbaEncoding parent2) {
-      //note - the inner crossover is called here and the result is converted to an alba representation
+      //note - the inner crossover is called here and the solution is converted to an alba representation
       //some refactoring should be done here in the future - the crossover operation should be called directly
 
-      InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
-      IAtomicOperation op = this.ExecutionContext.CreateOperation(
-        InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
-      op.Operator.Execute((IExecutionContext)op, CancellationToken);
+      if (parent1.Length == parent2.Length) {
+        InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
+        IAtomicOperation op = this.ExecutionContext.CreateOperation(
+          InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
+        op.Operator.Execute((IExecutionContext)op, CancellationToken);
 
-      string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
-      if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
-        Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
-        ExecutionContext.Scope.Variables.Remove(childName);
+        string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
+        if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
+          Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
+          ExecutionContext.Scope.Variables.Remove(childName);
 
-        return new AlbaEncoding(permutation, Cities);
-      } else
-        return null;
+          return new AlbaEncoding(permutation, Cities);
+        } else
+          return null;
+      } else {
+        return parent1.Clone() as AlbaEncoding;
+      }
     }
   }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs	(revision 6449)
@@ -91,7 +91,6 @@
     }
 
-    private double CalculateDistance(int start, int end) {
+    private double CalculateDistance(int start, int end, DoubleMatrix coordinates) {
       double distance = 0.0;
-      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
 
       distance =
@@ -103,11 +102,10 @@
     }
 
-    private DoubleMatrix CreateDistanceMatrix() {
-      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+    private DoubleMatrix CreateDistanceMatrix(DoubleMatrix coordinates) {
       DoubleMatrix distanceMatrix = new DoubleMatrix(coordinates.Rows, coordinates.Rows);
 
       for (int i = 0; i < distanceMatrix.Rows; i++) {
         for (int j = i; j < distanceMatrix.Columns; j++) {
-          double distance = CalculateDistance(i, j);
+          double distance = CalculateDistance(i, j, coordinates);
 
           distanceMatrix[i, j] = distance;
@@ -119,15 +117,11 @@
     }
 
-    private double Distance(int start, int end) {
+    private double Distance(int start, int end, DoubleMatrix coordinates, bool useDistanceMatrix) {
       double distance = 0.0;
 
-      if (UseDistanceMatrixParameter.ActualValue.Value) {
-        if (DistanceMatrixParameter.ActualValue == null) {
-          DistanceMatrixParameter.ActualValue = CreateDistanceMatrix();
-        }
-
-        distance = DistanceMatrixParameter.ActualValue[start, end];
-      } else {
-        distance = CalculateDistance(start, end);
+      if (useDistanceMatrix) {
+        distance = coordinates[start, end];
+      } else {  
+        distance = CalculateDistance(start, end, coordinates);
       }
 
@@ -135,23 +129,24 @@
     }
 
-    private double TravelDistance(List<int> route, int begin) {
+    private double TravelDistance(List<int> route, int begin, DoubleMatrix coordinates, bool useDistanceMatrix) {
       double distance = 0;
       for (int i = begin; i < route.Count - 1 && (i == begin || route[i] != 0); i++) {
-        distance += Distance(route[i], route[i + 1]);
+        distance += Distance(route[i], route[i + 1], coordinates, useDistanceMatrix);
       }
       return distance;
     }
 
-    private bool SubrouteConstraintsOK(List<int> route, int begin) {
+    private bool SubrouteConstraintsOK(List<int> route, int begin, DoubleMatrix coordinates, bool useDistanceMatrix, 
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand, DoubleValue capacity) {
       double t = 0.0, o = 0.0;
       for (int i = begin + 1; i < route.Count; i++) {
-        t += Distance(route[i - 1], route[i]);
+        t += Distance(route[i - 1], route[i], coordinates, useDistanceMatrix);
         if (route[i] == 0) return (t < DueTimeParameter.ActualValue[0]); // violation on capacity constraint is handled below
         else {
-          if (t > DueTimeParameter.ActualValue[route[i]]) return false;
-          t = Math.Max(ReadyTimeParameter.ActualValue[route[i]], t);
-          t += ServiceTimeParameter.ActualValue[route[i]];
-          o += DemandParameter.ActualValue[route[i]];
-          if (o > CapacityParameter.ActualValue.Value) return false; // premature exit on capacity constraint violation
+          if (t > dueTime[route[i]]) return false;
+          t = Math.Max(readyTime[route[i]], t);
+          t += serviceTime[route[i]];
+          o += demand[route[i]];
+          if (o > capacity.Value) return false; // premature exit on capacity constraint violation
         }
       }
@@ -159,15 +154,16 @@
     }
 
-    private bool SubrouteTardinessOK(List<int> route, int begin) {
+    private bool SubrouteTardinessOK(List<int> route, int begin, DoubleMatrix coordinates, bool useDistanceMatrix, 
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime) {
       double t = 0.0;
       for (int i = begin + 1; i < route.Count; i++) {
-        t += Distance(route[i - 1], route[i]);
+        t += Distance(route[i - 1], route[i], coordinates, useDistanceMatrix);
         if (route[i] == 0) {
-          if (t < DueTimeParameter.ActualValue[0]) return true;
+          if (t < dueTime[0]) return true;
           else return false;
         } else {
-          if (t > DueTimeParameter.ActualValue[route[i]]) return false;
-          t = Math.Max(ReadyTimeParameter.ActualValue[route[i]], t);
-          t += ServiceTimeParameter.ActualValue[route[i]];
+          if (t > dueTime[route[i]]) return false;
+          t = Math.Max(readyTime[route[i]], t);
+          t += serviceTime[route[i]];
         }
       }
@@ -175,20 +171,20 @@
     }
 
-    private bool SubrouteLoadOK(List<int> route, int begin) {
+    private bool SubrouteLoadOK(List<int> route, int begin, DoubleValue capacity, DoubleArray demand) {
       double o = 0.0;
       for (int i = begin + 1; i < route.Count; i++) {
-        if (route[i] == 0) return (o < CapacityParameter.ActualValue.Value);
+        if (route[i] == 0) return (o < capacity.Value);
         else {
-          o += DemandParameter.ActualValue[route[i]];
-        }
-      }
-      return (o < CapacityParameter.ActualValue.Value);
+          o += demand[route[i]];
+        }
+      }
+      return (o < capacity.Value);
     }
 
     protected override List<int> CreateSolution() {
-      double alpha, beta, gamma;
-      alpha = N(Alpha.Value.Value, Math.Sqrt(AlphaVariance.Value.Value), RandomParameter.ActualValue);
-      beta = N(Beta.Value.Value, Math.Sqrt(BetaVariance.Value.Value), RandomParameter.ActualValue);
-      gamma = N(Gamma.Value.Value, Math.Sqrt(GammaVariance.Value.Value), RandomParameter.ActualValue);
+      //double alpha, beta, gamma;
+      double alpha = N(Alpha.Value.Value, Math.Sqrt(AlphaVariance.Value.Value), RandomParameter.ActualValue);
+      double beta = N(Beta.Value.Value, Math.Sqrt(BetaVariance.Value.Value), RandomParameter.ActualValue);
+      double gamma = N(Gamma.Value.Value, Math.Sqrt(GammaVariance.Value.Value), RandomParameter.ActualValue);
 
       double x0 = CoordinatesParameter.ActualValue[0, 0];
@@ -203,4 +199,21 @@
       int indexOfCustomer = -1;
 
+      int vehicles = VehiclesParameter.ActualValue.Value;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+
+      bool useDistanceMatrix = UseDistanceMatrixParameter.ActualValue.Value;
+      if (useDistanceMatrix) {
+        if (DistanceMatrixParameter.ActualValue == null) {
+          DistanceMatrixParameter.ActualValue = CreateDistanceMatrix(coordinates);
+        }
+
+        coordinates = DistanceMatrixParameter.ActualValue;
+      }
+
       /*-----------------------------------------------------------------------------
        * generate cost list
@@ -208,9 +221,9 @@
        */
       for (int i = 1; i <= Cities; i++) {
-        distance = Distance(i, 0);
-        if (CoordinatesParameter.ActualValue[i, 0] < x0) distance = -distance;
+        distance = Distance(i, 0, coordinates, useDistanceMatrix);
+        if (coordinates[i, 0] < x0) distance = -distance;
         cost = -alpha * distance + // distance 0 <-> City[i]
                  beta * (DueTimeParameter.ActualValue[i]) + // latest arrival time
-                 gamma * (Math.Asin((CoordinatesParameter.ActualValue[i, 1] - y0) / distance) / 360 * distance); // polar angle
+                 gamma * (Math.Asin((coordinates[i, 1] - y0) / distance) / 360 * distance); // polar angle
 
         index = 0;
@@ -229,5 +242,6 @@
       int customer = -1;
       int subTourCount = 1;
-      List<int> route = new List<int>(Cities + VehiclesParameter.ActualValue.Value - 1);
+
+      List<int> route = new List<int>(Cities + vehicles - 1);
       minimumCost = double.MaxValue;
       indexOfMinimumCost = -1;
@@ -244,6 +258,6 @@
             route.Insert(i, (int)unroutedList[c]);
             if (route[currentRoute] != 0) { throw new Exception("currentRoute not depot"); }
-            cost = TravelDistance(route, currentRoute);
-            if (cost < minimumCost && SubrouteConstraintsOK(route, currentRoute)) {
+            cost = TravelDistance(route, currentRoute, coordinates, useDistanceMatrix);
+            if (cost < minimumCost && SubrouteConstraintsOK(route, currentRoute, coordinates, useDistanceMatrix, dueTime, readyTime, serviceTime, demand, capacity)) {
               minimumCost = cost;
               indexOfMinimumCost = i;
@@ -275,5 +289,5 @@
         customer = -1;
       } while (unroutedList.Count > 0);
-      while (route.Count < Cities + VehiclesParameter.ActualValue.Value - 1)
+      while (route.Count < Cities + vehicles)
         route.Add(0);
 
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs	(revision 6449)
@@ -26,4 +26,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -47,9 +48,11 @@
     protected abstract PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2);
 
-    protected bool FindInsertionPlace(PotvinEncoding individual, int city, out int route, out int place) {
+    protected static bool FindInsertionPlace(PotvinEncoding individual, int city, 
+      DoubleArray dueTime, DoubleArray serviceTime, DoubleArray readyTime, DoubleArray demand,
+      DoubleValue capacity, DistanceMatrix distMatrix, 
+      out int route, out int place) {
       return individual.FindInsertionPlace(
-        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
-        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
-        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
+        dueTime, serviceTime, readyTime,
+        demand, capacity, distMatrix,
         city, -1, out route, out place);
     }
@@ -68,5 +71,32 @@
     }
 
-    protected bool Repair(IRandom random, PotvinEncoding solution, Tour newTour) {
+    protected static bool RouteUnrouted(PotvinEncoding solution, DistanceMatrix distMatrix,
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand, DoubleValue capacity) {
+      bool success = true;
+      int index = 0;
+      while (index < solution.Unrouted.Count && success) {
+        int unrouted = solution.Unrouted[index];
+
+        int route, place;
+        if (FindInsertionPlace(solution, unrouted,
+          dueTime, serviceTime, readyTime, demand, capacity,
+          distMatrix,
+          out route, out place)) {
+          solution.Tours[route].Cities.Insert(place, unrouted);
+        } else {
+          success = false;
+        }
+
+        index++;
+      }
+
+      for (int i = 0; i < index; i++)
+        solution.Unrouted.RemoveAt(0);
+
+      return success;
+    }
+
+    protected static bool Repair(IRandom random, PotvinEncoding solution, Tour newTour, DistanceMatrix distmatrix,
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand, DoubleValue capacity) {
       bool success = true;
 
@@ -84,4 +114,8 @@
       while (newTour.Cities.Contains(0))
         newTour.Cities.Remove(0);
+
+      if (!newTour.Feasible(
+        dueTime, serviceTime, readyTime, demand, capacity, distmatrix))
+              return false; 
 
       //remove duplicates from old tours
@@ -105,20 +139,5 @@
 
       //route unrouted vehicles
-      int index = 0;
-      while (index < solution.Unrouted.Count && success) {
-        int unrouted = solution.Unrouted[index];
-
-        int route, place;
-        if (FindInsertionPlace(solution, unrouted, out route, out place)) {
-          solution.Tours[route].Cities.Insert(place, unrouted);
-        } else {
-          success = false;
-        }
-
-        index++;
-      }
-
-      for (int i = 0; i < index; i++)
-        solution.Unrouted.RemoveAt(0);
+      success = RouteUnrouted(solution, distmatrix, dueTime, readyTime, serviceTime, demand, capacity);
 
       return success;
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs	(revision 6449)
@@ -23,4 +23,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -40,4 +41,13 @@
 
     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
+      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, DistanceMatrixParameter, useDistanceMatrix);
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+
       PotvinEncoding child = parent2.Clone() as PotvinEncoding;
 
@@ -55,5 +65,5 @@
           child.Unrouted.Add(city);
 
-      if (Repair(random, child, replacing))
+      if (Repair(random, child, replacing, distMatrix, dueTime, readyTime, serviceTime, demand, capacity))
         return child;
       else {
@@ -61,5 +71,5 @@
           return parent1.Clone() as PotvinEncoding;
         else
-          return parent2.Clone() as PotvinEncoding;
+          return parent2.Clone() as PotvinEncoding;   
       }
     }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs	(revision 6449)
@@ -23,4 +23,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -41,4 +42,13 @@
 
     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
+      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, DistanceMatrixParameter, useDistanceMatrix);
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+
       PotvinEncoding child = parent1.Clone() as PotvinEncoding;
       Tour newTour = new Tour();
@@ -69,12 +79,11 @@
           child.Unrouted.Add(city);
 
-      if (Feasible(newTour) &&
-          Repair(random, child, newTour)) {
+      if (Repair(random, child, newTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity)) {
         return child;
       } else {
-        if (random.NextDouble() < 0.5)
+         if (random.NextDouble() < 0.5)
           return parent1.Clone() as PotvinEncoding;
         else
-          return parent2.Clone() as PotvinEncoding;
+          return parent2.Clone() as PotvinEncoding;   
       }
     }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs	(revision 6449)
@@ -49,5 +49,8 @@
 
     private bool FindBetterInsertionPlace(
-      PotvinEncoding individual, int tour, int city, int length,
+      PotvinEncoding individual,  
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand,
+      DoubleValue capacity, DistanceMatrix distMatrix,
+      int tour, int city, int length,
       out int insertionTour, out int insertionPlace) {
       bool insertionFound = false;
@@ -56,7 +59,7 @@
 
       List<int> toBeDeleted = individual.Tours[tour].Cities.GetRange(city, length);
-      double distance = GetLength(individual.Tours[tour]);
+      double distance = individual.Tours[tour].GetLength(distMatrix);
       individual.Tours[tour].Cities.RemoveRange(city, length);
-      double removalBenefit = distance - GetLength(individual.Tours[tour]);
+      double removalBenefit = distance - individual.Tours[tour].GetLength(distMatrix);
 
       int currentTour = 0;
@@ -64,9 +67,9 @@
         int currentCity = 0;
         while (currentCity <= individual.Tours[currentTour].Cities.Count && !insertionFound) {
-          distance = GetLength(individual.Tours[currentTour]);
+          distance = individual.Tours[currentTour].GetLength(distMatrix);
           individual.Tours[currentTour].Cities.InsertRange(currentCity, toBeDeleted);
-          if (Feasible(individual.Tours[currentTour])) {
+          if (individual.Tours[currentTour].Feasible(dueTime, serviceTime, readyTime, demand, capacity, distMatrix)) {
             double lengthIncrease =
-              GetLength(individual.Tours[currentTour]) - distance;
+              individual.Tours[currentTour].GetLength(distMatrix) - distance;
             if (removalBenefit > lengthIncrease) {
               insertionTour = currentTour;
@@ -83,5 +86,5 @@
       }
 
-      individual.Tours[tour].Cities.InsertRange(city, toBeDeleted);
+      individual.Tours[tour].Cities.InsertRange(city, toBeDeleted);  
 
       return insertionFound;
@@ -89,6 +92,24 @@
 
     protected override void Manipulate(IRandom random, PotvinEncoding individual) {
+      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, DistanceMatrixParameter, useDistanceMatrix);
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+      
       //only apply to feasible individuals
-      if (Feasible(individual)) {
+      bool feasible = true;
+
+      foreach (Tour tour in individual.Tours) {
+        if (!tour.Feasible(dueTime, serviceTime, readyTime, demand, capacity, distMatrix)) {
+          feasible = false;
+          break;
+        }
+      }
+
+      if (feasible) {
         bool insertionFound;
         int iterations = 0;
@@ -103,5 +124,6 @@
               while (city <= individual.Tours[tour].Cities.Count - length && !insertionFound) {
                 int insertionTour, insertionPlace;
-                if (FindBetterInsertionPlace(individual, tour, city, length,
+                if (FindBetterInsertionPlace(individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix,
+                  tour, city, length,
                  out insertionTour, out insertionPlace)) {
                   insertionFound = true;
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs	(revision 6449)
@@ -25,4 +25,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -45,5 +46,5 @@
     protected abstract void Manipulate(IRandom random, PotvinEncoding individual);
 
-    protected int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {
+    protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {
       int tourIndex = -1;
 
@@ -51,5 +52,5 @@
       double[] probabilities = new double[individual.Tours.Count];
       for (int i = 0; i < individual.Tours.Count; i++) {
-        probabilities[i] = 1.0 / ((double)individual.Tours[i].Cities.Count / (double)Cities);
+        probabilities[i] = 1.0 / ((double)individual.Tours[i].Cities.Count / (double)individual.Cities);
         sum += probabilities[i];
       }
@@ -72,11 +73,14 @@
     }
 
-    protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, out int route, out int place) {
+    protected static bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid,
+      DoubleArray dueTime, DoubleArray serviceTime, DoubleArray readyTime, DoubleArray demand,
+      DoubleValue capacity, DistanceMatrix distMatrix,
+      out int route, out int place) {
       return individual.FindInsertionPlace(
-        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
-        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
-        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
+        dueTime, serviceTime, readyTime,
+        demand, capacity, distMatrix,
         city, routeToAvoid, out route, out place);
     }
+      
 
     public override IOperation Apply() {
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs	(revision 6449)
@@ -24,4 +24,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -39,5 +40,7 @@
     public PotvinOneLevelExchangeMainpulator() : base() { }
 
-    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
+    public static void Apply(IRandom random, PotvinEncoding individual, 
+     DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand,
+      DoubleValue capacity, DistanceMatrix distMatrix) {
       int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
       Tour route1 =
@@ -48,5 +51,8 @@
         int insertedRoute, insertedPlace;
 
-        if (FindInsertionPlace(individual, route1.Cities[i], selectedIndex, out insertedRoute, out insertedPlace)) {
+        if (FindInsertionPlace(individual, route1.Cities[i], selectedIndex,
+          dueTime, serviceTime, readyTime, demand, capacity,
+          distMatrix,
+          out insertedRoute, out insertedPlace)) {
           individual.Tours[insertedRoute].Cities.Insert(insertedPlace, route1.Cities[i]);
           replaced.Add(route1.Cities[i]);
@@ -65,4 +71,17 @@
         individual.Tours.Remove(route1);
     }
+
+    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
+      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, DistanceMatrixParameter, useDistanceMatrix);
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+
+      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix); 
+    }
   }
 }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs	(revision 6449)
@@ -23,4 +23,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -36,7 +37,9 @@
     public PotvinTwoLevelExchangeManipulator() : base() { }
 
-    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
+    public static void Apply(IRandom random, PotvinEncoding individual, 
+      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand,
+      DoubleValue capacity, DistanceMatrix distMatrix) {
       int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
-      Tour route1 = individual.Tours[selectedIndex]; 
+      Tour route1 = individual.Tours[selectedIndex];
 
       bool performed = false;
@@ -53,12 +56,15 @@
               //customer1 can be feasibly inserted at the location of customer2
               tour.Cities[customer2Position] = customer1;
-              if (Feasible(tour)) {
+              if (tour.Feasible(dueTime, serviceTime, readyTime, demand, capacity, distMatrix)) {
                 int routeIdx, place;
                 if (FindInsertionPlace(individual,
-                  customer2, selectedIndex, out routeIdx, out place)) {
-                    individual.Tours[routeIdx].Cities.Insert(place, customer2);
-                    route1.Cities.RemoveAt(customer1Position);
+                  customer2, selectedIndex,
+                  dueTime, serviceTime, readyTime, demand, capacity,
+                  distMatrix,
+                  out routeIdx, out place)) {
+                  individual.Tours[routeIdx].Cities.Insert(place, customer2);
+                  route1.Cities.RemoveAt(customer1Position);
 
-                    if (route1.Cities.Count == 0)
+                  if (route1.Cities.Count == 0)
                     individual.Tours.Remove(route1);
 
@@ -83,4 +89,17 @@
       }
     }
+
+    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
+      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
+      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, DistanceMatrixParameter, useDistanceMatrix);
+      DoubleArray dueTime = DueTimeParameter.ActualValue;
+      DoubleArray readyTime = ReadyTimeParameter.ActualValue;
+      DoubleArray serviceTime = ServiceTimeParameter.ActualValue;
+      DoubleArray demand = DemandParameter.ActualValue;
+      DoubleValue capacity = CapacityParameter.ActualValue;
+
+      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix);
+    }
   }
 }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs	(revision 6449)
@@ -69,8 +69,9 @@
       DoubleArray dueTimeArray,
       DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
-      DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix,
+      DistanceMatrix distMatrix, 
       int city, int routeToAvoid, out int route, out int place) {
       route = -1;
       place = -1;
+      bool bestFeasible = false;
       double minDetour = 0;
 
@@ -78,18 +79,22 @@
         if (tour != routeToAvoid) {
           for (int i = 0; i <= Tours[tour].Cities.Count; i++) {
-            double length = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
+            double length = Tours[tour].GetLength(distMatrix);
 
             Tours[tour].Cities.Insert(i, city);
 
-            if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
-              capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
-              double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
+            bool feasible = Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
+              capacity, distMatrix);
 
+            if (!bestFeasible || feasible) {
+              double newLength = Tours[tour].GetLength(distMatrix);
               double detour = newLength - length;
 
-              if (route <= 0 || detour < minDetour) {
+              if (route <= 0 || detour < minDetour || (!(bestFeasible && !feasible)) && detour < minDetour || (feasible && !bestFeasible)) {
                 route = tour;
                 place = i;
                 minDetour = detour;
+
+                if (feasible)
+                  bestFeasible = true;
               }
             }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/Crossovers/PrinsPermutationCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/Crossovers/PrinsPermutationCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/Crossovers/PrinsPermutationCrossover.cs	(revision 6449)
@@ -46,32 +46,36 @@
 
     protected override PrinsEncoding Crossover(IRandom random, PrinsEncoding parent1, PrinsEncoding parent2) {
-      //note - the inner crossover is called here and the result is converted to a prins representation
+      //note - the inner crossover is called here and the solution is converted to a prins representation
       //some refactoring should be done here in the future - the crossover operation should be called directly
 
-      InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
-      IAtomicOperation op = this.ExecutionContext.CreateOperation(
-        InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
-      op.Operator.Execute((IExecutionContext)op, CancellationToken);
+      if (parent1.Length == parent2.Length) {
+        InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
+        IAtomicOperation op = this.ExecutionContext.CreateOperation(
+          InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
+        op.Operator.Execute((IExecutionContext)op, CancellationToken);
 
-      string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
-      if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
-        Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
-        ExecutionContext.Scope.Variables.Remove(childName);
+        string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
+        if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
+          Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
+          ExecutionContext.Scope.Variables.Remove(childName);
 
-        return new PrinsEncoding(permutation, Cities,
-          DueTimeParameter.ActualValue,
-            ServiceTimeParameter.ActualValue,
-            ReadyTimeParameter.ActualValue,
-            DemandParameter.ActualValue,
-            CapacityParameter.ActualValue,
-            FleetUsageFactor.ActualValue,
-            TimeFactor.ActualValue,
-            DistanceFactor.ActualValue,
-            OverloadPenalty.ActualValue,
-            TardinessPenalty.ActualValue,
-            CoordinatesParameter.ActualValue,
-            UseDistanceMatrixParameter.ActualValue);
-      } else
-        return null;
+          return new PrinsEncoding(permutation, Cities,
+            DueTimeParameter.ActualValue,
+              ServiceTimeParameter.ActualValue,
+              ReadyTimeParameter.ActualValue,
+              DemandParameter.ActualValue,
+              CapacityParameter.ActualValue,
+              FleetUsageFactor.ActualValue,
+              TimeFactor.ActualValue,
+              DistanceFactor.ActualValue,
+              OverloadPenalty.ActualValue,
+              TardinessPenalty.ActualValue,
+              CoordinatesParameter.ActualValue,
+              UseDistanceMatrixParameter.ActualValue);
+        } else
+          return null;
+      } else {
+        return parent1.Clone() as PrinsEncoding;
+      }
     }
   }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/PrinsEncoding.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/PrinsEncoding.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/PrinsEncoding.cs	(revision 6449)
@@ -75,4 +75,6 @@
     public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix, int maxVehicles = int.MaxValue) {
       List<Tour> result = new List<Tour>();
+
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, distanceMatrix, useDistanceMatrix);
 
       //Split permutation into vector P
@@ -106,7 +108,5 @@
             overloadPenalty,
             tardinessPenalty,
-            coordinates,
-            distanceMatrix,
-            useDistanceMatrix);
+            distMatrix);
 
           double cost = eval.Quality;
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Tour.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Tour.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Tour.cs	(revision 6449)
@@ -48,5 +48,5 @@
     public bool Feasible(DoubleArray dueTimeArray,
       DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
-      DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix) {
+      DistanceMatrix distMatrix) {
       TourEvaluation eval = VRPEvaluator.EvaluateTour(this,
         dueTimeArray,
@@ -60,14 +60,10 @@
         new DoubleValue(1),
         new DoubleValue(1),
-        coordinates,
-        distanceMatrix,
-        useDistanceMatrix);
+        distMatrix);
 
       return eval.Overload < double.Epsilon && eval.Tardiness < double.Epsilon;
     }
 
-    public double GetLength(DoubleMatrix coordinates,
-      ILookupParameter<DoubleMatrix> distanceMatrix,
-      BoolValue useDistanceMatrix) {
+    public double GetLength(DistanceMatrix distMatrix) {
       double length = 0;
 
@@ -82,5 +78,5 @@
         for (int i = 1; i < cities.Count; i++) {
           length += VRPUtilities.GetDistance(
-            cities[i - 1], cities[i], coordinates, distanceMatrix, useDistanceMatrix);
+            cities[i - 1], cities[i], distMatrix);
         }
       }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs	(revision 6449)
@@ -48,27 +48,31 @@
 
     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
-      //note - the inner crossover is called here and the result is converted to a prins representation
+      //note - the inner crossover is called here and the solution is converted to a prins representation
       //some refactoring should be done here in the future - the crossover operation should be called directly
 
-      InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
-      IAtomicOperation op = this.ExecutionContext.CreateOperation(
-        InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
-      op.Operator.Execute((IExecutionContext)op, CancellationToken);
+      if (parent1.Length == parent2.Length) {
+        InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
+        IAtomicOperation op = this.ExecutionContext.CreateOperation(
+          InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
+        op.Operator.Execute((IExecutionContext)op, CancellationToken);
 
-      string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
-      if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
-        Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
-        ExecutionContext.Scope.Variables.Remove(childName);
+        string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
+        if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
+          Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
+          ExecutionContext.Scope.Variables.Remove(childName);
 
-        return new ZhuEncoding(permutation, Cities,
-          DueTimeParameter.ActualValue,
-            ServiceTimeParameter.ActualValue,
-            ReadyTimeParameter.ActualValue,
-            DemandParameter.ActualValue,
-            CapacityParameter.ActualValue,
-            CoordinatesParameter.ActualValue,
-            UseDistanceMatrixParameter.ActualValue);
-      } else
-        return null;
+          return new ZhuEncoding(permutation, Cities,
+            DueTimeParameter.ActualValue,
+              ServiceTimeParameter.ActualValue,
+              ReadyTimeParameter.ActualValue,
+              DemandParameter.ActualValue,
+              CapacityParameter.ActualValue,
+              CoordinatesParameter.ActualValue,
+              UseDistanceMatrixParameter.ActualValue);
+        } else
+          return null;
+      } else {
+        return parent1.Clone() as ZhuEncoding;
+      }
     }
   }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/ZhuEncoding.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/ZhuEncoding.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/ZhuEncoding.cs	(revision 6449)
@@ -63,4 +63,6 @@
       Tour newTour = new Tour();
 
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, distanceMatrix, useDistanceMatrix);
+
       for (int i = 0; i < this.Length; i++) {
         int city = this[i] + 1;
@@ -72,7 +74,5 @@
           demandArray,
           capacity,
-          coordinates,
-          distanceMatrix,
-          useDistanceMatrix)) {
+          distMatrix)) {
           newTour.Cities.Remove(city);
           if (newTour.Cities.Count > 0)
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs	(revision 6449)
@@ -116,5 +116,5 @@
       DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
       DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
-      DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) {
+      DistanceMatrix distMatrix) {
       TourEvaluation eval = new TourEvaluation();
 
@@ -140,5 +140,5 @@
 
         //drive there
-        double currentDistace = VRPUtilities.GetDistance(start, end, coordinates, distanceMatrix, useDistanceMatrix);
+        double currentDistace = VRPUtilities.GetDistance(start, end, distMatrix);
         distance += currentDistace;
         time += currentDistace;
@@ -199,8 +199,10 @@
       sumEval.Tardiness = 0;
 
+      DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, distanceMatrix, useDistanceMatrix);
+
       foreach (Tour tour in solution.GetTours(distanceMatrix as ILookupParameter<DoubleMatrix>)) {
         TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
           fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty,
-          coordinates, distanceMatrix, useDistanceMatrix);
+          distMatrix);
         sumEval.Quality += eval.Quality;
         sumEval.Distance += eval.Distance;
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj	(revision 6449)
@@ -112,4 +112,8 @@
     <Compile Include="Analyzers\BestVRPToursMemorizer.cs" />
     <Compile Include="Analyzers\BestVRPSolutionAnalyzer.cs" />
+    <Compile Include="Encodings\Alba\LocalImprovement\AlbaLambdaInterchangeLocalImprovementOperator.cs" />
+    <Compile Include="Encodings\General\Creators\IterativeInsertionCreator.cs" />
+    <Compile Include="Encodings\Potvin\Crossovers\PotvinInsertionBasedCrossover.cs" />
+    <Compile Include="Encodings\Potvin\Manipulators\PotvinLocalSearchManipulator.cs" />
     <Compile Include="Interfaces\IVRPMultiNeighborhoodShakingOperator.cs" />
     <Compile Include="ShakingOperators\VehicleRoutingShakingOperator.cs" />
@@ -162,5 +166,4 @@
     <Compile Include="Encodings\Potvin\Crossovers\PotvinSequenceBasedCrossover.cs" />
     <Compile Include="Encodings\Potvin\Crossovers\PotvinCrossover.cs" />
-    <Compile Include="Encodings\Potvin\Manipulators\PotvinLocalSearchManipulator.cs" />
     <Compile Include="Encodings\Potvin\Manipulators\PotvinTwoLevelExchangeManipulator.cs" />
     <Compile Include="Encodings\Potvin\Manipulators\PotvinOneLevelExchangeManipulator.cs" />
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs	(revision 6449)
@@ -123,36 +123,4 @@
       Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
     }
-
-    protected bool Feasible(Tour tour) {
-      return tour.Feasible(
-                  DueTimeParameter.ActualValue,
-                  ServiceTimeParameter.ActualValue,
-                  ReadyTimeParameter.ActualValue,
-                  DemandParameter.ActualValue,
-                  CapacityParameter.ActualValue,
-                  CoordinatesParameter.ActualValue,
-                  DistanceMatrixParameter,
-                  UseDistanceMatrixParameter.ActualValue);
-    }
-
-    protected bool Feasible(IVRPEncoding solution) {
-      bool feasible = true;
-
-      foreach (Tour tour in solution.GetTours(DistanceMatrixParameter)) {
-        if (!Feasible(tour)) {
-          feasible = false;
-          break;
-        }
-      }
-
-      return feasible;
-    }
-
-    protected double GetLength(Tour tour) {
-      return tour.GetLength(
-                CoordinatesParameter.ActualValue,
-                DistanceMatrixParameter,
-                UseDistanceMatrixParameter.ActualValue);
-    }
   }
 }
Index: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs	(revision 6448)
+++ trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs	(revision 6449)
@@ -25,4 +25,9 @@
 
 namespace HeuristicLab.Problems.VehicleRouting {
+  public struct DistanceMatrix {
+    public DoubleMatrix Matrix { get; set; }
+    public BoolValue UseDistanceMatrix { get; set; }
+  }
+
   public sealed class VRPUtilities {
     public static double CalculateDistance(int start, int end, DoubleMatrix coordinates) {
@@ -50,4 +55,41 @@
 
       return distanceMatrix;
+    }
+
+    public static DistanceMatrix GetDistanceMatrix(DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) {
+      DistanceMatrix result = new DistanceMatrix();
+      
+      if (useDistanceMatrix.Value) {
+        result.UseDistanceMatrix = new BoolValue(true);
+        if (distanceMatrix is IValueParameter<DoubleMatrix>) {
+          if ((distanceMatrix as IValueParameter<DoubleMatrix>).Value == null) {
+            (distanceMatrix as IValueParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates);
+          }
+
+          result.Matrix = (distanceMatrix as IValueParameter<DoubleMatrix>).Value;
+        } else {
+          if (distanceMatrix.ActualValue == null) {
+            distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
+          }
+
+          result.Matrix = (distanceMatrix.ActualValue as DoubleMatrix);
+        }
+      } else {
+        result.UseDistanceMatrix = new BoolValue(false);
+        result.Matrix = coordinates;
+      }
+
+      return result;
+    }
+
+    public static double GetDistance(int start, int end, DistanceMatrix distMatrix) {
+      double distance = 0.0;
+
+      if (distMatrix.UseDistanceMatrix.Value)
+        distance = distMatrix.Matrix[start, end];
+      else
+        distance = CalculateDistance(start, end, distMatrix.Matrix);
+
+      return distance;
     }
 
