Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/17 09:28:34 (8 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

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/ManagedPoolProvider.cs

    r14875 r15017  
    2525
    2626    public readonly int PartitionSize;
    27     public readonly int MaxParitionCount;
     27    public readonly int MaxPartitionCount;
    2828    public const int DefaultMaxInstanceCount = 65536;
    2929
    3030    public ManagedPoolProvider(int partitionSize, Func<T> factory, int? maxPartitionCount = null) {
    3131      PartitionSize = partitionSize;
    32       MaxParitionCount = maxPartitionCount ?? DefaultMaxInstanceCount / PartitionSize;
     32      MaxPartitionCount = maxPartitionCount ?? DefaultMaxInstanceCount / PartitionSize;
    3333      this.factory = factory;
    3434
     
    5050    }
    5151
     52    public void Clear() {
     53      partitions.Clear();
     54    }
     55
    5256    public void ReleasePartitions(List<T[]> releasedPartitions) {
    53       if (partitions.Count < MaxParitionCount)
     57      if (partitions.Count < MaxPartitionCount)
    5458        partitions.PushRange((T[][])InternalListArrayProperty.GetValue(releasedPartitions), 0, releasedPartitions.Count);
    5559    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Tree/TreeExtensions.cs

    r14834 r15017  
    88
    99  public static class TreeExtensions {
    10     public static Tree<T> ToTree<T>(
     10    private static readonly Expression ExecNoop = ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
     11    private static readonly Expression CodeNoop = ExpressionTable.GetStatelessExpression<CodeNoopExpression>();
     12
     13    public static TreeNode<T> ToTree<T>(
    1114      this IEnumerable<T> items,
    1215      Predicate<T> isChild,
    1316      Func<T, IReadOnlyList<T>> childrenResolver) {
    14       var tree = new Tree<T>();
     17      var tree = new TreeNode<T>();
    1518
    1619      foreach (var item in items) {
     
    3538        } else yield return child;
    3639      }
     40
     41      yield return node;
    3742    }
    3843
     
    4651    }
    4752
     53    public static PushProgram ToPushProgramWithoutNoopExpressions(this TreeNode<Expression> tree) {
     54      return ToPushProgram(tree, e => !ReferenceEquals(e, ExecNoop) && !ReferenceEquals(e, CodeNoop));
     55    }
     56
    4857    public static PushProgram ToPushProgram(this TreeNode<Expression> tree, Func<Expression, bool> condition = null) {
     58      // wrap into program as depthlast expects that tree represents program and not a single expression
     59      if (tree.Count == 1) {
     60        var tmp = tree;
     61        tree = new TreeNode<Expression>();
     62        tree.AddNode(tmp);
     63      }
     64
    4965      var expressions = tree.DepthLast(e => ResolveProgram(e, condition));
    5066
     
    5268    }
    5369
    54     public static Tree<Expression> ToTree(this PushProgram program) {
     70    public static TreeNode<Expression> ToTree(this PushProgram program) {
    5571      var tree = program.Expressions.ToTree(e => e.IsProgram, e => ((PushProgram)e).Expressions);
    5672      tree.Value = program;
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Tree/TreeNode.cs

    r14908 r15017  
    55    public T Value { get; set; }
    66    public IList<TreeNode<T>> Children { get; private set; }
     7    public int Count { get; private set; }
    78
    89    public TreeNode() {
    910      Children = new List<TreeNode<T>>();
     11      Count = 1;
    1012    }
    1113
     
    1618    public void Add(T value) {
    1719      Children.Add(new TreeNode<T>(value));
     20      Count++;
    1821    }
    1922
    2023    public void AddNode(TreeNode<T> node) {
    2124      Children.Add(node);
     25      Count += node.Count;
    2226    }
    2327
    2428    public void ReplaceNode(int index, TreeNode<T> node) {
     29      Count -= Children[index].Count;
    2530      Children[index] = node;
     31      Count += node.Count;
    2632    }
    2733  }
Note: See TracChangeset for help on using the changeset viewer.