Changeset 12361
- Timestamp:
- 04/29/15 15:19:58 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs
r12358 r12361 45 45 private const string TotalNumberOfPrunedSubtreesParameterName = "Number of pruned subtrees"; 46 46 private const string TotalNumberOfPrunedTreesParameterName = "Number of pruned trees"; 47 private const string TotalNumberOfPrunedNodesParameterName = "Number of pruned nodes"; 47 48 private const string RandomParameterName = "Random"; 48 private const string PruneOnlyZeroImpactNodesParameterName = "PruneOnlyZeroImpactNodes";49 private const string NodeImpactThresholdParameterName = "ImpactThreshold";50 private const string PruningOperatorParameterName = "PruningOperator";51 49 private const string ResultsParameterName = "Results"; 52 50 private const string PopulationSizeParameterName = "PopulationSize"; … … 54 52 55 53 #region private members 54 private DataReducer prunedNodesReducer; 56 55 private DataReducer prunedSubtreesReducer; 57 56 private DataReducer prunedTreesReducer; … … 122 121 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner) 123 122 : base(original, cloner) { 123 if (original.prunedNodesReducer != null) 124 this.prunedNodesReducer = (DataReducer)original.prunedNodesReducer.Clone(); 124 125 if (original.prunedSubtreesReducer != null) 125 126 this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone(); … … 230 231 UpdateCounter = 0; 231 232 232 if (pruned SubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); }233 if (prunedNodesReducer == null || prunedSubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); } 233 234 234 235 var prune = CreatePruningOperation(); 236 var reducePrunedNodes = ExecutionContext.CreateChildOperation(prunedNodesReducer); 235 237 var reducePrunedSubtrees = ExecutionContext.CreateChildOperation(prunedSubtreesReducer); 236 238 var reducePrunedTrees = ExecutionContext.CreateChildOperation(prunedTreesReducer); … … 238 240 var collectResults = ExecutionContext.CreateChildOperation(resultsCollector); 239 241 240 return new OperationCollection { prune, reducePruned Subtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() };242 return new OperationCollection { prune, reducePrunedNodes, reducePrunedSubtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() }; 241 243 } 242 244 243 245 private void InitializeOperators() { 246 prunedNodesReducer = new DataReducer(); 247 prunedNodesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedNodesParameter.ActualName; 248 prunedNodesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); // sum all the pruned subtrees parameter values 249 prunedNodesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter 250 prunedNodesReducer.TargetParameter.ActualName = TotalNumberOfPrunedNodesParameterName; 251 244 252 prunedSubtreesReducer = new DataReducer(); 245 253 prunedSubtreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedSubtreesParameter.ActualName; … … 255 263 256 264 valuesCollector = new DataTableValuesCollector(); 265 valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedNodesParameterName)); 257 266 valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedSubtreesParameterName)); 258 267 valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedTreesParameterName)); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs
r12359 r12361 41 41 private const string PrunedSubtreesParameterName = "PrunedSubtrees"; 42 42 private const string PrunedTreesParameterName = "PrunedTrees"; 43 private const string PrunedNodesParameterName = "PrunedNodes"; 43 44 private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition"; 44 45 private const string NodeImpactThresholdParameterName = "ImpactThreshold"; … … 71 72 public ILookupParameter<IntValue> PrunedTreesParameter { 72 73 get { return (ILookupParameter<IntValue>)Parameters[PrunedTreesParameterName]; } 74 } 75 public ILookupParameter<IntValue> PrunedNodesParameter { 76 get { return (ILookupParameter<IntValue>)Parameters[PrunedNodesParameterName]; } 73 77 } 74 78 public IFixedValueParameter<DoubleValue> NodeImpactThresholdParameter { … … 111 115 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisModel>(SymbolicDataAnalysisModelParameterName)); 112 116 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName)); 117 Parameters.Add(new LookupParameter<IntValue>(PrunedNodesParameterName, "A counter of how many nodes were pruned.")); 113 118 Parameters.Add(new LookupParameter<IntValue>(PrunedSubtreesParameterName, "A counter of how many subtrees were replaced.")); 114 119 Parameters.Add(new LookupParameter<IntValue>(PrunedTreesParameterName, "A counter of how many trees were pruned.")); … … 139 144 var prunedSubtrees = 0; 140 145 var prunedTrees = 0; 146 var prunedNodes = 0; 141 147 142 148 double quality = Evaluate(model); … … 155 161 constantNode.Value = replacementValue; 156 162 163 var length = node.GetLength(); 157 164 ReplaceWithConstant(node, constantNode); 158 i += node.GetLength()- 1; // skip subtrees under the node that was folded165 i += length - 1; // skip subtrees under the node that was folded 159 166 160 167 quality -= impactValue; 161 168 prunedSubtrees++; 169 prunedNodes += length; 162 170 } 163 171 … … 165 173 PrunedSubtreesParameter.ActualValue = new IntValue(prunedSubtrees); 166 174 PrunedTreesParameter.ActualValue = new IntValue(prunedTrees); 175 PrunedNodesParameter.ActualValue = new IntValue(prunedNodes); 167 176 QualityParameter.ActualValue.Value = quality; 168 177
Note: See TracChangeset
for help on using the changeset viewer.