Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5510


Ignore:
Timestamp:
02/17/11 13:51:04 (13 years ago)
Author:
gkronber
Message:

#1418 Fixed compiler errors in symbolic expression tree encoding

Location:
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeLengthAnalyzer.cs

    r5499 r5510  
    4545
    4646    #region parameter properties
    47     public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    48       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     47    public IScopeTreeLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
     48      get { return (IScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    4949    }
    5050    public ScopeTreeLookupParameter<DoubleValue> SymbolicExpressionTreeLengthParameter {
     
    7373    public MinAverageMaxSymbolicExpressionTreeLengthAnalyzer()
    7474      : base() {
    75       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose length should be calculated."));
     75      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose length should be calculated."));
    7676      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(SymbolicExpressionTreeLengthParameterName, "The length of the symbolic expression tree."));
    7777      Parameters.Add(new ValueLookupParameter<DataTable>(SymbolicExpressionTreeLengthsParameterName, "The data table to store the symbolic expression tree lengths."));
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs

    r5499 r5510  
    4242
    4343    #region parameter properties
    44     public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    45       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     44    public IScopeTreeLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
     45      get { return (IScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    4646    }
    4747    public ILookupParameter<DataTable> SymbolFrequenciesParameter {
     
    6464    public SymbolicExpressionSymbolFrequencyAnalyzer()
    6565      : base() {
    66       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
     66      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
    6767      Parameters.Add(new ValueLookupParameter<DataTable>(SymbolFrequenciesParameterName, "The data table to store the symbol frequencies."));
    6868      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the symbol frequencies should be stored."));
     
    7373
    7474    public override IOperation Apply() {
    75       ItemArray<SymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue;
     75      ItemArray<ISymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue;
    7676      ResultCollection results = ResultsParameter.ActualValue;
    7777
     
    102102    }
    103103
    104     public static IEnumerable<KeyValuePair<string, double>> CalculateSymbolFrequencies(IEnumerable<SymbolicExpressionTree> trees) {
     104    public static IEnumerable<KeyValuePair<string, double>> CalculateSymbolFrequencies(IEnumerable<ISymbolicExpressionTree> trees) {
    105105      Dictionary<string, double> symbolFrequencies = new Dictionary<string, double>();
    106106      int totalNumberOfSymbols = 0;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r5499 r5510  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Parameters;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    3334  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 106
    3435  /// </summary>
    35   [Item("ArgumentCreater", "Manipulates a symbolic expression by creating a new argument within one function-defining branch.")]
     36  [Item("ArgumentCreater", "Manipulates a symbolic expression by creating a new argument within one function-defining branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 106")]
    3637  [StorableClass]
    37   public sealed class ArgumentCreater : SymbolicExpressionTreeArchitectureManipulator {
     38  public sealed class ArgumentCreater : SymbolicExpressionTreeArchitectureManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
     39    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     40    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
     41    #region Parameter Properties
     42    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     43      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     44    }
     45    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
     46      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     47    }
     48    #endregion
     49    #region Properties
     50    public IntValue MaximumSymbolicExpressionTreeLength {
     51      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     52    }
     53    public IntValue MaximumSymbolicExpressionTreeDepth {
     54      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     55    }
     56    #endregion
    3857    [StorableConstructor]
    3958    private ArgumentCreater(bool deserializing) : base(deserializing) { }
    4059    private ArgumentCreater(ArgumentCreater original, Cloner cloner) : base(original, cloner) { }
    41     public ArgumentCreater() : base() { }
     60    public ArgumentCreater()
     61      : base() {
     62      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
     63      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     64    }
     65
    4266    public override sealed void ModifyArchitecture(
    4367      IRandom random,
    44       SymbolicExpressionTree symbolicExpressionTree,
    45       ISymbolicExpressionGrammar grammar,
    46       IntValue maxTreeSize, IntValue maxTreeHeight,
    47       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    48       out bool success) {
    49       success = CreateNewArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     68      ISymbolicExpressionTree symbolicExpressionTree,
     69      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     70      CreateNewArgument(random, symbolicExpressionTree, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    5071    }
    5172
     
    5677    public static bool CreateNewArgument(
    5778      IRandom random,
    58       SymbolicExpressionTree symbolicExpressionTree,
    59       ISymbolicExpressionGrammar grammar,
    60       int maxTreeSize, int maxTreeHeight,
    61       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     79      ISymbolicExpressionTree symbolicExpressionTree,
     80      int maxTreeLength, int maxTreeDepth,
     81      int maxFunctionDefinitions, int maxFunctionArguments) {
    6282      // work on a copy in case we find out later that the tree would be too big
    6383      // in this case it's easiest to simply return the original tree.
    64       SymbolicExpressionTree clonedTree = (SymbolicExpressionTree)symbolicExpressionTree.Clone();
     84      ISymbolicExpressionTree clonedTree = (ISymbolicExpressionTree)symbolicExpressionTree.Clone();
    6585
    6686      var functionDefiningBranches = clonedTree.IterateNodesPrefix().OfType<DefunTreeNode>();
     
    83103      // this operation potentially creates very big trees so the access to the size property might throw overflow exception
    84104      try {
    85         if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size <= maxTreeSize && clonedTree.Height <= maxTreeHeight) {
     105        if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size <= maxTreeLength && clonedTree.Height <= maxTreeDepth) {
    86106
    87107          // size constraints are fulfilled
     
    100120    }
    101121
    102     private static bool CreateNewArgumentForDefun(IRandom random, SymbolicExpressionTree tree, DefunTreeNode defunBranch, ArgumentTreeNode newArgumentNode) {
     122    private static bool CreateNewArgumentForDefun(IRandom random, ISymbolicExpressionTree tree, DefunTreeNode defunBranch, ArgumentTreeNode newArgumentNode) {
    103123      // select a random cut point in the function defining branch
    104124      // the branch at the cut point is to be replaced by a new argument node
    105125      var cutPoints = (from node in defunBranch.IterateNodesPrefix()
    106                        where node.SubTrees.Count > 0
     126                       where node.SubTrees.Count() > 0
    107127                       from subtree in node.SubTrees
    108                        select new { Parent = node, ReplacedChildIndex = node.SubTrees.IndexOf(subtree), ReplacedChild = subtree }).ToList();
     128                       select new { Parent = node, ReplacedChildIndex = node.IndexOfSubTree(subtree), ReplacedChild = subtree }).ToList();
    109129
    110130      if (cutPoints.Count() == 0)
     
    121141      var invocationNodes = (from node in tree.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>()
    122142                             where node.Symbol.FunctionName == defunBranch.FunctionName
    123                              where node.SubTrees.Count == defunBranch.NumberOfArguments
     143                             where node.SubTrees.Count() == defunBranch.NumberOfArguments
    124144                             select node).ToList();
    125145      // do this repeatedly until no matching invocations are found     
    126146      while (invocationNodes.Count > 0) {
    127         List<SymbolicExpressionTreeNode> newlyAddedBranches = new List<SymbolicExpressionTreeNode>();
     147        List<ISymbolicExpressionTreeNode> newlyAddedBranches = new List<ISymbolicExpressionTreeNode>();
    128148        foreach (var invocationNode in invocationNodes) {
    129149          // check that the invocation node really has the correct number of arguments
    130           if (invocationNode.SubTrees.Count != defunBranch.NumberOfArguments) throw new InvalidOperationException();
     150          if (invocationNode.SubTrees.Count() != defunBranch.NumberOfArguments) throw new InvalidOperationException();
    131151          // append a new argument branch after expanding all argument nodes
    132           var clonedBranch = (SymbolicExpressionTreeNode)replacedBranch.Clone();
     152          var clonedBranch = (ISymbolicExpressionTreeNode)replacedBranch.Clone();
    133153          clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.SubTrees);
    134154          invocationNode.InsertSubTree(newArgumentNode.Symbol.ArgumentIndex, clonedBranch);
     
    139159                           from node in newlyAddedBranch.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>()
    140160                           where node.Symbol.FunctionName == defunBranch.FunctionName
    141                            where node.SubTrees.Count == defunBranch.NumberOfArguments
     161                           where node.SubTrees.Count() == defunBranch.NumberOfArguments
    142162                           select node).ToList();
    143163      }
     
    171191    }
    172192
    173     private static SymbolicExpressionTreeNode ReplaceArgumentsInBranch(SymbolicExpressionTreeNode branch, IList<SymbolicExpressionTreeNode> argumentTrees) {
     193    private static ISymbolicExpressionTreeNode ReplaceArgumentsInBranch(ISymbolicExpressionTreeNode branch, IEnumerable<ISymbolicExpressionTreeNode> argumentTrees) {
    174194      ArgumentTreeNode argNode = branch as ArgumentTreeNode;
    175195      if (argNode != null) {
    176196        // replace argument nodes by a clone of the original subtree that provided the result for the argument node
    177         return (SymbolicExpressionTreeNode)argumentTrees[argNode.Symbol.ArgumentIndex].Clone();
     197        return (SymbolicExpressionTreeNode)argumentTrees.ElementAt(argNode.Symbol.ArgumentIndex).Clone();
    178198      } else {
    179199        // call recursively for all subtree
    180         List<SymbolicExpressionTreeNode> subtrees = new List<SymbolicExpressionTreeNode>(branch.SubTrees);
    181         while (branch.SubTrees.Count > 0) branch.RemoveSubTree(0);
     200        List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(branch.SubTrees);
     201        while (branch.SubTrees.Count() > 0) branch.RemoveSubTree(0);
    182202        foreach (var subtree in subtrees) {
    183203          branch.AddSubTree(ReplaceArgumentsInBranch(subtree, argumentTrees));
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDeleter.cs

    r5499 r5510  
    3030  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 112
    3131  /// </summary>
    32   [Item("ArgumentDeleter", "Manipulates a symbolic expression by deleting an argument from an existing function defining branch.")]
     32  [Item("ArgumentDeleter", "Manipulates a symbolic expression by deleting an argument from an existing function defining branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 112")]
    3333  [StorableClass]
    3434  public sealed class ArgumentDeleter : SymbolicExpressionTreeArchitectureManipulator {
     
    4040    public override sealed void ModifyArchitecture(
    4141      IRandom random,
    42       SymbolicExpressionTree symbolicExpressionTree,
    43       ISymbolicExpressionGrammar grammar,
    44       IntValue maxTreeSize, IntValue maxTreeHeight,
    45       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    46       out bool success) {
    47       success = DeleteArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     42      ISymbolicExpressionTree symbolicExpressionTree,
     43      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     44      DeleteArgument(random, symbolicExpressionTree, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    4845    }
    4946
     
    5451    public static bool DeleteArgument(
    5552      IRandom random,
    56       SymbolicExpressionTree symbolicExpressionTree,
    57       ISymbolicExpressionGrammar grammar,
    58       int maxTreeSize, int maxTreeHeight,
    59       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     53      ISymbolicExpressionTree symbolicExpressionTree,
     54      int maxFunctionDefinitions, int maxFunctionArguments) {
    6055
    6156      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDuplicater.cs

    r5499 r5510  
    3333  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 94
    3434  /// </summary>
    35   [Item("ArgumentDuplicater", "Manipulates a symbolic expression by duplicating an existing argument node of a function-defining branch.")]
     35  [Item("ArgumentDuplicater", "Manipulates a symbolic expression by duplicating an existing argument node of a function-defining branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 94")]
    3636  [StorableClass]
    3737  public sealed class ArgumentDuplicater : SymbolicExpressionTreeArchitectureManipulator {
     
    4343    public override sealed void ModifyArchitecture(
    4444      IRandom random,
    45       SymbolicExpressionTree symbolicExpressionTree,
    46       ISymbolicExpressionGrammar grammar,
    47       IntValue maxTreeSize, IntValue maxTreeHeight,
    48       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    49       out bool success) {
    50       success = DuplicateArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     45      ISymbolicExpressionTree symbolicExpressionTree,
     46      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     47      DuplicateArgument(random, symbolicExpressionTree, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    5148    }
    5249
     
    5754    public static bool DuplicateArgument(
    5855      IRandom random,
    59       SymbolicExpressionTree symbolicExpressionTree,
    60       ISymbolicExpressionGrammar grammar,
    61       int maxTreeSize, int maxTreeHeight,
    62       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     56      ISymbolicExpressionTree symbolicExpressionTree,
     57      int maxFunctionDefinitions, int maxFunctionArguments) {
    6358      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    6459
     
    9186      var invocationNodes = (from node in symbolicExpressionTree.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>()
    9287                             where node.Symbol.FunctionName == selectedDefunBranch.FunctionName
    93                              where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments
     88                             where node.SubTrees.Count() == selectedDefunBranch.NumberOfArguments
    9489                             select node).ToList();
    9590      // do this repeatedly until no matching invocations are found     
    9691      while (invocationNodes.Count() > 0) {
    97         List<SymbolicExpressionTreeNode> newlyAddedBranches = new List<SymbolicExpressionTreeNode>();
     92        List<ISymbolicExpressionTreeNode> newlyAddedBranches = new List<ISymbolicExpressionTreeNode>();
    9893        foreach (var invokeNode in invocationNodes) {
    9994          // check that the invocation node really has the correct number of arguments
    100           if (invokeNode.SubTrees.Count != selectedDefunBranch.NumberOfArguments) throw new InvalidOperationException();
    101           var argumentBranch = invokeNode.SubTrees[selectedArgumentSymbol.ArgumentIndex];
    102           var clonedArgumentBranch = (SymbolicExpressionTreeNode)argumentBranch.Clone();
     95          if (invokeNode.SubTrees.Count() != selectedDefunBranch.NumberOfArguments) throw new InvalidOperationException();
     96          var argumentBranch = invokeNode.GetSubTree(selectedArgumentSymbol.ArgumentIndex);
     97          var clonedArgumentBranch = (ISymbolicExpressionTreeNode)argumentBranch.Clone();
    10398          invokeNode.InsertSubTree(newArgumentIndex, clonedArgumentBranch);
    10499          newlyAddedBranches.Add(clonedArgumentBranch);
     
    107102                           from node in newlyAddedBranch.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>()
    108103                           where node.Symbol.FunctionName == selectedDefunBranch.FunctionName
    109                            where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments
     104                           where node.SubTrees.Count() == selectedDefunBranch.NumberOfArguments
    110105                           select node).ToList();
    111106      }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/MultiSymbolicExpressionTreeArchitectureManipulator.cs

    r5499 r5510  
    3535  [Item("MultiSymbolicExpressionTreeArchitectureManipulator", "Randomly selects and applies one of its architecture manipulators every time it is called.")]
    3636  [StorableClass]
    37   public sealed class MultiSymbolicExpressionTreeArchitectureManipulator : StochasticMultiBranch<ISymbolicExpressionTreeArchitectureManipulator>, ISymbolicExpressionTreeArchitectureManipulator, IStochasticOperator {
    38     private const string MaxTreeSizeParameterName = "MaxTreeSize";
    39     private const string MaxTreeHeightParameterName = "MaxTreeHeight";
    40     private const string SymbolicExpressionGrammarParameterName = "SymbolicExpressionGrammar";
     37  public sealed class MultiSymbolicExpressionTreeArchitectureManipulator : StochasticMultiBranch<ISymbolicExpressionTreeArchitectureManipulator>,
     38    ISymbolicExpressionTreeArchitectureManipulator,
     39    ISymbolicExpressionTreeSizeConstraintOperator,
     40    IStochasticOperator {
     41    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     42    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    4143    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    42     private const string MaxFunctionArgumentsParameterName = "MaxFunctionArguments";
    43     private const string MaxFunctionDefiningBranchesParameterName = "MaxFunctionDefiningBranches";
     44    private const string MaximumFunctionArgumentsParameterName = "MaximumFunctionArguments";
     45    private const string MaximumFunctionDefinitionsParameterName = "MaximumFunctionDefinitions";
    4446
    4547    public override bool CanChangeName {
     
    4951      get { return true; }
    5052    }
    51     #region ISymbolicExpressionTreeArchitectureManipulator Members
    52     public IValueLookupParameter<IntValue> MaxFunctionDefinitionsParameter {
    53       get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionDefiningBranchesParameterName]; }
     53    #region Parameter properties
     54    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
     55      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    5456    }
    55     public IValueLookupParameter<IntValue> MaxFunctionArgumentsParameter {
    56       get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; }
     57    public IValueLookupParameter<IntValue> MaximumFunctionDefinitionsParameter {
     58      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
     59    }
     60    public IValueLookupParameter<IntValue> MaximumFunctionArgumentsParameter {
     61      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
     62    }
     63    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     64      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     65    }
     66    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
     67      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    5768    }
    5869    #endregion
    59 
    60     #region ISymbolicExpressionTreeManipulator Members
    61     public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    62       get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     70    #region Parameter Properties
     71    public IntValue MaximumFunctionDefinitions {
     72      get { return MaximumFunctionDefinitionsParameter.ActualValue; }
    6373    }
    64     #endregion
    65 
    66     #region ISymbolicExpressionTreeOperator Members
    67     public IValueLookupParameter<IntValue> MaxTreeSizeParameter {
    68       get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeSizeParameterName]; }
     74    public IntValue MaximumFunctionArguments {
     75      get { return MaximumFunctionArgumentsParameter.ActualValue; }
    6976    }
    70     public IValueLookupParameter<IntValue> MaxTreeHeightParameter {
    71       get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeHeightParameterName]; }
     77    public IntValue MaximumSymbolicExpressionTreeLength {
     78      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    7279    }
    73     public ILookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionGrammarParameter {
    74       get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionGrammarParameterName]; }
     80    public IntValue MaximumSymbolicExpressionTreeDepth {
     81      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    7582    }
    7683    #endregion
     
    8289    public MultiSymbolicExpressionTreeArchitectureManipulator()
    8390      : base() {
    84       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
    85       Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionDefiningBranchesParameterName, "The maximal allowed number of function defining branches."));
    86       Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionArgumentsParameterName, "The maximal allowed number of arguments of a newly created function."));
    87       Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeSizeParameterName, "The maximal size (number of nodes) of the symbolic expression tree."));
    88       Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeHeightParameterName, "The maximal height of the symbolic expression tree (a tree with one node has height = 0)."));
    89       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionGrammarParameterName, "The grammar that defines the allowed symbols and syntax of the symbolic expression trees."));
     91      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
     92      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumFunctionDefinitionsParameterName, "The maximal allowed number of automatically defined functions."));
     93      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumFunctionArgumentsParameterName, "The maximal allowed number of arguments of a automatically defined functions."));
     94      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
     95      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    9096
    9197      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ISymbolicExpressionTreeArchitectureManipulator))) {
     
    111117    private void ParameterizeManipulators() {
    112118      foreach (ISymbolicExpressionTreeArchitectureManipulator manipulator in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
    113         manipulator.MaxTreeSizeParameter.ActualName = MaxTreeSizeParameter.Name;
    114         manipulator.MaxTreeHeightParameter.ActualName = MaxTreeHeightParameter.Name;
    115         manipulator.SymbolicExpressionGrammarParameter.ActualName = SymbolicExpressionGrammarParameter.Name;
     119        manipulator.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name;
     120        manipulator.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
     121      }
     122      foreach(ISymbolicExpressionTreeSizeConstraintOperator manipulator in Operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
     123        manipulator.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
     124        manipulator.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
     125      }
     126      foreach(ISymbolicExpressionTreeManipulator manipulator in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
    116127        manipulator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
    117         manipulator.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
    118         manipulator.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
    119128      }
    120 
    121129      foreach (IStochasticOperator manipulator in Operators.OfType<IStochasticOperator>()) {
    122130        manipulator.RandomParameter.ActualName = RandomParameter.Name;
    123131      }
    124132    }
    125 
    126     #region ISymbolicExpressionTreeArchitectureManipulator Members
    127     public void ModifyArchitecture(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar, IntValue maxTreeSize, IntValue maxTreeHeight, IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments, out bool success) {
    128       var op = Operators.SelectRandom(random);
    129       op.ModifyArchitecture(random, symbolicExpressionTree, grammar, maxTreeSize, maxTreeHeight, maxFunctionDefiningBranches, maxFunctionArguments, out success);
    130     }
    131     #endregion
    132133  }
    133134}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r5499 r5510  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Parameters;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    3536  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 97
    3637  /// </summary>
    37   [Item("SubroutineCreater", "Manipulates a symbolic expression by adding one new function-defining branch containing a proportion of a preexisting branch and by creating a reference to the new branch.")]
     38  [Item("SubroutineCreater", "Manipulates a symbolic expression by adding one new function-defining branch containing a proportion of a preexisting branch and by creating a reference to the new branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 97")]
    3839  [StorableClass]
    39   public sealed class SubroutineCreater : SymbolicExpressionTreeArchitectureManipulator {
     40  public sealed class SubroutineCreater : SymbolicExpressionTreeArchitectureManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
    4041    private const double ARGUMENT_CUTOFF_PROBABILITY = 0.05;
    41 
     42    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     43    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
     44    #region Parameter Properties
     45    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     46      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     47    }
     48    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
     49      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     50    }
     51    #endregion
     52    #region Properties
     53    public IntValue MaximumSymbolicExpressionTreeLength {
     54      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     55    }
     56    public IntValue MaximumSymbolicExpressionTreeDepth {
     57      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     58    }
     59    #endregion
    4260    [StorableConstructor]
    4361    private SubroutineCreater(bool deserializing) : base(deserializing) { }
    4462    private SubroutineCreater(SubroutineCreater original, Cloner cloner) : base(original, cloner) { }
    45     public SubroutineCreater() : base() { }
     63    public SubroutineCreater() : base() {
     64      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
     65      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     66    }
    4667
    4768    public override IDeepCloneable Clone(Cloner cloner) {
     
    5172    public override sealed void ModifyArchitecture(
    5273      IRandom random,
    53       SymbolicExpressionTree symbolicExpressionTree,
    54       ISymbolicExpressionGrammar grammar,
    55       IntValue maxTreeSize, IntValue maxTreeHeight,
    56       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    57       out bool success) {
    58       success = CreateSubroutine(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     74      ISymbolicExpressionTree symbolicExpressionTree,
     75      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     76      CreateSubroutine(random, symbolicExpressionTree, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    5977    }
    6078
    6179    public static bool CreateSubroutine(
    6280      IRandom random,
    63       SymbolicExpressionTree symbolicExpressionTree,
    64       ISymbolicExpressionGrammar grammar,
    65       int maxTreeSize, int maxTreeHeight,
    66       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     81      ISymbolicExpressionTree symbolicExpressionTree,
     82      int maxTreeLength, int maxTreeDepth,
     83      int maxFunctionDefinitions, int maxFunctionArguments) {
    6784      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    68       if (functionDefiningBranches.Count() >= maxFunctionDefiningBranches)
     85      if (functionDefiningBranches.Count() >= maxFunctionDefinitions)
    6986        // allowed maximum number of ADF reached => abort
    7087        return false;
    71       if (symbolicExpressionTree.Size + 4 > maxTreeSize)
     88      if (symbolicExpressionTree.Size + 4 > maxTreeLength)
    7289        // defining a new function causes an size increase by 4 nodes (max) if the max tree size is reached => abort
    7390        return false;
    74       string formatString = new StringBuilder().Append('0', (int)Math.Log10(maxFunctionDefiningBranches * 10 - 1)).ToString(); // >= 100 functions => ###
    75       var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefiningBranches)
     91      string formatString = new StringBuilder().Append('0', (int)Math.Log10(maxFunctionDefinitions * 10 - 1)).ToString(); // >= 100 functions => ###
     92      var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefinitions)
    7693                                 select "ADF" + index.ToString(formatString);
    7794
     
    8299      int r = random.Next(totalNumberOfBodyNodes);
    83100      int aggregatedNumberOfBodyNodes = 0;
    84       SymbolicExpressionTreeNode selectedBody = null;
     101      ISymbolicExpressionTreeNode selectedBody = null;
    85102      foreach (var body in bodies) {
    86103        aggregatedNumberOfBodyNodes += body.Size;
     
    94111      var allCutPoints = from parent in selectedBody.IterateNodesPrefix()
    95112                         from subtree in parent.SubTrees
    96                          select new { Parent = parent, ReplacedBranchIndex = parent.SubTrees.IndexOf(subtree), ReplacedBranch = subtree };
     113                         select new { Parent = parent, ReplacedBranchIndex = parent.IndexOfSubTree(subtree), ReplacedBranch = subtree };
    97114      if (allCutPoints.Count() == 0)
    98115        // no cut points => abort
     
    101118      var selectedCutPoint = allCutPoints.SelectRandom(random);
    102119      // select random branches as argument cut-off points (replaced by argument terminal nodes in the function)
    103       List<SymbolicExpressionTreeNode> argumentBranches = SelectRandomArgumentBranches(selectedCutPoint.ReplacedBranch, random, ARGUMENT_CUTOFF_PROBABILITY, maxFunctionArguments);
    104       SymbolicExpressionTreeNode functionBody = selectedCutPoint.ReplacedBranch;
     120      List<ISymbolicExpressionTreeNode> argumentBranches = SelectRandomArgumentBranches(selectedCutPoint.ReplacedBranch, random, ARGUMENT_CUTOFF_PROBABILITY, maxFunctionArguments);
     121      ISymbolicExpressionTreeNode functionBody = selectedCutPoint.ReplacedBranch;
    105122      // disconnect the function body from the tree
    106123      selectedCutPoint.Parent.RemoveSubTree(selectedCutPoint.ReplacedBranchIndex);
     
    120137      symbolicExpressionTree.Root.AddSubTree(defunNode);
    121138      // the grammar in the newly defined function is a clone of the grammar of the originating branch
    122       defunNode.SetGrammar((ISymbolicExpressionGrammar)selectedBody.Grammar.Clone());
     139      defunNode.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBody.Grammar.Clone());
    123140      // remove all argument symbols from grammar
    124141      var oldArgumentSymbols = defunNode.Grammar.Symbols.OfType<Argument>().ToList();
     
    164181    }
    165182
    166     private static SymbolicExpressionTreeNode DisconnectBranches(SymbolicExpressionTreeNode node, List<SymbolicExpressionTreeNode> argumentBranches) {
     183    private static ISymbolicExpressionTreeNode DisconnectBranches(ISymbolicExpressionTreeNode node, List<ISymbolicExpressionTreeNode> argumentBranches) {
    167184      if (argumentBranches.Contains(node)) {
    168185        var argumentIndex = argumentBranches.IndexOf(node);
     
    171188      }
    172189      // remove the subtrees so that we can clone only the root node
    173       List<SymbolicExpressionTreeNode> subtrees = new List<SymbolicExpressionTreeNode>(node.SubTrees);
    174       while (node.SubTrees.Count > 0) node.RemoveSubTree(0);
     190      List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(node.SubTrees);
     191      while (node.SubTrees.Count() > 0) node.RemoveSubTree(0);
    175192      // recursively apply function for subtrees or append a argument terminal node
    176193      foreach (var subtree in subtrees) {
     
    180197    }
    181198
    182     private static List<SymbolicExpressionTreeNode> SelectRandomArgumentBranches(SymbolicExpressionTreeNode selectedRoot,
     199    private static List<ISymbolicExpressionTreeNode> SelectRandomArgumentBranches(ISymbolicExpressionTreeNode selectedRoot,
    183200      IRandom random,
    184201      double cutProbability,
     
    186203      // breadth first determination of argument cut-off points
    187204      // we must make sure that we cut off all original argument nodes and that the number of new argument is smaller than the limit
    188       List<SymbolicExpressionTreeNode> argumentBranches = new List<SymbolicExpressionTreeNode>();
     205      List<ISymbolicExpressionTreeNode> argumentBranches = new List<ISymbolicExpressionTreeNode>();
    189206      if (selectedRoot is ArgumentTreeNode) {
    190207        argumentBranches.Add(selectedRoot);
     
    202219        }
    203220        // cut-off in the sub-trees in random order
    204         var randomIndexes = (from index in Enumerable.Range(0, selectedRoot.SubTrees.Count)
     221        var randomIndexes = (from index in Enumerable.Range(0, selectedRoot.SubTrees.Count())
    205222                             select new { Index = index, OrderValue = random.NextDouble() }).OrderBy(x => x.OrderValue).Select(x => x.Index);
    206223        foreach (var subtreeIndex in randomIndexes) {
    207           var subtree = selectedRoot.SubTrees[subtreeIndex];
     224          var subtree = selectedRoot.GetSubTree(subtreeIndex);
    208225          minNewArgumentsForSubtrees[subtreeIndex] = 0;
    209226          // => cut-off at 0..n points somewhere in the current sub-tree
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs

    r5499 r5510  
    3333  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 108
    3434  /// </summary>
    35   [Item("SubroutineDeleter", "Manipulates a symbolic expression by deleting a preexisting function-defining branch.")]
     35  [Item("SubroutineDeleter", "Manipulates a symbolic expression by deleting a preexisting function-defining branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 108")]
    3636  [StorableClass]
    3737  public sealed class SubroutineDeleter : SymbolicExpressionTreeArchitectureManipulator {
     
    4747    public override sealed void ModifyArchitecture(
    4848      IRandom random,
    49       SymbolicExpressionTree symbolicExpressionTree,
    50       ISymbolicExpressionGrammar grammar,
    51       IntValue maxTreeSize, IntValue maxTreeHeight,
    52       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    53       out bool success) {
    54       success = DeleteSubroutine(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     49      ISymbolicExpressionTree symbolicExpressionTree,
     50      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     51      DeleteSubroutine(random, symbolicExpressionTree, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    5552    }
    5653
    5754    public static bool DeleteSubroutine(
    5855      IRandom random,
    59       SymbolicExpressionTree symbolicExpressionTree,
    60       ISymbolicExpressionGrammar grammar,
    61       int maxTreeSize, int maxTreeHeight,
    62       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     56      ISymbolicExpressionTree symbolicExpressionTree,
     57      int maxFunctionDefinitions, int maxFunctionArguments) {
    6358      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    6459
     
    6863      var selectedDefunBranch = functionDefiningBranches.SelectRandom(random);
    6964      // remove the selected defun
    70       int defunSubtreeIndex = symbolicExpressionTree.Root.SubTrees.IndexOf(selectedDefunBranch);
     65      int defunSubtreeIndex = symbolicExpressionTree.Root.IndexOfSubTree(selectedDefunBranch);
    7166      symbolicExpressionTree.Root.RemoveSubTree(defunSubtreeIndex);
    7267
     
    8580    }
    8681
    87     private static void DeletionByRandomRegeneration(IRandom random, SymbolicExpressionTree symbolicExpressionTree, DefunTreeNode selectedDefunBranch) {
     82    private static void DeletionByRandomRegeneration(IRandom random, ISymbolicExpressionTree symbolicExpressionTree, DefunTreeNode selectedDefunBranch) {
    8883      // find first invocation and replace it with a randomly generated tree
    8984      // can't find all invocations in one step because once we replaced a top level invocation
     
    9287                                from subtree in node.SubTrees.OfType<InvokeFunctionTreeNode>()
    9388                                where subtree.Symbol.FunctionName == selectedDefunBranch.FunctionName
    94                                 select new { Parent = node, ReplacedChildIndex = node.SubTrees.IndexOf(subtree), ReplacedChild = subtree }).FirstOrDefault();
     89                                select new { Parent = node, ReplacedChildIndex = node.IndexOfSubTree(subtree), ReplacedChild = subtree }).FirstOrDefault();
    9590      while (invocationCutPoint != null) {
    9691        // deletion by random regeneration
    97         SymbolicExpressionTreeNode replacementTree = null;
     92        ISymbolicExpressionTreeNode replacementTree = null;
    9893        var allowedSymbolsList = invocationCutPoint.Parent.GetAllowedSymbols(invocationCutPoint.ReplacedChildIndex).ToList();
    9994        var weights = allowedSymbolsList.Select(s => s.InitialFrequency);
     
    115110                              from subtree in node.SubTrees.OfType<InvokeFunctionTreeNode>()
    116111                              where subtree.Symbol.FunctionName == selectedDefunBranch.FunctionName
    117                               select new { Parent = node, ReplacedChildIndex = node.SubTrees.IndexOf(subtree), ReplacedChild = subtree }).FirstOrDefault();
     112                              select new { Parent = node, ReplacedChildIndex = node.IndexOfSubTree(subtree), ReplacedChild = subtree }).FirstOrDefault();
    118113      }
    119114    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r5499 r5510  
    3434  /// As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 88
    3535  /// </summary>
    36   [Item("SubroutineDuplicater", "Manipulates a symbolic expression by duplicating a preexisting function-defining branch.")]
     36  [Item("SubroutineDuplicater", "Manipulates a symbolic expression by duplicating a preexisting function-defining branch. As described in Koza, Bennett, Andre, Keane, Genetic Programming III - Darwinian Invention and Problem Solving, 1999, pp. 88")]
    3737  [StorableClass]
    3838  public sealed class SubroutineDuplicater : SymbolicExpressionTreeArchitectureManipulator {
     
    5050    public override sealed void ModifyArchitecture(
    5151      IRandom random,
    52       SymbolicExpressionTree symbolicExpressionTree,
    53       ISymbolicExpressionGrammar grammar,
    54       IntValue maxTreeSize, IntValue maxTreeHeight,
    55       IntValue maxFunctionDefiningBranches, IntValue maxFunctionArguments,
    56       out bool success) {
    57       success = DuplicateSubroutine(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     52      ISymbolicExpressionTree symbolicExpressionTree,
     53      IntValue maxFunctionDefinitions, IntValue maxFunctionArguments) {
     54      DuplicateSubroutine(random, symbolicExpressionTree, maxFunctionDefinitions.Value, maxFunctionArguments.Value);
    5855    }
    5956
    6057    public static bool DuplicateSubroutine(
    6158      IRandom random,
    62       SymbolicExpressionTree symbolicExpressionTree,
    63       ISymbolicExpressionGrammar grammar,
    64       int maxTreeSize, int maxTreeHeight,
    65       int maxFunctionDefiningBranches, int maxFunctionArguments) {
     59      ISymbolicExpressionTree symbolicExpressionTree,
     60      int maxFunctionDefinitions, int maxFunctionArguments) {
    6661      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    67       if (functionDefiningBranches.Count() == 0 || functionDefiningBranches.Count() == maxFunctionDefiningBranches)
     62      if (functionDefiningBranches.Count() == 0 || functionDefiningBranches.Count() == maxFunctionDefinitions)
    6863        // no function defining branches to duplicate or already reached the max number of ADFs
    6964        return false;
    7065
    71       string formatString = new StringBuilder().Append('0', (int)Math.Log10(maxFunctionDefiningBranches) + 1).ToString(); // >= 100 functions => ###
    72       var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefiningBranches)
     66      string formatString = new StringBuilder().Append('0', (int)Math.Log10(maxFunctionDefinitions) + 1).ToString(); // >= 100 functions => ###
     67      var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefinitions)
    7368                                 select "ADF" + index.ToString(formatString);
    7469      var selectedBranch = functionDefiningBranches.SelectRandom(random);
     
    7772      duplicatedDefunBranch.FunctionName = newFunctionName;
    7873      symbolicExpressionTree.Root.AddSubTree(duplicatedDefunBranch);
    79       duplicatedDefunBranch.SetGrammar((ISymbolicExpressionGrammar)selectedBranch.Grammar.Clone());
     74      duplicatedDefunBranch.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBranch.Grammar.Clone());
    8075      // add an invoke symbol for each branch that is allowed to invoke the original function
    8176      foreach (var subtree in symbolicExpressionTree.Root.SubTrees.OfType<SymbolicExpressionTreeTopLevelNode>()) {
     
    10499    }
    105100
    106     private static IEnumerable<string> UsedFunctionNames(SymbolicExpressionTree symbolicExpressionTree) {
     101    private static IEnumerable<string> UsedFunctionNames(ISymbolicExpressionTree symbolicExpressionTree) {
    107102      return from node in symbolicExpressionTree.IterateNodesPrefix()
    108103             where node.Symbol is Defun
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs

    r5499 r5510  
    6262    }
    6363
    64     protected override sealed void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree) {
     64    protected override sealed void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
    6565      ModifyArchitecture(random, symbolicExpressionTree, MaximumFunctionDefinitions, MaximumFunctionArguments);
    6666    }
     
    6868    public abstract void ModifyArchitecture(
    6969      IRandom random,
    70       SymbolicExpressionTree tree,
     70      ISymbolicExpressionTree tree,
    7171      IntValue maxFunctionDefinitions,
    7272      IntValue maxFunctionArguments);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs

    r5499 r5510  
    4343        if (code.Count > ushort.MaxValue) throw new ArgumentException("Code for the tree is too long (> ushort.MaxValue).");
    4444        entryPoint[branch.FunctionName] = (ushort)code.Count;
    45         code.AddRange(Compile(branch.SubTrees[0], opCodeMapper));
     45        code.AddRange(Compile(branch.GetSubTree(0), opCodeMapper));
    4646      }
    4747      // address of all functions is fixed now
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r5499 r5510  
    9292    }
    9393
    94     protected override SymbolicExpressionTree Create(IRandom random) {
     94    protected override ISymbolicExpressionTree Create(IRandom random) {
    9595      return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value,
    9696        MaximumFunctionDefinitions.Value, MaximumFunctionArguments.Value);
    9797    }
    9898
    99     public static SymbolicExpressionTree Create(IRandom random, ISymbolicExpressionTreeGrammar grammar,
     99    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionTreeGrammar grammar,
    100100      int maxTreeSize, int maxTreeHeight,
    101101      int maxFunctionDefinitions, int maxFunctionArguments
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs

    r5499 r5510  
    3535    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    3636    #region Parameter Properties
    37     public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    38       get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     37    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
     38      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    3939    }
    4040    #endregion
    4141
    4242    #region Propeties
    43     public SymbolicExpressionTree SymbolicExpressionTree {
     43    public ISymbolicExpressionTree SymbolicExpressionTree {
    4444      get { return SymbolicExpressionTreeParameter.ActualValue; }
    4545      set { SymbolicExpressionTreeParameter.ActualValue = value; }
     
    5252    protected SymbolicExpressionTreeCreator()
    5353      : base() {
    54       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree that should be created."));
     54      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree that should be created."));
    5555    }
    5656
     
    6060    }
    6161
    62     protected abstract SymbolicExpressionTree Create(IRandom random);
     62    protected abstract ISymbolicExpressionTree Create(IRandom random);
    6363  }
    6464}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/CrossoverPoint.cs

    r5499 r5510  
    2323namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2424  internal class CrossoverPoint {
    25     public SymbolicExpressionTreeNode Parent { get; set; }
    26     public SymbolicExpressionTreeNode Child { get; set; }
     25    public ISymbolicExpressionTreeNode Parent { get; set; }
     26    public ISymbolicExpressionTreeNode Child { get; set; }
    2727    public int SubtreeIndex {
    28       get { return Parent.SubTrees.IndexOf(Child); }
     28      get { return Parent.IndexOfSubTree(Child); }
    2929    }
    30     public CrossoverPoint(SymbolicExpressionTreeNode parent, SymbolicExpressionTreeNode child) {
     30    public CrossoverPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
    3131      this.Parent = parent;
    3232      this.Child = child;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r5499 r5510  
    7878    }
    7979
    80     protected override SymbolicExpressionTree Cross(IRandom random,
    81       SymbolicExpressionTree parent0, SymbolicExpressionTree parent1) {
     80    protected override ISymbolicExpressionTree Cross(IRandom random,
     81      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
    8282      return Cross(random, parent0, parent1, InternalCrossoverPointProbability.Value,
    8383        MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    8484    }
    8585
    86     public static SymbolicExpressionTree Cross(IRandom random,
    87       SymbolicExpressionTree parent0, SymbolicExpressionTree parent1,
     86    public static ISymbolicExpressionTree Cross(IRandom random,
     87      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1,
    8888      double internalCrossoverPointProbability, int maxTreeSize, int maxTreeHeight) {
    8989      // select a random crossover point in the first parent
    90       SymbolicExpressionTreeNode crossoverPoint0;
     90      ISymbolicExpressionTreeNode crossoverPoint0;
    9191      int replacedSubtreeIndex;
    9292      SelectCrossoverPoint(random, parent0, internalCrossoverPointProbability, maxTreeSize, maxTreeHeight, out crossoverPoint0, out replacedSubtreeIndex);
    9393
    9494      // calculate the max size and height that the inserted branch can have
    95       int maxInsertedBranchSize = maxTreeSize - (parent0.Size - crossoverPoint0.SubTrees[replacedSubtreeIndex].GetSize());
     95      int maxInsertedBranchSize = maxTreeSize - (parent0.Size - crossoverPoint0.GetSubTree(replacedSubtreeIndex).GetSize());
    9696      int maxInsertedBranchHeight = maxTreeHeight - GetBranchLevel(parent0.Root, crossoverPoint0);
    9797
    98       List<SymbolicExpressionTreeNode> allowedBranches = new List<SymbolicExpressionTreeNode>();
     98      List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
    9999      parent1.Root.ForEachNodePostfix((n) => {
    100100        if (n.GetSize() <= maxInsertedBranchSize &&
     
    117117    }
    118118
    119     private static bool IsMatchingPointType(SymbolicExpressionTreeNode parent, int replacedSubtreeIndex, SymbolicExpressionTreeNode branch) {
     119    private static bool IsMatchingPointType(ISymbolicExpressionTreeNode parent, int replacedSubtreeIndex, ISymbolicExpressionTreeNode branch) {
    120120      // check syntax constraints of direct parent - child relation
    121121      if (!parent.Grammar.ContainsSymbol(branch.Symbol) ||
     
    128128          result &&
    129129          parent.Grammar.ContainsSymbol(n.Symbol) &&
    130           n.SubTrees.Count >= parent.Grammar.GetMinSubtreeCount(n.Symbol) &&
    131           n.SubTrees.Count <= parent.Grammar.GetMaxSubtreeCount(n.Symbol);
     130          n.SubTrees.Count() >= parent.Grammar.GetMinSubtreeCount(n.Symbol) &&
     131          n.SubTrees.Count() <= parent.Grammar.GetMaxSubtreeCount(n.Symbol);
    132132      });
    133133      return result;
    134134    }
    135135
    136     private static void SelectCrossoverPoint(IRandom random, SymbolicExpressionTree parent0, double internalNodeProbability, int maxBranchSize, int maxBranchHeight, out SymbolicExpressionTreeNode crossoverPoint, out int subtreeIndex) {
     136    private static void SelectCrossoverPoint(IRandom random, ISymbolicExpressionTree parent0, double internalNodeProbability, int maxBranchSize, int maxBranchHeight, out ISymbolicExpressionTreeNode crossoverPoint, out int subtreeIndex) {
    137137      if (internalNodeProbability < 0.0 || internalNodeProbability > 1.0) throw new ArgumentException("internalNodeProbability");
    138138      List<CrossoverPoint> internalCrossoverPoints = new List<CrossoverPoint>();
    139139      List<CrossoverPoint> leafCrossoverPoints = new List<CrossoverPoint>();
    140140      parent0.Root.ForEachNodePostfix((n) => {
    141         if (n.SubTrees.Count > 0 && n != parent0.Root) {
     141        if (n.SubTrees.Count() > 0 && n != parent0.Root) {
    142142          foreach (var child in n.SubTrees) {
    143143            if (child.GetSize() <= maxBranchSize &&
    144144                child.GetHeight() <= maxBranchHeight) {
    145               if (child.SubTrees.Count > 0)
     145              if (child.SubTrees.Count() > 0)
    146146                internalCrossoverPoints.Add(new CrossoverPoint(n, child));
    147147              else
     
    178178    }
    179179
    180     private static SymbolicExpressionTreeNode SelectRandomBranch(IRandom random, IEnumerable<SymbolicExpressionTreeNode> branches, double internalNodeProbability) {
     180    private static ISymbolicExpressionTreeNode SelectRandomBranch(IRandom random, IEnumerable<ISymbolicExpressionTreeNode> branches, double internalNodeProbability) {
    181181      if (internalNodeProbability < 0.0 || internalNodeProbability > 1.0) throw new ArgumentException("internalNodeProbability");
    182       List<SymbolicExpressionTreeNode> allowedInternalBranches;
    183       List<SymbolicExpressionTreeNode> allowedLeafBranches;
     182      List<ISymbolicExpressionTreeNode> allowedInternalBranches;
     183      List<ISymbolicExpressionTreeNode> allowedLeafBranches;
    184184      if (random.NextDouble() < internalNodeProbability) {
    185185        // select internal node if possible
    186186        allowedInternalBranches = (from branch in branches
    187                                    where branch.SubTrees.Count > 0
     187                                   where branch.SubTrees.Count() > 0
    188188                                   select branch).ToList();
    189189        if (allowedInternalBranches.Count > 0) {
     
    192192          // no internal nodes allowed => select leaf nodes
    193193          allowedLeafBranches = (from branch in branches
    194                                  where branch.SubTrees.Count == 0
     194                                 where branch.SubTrees.Count() == 0
    195195                                 select branch).ToList();
    196196          return allowedLeafBranches.SelectRandom(random);
     
    199199        // select leaf node if possible
    200200        allowedLeafBranches = (from branch in branches
    201                                where branch.SubTrees.Count == 0
     201                               where branch.SubTrees.Count() == 0
    202202                               select branch).ToList();
    203203        if (allowedLeafBranches.Count > 0) {
     
    205205        } else {
    206206          allowedInternalBranches = (from branch in branches
    207                                      where branch.SubTrees.Count > 0
     207                                     where branch.SubTrees.Count() > 0
    208208                                     select branch).ToList();
    209209          return allowedInternalBranches.SelectRandom(random);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs

    r5499 r5510  
    3737    private const string ChildParameterName = "Child";
    3838    #region Parameter Properties
    39     public ILookupParameter<ItemArray<SymbolicExpressionTree>> ParentsParameter {
    40       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[ParentsParameterName]; }
     39    public ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter {
     40      get { return (ScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[ParentsParameterName]; }
    4141    }
    42     public ILookupParameter<SymbolicExpressionTree> ChildParameter {
    43       get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[ChildParameterName]; }
     42    public ILookupParameter<ISymbolicExpressionTree> ChildParameter {
     43      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[ChildParameterName]; }
    4444    }
    4545    #endregion
    4646    #region Properties
    47     public ItemArray<SymbolicExpressionTree> Parents {
     47    public ItemArray<ISymbolicExpressionTree> Parents {
    4848      get { return ParentsParameter.ActualValue; }
    4949    }
    50     public SymbolicExpressionTree Child {
     50    public ISymbolicExpressionTree Child {
    5151      get { return ChildParameter.ActualValue; }
    5252      set { ChildParameter.ActualValue = value; }
     
    5858    protected SymbolicExpressionTreeCrossover()
    5959      : base() {
    60       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
    61       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
     60      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
     61      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
    6262    }
    6363
     
    6666        throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators.");
    6767
    68       SymbolicExpressionTree result = Cross(Random, Parents[0], Parents[1]);
     68      ISymbolicExpressionTree result = Cross(Random, Parents[0], Parents[1]);
    6969
    7070      Child = result;
     
    7272    }
    7373
    74     protected abstract SymbolicExpressionTree Cross(IRandom random,
    75       SymbolicExpressionTree parent0, SymbolicExpressionTree parent1);
     74    protected abstract ISymbolicExpressionTree Cross(IRandom random,
     75      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1);
    7676  }
    7777}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/DefaultSymbolicExpressionGrammar.cs

    r5499 r5510  
    7474    }
    7575    [Storable]
    76     private IEnumerable<KeyValuePair<string, Symbol>> AllSymbols {
     76    private IEnumerable<KeyValuePair<string, ISymbol>> AllSymbols {
    7777      get { return allSymbols.AsEnumerable(); }
    7878      set { allSymbols = value.ToDictionary(x => x.Key, x => x.Value); }
     
    8383    private Dictionary<string, int> maxSubTreeCount;
    8484    private Dictionary<string, List<List<string>>> allowedChildSymbols;
    85     private Dictionary<string, Symbol> allSymbols;
    86     [Storable]
    87     private Symbol startSymbol;
     85    private Dictionary<string, ISymbol> allSymbols;
     86    [Storable]
     87    private ISymbol startSymbol;
    8888
    8989    [StorableConstructor]
     
    103103      maxSubTreeCount = new Dictionary<string, int>(original.maxSubTreeCount);
    104104
    105       allSymbols = new Dictionary<string, Symbol>();
    106       foreach (Symbol symbol in original.allSymbols.Values.Select(s => cloner.Clone(s)))
     105      allSymbols = new Dictionary<string, ISymbol>();
     106      foreach (ISymbol symbol in original.allSymbols.Values.Select(s => cloner.Clone(s)))
    107107        allSymbols.Add(symbol.Name, symbol);
    108108
    109       startSymbol = cloner.Clone<Symbol>(original.startSymbol);
     109      startSymbol = cloner.Clone<ISymbol>(original.startSymbol);
    110110      allowedChildSymbols = new Dictionary<string, List<List<string>>>();
    111111      foreach (var entry in original.allowedChildSymbols) {
     
    121121      this.maxSubTreeCount = new Dictionary<string, int>();
    122122      this.allowedChildSymbols = new Dictionary<string, List<List<string>>>();
    123       this.allSymbols = new Dictionary<string, Symbol>();
     123      this.allSymbols = new Dictionary<string, ISymbol>();
    124124      this.cachedMinExpressionLength = new Dictionary<string, int>();
    125125      this.cachedMaxExpressionLength = new Dictionary<string, int>();
     
    142142      this.maxSubTreeCount = new Dictionary<string, int>();
    143143      this.allowedChildSymbols = new Dictionary<string, List<List<string>>>();
    144       this.allSymbols = new Dictionary<string, Symbol>();
    145 
    146       this.StartSymbol = (Symbol)cloner.Clone(grammar.StartSymbol);
    147 
    148       foreach (Symbol symbol in grammar.Symbols) {
    149         Symbol clonedSymbol = (Symbol)cloner.Clone(symbol);
     144      this.allSymbols = new Dictionary<string, ISymbol>();
     145
     146      this.StartSymbol = (ISymbol)cloner.Clone(grammar.StartSymbol);
     147
     148      foreach (ISymbol symbol in grammar.Symbols) {
     149        ISymbol clonedSymbol = (ISymbol)cloner.Clone(symbol);
    150150        this.AddSymbol(clonedSymbol);
    151151        this.SetMinSubtreeCount(clonedSymbol, grammar.GetMinSubtreeCount(symbol));
     
    153153      }
    154154
    155       foreach (Symbol parent in grammar.Symbols) {
     155      foreach (ISymbol parent in grammar.Symbols) {
    156156        for (int i = 0; i < grammar.GetMaxSubtreeCount(parent); i++) {
    157           foreach (Symbol child in grammar.Symbols) {
     157          foreach (ISymbol child in grammar.Symbols) {
    158158            if (grammar.IsAllowedChild(parent, child, i)) {
    159               this.SetAllowedChild((Symbol)cloner.Clone(parent), (Symbol)cloner.Clone(child), i);
     159              this.SetAllowedChild((ISymbol)cloner.Clone(parent), (ISymbol)cloner.Clone(child), i);
    160160            }
    161161          }
     
    181181
    182182    #region ISymbolicExpressionGrammar Members
    183     public Symbol StartSymbol {
     183    public ISymbol StartSymbol {
    184184      get { return startSymbol; }
    185185      set { startSymbol = value; }
    186186    }
    187187
    188     public void AddSymbol(Symbol symbol) {
     188    public void AddSymbol(ISymbol symbol) {
    189189      if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined.");
    190190      allSymbols.Add(symbol.Name, symbol);
     
    193193    }
    194194
    195     public void RemoveSymbol(Symbol symbol) {
     195    public void RemoveSymbol(ISymbol symbol) {
    196196      foreach (var parent in Symbols) {
    197197        for (int i = 0; i < GetMaxSubtreeCount(parent); i++)
     
    206206    }
    207207
    208     public IEnumerable<Symbol> Symbols {
     208    public IEnumerable<ISymbol> Symbols {
    209209      get { return allSymbols.Values.AsEnumerable(); }
    210210    }
    211211
    212     public bool ContainsSymbol(Symbol symbol) {
     212    public bool ContainsSymbol(ISymbol symbol) {
    213213      return allSymbols.ContainsKey(symbol.Name);
    214214    }
    215215
    216     public void SetAllowedChild(Symbol parent, Symbol child, int argumentIndex) {
     216    public void SetAllowedChild(ISymbol parent, ISymbol child, int argumentIndex) {
    217217      if (!ContainsSymbol(parent)) throw new ArgumentException("Unknown symbol: " + parent, "parent");
    218218      if (!ContainsSymbol(child)) throw new ArgumentException("Unknown symbol: " + child, "child");
     
    222222    }
    223223
    224     public bool IsAllowedChild(Symbol parent, Symbol child, int argumentIndex) {
     224    public bool IsAllowedChild(ISymbol parent, ISymbol child, int argumentIndex) {
    225225      if (!ContainsSymbol(parent)) throw new ArgumentException("Unknown symbol: " + parent, "parent");
    226226      if (!ContainsSymbol(child)) throw new ArgumentException("Unknown symbol: " + child, "child");
     
    230230
    231231    private Dictionary<string, int> cachedMinExpressionLength;
    232     public int GetMinExpressionLength(Symbol symbol) {
     232    public int GetMinExpressionLength(ISymbol symbol) {
    233233      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    234234      if (!cachedMinExpressionLength.ContainsKey(symbol.Name)) {
     
    246246
    247247    private Dictionary<string, int> cachedMaxExpressionLength;
    248     public int GetMaxExpressionLength(Symbol symbol) {
     248    public int GetMaxExpressionLength(ISymbol symbol) {
    249249      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    250250      if (!cachedMaxExpressionLength.ContainsKey(symbol.Name)) {
     
    262262
    263263    private Dictionary<string, int> cachedMinExpressionDepth;
    264     public int GetMinExpressionDepth(Symbol symbol) {
     264    public int GetMinExpressionDepth(ISymbol symbol) {
    265265      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    266266      if (!cachedMinExpressionDepth.ContainsKey(symbol.Name)) {
     
    275275    }
    276276
    277     public void SetMaxSubtreeCount(Symbol symbol, int nSubTrees) {
     277    public void SetMaxSubtreeCount(ISymbol symbol, int nSubTrees) {
    278278      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    279279      maxSubTreeCount[symbol.Name] = nSubTrees;
     
    286286    }
    287287
    288     public void SetMinSubtreeCount(Symbol symbol, int nSubTrees) {
     288    public void SetMinSubtreeCount(ISymbol symbol, int nSubTrees) {
    289289      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    290290      minSubTreeCount[symbol.Name] = nSubTrees;
     
    292292    }
    293293
    294     public int GetMinSubtreeCount(Symbol symbol) {
     294    public int GetMinSubtreeCount(ISymbol symbol) {
    295295      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    296296      return minSubTreeCount[symbol.Name];
    297297    }
    298298
    299     public int GetMaxSubtreeCount(Symbol symbol) {
     299    public int GetMaxSubtreeCount(ISymbol symbol) {
    300300      if (!ContainsSymbol(symbol)) throw new ArgumentException("Unknown symbol: " + symbol);
    301301      return maxSubTreeCount[symbol.Name];
     
    313313      maxSubTreeCount = new Dictionary<string, int>(original.maxSubTreeCount);
    314314
    315       allSymbols = new Dictionary<string, Symbol>(original.allSymbols);
     315      allSymbols = new Dictionary<string, ISymbol>(original.allSymbols);
    316316      startSymbol = original.startSymbol;
    317317      allowedChildSymbols = new Dictionary<string, List<List<string>>>(original.allowedChildSymbols.Count);
     
    323323      }
    324324    }
    325 
    326325  }
    327326}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Formatters/SymbolicExpressionTreeStringFormatter.cs

    r5499 r5510  
    4646    }
    4747
    48     public string Format(SymbolicExpressionTree symbolicExpressionTree) {
     48    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
    4949      return FormatRecursively(symbolicExpressionTree.Root, 0);
    5050    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GlobalSymbolicExpressionGrammar.cs

    r5499 r5510  
    7979    }
    8080
    81     public GlobalSymbolicExpressionGrammar(ISymbolicExpressionGrammar mainBranchGrammar)
     81    public GlobalSymbolicExpressionGrammar(ISymbolicExpressionTreeGrammar mainBranchGrammar)
    8282      : base(mainBranchGrammar) {
    8383      maxFunctionArguments = 3;
     
    121121
    122122    [Obsolete]
    123     private void Initialize(ISymbolicExpressionGrammar mainBranchGrammar) {
     123    private void Initialize(ISymbolicExpressionTreeGrammar mainBranchGrammar) {
    124124      base.Clear();
    125125
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r5499 r5510  
    109109  </ItemGroup>
    110110  <ItemGroup>
     111    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeLengthAnalyzer.cs" />
    111112    <Compile Include="Analyzers\SymbolicExpressionSymbolFrequencyAnalyzer.cs" />
    112     <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs" />
    113     <Compile Include="Analyzers\SymbolicExpressionTreeSizeCalculator.cs" />
     113    <Compile Include="Analyzers\SymbolicExpressionTreeLengthCalculator.cs" />
    114114    <Compile Include="ArchitectureManipulators\ArgumentCreater.cs" />
    115115    <Compile Include="ArchitectureManipulators\ArgumentDeleter.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs

    r5499 r5510  
    2525  public interface ISymbol : INamedItem {
    2626    ISymbolicExpressionTreeNode CreateTreeNode();
    27     double InitialFrequency;
     27    double InitialFrequency { get; }
    2828  }
    2929}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs

    r5499 r5510  
    2525namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2626  public interface ISymbolicExpressionTree : IItem {
    27     ISymbolicExpressionTreeNode Root { get; }
     27    ISymbolicExpressionTreeNode Root { get; set; }
    2828    int Size { get; }
    2929    int Height { get; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs

    r5499 r5510  
    2222using HeuristicLab.Core;
    2323using System;
     24using HeuristicLab.Common;
    2425namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    25   public interface ISymbolicExpressionTreeNode : IItem {
     26  public interface ISymbolicExpressionTreeNode : IDeepCloneable {
    2627    ISymbolicExpressionTreeGrammar Grammar { get; }
    27 
     28    ISymbolicExpressionTreeNode Parent { get; set; }
    2829    ISymbol Symbol { get; }
    2930    bool HasLocalParameters { get; }
     
    3738    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix();
    3839    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix();
    39     void ForEachNodePostfix(Action<SymbolicExpressionTreeNode> a);
    40     void ForEachNodePrefix(Action<SymbolicExpressionTreeNode> a);
     40    void ForEachNodePostfix(Action<ISymbolicExpressionTreeNode> a);
     41    void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a);
    4142
    4243    IEnumerable<ISymbolicExpressionTreeNode> SubTrees { get; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs

    r5494 r5510  
    2828  /// </summary>
    2929  public interface ISymbolicExpressionTreeManipulator : ISymbolicExpressionTreeOperator, IManipulator {
    30     ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
     30    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3131  }
    3232}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs

    r5499 r5510  
    4141    }
    4242
    43     protected override void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree) {
     43    protected override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
    4444      ChangeNodeType(random, symbolicExpressionTree);
    4545    }
    4646
    47     public static void ChangeNodeType(IRandom random, SymbolicExpressionTree symbolicExpressionTree) {
     47    public static void ChangeNodeType(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
    4848
    4949      // select any node as parent (except the root node)
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs

    r5499 r5510  
    5454    }
    5555
    56     protected override void Manipulate(IRandom random, SymbolicExpressionTree tree) {
     56    protected override void Manipulate(IRandom random, ISymbolicExpressionTree tree) {
    5757      tree.Root.ForEachNodePostfix(node => {
    5858        if (node.HasLocalParameters) {
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r5499 r5510  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using HeuristicLab.Parameters;
     28using System.Collections.Generic;
    2829
    2930namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5455    }
    5556
    56     protected override void Manipulate(IRandom random, SymbolicExpressionTree tree) {
    57       var parametricNodes = from node in tree.IterateNodesPrefix()
    58                             where node.HasLocalParameters
    59                             select node;
    60       if (parametricNodes.Count() > 0) {
     57    protected override void Manipulate(IRandom random, ISymbolicExpressionTree tree) {
     58      List<ISymbolicExpressionTreeNode> parametricNodes = new List<ISymbolicExpressionTreeNode>();
     59      tree.Root.ForEachNodePostfix(n => {
     60        if (n.HasLocalParameters) parametricNodes.Add(n);
     61      });
     62      if (parametricNodes.Count > 0) {
    6163        var selectedPoint = parametricNodes.SelectRandom(random);
    62 
    6364        selectedPoint.ShakeLocalParameters(random, ShakingFactor.Value);
    6465      }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs

    r5499 r5510  
    3636
    3737    #region Parameter Properties
    38     public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    39       get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     38    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
     39      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    4040    }
    4141    #endregion
    4242
    4343    #region Properties
    44     public SymbolicExpressionTree SymbolicExpressionTree {
     44    public ISymbolicExpressionTree SymbolicExpressionTree {
    4545      get { return SymbolicExpressionTreeParameter.ActualValue; }
    4646    }
     
    5252    public SymbolicExpressionTreeManipulator()
    5353      : base() {
    54       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
     54      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
    5555    }
    5656
    5757    public sealed override IOperation Apply() {
    58       SymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
     58      ISymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
    5959      Manipulate(RandomParameter.ActualValue, tree);
    6060
     
    6262    }
    6363
    64     protected abstract void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree);
     64    protected abstract void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree);
    6565  }
    6666}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r5499 r5510  
    3131  public class SymbolicExpressionTreeNode : DeepCloneable, ISymbolicExpressionTreeNode {
    3232    [Storable]
    33     private IList<SymbolicExpressionTreeNode> subTrees;
     33    private IList<ISymbolicExpressionTreeNode> subTrees;
    3434    [Storable]
    35     private Symbol symbol;
     35    private ISymbol symbol;
    3636
    3737    // cached values to prevent unnecessary tree iterations
     
    3939    private ushort height;
    4040
    41     public Symbol Symbol {
     41    public ISymbol Symbol {
    4242      get { return symbol; }
    4343      protected set { symbol = value; }
     
    4545
    4646    // parent relation is not persisted or cloned (will be set on AddSubtree or RemoveSubtree)
    47     private SymbolicExpressionTreeNode parent;
    48     internal SymbolicExpressionTreeNode Parent {
     47    private ISymbolicExpressionTreeNode parent;
     48    public ISymbolicExpressionTreeNode Parent {
    4949      get { return parent; }
    5050      set { parent = value; }
     
    5656      : base() {
    5757      symbol = original.symbol; // symbols are reused
    58       subTrees = new List<SymbolicExpressionTreeNode>(original.SubTrees.Count);
    59       foreach (var subtree in original.SubTrees) {
     58      subTrees = new List<ISymbolicExpressionTreeNode>(original.subTrees.Count);
     59      foreach (var subtree in original.subTrees) {
    6060        var clonedSubTree = cloner.Clone(subtree);
    6161        subTrees.Add(clonedSubTree);
     
    7373    }
    7474
    75     public SymbolicExpressionTreeNode(Symbol symbol)
     75    public SymbolicExpressionTreeNode(ISymbol symbol)
    7676      : base() {
    77       subTrees = new List<SymbolicExpressionTreeNode>(3);
     77      subTrees = new List<ISymbolicExpressionTreeNode>(3);
    7878      this.symbol = symbol;
    7979    }
     
    8282    [StorableHook(HookType.AfterDeserialization)]
    8383    private void AfterDeserialization() {
    84       foreach (var subtree in SubTrees) {
     84      foreach (var subtree in subTrees) {
    8585        subtree.Parent = this;
    8686      }
     
    9191    }
    9292
    93     public virtual IList<SymbolicExpressionTreeNode> SubTrees {
     93    public virtual IEnumerable<ISymbolicExpressionTreeNode> SubTrees {
    9494      get { return subTrees; }
    9595    }
     
    103103      else {
    104104        size = 1;
    105         if (SubTrees != null) {
    106           for (int i = 0; i < SubTrees.Count; i++) {
    107             checked { size += (ushort)SubTrees[i].GetSize(); }
     105        if (subTrees != null) {
     106          for (int i = 0; i < subTrees.Count; i++) {
     107            checked { size += (ushort)subTrees[i].GetSize(); }
    108108          }
    109109        }
     
    115115      if (height > 0) return height;
    116116      else {
    117         if (SubTrees != null) {
    118           for (int i = 0; i < SubTrees.Count; i++) height = Math.Max(height, (ushort)SubTrees[i].GetHeight());
     117        if (subTrees != null) {
     118          for (int i = 0; i < subTrees.Count; i++) height = Math.Max(height, (ushort)subTrees[i].GetHeight());
    119119        }
    120120        height++;
     
    126126    public virtual void ShakeLocalParameters(IRandom random, double shakingFactor) { }
    127127
    128     public virtual void AddSubTree(SymbolicExpressionTreeNode tree) {
    129       SubTrees.Add(tree);
     128    public virtual ISymbolicExpressionTreeNode GetSubTree(int index) {
     129      return subTrees[index];
     130    }
     131    public virtual int IndexOfSubTree(ISymbolicExpressionTreeNode tree) {
     132      return subTrees.IndexOf(tree);
     133    }
     134    public virtual void AddSubTree(ISymbolicExpressionTreeNode tree) {
     135      subTrees.Add(tree);
    130136      tree.Parent = this;
    131137      ResetCachedValues();
    132138    }
    133 
    134     public virtual void InsertSubTree(int index, SymbolicExpressionTreeNode tree) {
    135       SubTrees.Insert(index, tree);
     139    public virtual void InsertSubTree(int index, ISymbolicExpressionTreeNode tree) {
     140      subTrees.Insert(index, tree);
    136141      tree.Parent = this;
    137142      ResetCachedValues();
    138143    }
    139 
    140144    public virtual void RemoveSubTree(int index) {
    141       SubTrees[index].Parent = null;
    142       SubTrees.RemoveAt(index);
     145      subTrees[index].Parent = null;
     146      subTrees.RemoveAt(index);
    143147      ResetCachedValues();
    144148    }
    145149
    146     public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix() {
    147       List<SymbolicExpressionTreeNode> list = new List<SymbolicExpressionTreeNode>();
     150    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() {
     151      List<ISymbolicExpressionTreeNode> list = new List<ISymbolicExpressionTreeNode>();
    148152      ForEachNodePrefix((n) => list.Add(n));
    149153      return list;
    150154    }
    151155
    152     public void ForEachNodePrefix(Action<SymbolicExpressionTreeNode> a) {
     156    public void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a) {
    153157      a(this);
    154158      if (SubTrees != null) {
    155         for (int i = 0; i < SubTrees.Count; i++) {
    156           SubTrees[i].ForEachNodePrefix(a);
    157         }
    158       }
    159     }
    160 
    161     public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix() {
    162       List<SymbolicExpressionTreeNode> list = new List<SymbolicExpressionTreeNode>();
     159        foreach (var subtree in SubTrees) {
     160          subtree.ForEachNodePrefix(a);
     161        }
     162      }
     163    }
     164
     165    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix() {
     166      List<ISymbolicExpressionTreeNode> list = new List<ISymbolicExpressionTreeNode>();
    163167      ForEachNodePostfix((n) => list.Add(n));
    164168      return list;
    165169    }
    166170
    167     public void ForEachNodePostfix(Action<SymbolicExpressionTreeNode> a) {
     171    public void ForEachNodePostfix(Action<ISymbolicExpressionTreeNode> a) {
    168172      if (SubTrees != null) {
    169         for (int i = 0; i < SubTrees.Count; i++) {
    170           SubTrees[i].ForEachNodePostfix(a);
     173        foreach (var subtree in SubTrees) {
     174          subtree.ForEachNodePostfix(a);
    171175        }
    172176      }
     
    190194    private void ResetCachedValues() {
    191195      size = 0; height = 0;
    192       if (parent != null) parent.ResetCachedValues();
     196      SymbolicExpressionTreeNode parentNode = parent as SymbolicExpressionTreeNode;
     197      if (parentNode != null) parentNode.ResetCachedValues();
    193198    }
    194199  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeSizeConstraintOperator.cs

    r5499 r5510  
    5252
    5353    #region Properties
    54     public IRandom Random {
    55       get { return RandomParameter.ActualValue; }
    56     }
    5754    public IntValue MaximumSymbolicExpressionTreeLength {
    5855      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs

    r5499 r5510  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using System.Linq;
    2627
    2728namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2829  [StorableClass]
    2930  public abstract class SymbolicExpressionTreeTerminalNode : SymbolicExpressionTreeNode {
    30     private static List<SymbolicExpressionTreeNode> emptyList = new List<SymbolicExpressionTreeNode>();
    31     public override IList<SymbolicExpressionTreeNode> SubTrees {
     31    public override IEnumerable<ISymbolicExpressionTreeNode> SubTrees {
    3232      get {
    33         return SymbolicExpressionTreeTerminalNode.emptyList;
     33        return Enumerable.Empty<ISymbolicExpressionTreeNode>();
    3434      }
    3535    }
     
    3737    [StorableConstructor]
    3838    protected SymbolicExpressionTreeTerminalNode(bool deserializing) : base(deserializing) { }
    39     // don't call storable constructor of base to prevent allocation of sub-trees list in base!
     39    // don't call cloning constructor of base to prevent allocation of sub-trees list in base!
    4040    protected SymbolicExpressionTreeTerminalNode(SymbolicExpressionTreeTerminalNode original, Cloner cloner)
    4141      : base() {
     
    5151    }
    5252
    53     public override void AddSubTree(SymbolicExpressionTreeNode tree) {
     53    public override int IndexOfSubTree(ISymbolicExpressionTreeNode tree) {
     54      return -1;
     55    }
     56    public override ISymbolicExpressionTreeNode GetSubTree(int index) {
    5457      throw new NotSupportedException();
    5558    }
    56     public override void InsertSubTree(int index, SymbolicExpressionTreeNode tree) {
     59    public override void AddSubTree(ISymbolicExpressionTreeNode tree) {
     60      throw new NotSupportedException();
     61    }
     62    public override void InsertSubTree(int index, ISymbolicExpressionTreeNode tree) {
    5763      throw new NotSupportedException();
    5864    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs

    r5499 r5510  
    5555    }
    5656
    57     public override SymbolicExpressionTreeNode CreateTreeNode() {
     57    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    5858      return new ArgumentTreeNode(this);
    5959    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs

    r5499 r5510  
    4242    }
    4343
    44     public override SymbolicExpressionTreeNode CreateTreeNode() {
     44    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    4545      return new DefunTreeNode(this);
    4646    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs

    r5499 r5510  
    6060    }
    6161
    62     public override SymbolicExpressionTreeNode CreateTreeNode() {
     62    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    6363      return new InvokeFunctionTreeNode(this);
    6464    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs

    r5499 r5510  
    3838      return new ProgramRootSymbol(this, cloner);
    3939    }
    40     public override SymbolicExpressionTreeNode CreateTreeNode() {
     40    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    4141      return new SymbolicExpressionTreeTopLevelNode(this);
    4242    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs

    r5499 r5510  
    3939    }
    4040
    41     public override SymbolicExpressionTreeNode CreateTreeNode() {
     41    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    4242      return new SymbolicExpressionTreeTopLevelNode(this);
    4343    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs

    r5499 r5510  
    6464
    6565
    66     public virtual SymbolicExpressionTreeNode CreateTreeNode() {
     66    public virtual ISymbolicExpressionTreeNode CreateTreeNode() {
    6767      return new SymbolicExpressionTreeNode(this);
    6868    }
Note: See TracChangeset for help on using the changeset viewer.