Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/17 11:23:05 (7 years ago)
Author:
pkimmesw
Message:

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

File:
1 edited

Legend:

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

    r14834 r14952  
    22  using System.Collections.Generic;
    33
     4  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    45  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
    56  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
     
    1011  /// </summary>
    1112  /// <typeparam name="T"></typeparam>
     13  [StorableClass]
    1214  public abstract class VectorPushAllExpression<T> : StatelessExpression {
    13     protected bool Eval(IPushStack<List<T>> vectorStack, IPushStack<T> literalStack) {
    14       if (vectorStack.IsEmpty)
    15         return false;
     15    protected VectorPushAllExpression() { }
     16    [StorableConstructor]
     17    protected VectorPushAllExpression(bool deserializing) : base(deserializing) { }
    1618
     19    protected bool IsNoop(IPushStack<List<T>> vectorStack) {
     20      return vectorStack.IsEmpty;
     21    }
     22
     23    protected void Eval(IPushStack<List<T>> vectorStack, IPushStack<T> literalStack) {
    1724      var vector = vectorStack.Pop();
    1825      vector.Reverse();
    1926      literalStack.Push(vector);
    20       return true;
    2127    }
    2228  }
    2329
     30  [StorableClass]
    2431  [PushExpression(StackTypes.IntegerVector, "INTEGER[].PUSHALL", StackTypes.Integer)]
    2532  public class IntegerVectorPushAllExpression : VectorPushAllExpression<long> {
    26     public override bool Eval(IInternalPushInterpreter interpreter) {
    27       return Eval(interpreter.IntegerVectorStack, interpreter.IntegerStack);
     33    public IntegerVectorPushAllExpression() { }
     34    [StorableConstructor]
     35    protected IntegerVectorPushAllExpression(bool deserializing) : base(deserializing) { }
     36
     37    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     38      return IsNoop(interpreter.IntegerVectorStack);
     39    }
     40
     41    public override void Eval(IInternalPushInterpreter interpreter) {
     42      Eval(interpreter.IntegerVectorStack, interpreter.IntegerStack);
    2843    }
    2944  }
    3045
     46  [StorableClass]
    3147  [PushExpression(StackTypes.FloatVector, "FLOAT[].PUSHALL", StackTypes.Float)]
    3248  public class FloatVectorPushAllExpression : VectorPushAllExpression<double> {
    33     public override bool Eval(IInternalPushInterpreter interpreter) {
    34       return Eval(interpreter.FloatVectorStack, interpreter.FloatStack);
     49    public FloatVectorPushAllExpression() { }
     50    [StorableConstructor]
     51    protected FloatVectorPushAllExpression(bool deserializing) : base(deserializing) { }
     52
     53    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     54      return IsNoop(interpreter.FloatVectorStack);
     55    }
     56
     57    public override void Eval(IInternalPushInterpreter interpreter) {
     58      Eval(interpreter.FloatVectorStack, interpreter.FloatStack);
    3559    }
    3660  }
    3761
     62  [StorableClass]
    3863  [PushExpression(StackTypes.BooleanVector, "BOOLEAN[].PUSHALL", StackTypes.Boolean)]
    3964  public class BooleanVectorPushAllExpression : VectorPushAllExpression<bool> {
    40     public override bool Eval(IInternalPushInterpreter interpreter) {
    41       return Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack);
     65    public BooleanVectorPushAllExpression() { }
     66    [StorableConstructor]
     67    protected BooleanVectorPushAllExpression(bool deserializing) : base(deserializing) { }
     68
     69    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     70      return IsNoop(interpreter.BooleanVectorStack);
     71    }
     72
     73    public override void Eval(IInternalPushInterpreter interpreter) {
     74      Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack);
    4275    }
    4376  }
    4477
     78  [StorableClass]
    4579  [PushExpression(StackTypes.StringVector, "STRING[].PUSHALL", StackTypes.String)]
    4680  public class StringVectorPushAllExpression : VectorPushAllExpression<string> {
    47     public override bool Eval(IInternalPushInterpreter interpreter) {
    48       return Eval(interpreter.StringVectorStack, interpreter.StringStack);
     81    public StringVectorPushAllExpression() { }
     82    [StorableConstructor]
     83    protected StringVectorPushAllExpression(bool deserializing) : base(deserializing) { }
     84
     85    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     86      return IsNoop(interpreter.StringVectorStack);
     87    }
     88
     89    public override void Eval(IInternalPushInterpreter interpreter) {
     90      Eval(interpreter.StringVectorStack, interpreter.StringStack);
    4991    }
    5092  }
Note: See TracChangeset for help on using the changeset viewer.