Changeset 12720 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs
- Timestamp:
- 07/10/15 15:41:09 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs
r12361 r12720 49 49 private const string EstimationLimitsParameterName = "EstimationLimits"; 50 50 private const string InterpreterParameterName = "SymbolicExpressionTreeInterpreter"; 51 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 51 52 #endregion 52 53 … … 88 89 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[InterpreterParameterName]; } 89 90 } 91 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 92 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 93 } 90 94 #endregion 91 95 … … 124 128 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName)); 125 129 Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName)); 130 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName)); 126 131 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisSolutionImpactValuesCalculator>(ImpactValuesCalculatorParameterName, impactValuesCalculator)); 127 132 #endregion … … 141 146 var model = CreateModel(tree, interpreter, problemData, estimationLimits); 142 147 var nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList(); 143 var rows = Enumerable.Range(fitnessCalculationPartition.Start, fitnessCalculationPartition.Size) ;148 var rows = Enumerable.Range(fitnessCalculationPartition.Start, fitnessCalculationPartition.Size).ToList(); 144 149 var prunedSubtrees = 0; 145 150 var prunedTrees = 0; 146 151 var prunedNodes = 0; 147 152 148 double quality = Evaluate(model);153 double qualityForImpactsCalculation = double.NaN; 149 154 150 155 for (int i = 0; i < nodes.Count; ++i) { … … 153 158 154 159 double impactValue, replacementValue; 155 ImpactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, quality); 160 double newQualityForImpacts; 161 ImpactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, out newQualityForImpacts, qualityForImpactsCalculation); 156 162 157 163 if (PruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue; … … 165 171 i += length - 1; // skip subtrees under the node that was folded 166 172 167 quality -= impactValue;168 173 prunedSubtrees++; 169 174 prunedNodes += length; 175 176 qualityForImpactsCalculation = newQualityForImpacts; 170 177 } 171 178 … … 174 181 PrunedTreesParameter.ActualValue = new IntValue(prunedTrees); 175 182 PrunedNodesParameter.ActualValue = new IntValue(prunedNodes); 176 QualityParameter.ActualValue.Value = quality; 183 184 if (prunedSubtrees > 0) // if nothing was pruned then there's no need to re-evaluate the tree 185 QualityParameter.ActualValue.Value = Evaluate(model); 177 186 178 187 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.