Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/11 19:01:00 (14 years ago)
Author:
gkronber
Message:

#1418 changes in symbolic expression tree encoding.

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

Legend:

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

    • Property svn:ignore
      •  

        old new  
        22obj
        33HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs
         4*.user
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/Instruction.cs

    r5445 r5499  
    2121
    2222
    23 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Compiler {
    24   // total size of this struct should be small to improve cache access while executing the code
    25   // should be aligned to 8/16/32 byte
    26   // size = 4(8) + 1 + 1 + 2 = 8 (12)
     23namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     24  // total size of this class should be small to improve cache access while executing the code
    2725  public class Instruction {
    2826    // the tree node can hold additional data that is necessary for the execution of this instruction
    29     public SymbolicExpressionTreeNode dynamicNode;
     27    public ISymbolicExpressionTreeNode dynamicNode;
    3028    // op code of the function that determines what operation should be executed
    3129    public byte opCode;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs

    r5445 r5499  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2625
    27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Compiler {
     26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2827  public class SymbolicExpressionTreeCompiler {
    2928    private Dictionary<string, ushort> entryPoint = new Dictionary<string, ushort>();
    3029    private List<Func<Instruction, Instruction>> postInstructionCompiledHooks = new List<Func<Instruction, Instruction>>();
    3130
    32     public Instruction[] Compile(SymbolicExpressionTree tree, Func<SymbolicExpressionTreeNode, byte> opCodeMapper) {
     31    public Instruction[] Compile(SymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
    3332      List<Instruction> code = new List<Instruction>();
    3433      entryPoint.Clear();
    3534      // compile main body branches
    36       foreach (var branch in tree.Root.SubTrees[0].SubTrees) {
     35      foreach (var branch in tree.Root.GetSubTree(0).SubTrees) {
    3736        code.AddRange(Compile(branch, opCodeMapper));
    3837      }
     
    6059    }
    6160
    62     private IEnumerable<Instruction> Compile(SymbolicExpressionTreeNode branch, Func<SymbolicExpressionTreeNode, byte> opCodeMapper) {
     61    private IEnumerable<Instruction> Compile(ISymbolicExpressionTreeNode branch, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
    6362      foreach (var node in branch.IterateNodesPrefix()) {
    6463        Instruction instr = new Instruction();
    65         if (node.SubTrees.Count > 255) throw new ArgumentException("Number of subtrees is too big (>255)");
    66         instr.nArguments = (byte)node.SubTrees.Count;
     64        int subTreesCount = node.SubTrees.Count();
     65        if (subTreesCount > 255) throw new ArgumentException("Number of subtrees is too big (>255)");
     66        instr.nArguments = (byte)subTreesCount;
    6767        instr.opCode = opCodeMapper(node);
    6868        if (node.Symbol is Argument) {
Note: See TracChangeset for help on using the changeset viewer.