Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/14 23:29:50 (11 years ago)
Author:
bburlacu
Message:

#1837: Merged trunk changes.

Location:
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs

    r10396 r10429  
    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      PrunedSubtrees.Value = 0;
     102      PrunedTrees.Value = 0;
     103    }
     104    public override void ClearState() {
     105      base.ClearState();
     106      UpdateCounter.Value = 0;
     107      PrunedSubtrees.Value = 0;
     108      PrunedTrees.Value = 0;
     109    }
     110    #endregion
     111
    91112    [StorableConstructor]
    92113    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(bool deserializing) : base(deserializing) { }
     114    [StorableHook(HookType.AfterDeserialization)]
     115    private void AfterDeserialization() {
     116      if (!Parameters.ContainsKey(FitnessCalculationPartitionParameterName))
     117        Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, ""));
     118    }
    93119    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
    94120      : base(original, cloner) {
     
    110136      Parameters.Add(new FixedValueParameter<DoubleValue>(NodeImpactThresholdParameterName, new DoubleValue(0.0)));
    111137      Parameters.Add(new FixedValueParameter<BoolValue>(PruneOnlyZeroImpactNodesParameterName, new BoolValue(false)));
     138      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, ""));
    112139    }
    113140
     
    147174            Random = Random,
    148175            PruneOnlyZeroImpactNodes = PruneOnlyZeroImpactNodes.Value,
    149             NodeImpactThreshold = NodeImpactThreshold.Value
     176            NodeImpactThreshold = NodeImpactThreshold.Value,
     177            FitnessCalculationPartition = FitnessCalculationPartition
    150178          };
    151179          operations.Add(ExecutionContext.CreateChildOperation(op, ExecutionContext.Scope));
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs

    r10373 r10429  
    4949    private DoubleValue PrunedTrees { get { return NumberOfPrunedTreesParameter.ActualValue; } }
    5050    #endregion
     51
     52    [StorableConstructor]
     53    protected SymbolicDataAnalysisExpressionPruningOperator(bool deserializing) : base(deserializing) { }
    5154    public override IDeepCloneable Clone(Cloner cloner) {
    5255      return new SymbolicDataAnalysisExpressionPruningOperator(this, cloner);
    5356    }
    54     private SymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner)
     57    protected SymbolicDataAnalysisExpressionPruningOperator(SymbolicDataAnalysisExpressionPruningOperator original, Cloner cloner)
    5558      : base(original, cloner) {
    5659    }
     
    6467    public IDataAnalysisProblemData ProblemData { get; set; }
    6568    public ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactsCalculator { get; set; }
     69
     70    public IntRange FitnessCalculationPartition { get; set; }
    6671    public IRandom Random { get; set; }
    6772
     
    7378
    7479      var nodes = Model.SymbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList();
     80      var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size).ToList();
    7581
    7682      for (int j = 0; j < nodes.Count; ++j) {
     
    7884        if (node is ConstantTreeNode) continue;
    7985
    80         var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, ProblemData.TrainingIndices);
     86        var impact = ImpactsCalculator.CalculateImpactValue(Model, node, ProblemData, rows);
    8187
    8288        if (PruneOnlyZeroImpactNodes) {
     
    8692        }
    8793
    88         var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, ProblemData.TrainingIndices);
     94        var replacementValue = ImpactsCalculator.CalculateReplacementValue(Model, node, ProblemData, rows);
    8995        var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
    9096        ReplaceWithConstant(node, constantNode);
Note: See TracChangeset for help on using the changeset viewer.