Changeset 15766


Ignore:
Timestamp:
02/13/18 13:31:24 (18 months ago)
Author:
mkommend
Message:

#1973: Adapted symbolic expression tree compilers to allow more than 256 child nodes.

Location:
trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/Instruction.cs

    r15583 r15766  
    2929    public byte opCode;
    3030    // number of arguments of the current instruction
    31     public byte nArguments;
     31    public ushort nArguments;
    3232    // an optional object value (addresses for calls, argument index for arguments)
    3333    public object data;
  • trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs

    r15583 r15766  
    6363        Instruction instr = new Instruction();
    6464        int subtreesCount = node.SubtreeCount;
    65         if (subtreesCount > 255) throw new ArgumentException("Number of subtrees is too big (>255)");
    66         instr.nArguments = (byte)subtreesCount;
     65        if (subtreesCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (> 65.535)");
     66        instr.nArguments = (ushort)subtreesCount;
    6767        instr.opCode = opCodeMapper(node);
    6868        if (node.Symbol is Argument) {
  • trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeLinearCompiler.cs

    r15583 r15766  
    2727      var root = tree.Root.GetSubtree(0).GetSubtree(0);
    2828      var code = new LinearInstruction[root.GetLength()];
    29       code[0] = new LinearInstruction { dynamicNode = root, nArguments = (byte)root.SubtreeCount, opCode = opCodeMapper(root) };
     29      if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
     30      code[0] = new LinearInstruction { dynamicNode = root, nArguments = (ushort)root.SubtreeCount, opCode = opCodeMapper(root) };
    3031      int c = 1, i = 0;
    3132      foreach (var node in root.IterateNodesBreadth()) {
    3233        for (int j = 0; j < node.SubtreeCount; ++j) {
    3334          var s = node.GetSubtree(j);
    34           code[c + j] = new LinearInstruction { dynamicNode = s, nArguments = (byte)s.SubtreeCount, opCode = opCodeMapper(s) };
     35          if (s.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
     36          code[c + j] = new LinearInstruction { dynamicNode = s, nArguments = (ushort)s.SubtreeCount, opCode = opCodeMapper(s) };
    3537        }
    3638        code[i].childIndex = c;
Note: See TracChangeset for help on using the changeset viewer.