Changeset 10414
- Timestamp:
- 01/28/14 19:18:25 (11 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
r10378 r10414 32 32 private const string NodeImpactThresholdParameterName = "ImpactThreshold"; 33 33 34 private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition"; 35 34 36 private bool reentry; 35 37 [Storable] … … 52 54 get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; } 53 55 } 56 public ILookupParameter<IntRange> FitnessCalculationPartitionParameter { 57 get { return (ILookupParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; } 58 } 54 59 private ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> InterpreterParameter { 55 60 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[InterpreterParameterName]; } … … 76 81 #region properties 77 82 protected IDataAnalysisProblemData ProblemData { get { return ProblemDataParameter.ActualValue; } } 83 protected IntRange FitnessCalculationPartition { get { return FitnessCalculationPartitionParameter.ActualValue; } } 78 84 protected ISymbolicDataAnalysisExpressionTreeInterpreter Interpreter { get { return InterpreterParameter.ActualValue; } } 79 85 protected IntValue UpdateInterval { get { return UpdateIntervalParameter.Value; } } … … 89 95 #endregion 90 96 97 #region IStatefulItem members 98 public override void InitializeState() { 99 base.InitializeState(); 100 UpdateCounter.Value = 0; 101 } 102 public override void ClearState() { 103 base.ClearState(); 104 UpdateCounter.Value = 0; 105 } 106 #endregion 107 91 108 [StorableConstructor] 92 109 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(bool deserializing) : base(deserializing) { } 110 [StorableHook(HookType.AfterDeserialization)] 111 private void AfterDeserialization() { 112 if (!Parameters.ContainsKey(FitnessCalculationPartitionParameterName)) 113 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "")); 114 } 93 115 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner) 94 116 : base(original, cloner) { … … 110 132 Parameters.Add(new FixedValueParameter<DoubleValue>(NodeImpactThresholdParameterName, new DoubleValue(0.0))); 111 133 Parameters.Add(new FixedValueParameter<BoolValue>(PruneOnlyZeroImpactNodesParameterName, new BoolValue(false))); 134 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "")); 112 135 } 113 136 … … 147 170 Random = Random, 148 171 PruneOnlyZeroImpactNodes = PruneOnlyZeroImpactNodes.Value, 149 NodeImpactThreshold = NodeImpactThreshold.Value 172 NodeImpactThreshold = NodeImpactThreshold.Value, 173 FitnessCalculationPartition = FitnessCalculationPartition 150 174 }; 151 175 operations.Add(ExecutionContext.CreateChildOperation(op, ExecutionContext.Scope)); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs
r10378 r10414 49 49 private DoubleValue PrunedTrees { get { return NumberOfPrunedTreesParameter.ActualValue; } } 50 50 #endregion 51 52 [StorableConstructor]53 protected SymbolicDataAnalysisExpressionPruningOperator(bool deserializing) : base(deserializing) { }54 51 public override IDeepCloneable Clone(Cloner cloner) { 55 52 return new SymbolicDataAnalysisExpressionPruningOperator(this, cloner); 56 53 } 57 pr otectedSymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner)54 private SymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner) 58 55 : base(original, cloner) { 59 56 } … … 67 64 public IDataAnalysisProblemData ProblemData { get; set; } 68 65 public ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactsCalculator { get; set; } 66 67 public IntRange FitnessCalculationPartition { get; set; } 69 68 public IRandom Random { get; set; } 70 69 … … 76 75 77 76 var nodes = Model.SymbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList(); 77 var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size).ToList(); 78 78 79 79 for (int j = 0; j < nodes.Count; ++j) { … … 81 81 if (node is ConstantTreeNode) continue; 82 82 83 var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, ProblemData.TrainingIndices);83 var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, rows); 84 84 85 85 if (PruneOnlyZeroImpactNodes) { … … 89 89 } 90 90 91 var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, ProblemData.TrainingIndices);91 var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, rows); 92 92 var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue }; 93 93 ReplaceWithConstant(node, constantNode);
Note: See TracChangeset
for help on using the changeset viewer.