Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/17 11:23:05 (7 years ago)
Author:
pkimmesw
Message:

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreter.cs

    r14914 r14952  
    192192
    193193      /* Push top expression so the loop is able to enter
    194        * If the top expression is a single statement then the loop has nothing to do.
    195        * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack.
    196        * Expanding the initial program is not counted */
    197       ExecStack.Push(expression);
    198 
    199       if (Configuration.TopLevelPushCode) CodeStack.Push(expression);
    200 
    201       // expand if program
    202       if (expression.IsProgram)
    203         DoStep();
     194       * If the top expression is a single statement it gets evaluated in Run.
     195       * Otherwise the push program will be evaluated and the expressions of the program are pushed onto the EXEC stack.
     196       * Expanding the initial program is not counted in ExecCount */
     197      InitRun(expression);
     198
     199      if (Configuration.TopLevelPushCode && CodeStack.IsEnabled)
     200        CodeStack.Push(expression);
    204201
    205202      Run();
     
    309306    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    310307    private void Finally() {
    311       if (Configuration.TopLevelPopCode && !CodeStack.IsEmpty)
     308      if (Configuration.TopLevelPopCode && !CodeStack.IsEmpty && CodeStack.IsEnabled)
    312309        CodeStack.Pop();
    313310
    314311      PoolContainer.DisposePools();
     312    }
     313
     314    private void InitRun(Expression expression) {
     315      ExecStack.Push(expression);
     316
     317      if (!expression.IsProgram)
     318        return;
     319
     320      DoStep();
     321      ExecCounter--;   // unpacking the initial program is not counted
    315322    }
    316323
     
    324331
    325332      var expression = ExecStack.Pop();
    326       var succ = expression.Eval(this);
     333      var succ = expression.TryEval(this);
    327334
    328335      if ((ExecStack.Count > 0 && ExecStack.Top == null) ||
     
    341348    private bool DoStep() {
    342349      ExecCounter++;
    343       return ExecStack.Pop().Eval(this);
     350      return ExecStack.Pop().TryEval(this);
    344351    }
    345352#endif
     
    347354    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    348355    private void DoTenSteps() {
    349       ExecStack[0].Eval(this);
    350       ExecStack[1].Eval(this);
    351       ExecStack[2].Eval(this);
    352       ExecStack[3].Eval(this);
    353       ExecStack[4].Eval(this);
    354       ExecStack[5].Eval(this);
    355       ExecStack[6].Eval(this);
    356       ExecStack[7].Eval(this);
    357       ExecStack[8].Eval(this);
    358       ExecStack[9].Eval(this);
     356      ExecStack[0].TryEval(this);
     357      ExecStack[1].TryEval(this);
     358      ExecStack[2].TryEval(this);
     359      ExecStack[3].TryEval(this);
     360      ExecStack[4].TryEval(this);
     361      ExecStack[5].TryEval(this);
     362      ExecStack[6].TryEval(this);
     363      ExecStack[7].TryEval(this);
     364      ExecStack[8].TryEval(this);
     365      ExecStack[9].TryEval(this);
    359366
    360367      ExecStack.Remove(10);
Note: See TracChangeset for help on using the changeset viewer.