Free cookie consent management tool by TermsFeed Policy Generator

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

#2665 Fixed Benchmark Problem Definition, Converted LoopExpressions to stateless expressions, Added several unit test to ensure funcionality, Fixed UI bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSetExpressions.cs

    r14952 r15017  
    44  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    55  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
     6  using HeuristicLab.Problems.ProgramSynthesis.Push.Extensions;
    67  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
    78  using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
     
    1718    protected VectorSetExpression(bool deserializing) : base(deserializing) { }
    1819
    19     protected bool IsNoop(IInternalPushInterpreter interpreter, IPushStack<List<T>> vectorStack, IPushStack<T> literalStack, bool isLiteralTypeInteger = false) {
     20    protected bool IsNoop(IInternalPushInterpreter interpreter, IPushStack<IReadOnlyList<T>> vectorStack, IPushStack<T> literalStack, bool isLiteralTypeInteger = false) {
    2021      return vectorStack.IsEmpty ||
    2122             vectorStack.Top.Count == 0 ||
     
    2728    protected void Eval(
    2829      IInternalPushInterpreter interpreter,
    29       IPushStack<List<T>> vectorStack,
     30      IPushStack<IReadOnlyList<T>> vectorStack,
    3031      IPushStack<T> literalStack,
    3132      bool isLiteralTypeInteger = false) {
    3233      T literal;
    33       int index;
     34      long x;
    3435
    3536      if (isLiteralTypeInteger) {
    3637        literal = literalStack.Top;
    37         index = (int)interpreter.IntegerStack[1];
     38        x = interpreter.IntegerStack[1];
    3839        interpreter.IntegerStack.Remove(2);
    3940      } else {
    4041        literal = literalStack.Pop();
    41         index = (int)interpreter.IntegerStack.Pop();
     42        x = interpreter.IntegerStack.Pop();
    4243      }
    4344
    44       var vector = vectorStack.Pop();
    45       index = index % vector.Count;
     45      var vector = vectorStack.Top;
     46      var newTop = new List<T>(vector);
     47      var index = x.AsInt(vector.Count);
    4648
    4749      if (index < 0)
    4850        index *= -1;
    4951
    50       vector[index] = literal;
     52      newTop[index] = literal;
     53      vectorStack.Top = newTop;
    5154    }
    5255  }
Note: See TracChangeset for help on using the changeset viewer.