Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/31/10 18:34:34 (15 years ago)
Author:
gkronber
Message:

Integrated graphical symbolic expression tree view from model analyzer. #937 (Data types and operators for symbolic expression tree encoding)

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

Legend:

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

    r3237 r3244  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using System.Text;
     
    6061    public SymbolicExpressionTree(SymbolicExpressionTreeNode root) : base() { }
    6162
     63    public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix() {
     64      return IterateNodesPrefix(root);
     65    }
     66    private IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix(SymbolicExpressionTreeNode node) {
     67      yield return node;
     68      foreach (var subtree in node.SubTrees) {
     69        foreach (var n in IterateNodesPrefix(subtree))
     70          yield return n;
     71      }
     72    }
     73    public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix() {
     74      return IterateNodesPostfix(root);
     75    }
     76    private IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix(SymbolicExpressionTreeNode node) {
     77      foreach (var subtree in node.SubTrees) {
     78        foreach (var n in IterateNodesPrefix(subtree))
     79          yield return n;
     80      }
     81      yield return node;
     82    }
     83
    6284    public override IDeepCloneable Clone(Cloner cloner) {
    6385      SymbolicExpressionTree clone = new SymbolicExpressionTree();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs

    r3237 r3244  
    2626using System.Xml;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Data;
    2829
    2930namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    4950    //}
    5051
    51     internal virtual bool HasLocalParameters {
     52    public virtual bool HasLocalParameters {
    5253      get { return false; }
    5354    }
     
    6263    }
    6364
    64     internal int GetSize() {
     65    public int GetSize() {
    6566      int size = 1;
    6667      foreach (SymbolicExpressionTreeNode tree in SubTrees) size += tree.GetSize();
     
    6869    }
    6970
    70     internal int GetHeight() {
     71    public int GetHeight() {
    7172      int maxHeight = 0;
    7273      foreach (SymbolicExpressionTreeNode tree in SubTrees) maxHeight = Math.Max(maxHeight, tree.GetHeight());
Note: See TracChangeset for help on using the changeset viewer.