Changeset 11320 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Shakers/OrienteeringShakingOperator.cs
- Timestamp:
- 09/01/14 10:36:54 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Shakers/OrienteeringShakingOperator.cs
r11319 r11320 76 76 get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; } 77 77 } 78 public ILookupParameter<DoubleValue> FixedPenaltyParameter {79 get { return (ILookupParameter<DoubleValue>)Parameters[" FixedPenalty"]; }78 public ILookupParameter<DoubleValue> PointVisitingCostsParameter { 79 get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; } 80 80 } 81 81 … … 101 101 Parameters.Add(new LookupParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points.")); 102 102 Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points.")); 103 Parameters.Add(new LookupParameter<DoubleValue>(" FixedPenalty", "The penalty for each visited vertex."));103 Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point.")); 104 104 105 105 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator that will be used.")); … … 116 116 var startingPoint = StartingPointParameter.ActualValue.Value; 117 117 var terminalPoint = TerminalPointParameter.ActualValue.Value; 118 var fixedPenalty = FixedPenaltyParameter.ActualValue.Value;118 var pointVisitingCosts = PointVisitingCostsParameter.ActualValue.Value; 119 119 double maxDistance = MaximumDistanceParameter.ActualValue.Value; 120 120 int numPoints = scores.Length; … … 139 139 from point in Enumerable.Range(0, numPoints) 140 140 // Calculate the distance when going from the starting point to this point and then to the end point 141 let distance = distances[startingPoint, point] + distances[point, terminalPoint] + fixedPenalty141 let distance = distances[startingPoint, point] + distances[point, terminalPoint] + pointVisitingCosts 142 142 // If this distance is feasible and the point is neither starting nor ending point, check the point 143 143 where distance < maxDistance && point != startingPoint && point != terminalPoint … … 157 157 158 158 // Bring the tour back to be feasible 159 CleanupTour(actualTour, distances, maxDistance, fixedPenalty);159 CleanupTour(actualTour, distances, maxDistance, pointVisitingCosts); 160 160 161 161 // Set new Tour … … 208 208 } 209 209 } 210 private void CleanupTour(List<int> actualTour, DistanceMatrix distances, double maxDistance, double fixedPenalty) {210 private void CleanupTour(List<int> actualTour, DistanceMatrix distances, double maxDistance, double pointVisitingCosts) { 211 211 // Sort the points on the tour according to their costs savings when removed 212 212 var distanceSavings = ( 213 213 from removePosition in Enumerable.Range(1, actualTour.Count - 2) 214 let saving = distances.CalculateRemovementSaving(actualTour, removePosition, fixedPenalty)214 let saving = distances.CalculateRemovementSaving(actualTour, removePosition, pointVisitingCosts) 215 215 orderby saving descending 216 216 select new SavingInfo { Index = removePosition, Saving = saving } 217 217 ).ToList(); 218 218 219 double tourLength = distances.CalculateTourLength(actualTour, fixedPenalty);219 double tourLength = distances.CalculateTourLength(actualTour, pointVisitingCosts); 220 220 221 221 // As long as the created path is infeasible, remove elements … … 223 223 // Remove the point that frees the largest distance 224 224 // Note, distance savings are not updated after removal 225 tourLength -= distances.CalculateRemovementSaving(actualTour, distanceSavings[0].Index, fixedPenalty);225 tourLength -= distances.CalculateRemovementSaving(actualTour, distanceSavings[0].Index, pointVisitingCosts); 226 226 actualTour.RemoveAt(distanceSavings[0].Index); 227 227
Note: See TracChangeset
for help on using the changeset viewer.