- Timestamp:
- 11/19/10 15:43:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/BestVRPSolutionAnalyzer.cs
r4752 r4860 62 62 } 63 63 64 public LookupParameter<DoubleValue> BestKnownQualityParameter { 65 get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 66 } 67 public LookupParameter<VRPSolution> BestKnownSolutionParameter { 68 get { return (LookupParameter<VRPSolution>)Parameters["BestKnownSolution"]; } 69 } 70 64 71 [StorableConstructor] 65 72 private BestVRPSolutionAnalyzer(bool deserializing) : base(deserializing) { } … … 69 76 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance.")); 70 77 Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("VRPTours", "The VRP tours which should be evaluated.")); 78 79 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 80 Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 71 81 72 82 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed.")); … … 86 96 } 87 97 98 [StorableHook(HookType.AfterDeserialization)] 99 private void AfterDeserializationHook() { 100 #region Backwards Compatibility 101 if (!Parameters.ContainsKey("BestKnownQuality")) { 102 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 103 } 104 if (!Parameters.ContainsKey("BestKnownSolution")) { 105 Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 106 } 107 #endregion 108 } 109 88 110 public override IOperation Apply() { 89 111 IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue; … … 96 118 97 119 int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index; 120 121 DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue; 98 122 99 123 IVRPEncoding best = solutions[i].Clone() as IVRPEncoding; … … 116 140 } 117 141 142 if (bestKnownQuality == null || 143 qualities[i].Value < bestKnownQuality.Value) { 144 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value); 145 BestKnownSolutionParameter.ActualValue = (VRPSolution)solution.Clone(); 146 } 147 118 148 return base.Apply(); 119 149 }
Note: See TracChangeset
for help on using the changeset viewer.