Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/19/17 12:55:58 (7 years ago)
Author:
pkimmesw
Message:

#2665 Started Plush Encoding, Added Zero Error Individual Count Analyzer

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

Legend:

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

    r15189 r15273  
    88
    99  using Attributes;
     10
     11  using HeuristicLab.BenchmarkSuite;
    1012
    1113  using Stack;
     
    6062      }
    6163    }
     64
     65    public static void InitExample(this IPushInterpreter interpreter, Example example) {
     66      interpreter.BooleanStack.Push(example.InputBoolean);
     67      interpreter.IntegerStack.Push(example.InputInteger);
     68      interpreter.FloatStack.Push(example.InputFloat);
     69      interpreter.CharStack.Push(example.InputChar);
     70      interpreter.StringStack.Push(example.InputString);
     71      interpreter.StringVectorStack.Push(example.InputStringVector);
     72      interpreter.IntegerVectorStack.Push(example.InputIntegerVector);
     73      interpreter.FloatVectorStack.Push(example.InputFloatVector);
     74
     75      interpreter.SetInput(
     76        integers: example.InputInteger,
     77        floats: example.InputFloat,
     78        booleans: example.InputBoolean,
     79        chars: example.InputChar,
     80        strings: example.InputString,
     81        integerVectors: example.InputIntegerVector,
     82        floatVectors: example.InputFloatVector,
     83        stringVectors: example.InputStringVector);
     84    }
    6285  }
    6386}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/IPushInterpreter.cs

    r15189 r15273  
    1111
    1212  public interface IPushInterpreter {
    13     IRandom Random { get; set; }
     13    IRandom Random { get; }
    1414    IPushStack<Expression> CodeStack { get; }
    1515    IPushStack<Expression> ExecStack { get; }
     
    2828    IReadOnlyDictionary<StackTypes, IPushStack> Stacks { get; }
    2929    IReadOnlyPushConfiguration Configuration { get; }
    30     void Clear();
    31     void Reset();
     30    void ClearStacks();
     31    void Reset(IRandom random = null);
    3232
    3333    void SetInput(
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PooledPushInterpreter.cs

    r15032 r15273  
    1515    public override void Dispose() {
    1616      base.Dispose();
    17       Clear();
     17      ClearStacks();
    1818      pool.Free(this);
    1919    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreter.cs

    r15189 r15273  
    1919    private Expression currentProgram;
    2020
     21    /// <summary>
     22    /// An interpreter for Push
     23    /// </summary>
     24    /// <param name="config">Determines the runtime behavior of the interpreter</param>
     25    /// <param name="random">Note that random may be reseted</param>
     26    /// <param name="poolContainer">Used to save resources used by the interpreter</param>
    2127    public PushInterpreter(IReadOnlyPushConfiguration config = null, IRandom random = null, InterpreterPoolContainer poolContainer = null) {
    22       Random = random ?? new MersenneTwister();
     28      randomOrigin = random ?? new MersenneTwister();
     29      Random = (IRandom)randomOrigin.Clone();
    2330      Configuration = config ?? new PushConfiguration();
    2431
     
    6976    public IReadOnlyDictionary<StackTypes, IPushStack> Stacks { get; private set; }
    7077
    71     public IRandom Random { get; set; }
     78    private IRandom randomOrigin;
     79    public IRandom Random { get; private set; }
    7280
    7381    public long ExecCounter { get; private set; }
     
    330338
    331339    /// <summary>
    332     /// Reset while interpreter
     340    /// Reset interpreter which clears and reconfigures stacks and local variables
    333341    /// </summary>
    334     public void Reset() {
     342    public void Reset(IRandom random = null) {
     343      if (random != null)
     344        randomOrigin = random;
     345
     346      // Reset Random
     347      Random = (IRandom)randomOrigin.Clone();
     348
    335349      ExecCounter = 0;
    336350      IsAborted = false;
     
    340354
    341355      inputExpressions.Clear();
    342       Clear();
     356      ClearStacks();
    343357      ConfigureStacks();
    344358    }
     
    357371    /// Clears Stacks and custom expressions
    358372    /// </summary>
    359     public void Clear() {
     373    public void ClearStacks() {
    360374      for (var i = 0u; i < supportedStackTypes.Length; i++) {
    361375        var key = supportedStackTypes[i];
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs

    r15189 r15273  
    55  using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
    66  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    7   using HeuristicLab.Random;
    87
    98  public class PushInterpreterPool {
     
    3332    public PooledPushInterpreter Create(IRandom random = null) {
    3433      var interpreter = pool.Allocate();
    35       interpreter.Random = random ?? new MersenneTwister();
    36       interpreter.Reset();
     34      interpreter.Reset(random);
    3735
    3836      return interpreter;
     
    4038
    4139    public void Free(PooledPushInterpreter interpreter) {
    42       interpreter.Random = null;
     40      interpreter.ClearStacks();
    4341      pool.Free(interpreter);
    4442    }
Note: See TracChangeset for help on using the changeset viewer.