- Timestamp:
- 01/03/11 16:19:17 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.