Changeset 6087 for branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
 Timestamp:
 05/01/11 14:57:08 (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
r6086 r6087 84 84 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best QAP solution should be stored.")); 85 85 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this QAP instance.")); 86 Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));86 Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions (there may be multiple) of this QAP instance.")); 87 87 Parameters.Add(new LookupParameter<Permutation>("BestKnownSolution", "The best known solution of this QAP instance.")); 88 88 } … … 92 92 // BackwardsCompatibility3.3 93 93 #region Backwards compatible code, remove with 3.4 94 /*if (Parameters.ContainsKey("BestKnownSolution")) {95 Parameters.Remove("BestKnownSolution");96 Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));97 }*/98 94 if (!Parameters.ContainsKey("BestKnownSolutions")) { 99 95 Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance.")); … … 117 113 if (bestKnownQuality == null 118 114  max && qualities[i].Value > bestKnownQuality.Value 119  !max && qualities[i].Value < bestKnownQuality.Value 120  bestKnownQuality.Value == qualities[i].Value 121 && (BestKnownSolutionsParameter.ActualValue == null  BestKnownSolutionsParameter.ActualValue.Count == 0)) { 115  !max && qualities[i].Value < bestKnownQuality.Value) { 116 // if there isn't a bestknown quality or we improved the bestknown quality we'll add the current solution as bestknown 122 117 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value); 123 118 BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone(); 124 119 BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>(); 125 120 BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[i].Clone()); 126 } else if (bestKnownQuality != null && qualities[i].Value == bestKnownQuality.Value) { 121 } else if (bestKnownQuality.Value == qualities[i].Value) { 122 // if we matched the bestknown quality we'll try to set the bestknown solution if it isn't null 123 // and try to add it to the pool of best solutions if it is different 124 if (BestKnownSolutionParameter.ActualValue == null) 125 BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone(); 126 if (BestKnownSolutionsParameter.ActualValue == null) 127 BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>(); 127 128 PermutationEqualityComparer comparer = new PermutationEqualityComparer(); 128 foreach (var k in sorted) { 129 foreach (var k in sorted) { // for each solution that we found check if it is in the pool of bestknowns 129 130 if (!max && k.Value > qualities[i].Value 130  max && k.Value < qualities[i].Value) break; 131  max && k.Value < qualities[i].Value) break; // stop when we reached a solution worse than the bestknown quality 131 132 Permutation p = permutations[k.index]; 132 133 bool alreadyPresent = false;
Note: See TracChangeset
for help on using the changeset viewer.