Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/26/16 00:02:05 (8 years ago)
Author:
abeham
Message:

#2457: worked on recommendation algorithms (x-validation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/OverallBestRecommender.cs

    r13791 r13794  
    4949
    5050    public IRecommendationModel TrainModel(IRun[] problemInstances, KnowledgeCenter kc, string[] characteristics) {
    51       var instances = new List<Tuple<IAlgorithm, double>>();
     51      var instances = new List<KeyValuePair<IAlgorithm, double>>();
    5252      foreach (var relevantRuns in kc.GetKnowledgeBaseByAlgorithm()) {
    5353        var algorithm = relevantRuns.Key;
     
    6060        var count = 0;
    6161        foreach (var problemRuns in relevantRuns.Value.GroupBy(x => ((StringValue)x.Parameters["Problem Name"]).Value)) {
    62           var bkq = pis[problemRuns.Key];
     62          double bkq;
     63          if (!pis.TryGetValue(problemRuns.Key, out bkq)) continue;
    6364          var ert = ExpectedRuntimeHelper.CalculateErt(problemRuns.ToList(), "QualityPerEvaluations", kc.GetTarget(bkq, kc.Maximization), kc.Maximization).ExpectedRuntime;
    6465          if (double.IsNaN(ert)) ert = int.MaxValue;
     
    6768        }
    6869        avgERT /= count;
    69         instances.Add(Tuple.Create((IAlgorithm)algorithm.Clone(), avgERT));
     70        instances.Add(new KeyValuePair<IAlgorithm, double>(algorithm, avgERT));
    7071      }
    7172
    72       return new FixedRankModel(instances.OrderBy(x => x.Item2));
     73      return new FixedRankModel(instances.OrderBy(x => x.Value));
    7374    }
    7475  }
Note: See TracChangeset for help on using the changeset viewer.