Changeset 4265
- Timestamp:
- 08/19/10 14:37:48 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/LocalSearchManipulator.cs
r4206 r4265 31 31 [StorableClass] 32 32 public sealed class LocalSearchManipulator : PotvinManipulator { 33 public IValueParameter<IntValue> Iterations { 34 get { return (IValueParameter<IntValue>)Parameters["Iterations"]; } 35 } 36 33 37 [StorableConstructor] 34 38 private LocalSearchManipulator(bool deserializing) : base(deserializing) { } 35 39 36 public LocalSearchManipulator() : base() { } 40 public LocalSearchManipulator() : base() { 41 Parameters.Add(new ValueParameter<IntValue>("Iterations", "The number of max iterations.", new IntValue(100))); 42 } 37 43 38 44 private bool FindBetterInsertionPlace( … … 80 86 if (Feasible(individual)) { 81 87 bool insertionFound; 88 int iterations = 0; 82 89 83 90 do { … … 99 106 individual.Tours[insertionTour].Cities.InsertRange( 100 107 insertionPlace, 101 toBeInserted); 108 toBeInserted); 102 109 } 103 110 city++; … … 107 114 length--; 108 115 } 109 } while (insertionFound); 116 iterations++; 117 } while (insertionFound && 118 iterations < Iterations.Value.Value); 119 120 IList<Tour> toBeRemoved = new List<Tour>(); 121 foreach (Tour tour in individual.Tours) { 122 if (tour.Cities.Count == 0) 123 toBeRemoved.Add(tour); 124 } 125 126 foreach (Tour tour in toBeRemoved) { 127 individual.Tours.Remove(tour); 128 } 110 129 } 111 130 }
Note: See TracChangeset
for help on using the changeset viewer.