Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/16 22:57:11 (7 years ago)
Author:
pkimmesw
Message:

#2665 Added Problem.ProgramSynthesis Project, Fixed Expression Issues, Fixed Code Generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs

    r14398 r14513  
    1 using System;
    2 using HeuristicLab.Algorithms.PushGP.Stack;
     1namespace HeuristicLab.Algorithms.PushGP.Expressions {
     2  using System;
    33
    4 namespace HeuristicLab.Algorithms.PushGP.Expressions
    5 {
    6     public abstract class PushResultExpression<T> : StatelessExpression
    7     {
    8         protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc)
    9         {
    10             if (stack.Count < count)
    11                 return;
     4  using HeuristicLab.Algorithms.PushGP.Stack;
    125
    13             stack.PushResult(count, templateFunc);
    14         }
     6  public abstract class PushResultExpression<T> : StatelessExpression {
     7    protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc) {
     8      if (stack.Count < count) return;
    159
    16         protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue)
    17         {
    18             if (stack.Count < count || stack.Top.Equals(ignoreValue))
    19                 return;
     10      stack.PushResult(count, templateFunc);
     11    }
    2012
    21             stack.PushResult(count, templateFunc);
    22         }
     13    protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue) {
     14      if ((stack.Count < count) || stack.Top.Equals(ignoreValue)) return;
    2315
    24         protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc)
    25         {
    26             if (stack.Count < count)
    27                 return;
     16      stack.PushResult(count, templateFunc);
     17    }
    2818
    29             var items = stack.Pop(count);
    30             var result = templateFunc(items);
     19    protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc) {
     20      if (stack.Count < count) return;
    3121
    32             resultStack.Push(result);
    33         }
     22      var items = stack.Pop(count);
     23      var result = templateFunc(items);
     24
     25      resultStack.Push(result);
    3426    }
     27  }
    3528}
Note: See TracChangeset for help on using the changeset viewer.