Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/12/17 13:16:56 (7 years ago)
Author:
pkimmesw
Message:

#2665 fixed enable/disable issue for single instruction in selection view

File:
1 edited

Legend:

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

    r14746 r14747  
    1919    private Task currentTask;
    2020
    21     public PushInterpreter(IReadonlyPushConfiguration config = null, IRandom random = null) {
     21    public PushInterpreter(IReadonlyPushConfiguration config = null, IRandom random = null, ManagedPoolProvider<PushProgram> pushProgramPoolProvider = null) {
    2222      Random = random ?? new FastRandom();
    2323
     
    4545
    4646      CustomExpressions = new Dictionary<string, Expression>();
     47
     48      PushProgramPoolProvider = pushProgramPoolProvider ?? new ManagedPoolProvider<PushProgram>(1024);
     49
     50      if (pushProgramPoolProvider == null)
     51      {
     52        PushProgramPoolProvider.InitDummyPartition(() => new PushProgram());
     53      }
    4754    }
    4855
     
    8693    }
    8794
    88     public IManagedPool<PushProgram> PushProgramPool { get; set; }
     95    private readonly ManagedPoolProvider<PushProgram> PushProgramPoolProvider;
     96    public IManagedPool<PushProgram> PushProgramPool { get; private set; }
    8997
    9098    public IReadonlyPushConfiguration Configuration { get; protected set; }
     
    127135
    128136    public void Run(Expression program, bool stepwise = false) {
    129       IsPaused = stepwise;
    130 
    131       /* Push top expression so the loop is able to enter
    132        * If the top expression is a single statement then the loop has nothing to do
    133        * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack */
    134       ExecStack.Push(program);
    135 
    136       if (Configuration.TopLevelPushCode) CodeStack.Insert(0, program);
    137 
    138       // run top expression
    139       DoStep();
    140 
    141       Interpret();
     137      using (PushProgramPool = PushProgramPoolProvider.CreatePool()) {
     138        IsPaused = stepwise;
     139
     140        /* Push top expression so the loop is able to enter
     141         * If the top expression is a single statement then the loop has nothing to do
     142         * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack */
     143        ExecStack.Push(program);
     144
     145        if (Configuration.TopLevelPushCode) CodeStack.Insert(0, program);
     146
     147        // run top expression
     148        DoStep();
     149
     150        Interpret();
     151      }
    142152    }
    143153
     
    146156
    147157      IsAborted = true;
     158
     159      if (PushProgramPool != null) PushProgramPool.Dispose();
    148160
    149161      if (currentTask != null) await currentTask;
Note: See TracChangeset for help on using the changeset viewer.