Changeset 17920


Ignore:
Timestamp:
03/29/21 19:29:08 (2 weeks ago)
Author:
gkronber
Message:

#3115 cache calculations to improve speed when plotting multiple solutions in a partial dependence plot with factor variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs

    r17775 r17920  
    530530
    531531    public async Task AddSolutionAsync(IRegressionSolution solution) {
     532      if (solutions.Contains(solution))
     533        return;
    532534      if (!SolutionsCompatible(solutions.Concat(new[] { solution })))
    533535        throw new ArgumentException("The solution is not compatible with the problem data.");
    534       if (solutions.Contains(solution))
    535         return;
    536536
    537537      solutions.Add(solution);
     
    568568      var refSolution = solutions.First();
    569569      var refSolVars = refSolution.ProblemData.Dataset.VariableNames;
     570      var refFactorVars = refSolVars.Where(refSolution.ProblemData.Dataset.VariableHasType<string>);
     571      var distinctVals = refFactorVars.ToDictionary(fv => fv, fv => refSolution.ProblemData.Dataset.GetStringValues(fv).Distinct().ToArray());
    570572      foreach (var solution in solutions.Skip(1)) {
    571573        var variables1 = solution.ProblemData.Dataset.VariableNames;
     
    574576
    575577        foreach (var factorVar in variables1.Where(solution.ProblemData.Dataset.VariableHasType<string>)) {
    576           var distinctVals = refSolution.ProblemData.Dataset.GetStringValues(factorVar).Distinct();
    577           if (solution.ProblemData.Dataset.GetStringValues(factorVar).Any(val => !distinctVals.Contains(val))) return false;
     578          var refValues = distinctVals[factorVar];
     579          if (solution.ProblemData.Dataset.GetStringValues(factorVar).Distinct().Any(val => !refValues.Contains(val))) return false;
    578580        }
    579581      }
Note: See TracChangeset for help on using the changeset viewer.