Changeset 6752 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs
- Timestamp:
- 09/13/11 16:00:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs
r6710 r6752 156 156 return false; 157 157 158 bool bestFeasible = false; 158 if (tour.Stops.Count == 0) { 159 place = 0; 160 return true; 161 } 162 159 163 double minDetour = 0; 160 161 164 VRPEvaluation eval = ProblemInstance.Evaluate(tour); 162 double length = eval.Quality; 165 bool originalFeasible = ProblemInstance.Feasible(eval); 166 163 167 for (int i = 0; i <= tour.Stops.Count; i++) { 164 tour.Stops.Insert(i, city); 165 166 eval = ProblemInstance.Evaluate(tour); 167 bool feasible = ProblemInstance.Feasible(eval); 168 169 if (feasible || allowInfeasible && !bestFeasible) { 170 double newLength = eval.Quality; 171 double detour = newLength - length; 172 173 if (place < 0 || detour < minDetour || feasible && !bestFeasible) { 168 bool feasible; 169 double detour = ProblemInstance.GetInsertionCosts(eval, city, 0, i, out feasible); 170 if (feasible || allowInfeasible) { 171 if (place < 0 || detour < minDetour) { 174 172 place = i; 175 173 minDetour = detour; 176 177 if (feasible)178 bestFeasible = true;179 174 } 180 175 } 181 182 tour.Stops.RemoveAt(i);183 176 } 184 177 … … 248 241 249 242 int place = -1; 250 if (FindRouteInsertionPlace(childTour, city, allowInfeasible, out place)) { 243 bool found = FindRouteInsertionPlace(childTour, city, allowInfeasible, out place); 244 if (found) { 251 245 childTour.Stops.Insert(place, city); 252 246
Note: See TracChangeset
for help on using the changeset viewer.