- Timestamp:
- 09/09/11 10:45:50 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r6503 r6728 70 70 71 71 protected override Allele[] CalculateAlleles(ISymbolicExpressionTree solution) { 72 List<Allele> alleles = new List<Allele>(); 73 74 foreach (var subtree in GetAllSubtreesOfDepth(solution, AlleleTreeDepth)) { 75 alleles.Add(GetAlleleFromSubtreeOfDepth(subtree, AlleleTreeDepth)); 76 } 77 return alleles.ToArray(); 72 return GetAllSubtreesOfDepth(solution, AlleleTreeDepth) 73 .AsParallel() 74 .Select(t => GetAlleleFromSubtreeOfDepth(t, AlleleTreeDepth)) 75 .ToArray(); 78 76 } 79 77 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6728 93 93 IList<int> nonDominatedIndexes = new List<int>(); 94 94 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 95 List<double[]> qualities = new List<double[]>();96 95 bool[] maximization = Maximization.ToArray(); 97 96 List<double[]> newNonDominatedQualities = new List<double[]>(); 98 97 var evaluator = EvaluatorParameter.ActualValue; 98 var problemData = ProblemDataParameter.ActualValue; 99 99 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 100 101 var qualities = tree 102 .AsParallel() 103 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 104 .ToArray(); 100 105 for (int i = 0; i < tree.Length; i++) { 101 qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows)); // qualities[i] = ...102 106 if (IsNonDominated(qualities[i], trainingBestQualities, maximization) && 103 107 IsNonDominated(qualities[i], qualities, maximization)) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6728 76 76 ISymbolicExpressionTree bestTree = null; 77 77 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 78 double[] quality = new double[tree.Length];79 78 var evaluator = EvaluatorParameter.ActualValue; 79 var problemData = ProblemDataParameter.ActualValue; 80 80 IEnumerable<int> rows = GenerateRowsToEvaluate(); 81 81 if (!rows.Any()) return base.Apply(); 82 82 83 83 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 84 var quality = tree 85 .AsParallel() 86 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 87 .ToArray(); 88 84 89 for (int i = 0; i < tree.Length; i++) { 85 quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows);86 90 if (IsBetter(quality[i], bestQuality, Maximization.Value)) { 87 91 bestQuality = quality[i]; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r6709 r6728 131 131 132 132 public static IEnumerable<KeyValuePair<string, double>> CalculateVariableFrequencies(IEnumerable<ISymbolicExpressionTree> trees, bool aggregateLaggedVariables = true) { 133 Dictionary<string, double> variableFrequencies = new Dictionary<string, double>(); 134 int totalNumberOfSymbols = 0; 135 136 foreach (var tree in trees) { 137 var variableReferences = GetVariableReferences(tree, aggregateLaggedVariables); 138 foreach (var pair in variableReferences) { 139 totalNumberOfSymbols += pair.Value; 140 if (variableFrequencies.ContainsKey(pair.Key)) { 141 variableFrequencies[pair.Key] += pair.Value; 142 } else { 143 variableFrequencies.Add(pair.Key, pair.Value); 144 } 145 } 146 } 133 134 var variableFrequencies = trees 135 .AsParallel() 136 .SelectMany(t => GetVariableReferences(t, aggregateLaggedVariables)) 137 .GroupBy(pair => pair.Key, pair => pair.Value) 138 .ToDictionary(g => g.Key, g => (double)g.Sum()); 139 140 double totalNumberOfSymbols = variableFrequencies.Values.Sum(); 147 141 148 142 foreach (var pair in variableFrequencies)
Note: See TracChangeset
for help on using the changeset viewer.