Changeset 7786 for branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/TravelingSalesman/TravelingSalesmanPathRelinker.cs
- Timestamp:
- 05/09/12 12:22:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/TravelingSalesman/TravelingSalesmanPathRelinker.cs
r7775 r7786 54 54 throw new ArgumentException("RelinkingAccuracy must be greater than 0."); 55 55 56 varv1 = initiator.Clone() as Permutation;57 varv2 = guide as Permutation;56 Permutation v1 = initiator.Clone() as Permutation; 57 Permutation v2 = guide as Permutation; 58 58 59 59 if (v1.Length != v2.Length) 60 60 throw new ArgumentException("The solutions are of different length."); 61 61 62 varsolutions = new List<Permutation>();62 IList<Permutation> solutions = new List<Permutation>(); 63 63 for (int i = 0; i < v1.Length; i++) 64 64 if (v1[i] != v2[i]) { … … 73 73 } 74 74 75 varselection = new List<IItem>();75 IList<IItem> selection = new List<IItem>(); 76 76 if (solutions.Count > 0) { 77 var noSol = (int)Math.Round(solutions.Count * n.Value);77 int noSol = (int)(solutions.Count * n.Value); 78 78 if (noSol <= 0) noSol++; 79 varstepSize = (double)solutions.Count / (double)noSol;79 double stepSize = (double)solutions.Count / (double)noSol; 80 80 for (int i = 0; i < noSol; i++) 81 selection.Add(solutions.ElementAt((int) Math.Round((i + 1) * stepSize - stepSize * 0.5)));81 selection.Add(solutions.ElementAt((int)((i + 1) * stepSize - stepSize * 0.5))); 82 82 } 83 83
Note: See TracChangeset
for help on using the changeset viewer.