Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs	(revision 6569)
@@ -26,4 +26,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -33,4 +34,18 @@
     public ILookupParameter<IRandom> RandomParameter {
       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
+    }
+
+    public IValueParameter<BoolValue> AllowInfeasibleSolutions {
+      get { return (IValueParameter<BoolValue>)Parameters["AllowInfeasibleSolutions"]; }
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      // BackwardsCompatibility3.3
+      #region Backwards compatible code (remove with 3.4)
+      if (!Parameters.ContainsKey("AllowInfeasibleSolutions")) {
+        Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
+      }
+      #endregion
     }
 
@@ -43,14 +58,18 @@
     public PotvinCrossover() {
       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
+      Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
     }
 
     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, bool allowInfeasible,
+      out int route, out int place) {
       return individual.FindInsertionPlace(
-        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
-        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
-        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
-        city, -1, out route, out place);
+        dueTime, serviceTime, readyTime,
+        demand, capacity, distMatrix,
+        city, -1, allowInfeasible,
+        out route, out place);
     }
 
@@ -68,5 +87,33 @@
     }
 
-    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 allowInfeasible) {
+      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, allowInfeasible,
+          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 allowInfeasible) {
       bool success = true;
 
@@ -104,21 +151,10 @@
       }
 
+      if (!allowInfeasible && !newTour.Feasible(
+        dueTime, serviceTime, readyTime, demand, capacity, distmatrix))
+        return false;
+
       //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, allowInfeasible);
 
       return success;
Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs	(revision 6569)
@@ -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,15 @@
 
     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;
+
+      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
+
       PotvinEncoding child = parent2.Clone() as PotvinEncoding;
 
@@ -55,5 +67,5 @@
           child.Unrouted.Add(city);
 
-      if (Repair(random, child, replacing))
+      if (Repair(random, child, replacing, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible) || allowInfeasible)
         return child;
       else {
@@ -61,5 +73,5 @@
           return parent1.Clone() as PotvinEncoding;
         else
-          return parent2.Clone() as PotvinEncoding;
+          return parent2.Clone() as PotvinEncoding;   
       }
     }
Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs	(revision 6569)
@@ -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,15 @@
 
     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;
+
+      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
+
       PotvinEncoding child = parent1.Clone() as PotvinEncoding;
       Tour newTour = new Tour();
@@ -69,12 +81,11 @@
           child.Unrouted.Add(city);
 
-      if (Feasible(newTour) &&
-          Repair(random, child, newTour)) {
+      if (Repair(random, child, newTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible) || allowInfeasible) {
         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: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs	(revision 6569)
@@ -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: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs	(revision 6569)
@@ -25,4 +25,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
@@ -34,4 +35,18 @@
     }
 
+    public IValueParameter<BoolValue> AllowInfeasibleSolutions {
+      get { return (IValueParameter<BoolValue>)Parameters["AllowInfeasibleSolutions"]; }
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      // BackwardsCompatibility3.3
+      #region Backwards compatible code (remove with 3.4)
+      if (!Parameters.ContainsKey("AllowInfeasibleSolutions")) {
+        Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
+      }
+      #endregion
+    }
+
     [StorableConstructor]
     protected PotvinManipulator(bool deserializing) : base(deserializing) { }
@@ -41,9 +56,10 @@
     public PotvinManipulator() {
       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
+      Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
     }
 
     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 +67,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 +88,15 @@
     }
 
-    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,  bool allowInfeasible,
+      out int route, out int place) {
       return individual.FindInsertionPlace(
-        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
-        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
-        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
-        city, routeToAvoid, out route, out place);
+        dueTime, serviceTime, readyTime,
+        demand, capacity, distMatrix,
+        city, routeToAvoid, allowInfeasible, 
+        out route, out place);
     }
+      
 
     public override IOperation Apply() {
Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs	(revision 6569)
@@ -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, bool allowInfeasible) {
       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, allowInfeasible,
+          out insertedRoute, out insertedPlace)) {
           individual.Tours[insertedRoute].Cities.Insert(insertedPlace, route1.Cities[i]);
           replaced.Add(route1.Cities[i]);
@@ -65,4 +71,19 @@
         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;
+
+      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
+
+      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix, allowInfeasible); 
+    }
   }
 }
Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs	(revision 6569)
@@ -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, bool allowInfeasible) {
       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, allowInfeasible,
+                  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,19 @@
       }
     }
+
+    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;
+
+      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
+
+      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix, allowInfeasible);
+    }
   }
 }
Index: branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs	(revision 6569)
@@ -69,8 +69,10 @@
       DoubleArray dueTimeArray,
       DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
-      DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix,
-      int city, int routeToAvoid, out int route, out int place) {
+      DistanceMatrix distMatrix,
+      int city, int routeToAvoid, bool allowInfeasible,
+      out int route, out int place) {
       route = -1;
       place = -1;
+      bool bestFeasible = false;
       double minDetour = 0;
 
@@ -78,18 +80,23 @@
         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 ((!allowInfeasible && feasible) || (allowInfeasible && (!bestFeasible || feasible))) {
+              double newLength = Tours[tour].GetLength(distMatrix);
               double detour = newLength - length;
 
-              if (route <= 0 || detour < minDetour) {
+              if (route <= 0 || detour < minDetour ||
+                (allowInfeasible && ((!(bestFeasible && !feasible)) && detour < minDetour || (feasible && !bestFeasible)))) {
                 route = tour;
                 place = i;
                 minDetour = detour;
+
+                if (feasible)
+                  bestFeasible = true;
               }
             }
