Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/10/17 21:36:03 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed small issues, testet benchmark suite, added INX Expressions

File:
1 edited

Legend:

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

    r15017 r15189  
    88  using Data.Pool;
    99  using Extensions;
     10
     11  using HeuristicLab.Common;
     12
    1013  using Interpreter;
    1114  using Persistence.Default.CompositeSerializers.Storable;
     
    4144    }
    4245
     46    public PushProgram(PushProgram origin, Cloner cloner) {
     47      stringRepresentation = origin.stringRepresentation;
     48      hashCode = origin.hashCode;
     49      depth = origin.depth;
     50      treeIndex = origin.treeIndex;
     51      expressions = new List<Expression>(origin.expressions);
     52    }
     53
     54    public override IDeepCloneable Clone(Cloner cloner) {
     55      return new PushProgram(this, cloner);
     56    }
     57
    4358    public bool IsEmpty { get { return Count == 0; } }
    4459    public int Count { get { return expressions.Count; } }
     
    5166      return program;
    5267    }
     68
     69    void IPooledObject.Init() { }
    5370
    5471    void IPooledObject.Reset() {
     
    263280            yield return sub;
    264281        else yield return expr;
     282      }
     283    }
     284
     285    public IReadOnlyList<Expression> Flatten() {
     286      var result = new List<Expression>();
     287      Flatten(result);
     288      return result;
     289    }
     290
     291    private void Flatten(List<Expression> result) {
     292      result.AddRange(expressions);
     293
     294      for (var i = 0; i < expressions.Count; i++) {
     295        var expr = expressions[i];
     296        if (expr.IsProgram) {
     297          ((PushProgram)expr).Flatten(result);
     298        }
    265299      }
    266300    }
Note: See TracChangeset for help on using the changeset viewer.