Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/08/11 16:02:47 (14 years ago)
Author:
gkronber
Message:

#1418 improved memory usage of symbolic data analysis expression tree interpreter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r5925 r5987  
    3636    #region private classes
    3737    private class InterpreterState {
    38       private const int ARGUMENT_STACK_SIZE = 1024;
    3938      private double[] argumentStack;
    4039      private int argumentStackPointer;
     
    4544        set { pc = value; }
    4645      }
    47       internal InterpreterState(Instruction[] code) {
     46      internal InterpreterState(Instruction[] code, int argumentStackSize) {
    4847        this.code = code;
    4948        this.pc = 0;
    50         this.argumentStack = new double[ARGUMENT_STACK_SIZE];
     49        if (argumentStackSize > 0) {
     50          this.argumentStack = new double[argumentStackSize];
     51        }
    5152        this.argumentStackPointer = 0;
    5253      }
     
    202203      var compiler = new SymbolicExpressionTreeCompiler();
    203204      Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);
    204 
     205      int necessaryArgStackSize = 0;
    205206      for (int i = 0; i < code.Length; i++) {
    206207        Instruction instr = code[i];
     
    216217          var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode;
    217218          instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);
     219        } else if (instr.opCode == OpCodes.Call) {
     220          necessaryArgStackSize += instr.nArguments + 1;
    218221        }
    219222      }
    220       var state = new InterpreterState(code);
     223      var state = new InterpreterState(code, necessaryArgStackSize);
    221224
    222225      foreach (var rowEnum in rows) {
     
    370373            double f_3 = Evaluate(dataset, ref row, state); row--;
    371374            state.ProgramCounter = savedPc;
    372             double f_4 = Evaluate(dataset, ref row, state); 
     375            double f_4 = Evaluate(dataset, ref row, state);
    373376            row += 4;
    374377
Note: See TracChangeset for help on using the changeset viewer.