Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/10 20:27:08 (15 years ago)
Author:
gkronber
Message:

Added 'special treatment' of operators that use LookupParameters instead of ScopeTreeLookupParameters contained in analyzers. #999

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers
Files:
2 edited

Legend:

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

    r3681 r3683  
    6262    [Storable]
    6363    private MinAverageMaxValueAnalyzer valueAnalyzer;
     64    [Storable]
     65    private SymbolicExpressionTreeSizeCalculator sizeCalculator;
    6466
    6567    #endregion
     
    7173      Parameters.Add(new ValueLookupParameter<VariableCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    7274
    73       UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor();
    74       SymbolicExpressionTreeSizeCalculator sizeCalculator = new SymbolicExpressionTreeSizeCalculator();
     75      sizeCalculator = new SymbolicExpressionTreeSizeCalculator();
    7576      valueAnalyzer = new MinAverageMaxValueAnalyzer();
    7677      sizeCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
     78      sizeCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    7779      sizeCalculator.SymbolicExpressionTreeSizeParameter.ActualName = SymbolicExpressionTreeSizeParameter.Name;
     80      sizeCalculator.SymbolicExpressionTreeSizeParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
    7881      valueAnalyzer.ValueParameter.ActualName = sizeCalculator.SymbolicExpressionTreeSizeParameter.Name;
    7982      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
     
    8487      valueAnalyzer.MinValueParameter.ActualName = "Min Tree Size";
    8588
    86       OperatorGraph.InitialOperator = subScopesProcessor;
    87       subScopesProcessor.Operator = sizeCalculator;
    88       subScopesProcessor.Successor = valueAnalyzer;
     89      OperatorGraph.InitialOperator = sizeCalculator;
     90      sizeCalculator.Successor = valueAnalyzer;
    8991      valueAnalyzer.Successor = null;
    9092
     
    98100    private void Initialize() {
    99101      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
     102      SymbolicExpressionTreeSizeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeSizeParameter_DepthChanged);
    100103    }
    101104
     
    107110
    108111    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
     112      OnDepthParameterChanged();
     113    }
     114
     115    private void SymbolicExpressionTreeSizeParameter_DepthChanged(object sender, EventArgs e) {
     116      OnDepthParameterChanged();
     117    }
     118
     119    private void OnDepthParameterChanged() {
    109120      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     121      sizeCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     122      sizeCalculator.SymbolicExpressionTreeSizeParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
    110123    }
    111124  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/SymbolicExpressionTreeSizeCalculator.cs

    r3651 r3683  
    4242
    4343    #region parameter properties
    44     public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    45       get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     44    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     45      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    4646    }
    47     public ILookupParameter<DoubleValue> SymbolicExpressionTreeSizeParameter {
    48       get { return (ILookupParameter<DoubleValue>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
     47    public ScopeTreeLookupParameter<DoubleValue> SymbolicExpressionTreeSizeParameter {
     48      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
    4949    }
    5050    #endregion
    5151
    5252    #region properties
    53     public SymbolicExpressionTree SymbolicExpressionTree {
    54       get { return SymbolicExpressionTreeParameter.ActualValue;}
     53    public ItemArray<SymbolicExpressionTree> SymbolicExpressionTree {
     54      get { return SymbolicExpressionTreeParameter.ActualValue; }
    5555    }
    56     public DoubleValue SymbolicExpressionTreeSize {
    57       get { return SymbolicExpressionTreeSizeParameter.ActualValue;}
    58       set { SymbolicExpressionTreeSizeParameter.ActualValue = value;}
     56    public ItemArray<DoubleValue> SymbolicExpressionTreeSize {
     57      get { return SymbolicExpressionTreeSizeParameter.ActualValue; }
     58      set { SymbolicExpressionTreeSizeParameter.ActualValue = value; }
    5959    }
    6060    #endregion
     
    6262    public SymbolicExpressionTreeSizeCalculator()
    6363      : base() {
    64       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose size should be calculated."));
    65       Parameters.Add(new LookupParameter<DoubleValue>(SymbolicExpressionTreeSizeParameterName, "The tree size of the symbolic expression tree."));
     64      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose size should be calculated."));
     65      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(SymbolicExpressionTreeSizeParameterName, "The tree size of the symbolic expression tree."));
    6666    }
    6767
    6868    public override IOperation Apply() {
    69       SymbolicExpressionTreeSize = new DoubleValue(SymbolicExpressionTree.Size);
     69      ItemArray<SymbolicExpressionTree> trees = SymbolicExpressionTree;
     70      SymbolicExpressionTreeSize = new ItemArray<DoubleValue>(from tree in trees
     71                                                              select new DoubleValue(tree.Size));
    7072      return base.Apply();
    7173    }
Note: See TracChangeset for help on using the changeset viewer.