Changeset 6569 for branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
r6342 r6569 61 61 get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 62 62 } 63 public LookupParameter<Item List<Permutation>> BestKnownSolutionsParameter {64 get { return (LookupParameter<Item List<Permutation>>)Parameters["BestKnownSolutions"]; }63 public LookupParameter<ItemSet<Permutation>> BestKnownSolutionsParameter { 64 get { return (LookupParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; } 65 65 } 66 66 public LookupParameter<Permutation> BestKnownSolutionParameter { … … 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<Item List<Permutation>>("BestKnownSolutions", "The best known solutions (there may be multiple) of this QAP instance."));86 Parameters.Add(new LookupParameter<ItemSet<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 } … … 93 93 #region Backwards compatible code, remove with 3.4 94 94 if (!Parameters.ContainsKey("BestKnownSolutions")) { 95 Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance.")); 95 Parameters.Add(new LookupParameter<ItemSet<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance.")); 96 } else if (Parameters["BestKnownSolutions"].GetType().Equals(typeof(LookupParameter<ItemList<Permutation>>))) { 97 string actualName = (Parameters["BestKnownSolutions"] as LookupParameter<ItemList<Permutation>>).ActualName; 98 Parameters.Remove("BestKnownSolutions"); 99 Parameters.Add(new LookupParameter<ItemSet<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance.", actualName)); 96 100 } 97 101 #endregion … … 117 121 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value); 118 122 BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone(); 119 BestKnownSolutionsParameter.ActualValue = new Item List<Permutation>();123 BestKnownSolutionsParameter.ActualValue = new ItemSet<Permutation>(new PermutationEqualityComparer()); 120 124 BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[i].Clone()); 121 125 } else if (bestKnownQuality.Value == qualities[i].Value) { … … 125 129 BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone(); 126 130 if (BestKnownSolutionsParameter.ActualValue == null) 127 BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>(); 128 PermutationEqualityComparer comparer = new PermutationEqualityComparer(); 131 BestKnownSolutionsParameter.ActualValue = new ItemSet<Permutation>(new PermutationEqualityComparer()); 129 132 foreach (var k in sorted) { // for each solution that we found check if it is in the pool of best-knowns 130 133 if (!max && k.Value > qualities[i].Value 131 134 || max && k.Value < qualities[i].Value) break; // stop when we reached a solution worse than the best-known quality 132 135 Permutation p = permutations[k.index]; 133 bool alreadyPresent = false; 134 foreach (Permutation p2 in BestKnownSolutionsParameter.ActualValue) { 135 if (comparer.Equals(p, p2)) { 136 alreadyPresent = true; 137 break; 138 } 139 } 140 if (!alreadyPresent) 136 if (!BestKnownSolutionsParameter.ActualValue.Contains(p)) 141 137 BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[k.index].Clone()); 142 138 }
Note: See TracChangeset
for help on using the changeset viewer.