Changeset 11228 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/DistanceMatrix.cs
- Timestamp:
- 07/29/14 15:43:47 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/DistanceMatrix.cs
r11193 r11228 55 55 public double CalculateTourLength(IList<int> path, double fixedPenalty) { 56 56 double length = 0.0; 57 58 for (int i = 1; i < path.Count; i++) { 59 length += this[i - 1, i]; 60 } 61 57 for (int i = 1; i < path.Count; i++) 58 length += this[path[i - 1], path[i]]; 62 59 // Add the fixed penalty for every vertex except for the starting and ending vertex 63 60 length += (path.Count - 2) * fixedPenalty; 64 65 61 return length; 66 62 } 67 68 public double CalculateInsertionCosts(IList<int> path, int pointPosition, int insertPosition, double fixedPenalty) { 69 double detour = this[path[insertPosition - 1], pointPosition] + this[pointPosition, path[insertPosition]]; 63 public double CalculateInsertionCosts(IList<int> path, int insertPosition, int point, double fixedPenalty) { 64 double detour = this[path[insertPosition - 1], point] + this[point, path[insertPosition]]; 70 65 detour += fixedPenalty; 71 66 detour -= this[path[insertPosition - 1], path[insertPosition]]; 72 67 return detour; 73 68 } 74 75 public double CalculateReplacementCosts(List<int> path, int pointPosition, int replacementPosition) { 76 double detour = this[pointPosition - 1, replacementPosition] + this[replacementPosition, pointPosition + 1]; 77 detour -= this[pointPosition - 1, pointPosition] + this[pointPosition, pointPosition + 1]; 69 public double CalculateReplacementCosts(List<int> path, int replacePosition, int point) { 70 double detour = this[path[replacePosition - 1], point] + this[point, path[replacePosition + 1]]; 71 detour -= this[path[replacePosition - 1], path[replacePosition]] + this[path[replacePosition], path[replacePosition + 1]]; 78 72 return detour; 73 } 74 public double CalculateRemovementSaving(List<int> path, int removePosition, double fixedPenalty) { 75 double saving = this[path[removePosition - 1], path[removePosition]]; 76 saving += this[path[removePosition], path[removePosition + 1]]; 77 saving -= this[path[removePosition - 1], path[removePosition + 1]]; 78 saving += fixedPenalty; 79 return saving; 79 80 } 80 81 }
Note: See TracChangeset
for help on using the changeset viewer.