Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/PushConfiguration.cs

    r14744 r14747  
    5858      this.isNameStackEnabled = origin.IsNameStackEnabled;
    5959      this.isCodeStackEnabled = origin.IsCodeStackEnabled;
    60       this.isExecStackEnabled = origin.IsExecStackEnable;
     60      this.isExecStackEnabled = origin.IsExecStackEnabled;
    6161    }
    6262
     
    155155    private bool isExecStackEnabled = true;
    156156
    157     public bool IsExecStackEnable
     157    public bool IsExecStackEnabled
    158158    {
    159159      get
     
    347347          IsCodeStackEnabled = value;
    348348          break;
     349        case StackType.Exec:
     350          this.IsExecStackEnabled = value;
     351          break;
    349352        default: throw new InvalidOperationException("Stacktype unkown");
    350353      }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/ManagedPoolProvider.cs

    r14746 r14747  
    2121    public const int DefaultMaxInstanceCount = 65536;
    2222
    23     public ManagedPoolProvider(int partitionSize, int maxPartitionCount = -1) {
     23    public ManagedPoolProvider(int partitionSize, int? maxPartitionCount = null) {
    2424      PartitionSize = partitionSize;
     25      MaxParitionCount = maxPartitionCount ?? DefaultMaxInstanceCount / PartitionSize;
    2526
    26       if (maxPartitionCount <= 0) {
    27         MaxParitionCount = DefaultMaxInstanceCount / PartitionSize;
    28       }
    29 
    30       managedPools = new ObjectPool<IManagedPool<T>>(() => new ManagedPool2<T>(this));
     27      managedPools = new ObjectPool<IManagedPool<T>>(() => new ManagedPool<T>(this));
    3128    }
    3229
     
    6562    }
    6663
    67     private class ManagedPool2<T> : IManagedPool<T> where T : class {
     64    private class ManagedPool<T> : IManagedPool<T> where T : class {
    6865      private readonly ManagedPoolProvider<T> provider;
    6966      private readonly IList<T[]> partitions = new List<T[]>();
     
    7168      private int entryIndex;
    7269
    73       public ManagedPool2(ManagedPoolProvider<T> provider) {
     70      public ManagedPool(ManagedPoolProvider<T> provider) {
    7471        this.provider = provider;
    7572        entryIndex = provider.PartitionSize;
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PooledPushInterpreter.cs

    r14744 r14747  
    44  using HeuristicLab.Core;
    55  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
     6  using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
     7  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    68
    79  public class PooledPushInterpreter : PushInterpreter, IDisposable {
     
    911    private readonly PushInterpreterPool pool;
    1012
    11     public PooledPushInterpreter(PushInterpreterPool pool, PushConfiguration config, IRandom random = null)
    12       : base(config, random) {
     13    public PooledPushInterpreter(PushInterpreterPool pool, PushConfiguration config, ManagedPoolProvider<PushProgram> pushProgramPoolProvider, IRandom random = null)
     14      : base(config, random, pushProgramPoolProvider) {
    1315      this.pool = pool;
    1416    }
  • 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;
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs

    r14744 r14747  
    11namespace HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter {
    22  using System;
    3 
    4   using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
    53  using HeuristicLab.Core;
    64  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
     5  using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
     6  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    77  using HeuristicLab.Random;
    88
    99  public class PushInterpreterPool {
    1010    private readonly ObjectPool<PooledPushInterpreter> pool;
     11    private ManagedPoolProvider<PushProgram> pushProgramPoolProvider;
    1112
    1213    public PushInterpreterPool(PushConfiguration config = null)
    13       : this(Environment.ProcessorCount * 2, config) {
     14      : this(Environment.ProcessorCount * 2, 1024, null, config) {
    1415    }
    1516
    16     public PushInterpreterPool(int size, PushConfiguration config = null) {
    17       this.PushGpConfiguration = config ?? new PushConfiguration();
     17    public PushInterpreterPool(int size, int pushProgramPoolPartitionSize, int? maxPartitionCount = null, PushConfiguration config = null) {
     18      PushGpConfiguration = config ?? new PushConfiguration();
    1819
    19       this.pool = new ObjectPool<PooledPushInterpreter>(() => new PooledPushInterpreter(this, this.PushGpConfiguration), size);
     20      pushProgramPoolProvider = new ManagedPoolProvider<PushProgram>(pushProgramPoolPartitionSize, maxPartitionCount);
     21      pushProgramPoolProvider.InitDummyPartition(() => new PushProgram());
     22
     23      pool = new ObjectPool<PooledPushInterpreter>(() => new PooledPushInterpreter(this, PushGpConfiguration, pushProgramPoolProvider), size);
    2024    }
    2125
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushProblem.cs

    r14746 r14747  
    88  using Core;
    99  using Encodings.IntegerVectorEncoding;
    10   using Expressions;
    1110
    1211  using HeuristicLab.BenchmarkSuite;
    1312  using HeuristicLab.Data;
    14   using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
    1513
    1614  using Instances;
     
    2826    private readonly PushConfiguration config;
    2927    private PushInterpreterPool pool;
    30     private ManagedPoolProvider<PushProgram> pushProgramPoolProvider;
    3128
    3229    public PushProblem() {
    3330      config = new PushConfiguration();
    34       pool = new PushInterpreterPool(config);
    35 
    36       pushProgramPoolProvider = new ManagedPoolProvider<PushProgram>(1024);
    37       pushProgramPoolProvider.InitDummyPartition(() => new PushProgram());
     31      pool = new PushInterpreterPool(10000, 1024, 65536, config);
    3832
    3933      InitEvents();
     
    5044      : base(original, cloner) {
    5145      config = cloner.Clone(original.config);
    52       pool = new PushInterpreterPool(config);
     46      pool = new PushInterpreterPool(65536, 1024, 65536, config);
    5347
    5448      Instructions = config;
     
    6256      pool = new PushInterpreterPool(config);
    6357      Instructions = config;
    64 
    65       pushProgramPoolProvider = new ManagedPoolProvider<PushProgram>(1024);
    66       pushProgramPoolProvider.InitDummyPartition(() => new PushProgram());
    6758
    6859      InitEvents();
     
    426417          interpreter.FloatStack.Push(example.InputFloat);
    427418
    428           using (interpreter.PushProgramPool = pushProgramPoolProvider.CreatePool()) {
    429             interpreter.Run(program);
    430           }
     419          interpreter.Run(program);
    431420
    432421          result += GetDiff(example.OutputInt, interpreter.IntegerStack, DataDescriptor.WorstResult, LongDiffer)
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/ExpressionSelectionView.cs

    r14727 r14747  
    5757      } else {
    5858        if (e.Node.Checked) {
    59           Content.EnableExpression(e.Node.Name);
     59          Content.EnableExpression(e.Node.Text);
    6060        } else {
    61           Content.DisableExpression(e.Node.Name);
     61          Content.DisableExpression(e.Node.Text);
    6262        }
    6363      }
Note: See TracChangeset for help on using the changeset viewer.