Free cookie consent management tool by TermsFeed Policy Generator

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

#1418 Fixed compiler errors in symbolic expression tree encoding

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

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.