Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10414 for trunk/sources


Ignore:
Timestamp:
01/28/14 19:18:25 (11 years ago)
Author:
bburlacu
Message:

#2143: Modified the pruning operator and analyzer to use the FitnessCalculationPartition for impact and replacement values calculation, instead of the whole training data partition.

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  
    3232    private const string NodeImpactThresholdParameterName = "ImpactThreshold";
    3333
     34    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
     35
    3436    private bool reentry;
    3537    [Storable]
     
    5254      get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
    5355    }
     56    public ILookupParameter<IntRange> FitnessCalculationPartitionParameter {
     57      get { return (ILookupParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; }
     58    }
    5459    private ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> InterpreterParameter {
    5560      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[InterpreterParameterName]; }
     
    7681    #region properties
    7782    protected IDataAnalysisProblemData ProblemData { get { return ProblemDataParameter.ActualValue; } }
     83    protected IntRange FitnessCalculationPartition { get { return FitnessCalculationPartitionParameter.ActualValue; } }
    7884    protected ISymbolicDataAnalysisExpressionTreeInterpreter Interpreter { get { return InterpreterParameter.ActualValue; } }
    7985    protected IntValue UpdateInterval { get { return UpdateIntervalParameter.Value; } }
     
    8995    #endregion
    9096
     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
    91108    [StorableConstructor]
    92109    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    }
    93115    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
    94116      : base(original, cloner) {
     
    110132      Parameters.Add(new FixedValueParameter<DoubleValue>(NodeImpactThresholdParameterName, new DoubleValue(0.0)));
    111133      Parameters.Add(new FixedValueParameter<BoolValue>(PruneOnlyZeroImpactNodesParameterName, new BoolValue(false)));
     134      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, ""));
    112135    }
    113136
     
    147170            Random = Random,
    148171            PruneOnlyZeroImpactNodes = PruneOnlyZeroImpactNodes.Value,
    149             NodeImpactThreshold = NodeImpactThreshold.Value
     172            NodeImpactThreshold = NodeImpactThreshold.Value,
     173            FitnessCalculationPartition = FitnessCalculationPartition
    150174          };
    151175          operations.Add(ExecutionContext.CreateChildOperation(op, ExecutionContext.Scope));
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs

    r10378 r10414  
    4949    private DoubleValue PrunedTrees { get { return NumberOfPrunedTreesParameter.ActualValue; } }
    5050    #endregion
    51 
    52     [StorableConstructor]
    53     protected SymbolicDataAnalysisExpressionPruningOperator(bool deserializing) : base(deserializing) { }
    5451    public override IDeepCloneable Clone(Cloner cloner) {
    5552      return new SymbolicDataAnalysisExpressionPruningOperator(this, cloner);
    5653    }
    57     protected SymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner)
     54    private SymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner)
    5855      : base(original, cloner) {
    5956    }
     
    6764    public IDataAnalysisProblemData ProblemData { get; set; }
    6865    public ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactsCalculator { get; set; }
     66
     67    public IntRange FitnessCalculationPartition { get; set; }
    6968    public IRandom Random { get; set; }
    7069
     
    7675
    7776      var nodes = Model.SymbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList();
     77      var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size).ToList();
    7878
    7979      for (int j = 0; j < nodes.Count; ++j) {
     
    8181        if (node is ConstantTreeNode) continue;
    8282
    83         var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, ProblemData.TrainingIndices);
     83        var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, rows);
    8484
    8585        if (PruneOnlyZeroImpactNodes) {
     
    8989        }
    9090
    91         var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, ProblemData.TrainingIndices);
     91        var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, rows);
    9292        var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
    9393        ReplaceWithConstant(node, constantNode);
Note: See TracChangeset for help on using the changeset viewer.