Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/10 19:02:45 (15 years ago)
Author:
gkronber
Message:

Adapted analyzers to use ScopeTreeLookupParameter and wire the depth setting correctly for

  • SymbolicExpressionTreeEncoding
  • ArtificialAntProblem
  • SymbolicRegression

#999

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
Files:
3 deleted
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAvgMaxSymbolicExpressionTreeSizeAnalyzer.cs

    r3665 r3681  
    3232using HeuristicLab.Analysis;
    3333using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
     34using System;
    3435
    3536namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers {
    3637  /// <summary>
    37   /// An operator that tracks the min avgerage and max tree size in the population.
     38  /// An operator that tracks the min avgerage and max tree size.
    3839  /// </summary>
    39   [Item("PopulationMinAvgMaxTreeSizeAnalyzer", "An operator that tracks the min avgerage and max tree size in the population.")]
     40  [Item("MinAvgMaxSymbolicExpressionTreeSizeAnalyzer", "An operator that tracks the min avgerage and max tree size.")]
    4041  [StorableClass]
    41   public sealed class PopulationMinAvgMaxTreeSizeAnalyzer : AlgorithmOperator, ISymbolicExpressionTreePopulationAnalyzer {
     42  public sealed class MinAvgMaxSymbolicExpressionTreeSizeAnalyzer : AlgorithmOperator, ISymbolicExpressionTreeAnalyzer {
    4243    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    4344    private const string SymbolicExpressionTreeSizeParameterName = "SymbolicExpressionTreeSize";
     
    4546    private const string ResultsParameterName = "Results";
    4647
    47 
    4848    #region parameter properties
    49     public ILookupParameter<ItemArray<SymbolicExpressionTree>> SymbolicExpressionTreeParameter {
    50       get { return (ILookupParameter<ItemArray<SymbolicExpressionTree>>)Parameters[SymbolicExpressionTreeParameterName]; }
     49    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     50      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    5151    }
    52     public ILookupParameter<ItemArray<DoubleValue>> SymbolicExpressionTreeSizeParameter {
    53       get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
     52    public ScopeTreeLookupParameter<DoubleValue> SymbolicExpressionTreeSizeParameter {
     53      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
    5454    }
    5555    public ValueLookupParameter<DataTable> SymbolicExpressionTreeSizesParameter {
     
    5959      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
    6060    }
     61   
     62    [Storable]
     63    private MinAverageMaxValueAnalyzer valueAnalyzer;
     64
    6165    #endregion
    62     public PopulationMinAvgMaxTreeSizeAnalyzer()
     66    public MinAvgMaxSymbolicExpressionTreeSizeAnalyzer()
    6367      : base() {
    6468      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose size should be calculated."));
     
    6973      UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor();
    7074      SymbolicExpressionTreeSizeCalculator sizeCalculator = new SymbolicExpressionTreeSizeCalculator();
    71       MinAverageMaxValueAnalyzer valuesAnalyzer = new MinAverageMaxValueAnalyzer();
     75      valueAnalyzer = new MinAverageMaxValueAnalyzer();
    7276      sizeCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
    7377      sizeCalculator.SymbolicExpressionTreeSizeParameter.ActualName = SymbolicExpressionTreeSizeParameter.Name;
    74       valuesAnalyzer.ValueParameter.ActualName = sizeCalculator.SymbolicExpressionTreeSizeParameter.Name;
    75       valuesAnalyzer.ValuesParameter.ActualName = SymbolicExpressionTreeSizesParameter.Name;
    76       valuesAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
    77       valuesAnalyzer.AverageValueParameter.ActualName = "Avg. Tree Size";
    78       valuesAnalyzer.MaxValueParameter.ActualName = "Max Tree Size";
    79       valuesAnalyzer.MinValueParameter.ActualName = "Min Tree Size";
     78      valueAnalyzer.ValueParameter.ActualName = sizeCalculator.SymbolicExpressionTreeSizeParameter.Name;
     79      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
     80      valueAnalyzer.ValuesParameter.ActualName = SymbolicExpressionTreeSizesParameter.Name;
     81      valueAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     82      valueAnalyzer.AverageValueParameter.ActualName = "Avg. Tree Size";
     83      valueAnalyzer.MaxValueParameter.ActualName = "Max Tree Size";
     84      valueAnalyzer.MinValueParameter.ActualName = "Min Tree Size";
    8085
    8186      OperatorGraph.InitialOperator = subScopesProcessor;
    8287      subScopesProcessor.Operator = sizeCalculator;
    83       subScopesProcessor.Successor = valuesAnalyzer;
    84       valuesAnalyzer.Successor = null;
     88      subScopesProcessor.Successor = valueAnalyzer;
     89      valueAnalyzer.Successor = null;
     90
     91      Initialize();
     92    }
     93
     94    [StorableConstructor]
     95    private MinAvgMaxSymbolicExpressionTreeSizeAnalyzer(bool deserializing) : base() { }
     96
     97    [StorableHook(HookType.AfterDeserialization)]
     98    private void Initialize() {
     99      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
     100    }
     101
     102    public override IDeepCloneable Clone(Cloner cloner) {
     103      MinAvgMaxSymbolicExpressionTreeSizeAnalyzer clone = (MinAvgMaxSymbolicExpressionTreeSizeAnalyzer)base.Clone(cloner);
     104      clone.Initialize();
     105      return clone;
     106    }
     107
     108    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
     109      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    85110    }
    86111  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj

    r3651 r3681  
    8383  </ItemGroup>
    8484  <ItemGroup>
    85     <Compile Include="Analyzers\PopulationMinAvgMaxTreeSizeAnalyzer.cs" />
    86     <Compile Include="Analyzers\SymbolicExpressionTreeSizeAnalyzer.cs" />
     85    <Compile Include="Analyzers\MinAvgMaxSymbolicExpressionTreeSizeAnalyzer.cs" />
    8786    <Compile Include="Analyzers\SymbolicExpressionTreeSizeCalculator.cs" />
    8887    <Compile Include="ArchitectureManipulators\ArgumentCreater.cs" />
     
    103102    <Compile Include="Interfaces\ISymbolicExpressionTreeCreator.cs" />
    104103    <Compile Include="Interfaces\ISymbolicExpressionTreeCrossover.cs" />
    105     <Compile Include="Interfaces\ISymbolicExpressionTreeMultiPopulationAnalyzer.cs" />
    106     <Compile Include="Interfaces\ISymbolicExpressionTreePopulationAnalyzer.cs" />
    107104    <Compile Include="Manipulators\ChangeNodeTypeManipulation.cs" />
    108105    <Compile Include="Interfaces\ISymbolicExpressionTreeManipulator.cs" />
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Interfaces/ISymbolicExpressionTreeAnalyzer.cs

    r3658 r3681  
    3535  /// </summary>
    3636  public interface ISymbolicExpressionTreeAnalyzer : IAnalyzer {
    37     ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
     37    ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3838  }
    3939}
Note: See TracChangeset for help on using the changeset viewer.