Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/03/17 01:31:10 (8 years ago)
Author:
pkimmesw
Message:

#2665 Fixed VectorExpression errors, Fixed BenchmarkSuite Problem Data View issues

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

Legend:

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

    r14905 r14909  
    166166      EnabledExpressions.Clear();
    167167
    168       // Enable those are required
    169168      foreach (StackTypes type in Enum.GetValues(types.GetType())) {
    170169        if (type == StackTypes.None) continue;
    171 
    172170        enabledStacks[type] = false;
    173 
    174         if (types.HasFlag(type))
    175           EnableStack(type, false, true);
     171      }
     172
     173      foreach (var pair in ExpressionTable.StackDependencyToNamesTable) {
     174        if (types.HasFlag(pair.Key)) {
     175          foreach (var name in pair.Value) {
     176            EnableExpression(name, true);
     177          }
     178        }
    176179      }
    177180    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExpressionTable.cs

    r14875 r14909  
    141141    public static IReadOnlyList<string> GetExpressionsByStackTypes(StackTypes allowedTypes) {
    142142      return stackDependencyToNamesTable
    143           .Where(entry => (entry.Key & ~allowedTypes) == StackTypes.None)
     143          .Where(entry => (entry.Key & ~allowedTypes) == 0x0)
    144144          .SelectMany(entry => entry.Value)
    145145          .ToArray();
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorNthExpressions.cs

    r14834 r14909  
    1616      IPushStack<List<T>> vectorStack,
    1717      IPushStack<T> literalStack) {
    18       if (vectorStack.IsEmpty || interpreter.IntegerStack.IsEmpty) return false;
     18      if (vectorStack.IsEmpty || vectorStack.Top.Count == 0 || interpreter.IntegerStack.IsEmpty) return false;
    1919
    2020      var vector = vectorStack.Pop();
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSetExpressions.cs

    r14875 r14909  
    1717      bool isLiteralTypeInteger = false) {
    1818      if (vectorStack.IsEmpty ||
     19          vectorStack.Top.Count == 0 ||
    1920          literalStack.IsEmpty ||
    2021          (isLiteralTypeInteger && interpreter.IntegerStack.Count < 2) ||
     
    3839
    3940      if (index < 0)
    40         index = vector.Count - index;
     41        index *= -1;
    4142
    4243      vector[index] = literal;
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSubExpressions.cs

    r14875 r14909  
    1616      if (vectorStack.IsEmpty || interpreter.IntegerStack.Count < 2) return false;
    1717
    18       var first = (int)Math.Min(vectorStack.Count, Math.Max(0, interpreter.IntegerStack[1]));
    19       var second = (int)Math.Min(vectorStack.Count, Math.Max(first, interpreter.IntegerStack.Top));
     18      var first = (int)Math.Min(vectorStack.Top.Count, Math.Max(0, interpreter.IntegerStack[1]));
     19      var second = (int)Math.Min(vectorStack.Top.Count, Math.Max(first, interpreter.IntegerStack.Top));
    2020      interpreter.IntegerStack.Remove(2);
    2121
     22      if (vectorStack.Top.Count == 0)
     23        return true;
     24
    2225      var result = vectorStack.Top.GetRange(first, second - first);
    23       vectorStack.Push(result);
     26      vectorStack.SetTop(result);
    2427      return true;
    2528    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorTakeExpressions.cs

    r14834 r14909  
    1616
    1717      var count = (int)interpreter.IntegerStack.Pop();
     18
     19      if (vectorStack.Top.Count == 0)
     20        return true;
     21
     22      count %= vectorStack.Top.Count;
     23
     24      if (count < 0)
     25        count *= -1;
     26
    1827      var result = vectorStack.Top.GetRange(0, count);
     28      vectorStack.SetTop(result);
    1929
    20       vectorStack.Push(result);
    2130      return true;
    2231    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteEvaluator.cs

    r14908 r14909  
    22  using System;
    33  using System.Collections.Generic;
     4  using System.Linq;
     5
    46  using Common;
    57  using Core;
     
    79
    810  using HeuristicLab.BenchmarkSuite;
    9   using HeuristicLab.BenchmarkSuite.Problems;
    1011  using HeuristicLab.Parameters;
    1112  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    131132      interpreter.IntegerStack.Push(example.InputInteger);
    132133      interpreter.FloatStack.Push(example.InputFloat);
     134      interpreter.CharStack.Push(example.InputChar);
     135      interpreter.StringStack.Push(example.InputString);
     136      interpreter.StringVectorStack.Push(example.InputStringVector.Select(v => new List<string>(v)));
     137      interpreter.IntegerVectorStack.Push(example.InputIntegerVector.Select(v => new List<long>(v)));
     138      interpreter.FloatVectorStack.Push(example.InputFloatVector.Select(v => new List<double>(v)));
    133139
    134140      interpreter.Run(program);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/IPushStack.cs

    r14875 r14909  
    1515    void Push(IReadOnlyList<T> items, int startIndex = 0);
    1616    void Push(IReadOnlyList<T> items);
     17    void Push(IEnumerable<T> items);
    1718    T Peek();
    1819    T[] Peek(int count);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/PushStack.cs

    r14908 r14909  
    230230    }
    231231
     232    public void Push(IEnumerable<T> items) {
     233      if (!IsEnabled) return;
     234
     235      data.AddRange(items);
     236    }
     237
    232238    public void Insert(int index, T item) {
    233239      if (!IsEnabled) return;
Note: See TracChangeset for help on using the changeset viewer.