- Timestamp:
- 09/06/11 13:00:12 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs
r6608 r6710 27 27 using System; 28 28 using HeuristicLab.Parameters; 29 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 151 152 int city, bool allowInfeasible, out int place) { 152 153 place = -1; 154 155 if (tour.Stops.Contains(city)) 156 return false; 157 153 158 bool bestFeasible = false; 154 159 double minDetour = 0; 155 160 161 VRPEvaluation eval = ProblemInstance.Evaluate(tour); 162 double length = eval.Quality; 156 163 for (int i = 0; i <= tour.Stops.Count; i++) { 157 double length = tour.GetTourLength(ProblemInstance);158 159 164 tour.Stops.Insert(i, city); 160 165 161 bool feasible = ProblemInstance.Feasible(tour); 166 eval = ProblemInstance.Evaluate(tour); 167 bool feasible = ProblemInstance.Feasible(eval); 162 168 163 169 if (feasible || allowInfeasible && !bestFeasible) { 164 double newLength = tour.GetTourLength(ProblemInstance);170 double newLength = eval.Quality; 165 171 double detour = newLength - length; 166 172 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r6607 r6710 35 35 [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")] 36 36 [StorableClass] 37 public class PotvinEncoding : TourEncoding , ISingleDepotEncoding, ITimeWindowedEncoding, IHomogenousCapacitatedEncoding{37 public class PotvinEncoding : TourEncoding { 38 38 [Storable] 39 39 public List<int> Unrouted { get; set; } … … 115 115 for (int tour = 0; tour < Tours.Count; tour++) { 116 116 if (tour != routeToAvoid) { 117 VRPEvaluation eval = ProblemInstance.Evaluate(Tours[tour]); 118 double length = eval.Quality; 119 117 120 for (int i = 0; i <= Tours[tour].Stops.Count; i++) { 118 double length = GetTourLength(Tours[tour]);119 120 121 Tours[tour].Stops.Insert(i, city); 121 122 122 bool feasible = ProblemInstance.Feasible(Tours[tour]); 123 eval = ProblemInstance.Evaluate(Tours[tour]); 124 bool feasible = ProblemInstance.Feasible(eval); 123 125 124 126 if (feasible || allowInfeasible && !bestFeasible) { 125 double newLength = GetTourLength(Tours[tour]);127 double newLength = eval.Quality; 126 128 double detour = newLength - length; 127 129
Note: See TracChangeset
for help on using the changeset viewer.