Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/26/16 13:07:26 (8 years ago)
Author:
abeham
Message:

#2457: worked on testing recommendation algorithms through x-validation

Location:
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3
Files:
2 edited

Legend:

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

    r13794 r13797  
    421421        var characteristics = new HashSet<string>();
    422422        var totalProblems = adminClient.Problems.Count(x => x.ProblemClassId == probClassId);
    423         Parallel.ForEach(adminClient.Problems.Where(x => x.ProblemClassId == probClassId), new ParallelOptions { MaxDegreeOfParallelism = 3 }, (pInst) => {
     423        Parallel.ForEach(adminClient.Problems.Where(x => x.ProblemClassId == probClassId), new ParallelOptions { MaxDegreeOfParallelism = 8 }, (pInst) => {
    424424          var charas = new List<string>();
    425425          IRun probRun = null;
     
    457457        progress.ProgressValue = 0;
    458458        p[0] = 0;
    459         Parallel.ForEach(adminClient.Algorithms, new ParallelOptions { MaxDegreeOfParallelism = 3 }, (algInst) => {
     459        Parallel.ForEach(adminClient.Algorithms, new ParallelOptions { MaxDegreeOfParallelism = 8 }, (algInst) => {
    460460          IAlgorithm alg = null;
    461461          var data = Clients.OKB.Administration.AdministrationClient.GetAlgorithmData(algInst.Id);
     
    490490        var runIds = queryClient.GetRunIds(problemClassFilter).ToList();
    491491        var batches = runIds.Select((v, i) => new { Idx = i, Val = v }).GroupBy(x => x.Idx / 500, x => x.Val);
    492         Parallel.ForEach(batches.Select(x => x.ToList()), new ParallelOptions { MaxDegreeOfParallelism = 3 }, (batch) => {
     492        Parallel.ForEach(batches.Select(x => x.ToList()), new ParallelOptions { MaxDegreeOfParallelism = 4 }, (batch) => {
    493493          var okbRuns = queryClient.GetRunsWithValues(batch, true, interestingValues);
    494494          var hlRuns = okbRuns.AsParallel().Select(x => new { AlgorithmId = x.Algorithm.Id, Run = queryClient.ConvertToOptimizationRun(x) }).ToList();
     
    535535
    536536        // add algorithm instance ranks as features to the problem instances for a range of targets
    537         foreach (var target in new[] {1, 1.01, 1.05, 1.1, 1.2, 1.5}) {
     537        foreach (var target in new[] {0, 0.01, 0.05, 0.1, 0.2, 0.5}) {
    538538          var cls = GetPerformanceClasses(target, 5);
    539539          foreach (var kvp in cls) {
    540540            var prob = kvp.Key;
    541541            foreach (var kvp2 in kvp.Value) {
    542               var resultName = "Rank." + algorithmId2AlgorithmInstanceMapping.GetByFirst(kvp2.Key) + "@" + ((target - 1) * 100) + "%";
     542              var resultName = "Rank." + algorithmId2AlgorithmInstanceMapping.GetByFirst(kvp2.Key) + "@" + (target * 100) + "%";
    543543              prob.Results[resultName] = new IntValue(kvp2.Value);
    544544            }
     
    617617    public Dictionary<IAlgorithm, double> GetAlgorithmPerformance(IRun problemInstance) {
    618618      if (!problemInstance.Parameters.ContainsKey("BestKnownQuality")) return new Dictionary<IAlgorithm, double>();
    619       var target = GetTarget(((DoubleValue)problemInstance.Parameters["BestKnownQuality"]).Value, Maximization);
     619      var target = GetTarget(((DoubleValue)problemInstance.Parameters["BestKnownQuality"]).Value, MinimumTarget.Value, Maximization);
    620620      return knowledgeBase.Where(x => ((StringValue)x.Parameters["Problem Name"]).Value == ((StringValue)problemInstance.Parameters["Problem Name"]).Value)
    621621                          .GroupBy(x => algorithmId2AlgorithmInstanceMapping.GetByFirst(algorithmId2RunMapping.GetBySecond(x).Single()))
     
    653653          var max = ((BoolValue)prob.Parameters["Maximization"]).Value;
    654654          var bkq = ((DoubleValue)prob.Parameters["BestKnownQuality"]).Value;
    655           var ert = ExpectedRuntimeHelper.CalculateErt(pr.ToList(), "QualityPerEvaluations", GetTarget(bkq, max), max).ExpectedRuntime;
     655          var ert = ExpectedRuntimeHelper.CalculateErt(pr.ToList(), "QualityPerEvaluations", GetTarget(bkq, target, max), max).ExpectedRuntime;
    656656          if (double.IsNaN(ert)) ert = int.MaxValue;
    657657          ds.AddRow(new object[] { pr.Key }.Concat(f.Cast<object>()).Concat(new object[] { ert }));
     
    719719
    720720        var values = pr.GroupBy(x => algorithmId2RunMapping.GetBySecond(x).Single())
    721                        .ToDictionary(x => x.Key, x => ExpectedRuntimeHelper.CalculateErt(x.ToList(), "QualityPerEvaluations", GetTarget(bkq, max), max).ExpectedRuntime);
     721                       .ToDictionary(x => x.Key, x => ExpectedRuntimeHelper.CalculateErt(x.ToList(), "QualityPerEvaluations", GetTarget(bkq, target, max), max).ExpectedRuntime);
    722722        var ranks = ClusteringHelper<long>.Cluster(nClasses, values, x => double.IsNaN(x.Value))
    723723          .GetByCluster().ToList();
    724         var minRank = ranks.Min(x => x.Key);
    725724        foreach (var c in ranks) {
    726725          foreach (var a in c.Value)
    727             result[problemMap[pr.Key]][a.Key] = c.Key == nClasses ? c.Key : c.Key - minRank;
     726            result[problemMap[pr.Key]][a.Key] = c.Key;
    728727        }
    729728      }
     
    731730    }
    732731
    733     public double GetTarget(double bestKnownQuality, bool maximization) {
    734       return bestKnownQuality * (maximization ? (1 - MinimumTarget.Value) : (1 + MinimumTarget.Value));
     732    public double GetTarget(double bestKnownQuality, double target, bool maximization) {
     733      return bestKnownQuality * (maximization ? (1 - target) : (1 + target));
    735734    }
    736735
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/OverallBestRecommender.cs

    r13794 r13797  
    6262          double bkq;
    6363          if (!pis.TryGetValue(problemRuns.Key, out bkq)) continue;
    64           var ert = ExpectedRuntimeHelper.CalculateErt(problemRuns.ToList(), "QualityPerEvaluations", kc.GetTarget(bkq, kc.Maximization), kc.Maximization).ExpectedRuntime;
     64          var ert = ExpectedRuntimeHelper.CalculateErt(problemRuns.ToList(), "QualityPerEvaluations", kc.GetTarget(bkq, kc.MinimumTarget.Value, kc.Maximization), kc.Maximization).ExpectedRuntime;
    6565          if (double.IsNaN(ert)) ert = int.MaxValue;
    6666          avgERT += ert;
Note: See TracChangeset for help on using the changeset viewer.