Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/11 00:37:06 (13 years ago)
Author:
abeham
Message:

#1469

  • Added additional constructors to ItemSet<T> that allow to take a custom IEqualityComparer<T>
  • Changed BestKnownSolutions from ItemList<T> to ItemSet<T>
  • Adapted BestQAPSolutionAnalyzer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs

    r6342 r6525  
    6161      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    6262    }
    63     public LookupParameter<ItemList<Permutation>> BestKnownSolutionsParameter {
    64       get { return (LookupParameter<ItemList<Permutation>>)Parameters["BestKnownSolutions"]; }
     63    public LookupParameter<ItemSet<Permutation>> BestKnownSolutionsParameter {
     64      get { return (LookupParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; }
    6565    }
    6666    public LookupParameter<Permutation> BestKnownSolutionParameter {
     
    8484      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best QAP solution should be stored."));
    8585      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 (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."));
    8787      Parameters.Add(new LookupParameter<Permutation>("BestKnownSolution", "The best known solution of this QAP instance."));
    8888    }
     
    117117        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
    118118        BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone();
    119         BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>();
     119        BestKnownSolutionsParameter.ActualValue = new ItemSet<Permutation>(new PermutationEqualityComparer());
    120120        BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[i].Clone());
    121121      } else if (bestKnownQuality.Value == qualities[i].Value) {
     
    125125          BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone();
    126126        if (BestKnownSolutionsParameter.ActualValue == null)
    127           BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>();
    128         PermutationEqualityComparer comparer = new PermutationEqualityComparer();
     127          BestKnownSolutionsParameter.ActualValue = new ItemSet<Permutation>(new PermutationEqualityComparer());
    129128        foreach (var k in sorted) { // for each solution that we found check if it is in the pool of best-knowns
    130129          if (!max && k.Value > qualities[i].Value
    131130            || max && k.Value < qualities[i].Value) break; // stop when we reached a solution worse than the best-known quality
    132131          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)
     132          if (!BestKnownSolutionsParameter.ActualValue.Contains(p))
    141133            BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[k.index].Clone());
    142134        }
Note: See TracChangeset for help on using the changeset viewer.