Changeset 5202 for branches/VRP
- Timestamp:
- 01/03/11 16:19:17 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/BestVRPSolutionAnalyzer.cs
r4860 r5202 58 58 get { return (LookupParameter<VRPSolution>)Parameters["BestSolution"]; } 59 59 } 60 public LookupParameter<VRPSolution> BestValidSolutionParameter { 61 get { return (LookupParameter<VRPSolution>)Parameters["BestValidSolution"]; } 62 } 60 63 public ValueLookupParameter<ResultCollection> ResultsParameter { 61 64 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } … … 84 87 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("VehiclesUtilized", "The utilized vehicles of the VRP solutions which should be analyzed.")); 85 88 86 Parameters.Add(new LookupParameter<VRPSolution>("BestSolution", "The best TSP solution.")); 89 Parameters.Add(new LookupParameter<VRPSolution>("BestSolution", "The best VRP solution.")); 90 Parameters.Add(new LookupParameter<VRPSolution>("BestValidSolution", "The best valid VRP solution.")); 87 91 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored.")); 88 92 } … … 140 144 } 141 145 146 VRPSolution validSolution = BestValidSolutionParameter.ActualValue; 147 if (validSolution == null) { 148 if (ProblemInstanceParameter.ActualValue.Feasible(best)) { 149 validSolution = new VRPSolution(problemInstance, best.Clone() as IVRPEncoding, new DoubleValue(qualities[i].Value)); 150 BestValidSolutionParameter.ActualValue = validSolution; 151 results.Add(new Result("Best valid VRP Solution", validSolution)); 152 } 153 } else { 154 if (qualities[i].Value <= validSolution.Quality.Value) { 155 if (ProblemInstanceParameter.ActualValue.Feasible(best)) { 156 validSolution.ProblemInstance = problemInstance; 157 validSolution.Solution = best.Clone() as IVRPEncoding; 158 validSolution.Quality.Value = qualities[i].Value; 159 } 160 } 161 } 162 142 163 if (bestKnownQuality == null || 143 164 qualities[i].Value < bestKnownQuality.Value) { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveEvaluator.cs
r5127 r5202 40 40 } 41 41 42 public ILookupParameter< IMemory> MemoryParameter {43 get { return (ILookupParameter< IMemory>)Parameters["Memory"]; }42 public ILookupParameter<VariableCollection> MemoriesParameter { 43 get { return (ILookupParameter<VariableCollection>)Parameters["Memories"]; } 44 44 } 45 45 46 public IValueParameter<StringValue> AdditionFrequency Parameter {47 get { return (IValueParameter<StringValue>)Parameters["AdditionFrequency "]; }46 public IValueParameter<StringValue> AdditionFrequencyMemoryKeyParameter { 47 get { return (IValueParameter<StringValue>)Parameters["AdditionFrequencyMemoryKey"]; } 48 48 } 49 49 … … 59 59 Parameters.Add(new LookupParameter<PotvinCustomerRelocationMove>("PotvinCustomerRelocationMove", "The move that should be evaluated.")); 60 60 61 Parameters.Add(new LookupParameter< IMemory>("Memory", "The TS memory."));62 Parameters.Add(new ValueParameter<StringValue>("AdditionFrequency ", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency")));61 Parameters.Add(new LookupParameter<VariableCollection>("Memories", "The TS memory collection.")); 62 Parameters.Add(new ValueParameter<StringValue>("AdditionFrequencyMemoryKey", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency"))); 63 63 Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The lambda parameter.", new DoubleValue(0.015))); 64 64 } … … 82 82 //Apply memory, only if move is worse 83 83 if (MoveQualityParameter.ActualValue.Value >= QualityParameter.ActualValue.Value) { 84 IMemory memory = MemoryParameter.ActualValue; 85 string key = AdditionFrequencyParameter.Value.Value; 86 ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = 87 memory.Get(key) as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>; 88 if (additionFrequency != null) { 84 VariableCollection memory = MemoriesParameter.ActualValue; 85 string key = AdditionFrequencyMemoryKeyParameter.Value.Value; 86 87 if (memory.ContainsKey(key)) { 88 ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = 89 memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>; 89 90 PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City); 90 91 if (additionFrequency.ContainsKey(attr)) { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveMaker.cs
r5127 r5202 53 53 } 54 54 55 public ILookupParameter< IMemory> MemoryParameter {56 get { return (ILookupParameter< IMemory>)Parameters["Memory"]; }55 public ILookupParameter<VariableCollection> MemoriesParameter { 56 get { return (ILookupParameter<VariableCollection>)Parameters["Memories"]; } 57 57 } 58 58 59 public IValueParameter<StringValue> AdditionFrequency Parameter {60 get { return (IValueParameter<StringValue>)Parameters["AdditionFrequency "]; }59 public IValueParameter<StringValue> AdditionFrequencyMemoryKeyParameter { 60 get { return (IValueParameter<StringValue>)Parameters["AdditionFrequencyMemoryKey"]; } 61 61 } 62 62 … … 71 71 Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(1000.0))); 72 72 73 Parameters.Add(new LookupParameter< IMemory>("Memory", "The TS memory."));74 Parameters.Add(new ValueParameter<StringValue>("AdditionFrequency ", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency")));73 Parameters.Add(new LookupParameter<VariableCollection>("Memories", "The TS memory collection.")); 74 Parameters.Add(new ValueParameter<StringValue>("AdditionFrequencyMemoryKey", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency"))); 75 75 } 76 76 … … 122 122 123 123 //update memory 124 IMemory memory = MemoryParameter.ActualValue; 125 string key = AdditionFrequencyParameter.Value.Value; 124 VariableCollection memory = MemoriesParameter.ActualValue; 125 string key = AdditionFrequencyMemoryKeyParameter.Value.Value; 126 127 if (!memory.ContainsKey(key)) { 128 memory.Add(new Variable(key, 129 new ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>())); 130 } 126 131 ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = 127 memory.Get(key) as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>; 128 if (additionFrequency == null) { 129 additionFrequency = new ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>(); 130 memory.Put(key, additionFrequency); 131 } 132 memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>; 133 132 134 PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City); 133 135 if (!additionFrequency.ContainsKey(attr)) -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r5127 r5202 79 79 } 80 80 81 public double EvaluateTour(Tour tour) {82 return ProblemInstance.Evaluate(tour);83 }84 85 81 public double GetTourLength(Tour tour) { 86 82 double length = 0; … … 109 105 tour.Stops.Insert(i, city); 110 106 111 double quality = EvaluateTour(tour); 107 VRPEvaluation eval = ProblemInstance.EvaluatorParameter.Value.Evaluate(ProblemInstance, tour); 108 double quality = eval.Quality + eval.Penalty * (PenaltyFactor - 1.0); 112 109 113 110 if (place < 0 || quality < minQuality) {
Note: See TracChangeset
for help on using the changeset viewer.