Changeset 6760 for branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Timestamp:
- 09/14/11 13:59:25 (13 years ago)
- Location:
- branches/PersistenceSpeedUp
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r6135 r6760 20 20 #endregion 21 21 22 using System ;22 using System.Collections.Generic; 23 23 using System.Linq; 24 using System.Text; 24 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 30 using HeuristicLab.Parameters; 29 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using System.Collections.Generic;31 using System.Text;32 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;33 32 34 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 47 46 } 48 47 49 public I ValueParameter<IntValue> AlleleTreeDepthParameter {48 public IFixedValueParameter<IntValue> AlleleTreeDepthParameter { 50 49 get { return (IFixedValueParameter<IntValue>)Parameters[AlleleTreeDepthParameterName]; } 51 50 } … … 71 70 72 71 protected override Allele[] CalculateAlleles(ISymbolicExpressionTree solution) { 73 List<Allele> alleles = new List<Allele>(); 74 75 foreach (var subtree in GetAllSubtreesOfDepth(solution, AlleleTreeDepth)) { 76 alleles.Add(GetAlleleFromSubtreeOfDepth(subtree, AlleleTreeDepth)); 77 } 78 return alleles.ToArray(); 72 return GetAllSubtreesOfDepth(solution, AlleleTreeDepth) 73 .AsParallel() 74 .Select(t => GetAlleleFromSubtreeOfDepth(t, AlleleTreeDepth)) 75 .ToArray(); 79 76 } 80 77 -
branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6760 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)) { -
branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6760 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]; -
branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r5924 r6760 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 104 105 datatable.Rows.Add(row); 105 106 } 106 datatable.Rows[pair.Key].Values.Add( pair.Value);107 datatable.Rows[pair.Key].Values.Add(Math.Round(pair.Value, 3)); 107 108 } 108 109 … … 130 131 131 132 public static IEnumerable<KeyValuePair<string, double>> CalculateVariableFrequencies(IEnumerable<ISymbolicExpressionTree> trees, bool aggregateLaggedVariables = true) { 132 Dictionary<string, double> variableFrequencies = new Dictionary<string, double>(); 133 int totalNumberOfSymbols = 0; 134 135 foreach (var tree in trees) { 136 var variableReferences = GetVariableReferences(tree, aggregateLaggedVariables); 137 foreach (var pair in variableReferences) { 138 totalNumberOfSymbols += pair.Value; 139 if (variableFrequencies.ContainsKey(pair.Key)) { 140 variableFrequencies[pair.Key] += pair.Value; 141 } else { 142 variableFrequencies.Add(pair.Key, pair.Value); 143 } 144 } 145 } 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(); 146 141 147 142 foreach (var pair in variableFrequencies)
Note: See TracChangeset
for help on using the changeset viewer.