Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/29/15 11:56:50 (10 years ago)
Author:
mkommend
Message:

#2359: Refactored pruning operators and analyzers.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningAnalyzer.cs

    r12189 r12358  
    3131  [StorableClass]
    3232  public sealed class SymbolicRegressionPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
    33     private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
    3433    private const string PruningOperatorParameterName = "PruningOperator";
    35     private SymbolicRegressionPruningAnalyzer(SymbolicRegressionPruningAnalyzer original, Cloner cloner)
    36       : base(original, cloner) {
     34    public IValueParameter<SymbolicRegressionPruningOperator> PruningOperatorParameter {
     35      get { return (IValueParameter<SymbolicRegressionPruningOperator>)Parameters[PruningOperatorParameterName]; }
    3736    }
    38     public override IDeepCloneable Clone(Cloner cloner) {
    39       return new SymbolicRegressionPruningAnalyzer(this, cloner);
     37
     38    protected override SymbolicDataAnalysisExpressionPruningOperator PruningOperator {
     39      get { return PruningOperatorParameter.Value; }
    4040    }
     41
     42    private SymbolicRegressionPruningAnalyzer(SymbolicRegressionPruningAnalyzer original, Cloner cloner) : base(original, cloner) { }
     43    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionPruningAnalyzer(this, cloner); }
    4144
    4245    [StorableConstructor]
     
    4447
    4548    public SymbolicRegressionPruningAnalyzer() {
    46       Parameters.Add(new ValueParameter<SymbolicDataAnalysisSolutionImpactValuesCalculator>(ImpactValuesCalculatorParameterName, "The impact values calculator", new SymbolicRegressionSolutionImpactValuesCalculator()));
    47       Parameters.Add(new ValueParameter<SymbolicDataAnalysisExpressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicRegressionPruningOperator(new SymbolicRegressionSolutionImpactValuesCalculator())));
     49      Parameters.Add(new ValueParameter<SymbolicRegressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicRegressionPruningOperator(new SymbolicRegressionSolutionImpactValuesCalculator())));
    4850    }
    4951  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs

    r12189 r12358  
    5353    protected override double Evaluate(IDataAnalysisModel model) {
    5454      var regressionModel = (IRegressionModel)model;
    55       var regressionProblemData = (IRegressionProblemData)ProblemData;
    56       var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
     55      var regressionProblemData = (IRegressionProblemData)ProblemDataParameter.ActualValue;
     56      var rows = Enumerable.Range(FitnessCalculationPartitionParameter.ActualValue.Start, FitnessCalculationPartitionParameter.ActualValue.Size);
    5757      return Evaluate(regressionModel, regressionProblemData, rows);
    5858    }
     
    8181        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, quality);
    8282
    83         if (pruneOnlyZeroImpactNodes) {
    84           if (!impactValue.IsAlmost(0.0)) continue;
    85         } else if (nodeImpactThreshold < impactValue) {
    86           continue;
    87         }
     83        if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
     84        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    8885
    8986        var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
Note: See TracChangeset for help on using the changeset viewer.