Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/01/11 14:57:08 (13 years ago)
Author:
abeham
Message:

#1469

  • Adapted analyzer to add best-known solution in case it was unknown, but its quality was known
  • Added best-known solutions for esc32a, sko49 in QAPLIB Solution format
  • Changed some solutions to be EmbeddedResources so that they'd be picked up
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs

    r6086 r6087  
    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 of this QAP instance."));
     86      Parameters.Add(new LookupParameter<ItemList<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    }
     
    9292      // BackwardsCompatibility3.3
    9393      #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       }*/
    9894      if (!Parameters.ContainsKey("BestKnownSolutions")) {
    9995        Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));
     
    117113      if (bestKnownQuality == null
    118114          || 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 best-known quality or we improved the best-known quality we'll add the current solution as best-known
    122117        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
    123118        BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone();
    124119        BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>();
    125120        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 best-known quality we'll try to set the best-known 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>();
    127128        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 best-knowns
    129130          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 best-known quality
    131132          Permutation p = permutations[k.index];
    132133          bool alreadyPresent = false;
Note: See TracChangeset for help on using the changeset viewer.