Changeset 7669 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs
- Timestamp:
- 03/28/12 15:47:26 (12 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 3 3 *.resharper 4 4 *.suo 5 *.user 5 6 *.vsp 6 7 Doxygen 8 FxCopResults.txt 7 9 Google.ProtocolBuffers-0.9.1.dll 8 10 HeuristicLab 3.3.5.1.ReSharper.user
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs
r7270 r7669 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 73 74 } 74 75 76 public static double Apply(TSPCoordinatesPathEvaluator evaluator, DoubleMatrix coordinates, Permutation tour) { 77 DoubleMatrix c = coordinates; 78 Permutation p = tour; 79 double length = 0; 80 for (int i = 0; i < p.Length - 1; i++) 81 length += evaluator.CalculateDistance(c[p[i], 0], c[p[i], 1], c[p[i + 1], 0], c[p[i + 1], 1]); 82 length += evaluator.CalculateDistance(c[p[p.Length - 1], 0], c[p[p.Length - 1], 1], c[p[0], 0], c[p[0], 1]); 83 return length; 84 } 85 75 86 public sealed override IOperation Apply() { 76 87 if (UseDistanceMatrixParameter.ActualValue.Value) { … … 83 94 if (dm == null) { // check again to avoid race condition 84 95 DoubleMatrix c = CoordinatesParameter.ActualValue; 96 if (c == null) throw new InvalidOperationException("Neither a distance matrix nor coordinates were given."); 85 97 dm = new DistanceMatrix(c.Rows, c.Rows); 86 98 for (int i = 0; i < dm.Rows; i++) { … … 101 113 Permutation p = PermutationParameter.ActualValue; 102 114 DoubleMatrix c = CoordinatesParameter.ActualValue; 103 115 if (c == null) throw new InvalidOperationException("No coordinates were given."); 104 116 double length = 0; 105 117 for (int i = 0; i < p.Length - 1; i++)
Note: See TracChangeset
for help on using the changeset viewer.