Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12361


Ignore:
Timestamp:
04/29/15 15:19:58 (9 years ago)
Author:
bburlacu
Message:

#2359: The changes in r12358 look fine to me. Added total number of pruned nodes in the analyzer's data table. Removed unused parameter names in the SymbolicDataAnalysisSingleObjectivePruningAnalyzer.

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  
    4545    private const string TotalNumberOfPrunedSubtreesParameterName = "Number of pruned subtrees";
    4646    private const string TotalNumberOfPrunedTreesParameterName = "Number of pruned trees";
     47    private const string TotalNumberOfPrunedNodesParameterName = "Number of pruned nodes";
    4748    private const string RandomParameterName = "Random";
    48     private const string PruneOnlyZeroImpactNodesParameterName = "PruneOnlyZeroImpactNodes";
    49     private const string NodeImpactThresholdParameterName = "ImpactThreshold";
    50     private const string PruningOperatorParameterName = "PruningOperator";
    5149    private const string ResultsParameterName = "Results";
    5250    private const string PopulationSizeParameterName = "PopulationSize";
     
    5452
    5553    #region private members
     54    private DataReducer prunedNodesReducer;
    5655    private DataReducer prunedSubtreesReducer;
    5756    private DataReducer prunedTreesReducer;
     
    122121    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
    123122      : base(original, cloner) {
     123      if (original.prunedNodesReducer != null)
     124        this.prunedNodesReducer = (DataReducer)original.prunedNodesReducer.Clone();
    124125      if (original.prunedSubtreesReducer != null)
    125126        this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone();
     
    230231      UpdateCounter = 0;
    231232
    232       if (prunedSubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); }
     233      if (prunedNodesReducer == null || prunedSubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); }
    233234
    234235      var prune = CreatePruningOperation();
     236      var reducePrunedNodes = ExecutionContext.CreateChildOperation(prunedNodesReducer);
    235237      var reducePrunedSubtrees = ExecutionContext.CreateChildOperation(prunedSubtreesReducer);
    236238      var reducePrunedTrees = ExecutionContext.CreateChildOperation(prunedTreesReducer);
     
    238240      var collectResults = ExecutionContext.CreateChildOperation(resultsCollector);
    239241
    240       return new OperationCollection { prune, reducePrunedSubtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() };
     242      return new OperationCollection { prune, reducePrunedNodes, reducePrunedSubtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() };
    241243    }
    242244
    243245    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
    244252      prunedSubtreesReducer = new DataReducer();
    245253      prunedSubtreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedSubtreesParameter.ActualName;
     
    255263
    256264      valuesCollector = new DataTableValuesCollector();
     265      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedNodesParameterName));
    257266      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedSubtreesParameterName));
    258267      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedTreesParameterName));
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs

    r12359 r12361  
    4141    private const string PrunedSubtreesParameterName = "PrunedSubtrees";
    4242    private const string PrunedTreesParameterName = "PrunedTrees";
     43    private const string PrunedNodesParameterName = "PrunedNodes";
    4344    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    4445    private const string NodeImpactThresholdParameterName = "ImpactThreshold";
     
    7172    public ILookupParameter<IntValue> PrunedTreesParameter {
    7273      get { return (ILookupParameter<IntValue>)Parameters[PrunedTreesParameterName]; }
     74    }
     75    public ILookupParameter<IntValue> PrunedNodesParameter {
     76      get { return (ILookupParameter<IntValue>)Parameters[PrunedNodesParameterName]; }
    7377    }
    7478    public IFixedValueParameter<DoubleValue> NodeImpactThresholdParameter {
     
    111115      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisModel>(SymbolicDataAnalysisModelParameterName));
    112116      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName));
     117      Parameters.Add(new LookupParameter<IntValue>(PrunedNodesParameterName, "A counter of how many nodes were pruned."));
    113118      Parameters.Add(new LookupParameter<IntValue>(PrunedSubtreesParameterName, "A counter of how many subtrees were replaced."));
    114119      Parameters.Add(new LookupParameter<IntValue>(PrunedTreesParameterName, "A counter of how many trees were pruned."));
     
    139144      var prunedSubtrees = 0;
    140145      var prunedTrees = 0;
     146      var prunedNodes = 0;
    141147
    142148      double quality = Evaluate(model);
     
    155161        constantNode.Value = replacementValue;
    156162
     163        var length = node.GetLength();
    157164        ReplaceWithConstant(node, constantNode);
    158         i += node.GetLength() - 1; // skip subtrees under the node that was folded
     165        i += length - 1; // skip subtrees under the node that was folded
    159166
    160167        quality -= impactValue;
    161168        prunedSubtrees++;
     169        prunedNodes += length;
    162170      }
    163171
     
    165173      PrunedSubtreesParameter.ActualValue = new IntValue(prunedSubtrees);
    166174      PrunedTreesParameter.ActualValue = new IntValue(prunedTrees);
     175      PrunedNodesParameter.ActualValue = new IntValue(prunedNodes);
    167176      QualityParameter.ActualValue.Value = quality;
    168177
Note: See TracChangeset for help on using the changeset viewer.