Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/28/17 22:52:08 (8 years ago)
Author:
pkimmesw
Message:

#2665 Dynamic ErcValues, Separate Push from BenchmarkSuite Push

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators
Files:
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator/CodeGeneratorUtils.cs

    r14875 r14897  
    33
    44namespace HeuristicLab.Problems.ProgramSynthesis.Push.Generators.CodeGenerator {
     5  using Core;
     6  using Expressions;
    57
    6   using HeuristicLab.Core;
    7   using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Interfaces;
    8   using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    9   using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
     8  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc;
     9
     10  using Stack;
    1011
    1112  internal static class CodeGeneratorUtils {
     
    1920
    2021      return index >= enabledExpressions.Count
    21         ? customExpressions.ElementAt(index - (enabledExpressions.Count - 1)).Value
     22        ? customExpressions.Values.ElementAt(index - enabledExpressions.Count)
    2223        : CreateExpressionOrErc(index, random, enabledExpressions, ercOptions);
    2324    }
     
    5556    }
    5657
     58    private static readonly Expression Noop = ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
    5759    /// <summary>
    5860    /// Create a ErcExpression whereby the type of the expression conforms to the passed stack type.
     
    6567      switch (type) {
    6668        case StackTypes.Integer:
    67           if (ercOptions.IntegerErcOptions == null || !ercOptions.IntegerErcOptions.IsEnabled)
    68             return ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
    69 
    70           var intValue = ErcUtils.GetInteger(ercOptions.IntegerErcOptions, random);
    71 
    72           return new IntegerPushExpression(intValue);
     69          return ercOptions.IntegerErcOptions == null || !ercOptions.IntegerErcOptions.IsEnabled
     70             ? Noop
     71             : new IntegerPushExpression(ercOptions.IntegerErcOptions.GetErcValue(random));
    7372
    7473        case StackTypes.Float:
    75           if (ercOptions.FloatErcOptions == null || !ercOptions.FloatErcOptions.IsEnabled)
    76             return ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
    77 
    78           var doubleValue = ErcUtils.GetDouble(ercOptions.FloatErcOptions, random);
    79 
    80           return new FloatPushExpression(doubleValue);
     74          return ercOptions.FloatErcOptions == null || !ercOptions.FloatErcOptions.IsEnabled
     75            ? Noop
     76            : new FloatPushExpression(ercOptions.FloatErcOptions.GetErcValue(random));
    8177
    8278        case StackTypes.Boolean:
    8379          return ercOptions.BooleanErcOptions == null || !ercOptions.BooleanErcOptions.IsEnabled
    84             ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()
    85             : new BooleanPushExpression(ErcUtils.GetBoolean(ercOptions.BooleanErcOptions, random));
     80            ? Noop
     81            : new BooleanPushExpression(ercOptions.BooleanErcOptions.GetErcValue(random));
    8682
    8783        case StackTypes.Name:
    8884          return ercOptions.NameErcOptions == null || !ercOptions.NameErcOptions.IsEnabled
    89             ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()
    90             : new NamePushExpression(ErcUtils.GetName(ercOptions.NameErcOptions, random));
     85            ? Noop
     86            : new NamePushExpression(ercOptions.NameErcOptions.GetErcValue(random));
    9187
    9288        case StackTypes.String:
    9389          return ercOptions.StringErcOptions == null || !ercOptions.StringErcOptions.IsEnabled
    94             ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()
    95             : new StringPushExpression(ErcUtils.GetString(ercOptions.StringErcOptions, random));
     90            ? Noop
     91            : new StringPushExpression(ercOptions.StringErcOptions.GetErcValue(random));
    9692
    9793        case StackTypes.Char:
    9894          return ercOptions.CharErcOptions == null || !ercOptions.CharErcOptions.IsEnabled
    99             ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()
    100             : new CharPushExpression(ErcUtils.GetChar(ercOptions.CharErcOptions, random));
     95            ? Noop
     96            : new CharPushExpression(ercOptions.CharErcOptions.GetErcValue(random));
    10197
    10298        default:
    103           return ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
     99          return Noop;
    104100      }
    105101    }
Note: See TracChangeset for help on using the changeset viewer.