Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/28/17 09:03:34 (7 years ago)
Author:
pkimmesw
Message:

#2665 Testet Problems, Improved Performance

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter
Files:
2 edited

Legend:

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

    r15334 r15341  
    1717  public class PushInterpreter : IInternalPushInterpreter, IDisposable {
    1818    private Task currentTask;
    19     private Expression currentProgram;
     19    private int evalPushLimit;
    2020
    2121    /// <summary>
     
    3030      Configuration = config ?? new PushConfiguration();
    3131
    32       // setting the capacity of the Stacks to max points ensures that there will be enough memory at runtime
    3332      ExecStack = new PushStack<Expression>(Configuration.MaxProgramLength);
    3433      CodeStack = new PushStack<Expression>();
     
    6665      PoolContainer = poolContainer ?? new InterpreterPoolContainer();
    6766
     67      InitEvalPushLimit();
    6868      ConfigureStacks();
    6969    }
     
    9292               !IsPaused &&
    9393               !IsAborted &&
    94                (ExecCounter < Configuration.EvalPushLimit);
     94               (ExecCounter < evalPushLimit);
    9595      }
    9696    }
     
    261261    public void Run(Expression expression, bool stepwise = false) {
    262262      IsPaused = stepwise;
    263       currentProgram = expression;
    264263
    265264      /* Push top expression so the loop is able to enter
     
    347346      Random = (IRandom)randomOrigin.Clone();
    348347
     348      InitEvalPushLimit();
     349
    349350      ExecCounter = 0;
    350351      IsAborted = false;
    351352      IsPaused = false;
    352353      currentTask = null;
    353       currentProgram = null;
    354354
    355355      inputExpressions.Clear();
    356356      ClearStacks();
    357357      ConfigureStacks();
     358    }
     359
     360    private void InitEvalPushLimit() {
     361      // evalPushLimit is accessed very often and using the getter of the configuration object is rather expensive as the values is capsuled within a parameter
     362      evalPushLimit = Configuration.EvalPushLimit;
     363    }
     364
     365    private void EvalPushLimitChanged(object sender, EventArgs e) {
     366      this.evalPushLimit = Configuration.EvalPushLimit;
    358367    }
    359368
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs

    r15334 r15341  
    3333
    3434    public PooledPushInterpreter Create(IRandom random = null) {
    35       //var interpreter = pool.Allocate();
    36       //interpreter.Reset(random);
    37 
    38       var poolContainer = new InterpreterPoolContainer(PushProgramPoolProvider, ExpressionListPoolProvider);
    39       var interpreter = new PooledPushInterpreter(this, PushConfiguration, poolContainer, random);
     35      var interpreter = pool.Allocate();
     36      interpreter.Reset(random);
    4037
    4138      return interpreter;
Note: See TracChangeset for help on using the changeset viewer.