Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/19/17 12:55:58 (7 years ago)
Author:
pkimmesw
Message:

#2665 Started Plush Encoding, Added Zero Error Individual Count Analyzer

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis
Files:
13 added
3 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.ProgramSynthesis.csproj

    r15189 r15273  
    122122      <DependentUpon>Resources.resx</DependentUpon>
    123123    </Compile>
     124    <Compile Include="Push\Analyzer\IIndividualZeroErrorAnalyzer.cs" />
     125    <Compile Include="Push\Analyzer\IndividualZeroErrorAnalyzer.cs" />
    124126    <Compile Include="Push\Analyzer\IPushExpressionAnalyzer.cs" />
    125127    <Compile Include="Push\Analyzer\PushExpressionFrequencyAnalyzer.cs" />
     
    195197    <Compile Include="Push\Extensions\ControlExntensions.cs" />
    196198    <Compile Include="Push\Extensions\EnumExtensions.cs" />
    197     <Compile Include="Push\Extensions\ProblemDataExtensions.cs" />
    198199    <Compile Include="Push\Extensions\LongExtensions.cs" />
    199200    <Compile Include="Push\Extensions\RandomExtensions.cs" />
     
    212213    <Compile Include="Push\Interpreter\PushInterpreter.cs" />
    213214    <Compile Include="Push\Interpreter\PushInterpreterPool.cs" />
     215    <Compile Include="Push\ObjectPools\Random\SeededRandomPool.cs" />
    214216    <Compile Include="Push\ObjectPools\StringBuilderPool.cs" />
    215217    <Compile Include="Push\Parser\PushParser.cs" />
     
    228230    <Compile Include="Push\Selector\LexicaseSelector.cs" />
    229231    <Compile Include="Push\Simplifier\Simplifier.cs" />
     232    <Compile Include="Push\SolutionCreator\PushSolutionCreator.cs" />
     233    <Compile Include="Push\SolutionCreator\PushSolutionEncoding.cs" />
    230234    <Compile Include="Push\Stack\IPrintStack.cs" />
    231235    <Compile Include="Push\Stack\IPushStack.cs" />
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Analyzer/PushExpressionFrequencyAnalyzer.cs

    r15189 r15273  
    1212  using HeuristicLab.Parameters;
    1313  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     14  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
    1415  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
    1516  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    1617  using HeuristicLab.Problems.ProgramSynthesis.Push.Individual;
     18  using HeuristicLab.Problems.ProgramSynthesis.Push.ObjectPools.Random;
    1719
    1820  /// <summary>
     
    2224  [StorableClass]
    2325  public class PushExpressionFrequencyAnalyzer : SingleSuccessorOperator, IPushExpressionAnalyzer {
     26    private readonly SeededRandomPool randomPool = new SeededRandomPool();
    2427
    25     private const string PushConfigurationParameterName = "PushConfiguration";
    26     private const string IntegerVectorParameterName = "IntegerVector";
    27     private const string ResultsParameterName = "Results";
    28     private const string ExpressionFrequenciesParameterName = "InstructionFrequencies";
    29     private const string AggregateStackTypesParameterName = "Aggregate stack types";
     28    private const string PUSH_CONFIGURATION_PARAMETER_NAME = "PushConfiguration";
     29    private const string INTEGER_VECTOR_PARAMETER_NAME = "IntegerVector";
     30    private const string RESULTS_PARAMETER_NAME = "Results";
     31    private const string EXPRESSION_FREQUENCIES_PARAMETER_NAME = "InstructionFrequencies";
     32    private const string AGGREGATE_STACK_TYPES_PARAMETER_NAME = "Aggregate stack types";
     33    private const string IN_EXPRESSION_GROUP_NAME = "IN";
     34    private const string RANDOM_PARAMETER_NAME = "Random";
     35    private const string RESULT_PARAMETER_NAME = "Instruction frequencies";
     36    private const string RESULT_PARAMETER_DESCRIPTION = "Relative frequency of instructions aggregated over the whole population.";
     37    private const string Y_AXIS_TITLE = "Relative Instruction Frequency";
    3038
    3139    public PushExpressionFrequencyAnalyzer() {
    32       Parameters.Add(new LookupParameter<IReadOnlyPushConfiguration>(PushConfigurationParameterName, "The current specified push configuration."));
    33       Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>(IntegerVectorParameterName, "The integer vectors to analyze."));
    34       Parameters.Add(new LookupParameter<DataTable>(ExpressionFrequenciesParameterName, "The data table to store the instruction frequencies."));
    35       Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the symbol frequencies should be stored."));
     40      Parameters.Add(new LookupParameter<IReadOnlyPushConfiguration>(PUSH_CONFIGURATION_PARAMETER_NAME, "The current specified push configuration."));
     41      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>(INTEGER_VECTOR_PARAMETER_NAME, "The integer vectors to analyze."));
     42      Parameters.Add(new LookupParameter<DataTable>(EXPRESSION_FREQUENCIES_PARAMETER_NAME, "The data table to store the instruction frequencies."));
     43      Parameters.Add(new LookupParameter<ResultCollection>(RESULTS_PARAMETER_NAME, "The result collection where the symbol frequencies should be stored."));
    3644
    37       Parameters.Add(new FixedValueParameter<BoolValue>(AggregateStackTypesParameterName, "Determines if expressions should be aggregated by their primary stack type.", new BoolValue(true)));
     45      Parameters.Add(new FixedValueParameter<BoolValue>(AGGREGATE_STACK_TYPES_PARAMETER_NAME, "Determines if expressions should be aggregated by their primary stack type.", new BoolValue(true)));
    3846    }
    3947
     
    5159    public ILookupParameter<IReadOnlyPushConfiguration> PushConfigurationParameter
    5260    {
    53       get { return (ILookupParameter<IReadOnlyPushConfiguration>)Parameters[PushConfigurationParameterName]; }
     61      get { return (ILookupParameter<IReadOnlyPushConfiguration>)Parameters[PUSH_CONFIGURATION_PARAMETER_NAME]; }
    5462    }
    5563
    5664    public IScopeTreeLookupParameter<IntegerVector> IntegerVectorParameter
    5765    {
    58       get { return (IScopeTreeLookupParameter<IntegerVector>)Parameters[IntegerVectorParameterName]; }
     66      get { return (IScopeTreeLookupParameter<IntegerVector>)Parameters[INTEGER_VECTOR_PARAMETER_NAME]; }
    5967    }
    6068
    6169    public ILookupParameter<DataTable> ExpressionFrequenciesParameter
    6270    {
    63       get { return (ILookupParameter<DataTable>)Parameters[ExpressionFrequenciesParameterName]; }
     71      get { return (ILookupParameter<DataTable>)Parameters[EXPRESSION_FREQUENCIES_PARAMETER_NAME]; }
     72    }
     73
     74    public ILookupParameter<IRandom> RandomParameter
     75    {
     76      get { return (ILookupParameter<IRandom>)Parameters[RANDOM_PARAMETER_NAME]; }
    6477    }
    6578
    6679    public ILookupParameter<ResultCollection> ResultsParameter
    6780    {
    68       get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
     81      get { return (ILookupParameter<ResultCollection>)Parameters[RESULTS_PARAMETER_NAME]; }
    6982    }
    7083
    7184    public IValueParameter<BoolValue> AggregateStackTypesParameter
    7285    {
    73       get { return (IValueParameter<BoolValue>)Parameters[AggregateStackTypesParameterName]; }
     86      get { return (IValueParameter<BoolValue>)Parameters[AGGREGATE_STACK_TYPES_PARAMETER_NAME]; }
    7487    }
    7588
     
    8093    }
    8194
    82 
    8395    public override IOperation Apply() {
    8496      var config = PushConfigurationParameter.ActualValue;
    8597      var integerVectors = IntegerVectorParameter.ActualValue;
    86       var pushPrograms = integerVectors.Select(iv => iv.ToPushProgram(config));
     98
     99      randomPool.Seed = config.Seed;
     100
     101      var pushPrograms = integerVectors.Select(iv => {
     102        var random = randomPool.ResetAndAllocate();
     103        var program = iv.ToPushProgram(config, random);
     104        randomPool.Free(random);
     105
     106        return program;
     107      });
    87108
    88109      var results = ResultsParameter.ActualValue;
     
    91112      if (frequencies == null) {
    92113        frequencies = new DataTable(
    93           "Instruction frequencies",
    94           "Relative frequency of instructions aggregated over the whole population.") {
     114          RESULT_PARAMETER_NAME,
     115          RESULT_PARAMETER_DESCRIPTION) {
    95116          VisualProperties = {
    96             YAxisTitle = "Relative Instruction Frequency"
     117            YAxisTitle = Y_AXIS_TITLE
    97118          }
    98119        };
    99120
    100121        ExpressionFrequenciesParameter.ActualValue = frequencies;
    101         results.Add(new Result("Instruction frequencies", frequencies));
     122        results.Add(new Result(RESULT_PARAMETER_NAME, frequencies));
    102123      }
    103124
     
    110131
    111132      var expressionFrequencies = allExpressions
    112         .GroupBy(x => AggregateStackTypes
    113           ? x.Attribute.StackType.ToString()
    114           : x.Attribute.Name)
     133        .GroupBy(x => GetGroupName(x.Attribute, AggregateStackTypes))
    115134        .ToDictionary(
    116135          group => group.Key,
     
    126145          var row = new DataRow(pair.Key, string.Empty, Enumerable.Repeat(0.0, numberOfValues)) {
    127146            VisualProperties = {
    128               StartIndexZero = true
     147              StartIndexZero = true,
    129148            }
    130149          };
     
    142161      return base.Apply();
    143162    }
     163
     164    private string GetGroupName(PushExpressionAttribute attribute, bool aggregateStackTypes) {
     165      if (aggregateStackTypes) {
     166        return attribute.IsInExpression
     167         ? IN_EXPRESSION_GROUP_NAME
     168         : attribute.StackType.ToString();
     169      }
     170
     171      return attribute.Name;
     172    }
    144173  }
    145174}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Attributes/PushExpressionAttriubte.cs

    r15032 r15273  
    1010    public readonly string Name;
    1111    public readonly string Description;
     12    public readonly int? InExpressionNr;
    1213
    1314    /// <summary>
     
    3233      StackTypes additionalStackDependencies = default(StackTypes),
    3334      uint execIn = 0,
    34       bool isHidden = false) {
     35      bool isHidden = false,
     36      int inExpressionNr = -1) {
    3537
    3638      StackType = stackType;
     
    4042      ExecIn = execIn;
    4143      IsHidden = isHidden;
     44      InExpressionNr = inExpressionNr > 0 ? inExpressionNr : default(int?);
    4245      ManipulatesExec = stackType == StackTypes.Exec || AdditionalStackDependencies.HasFlag(StackTypes.Exec);
    4346    }
     47
     48    public bool IsInExpression { get { return this.InExpressionNr.HasValue; } }
    4449  }
    4550}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/IEnabledExpressionsConfiguration.cs

    r15032 r15273  
    1717  }
    1818
    19   public interface IEnabledExpressionsConfiguration : INamedItem {
     19  public interface IReadOnlyExpressionsConfiguration : INamedItem {
     20    int InExpressionCount { get; }
     21
     22    IReadOnlyList<string> EnabledExpressions { get; }
     23    IReadOnlyDictionary<StackTypes, int> ExpressionsPerStackCount { get; }
     24  }
     25
     26  public interface IExpressionsConfiguration : IReadOnlyExpressionsConfiguration {
    2027    event EventHandler<EnabledExpressionsChangedEventArgs> EnabledExpressionsChanged;
    2128
    22     IReadOnlyList<string> EnabledExpressions { get; }
    23 
    2429    void EnableStack(StackTypes types, bool enableDependencies = false);
    25     void DisableStack(StackTypes type, bool enableDepenencies = false);
     30    void DisableStack(StackTypes type, bool enableDependencies = false);
    2631    void SetStack(StackTypes type, bool state, bool setDependencies = false);
    2732    void EnableExpressionOfStack(StackTypes types);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/IReadonlyPushConfiguration.cs

    r15032 r15273  
    22  using System.Collections.Generic;
    33  using Base.Erc;
    4   using Common;
    5 
    6   using HeuristicLab.Core;
    74
    85  using Stack;
    96
    10   public interface IReadOnlyPushConfiguration : IItem {
     7  public interface IReadOnlyPushConfiguration : IReadOnlyExpressionsConfiguration {
     8    int Seed { get; }
    119    int EvalPushLimit { get; }
    1210    int MaxDepth { get; }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/PushConfigurationBase.cs

    r15189 r15273  
    1212
    1313  [StorableClass]
    14   public abstract class PushConfigurationBase : NamedItem, IEnabledExpressionsConfiguration {
     14  public abstract class PushConfigurationBase : NamedItem, IExpressionsConfiguration {
    1515
    1616    protected PushConfigurationBase() {
     
    2828      enabledExpressions = origin.EnabledExpressions.ToList();
    2929      expressionsPerStackCount = origin.expressionsPerStackCount.ToDictionary(x => x.Key, x => x.Value);
    30     }
     30      InExpressionCount = origin.InExpressionCount;
     31      Seed = origin.Seed;
     32    }
     33
     34    [Storable]
     35    public int Seed { get; set; }
     36
     37    [Storable]
     38    public int InExpressionCount { get; private set; }
    3139
    3240    [Storable]
    3341    private readonly Dictionary<StackTypes, int> expressionsPerStackCount;
     42
     43    public IReadOnlyDictionary<StackTypes, int> ExpressionsPerStackCount { get { return expressionsPerStackCount; } }
    3444
    3545    public event EventHandler<EnabledExpressionsChangedEventArgs> EnabledExpressionsChanged;
     
    112122
    113123    private void EnableExpressions(IEnumerable<string> expressionNames) {
    114       foreach (var expressionName in expressionNames.Except(EnabledExpressions))
     124      var addedExpressions = expressionNames as IList<string> ?? expressionNames.ToList();
     125
     126      foreach (var expressionName in addedExpressions.Except(EnabledExpressions))
    115127        EnableExpression(expressionName, false);
    116128
    117129      if (EnabledExpressionsChanged != null) {
    118         EnabledExpressionsChanged(this, new EnabledExpressionsChangedEventArgs(expressionNames, new string[0]));
     130        EnabledExpressionsChanged(this, new EnabledExpressionsChangedEventArgs(addedExpressions, new string[0]));
    119131      }
    120132    }
     
    133145
    134146    private void DisableExpressions(IEnumerable<string> expressionNames) {
    135       foreach (var expressionName in expressionNames.Intersect(EnabledExpressions))
     147      var removedExpressions = expressionNames as IList<string> ?? expressionNames.ToList();
     148
     149      foreach (var expressionName in removedExpressions.Intersect(EnabledExpressions))
    136150        DisableExpression(expressionName, false);
    137151
    138152      if (EnabledExpressionsChanged != null) {
    139         EnabledExpressionsChanged(this, new EnabledExpressionsChangedEventArgs(new string[0], expressionNames));
     153        EnabledExpressionsChanged(this, new EnabledExpressionsChangedEventArgs(new string[0], removedExpressions));
    140154      }
    141155    }
     
    229243      else DisableStack(type, setDependencies);
    230244    }
     245
     246    public void InitInExpressions(int totalInputArgumentCount) {
     247      InExpressionCount = totalInputArgumentCount;
     248
     249      for (var i = 0; i < ExpressionTable.InExpressionTable.Count; i++) {
     250        var expression = ExpressionTable.InExpressionTable[i];
     251        var expressionName = ExpressionTable.TypeToNameTable[expression.GetType()];
     252
     253        DisableExpression(expressionName);
     254      }
     255
     256      if (totalInputArgumentCount > ExpressionTable.InExpressionTable.Count)
     257        throw new InvalidOperationException("More input arguments defined as InExpression types");
     258
     259      for (var i = 0; i < totalInputArgumentCount; i++) {
     260        var expression = ExpressionTable.InExpressionTable[i];
     261        var expressionName = ExpressionTable.TypeToNameTable[expression.GetType()];
     262
     263        EnableExpression(expressionName);
     264      }
     265    }
    231266  }
    232267}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/PushConfigurationParameterCollection.cs

    r15032 r15273  
    1111  [StorableClass]
    1212  public class PushConfigurationParameterCollection : PushConfigurationBase, IReadOnlyPushConfiguration {
    13     private const string InstructionsParameterName = "Instructions";
    14     private const string InstructionsParameterDescription = "Enables/Disables Instructions";
    15     private const string EvalPushLimitParameterName = "EvalPushLimit";
    16     private const string EvalPushLimitParameterDescription = "This is the maximum allowed number of \"executions\" in a single top-level call to the interpreter. The execution of a single Push instruction counts as one execution, as does the processing of a single literal, as does the descent into one layer of parentheses (that is, the processing of the \"(\" counts as one execution).";
    17     private const string MaxPointsInProgramParameterName = "MaxProgramLength";
    18     private const string MaxProgramLengthParameterDescription = "This is the maximum size of an item on the CODE/EXEC stack, expressed as a number of points. A point is an instruction, a literal, or a pair of parentheses.";
    19     private const string TopLevelPushCodeParameterName = "TopLevelPushCode";
    20     private const string TopLevelPushCodeParameterDescription = "When TRUE (which is the default), code passed to the top level of the interpreter will be pushed onto the CODE stack prior to execution.";
    21     private const string TopLevelPopCodeParameterName = "TopLevelPopCode";
    22     private const string TopLevelPopCodeParameterDescription = "When TRUE, the CODE stack will be popped at the end of top level calls to the interpreter. The default is FALSE.";
    23     private const string MaxPointsInRandomInstructionParameterName = "MaxPointsInRandomInstruction";
    24     private const string MaxPointsInRandomInstructionParameterDescription = "MaxPointsInRandomInstruction";
    25     private const string ErcOptionsParameterName = "ERC options";
    26     private const string MaxStringLengthParameterName = "Max. string length";
    27     private const string MaxDepthParameterName = "Max. program recursion";
    28     private const string MaxParenthesesCloseParameterName = "Max. parentheses close";
    29     private const string MaxParenthesesCloseParameterDescription = "Specifies how many sub programs are closed if open during the recursive translation of an individual to a push program. Value is exclusive.";
    30     private const string ParenthesesCloseBiasLevelParameterName = "Parentheses close bias level";
    31     private const string ParenthesesCloseBiasLevelParameterDescription = "Specifies how strong a random value between 0 .. 'Max. parentheses close' is biased towards 0. In other words, this parameter controls the length of sub programs.";
    32     private const string MaxVectorLengthParameterName = "Max. vector length";
     13    private const string INSTRUCTIONS_PARAMETER_NAME = "Instructions";
     14    private const string INSTRUCTIONS_PARAMETER_DESCRIPTION = "Enables/Disables Instructions";
     15    private const string EVAL_PUSH_LIMIT_PARAMETER_NAME = "EvalPushLimit";
     16    private const string EVAL_PUSH_LIMIT_PARAMETER_DESCRIPTION = "This is the maximum allowed number of \"executions\" in a single top-level call to the interpreter. The execution of a single Push instruction counts as one execution, as does the processing of a single literal, as does the descent into one layer of parentheses (that is, the processing of the \"(\" counts as one execution).";
     17    private const string MAX_POINTS_IN_PROGRAM_PARAMETER_NAME = "MaxProgramLength";
     18    private const string MAX_PROGRAM_LENGTH_PARAMETER_DESCRIPTION = "This is the maximum size of an item on the CODE/EXEC stack, expressed as a number of points. A point is an instruction, a literal, or a pair of parentheses.";
     19    private const string TOP_LEVEL_PUSH_CODE_PARAMETER_NAME = "TopLevelPushCode";
     20    private const string TOP_LEVEL_PUSH_CODE_PARAMETER_DESCRIPTION = "When TRUE (which is the default), code passed to the top level of the interpreter will be pushed onto the CODE stack prior to execution.";
     21    private const string TOP_LEVEL_POP_CODE_PARAMETER_NAME = "TopLevelPopCode";
     22    private const string TOP_LEVEL_POP_CODE_PARAMETER_DESCRIPTION = "When TRUE, the CODE stack will be popped at the end of top level calls to the interpreter. The default is FALSE.";
     23    private const string MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_NAME = "MaxPointsInRandomInstruction";
     24    private const string MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_DESCRIPTION = "MaxPointsInRandomInstruction";
     25    private const string ERC_OPTIONS_PARAMETER_NAME = "ERC options";
     26    private const string MAX_STRING_LENGTH_PARAMETER_NAME = "Max. string length";
     27    private const string MAX_DEPTH_PARAMETER_NAME = "Max. program recursion";
     28    private const string MAX_PARENTHESES_CLOSE_PARAMETER_NAME = "Max. parentheses close";
     29    private const string MAX_PARENTHESES_CLOSE_PARAMETER_DESCRIPTION = "Specifies how many sub programs are closed if open during the recursive translation of an individual to a push program. Value is exclusive.";
     30    private const string PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_NAME = "Parentheses close bias level";
     31    private const string PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_DESCRIPTION = "Specifies how strong a random value between 0 .. 'Max. parentheses close' is biased towards 0. In other words, this parameter controls the length of sub programs.";
     32    private const string MAX_VECTOR_LENGTH_PARAMETER_NAME = "Max. vector length";
    3333
    3434    public PushConfigurationParameterCollection() {
     
    6262
    6363    private void InitParameters() {
    64       if (!Parameters.ContainsKey(InstructionsParameterName))
    65         Parameters.Add(new ValueParameter<IEnabledExpressionsConfiguration>(
    66           InstructionsParameterName,
    67           InstructionsParameterDescription,
     64      if (!Parameters.ContainsKey(INSTRUCTIONS_PARAMETER_NAME))
     65        Parameters.Add(new ValueParameter<IExpressionsConfiguration>(
     66          INSTRUCTIONS_PARAMETER_NAME,
     67          INSTRUCTIONS_PARAMETER_DESCRIPTION,
    6868          this));
    6969
    70       if (!Parameters.ContainsKey(ErcOptionsParameterName))
    71         Parameters.Add(new ValueParameter<ErcOptions>(ErcOptionsParameterName));
    72 
    73       if (!Parameters.ContainsKey(MaxVectorLengthParameterName))
    74         Parameters.Add(new FixedValueParameter<IntValue>(
    75           MaxVectorLengthParameterName,
     70      if (!Parameters.ContainsKey(ERC_OPTIONS_PARAMETER_NAME))
     71        Parameters.Add(new ValueParameter<ErcOptions>(ERC_OPTIONS_PARAMETER_NAME));
     72
     73      if (!Parameters.ContainsKey(MAX_VECTOR_LENGTH_PARAMETER_NAME))
     74        Parameters.Add(new FixedValueParameter<IntValue>(
     75          MAX_VECTOR_LENGTH_PARAMETER_NAME,
    7676          new IntValue(500)) { Hidden = true });
    7777
    78       if (!Parameters.ContainsKey(EvalPushLimitParameterName))
    79         Parameters.Add(new FixedValueParameter<IntValue>(
    80           EvalPushLimitParameterName,
    81           EvalPushLimitParameterDescription,
     78      if (!Parameters.ContainsKey(EVAL_PUSH_LIMIT_PARAMETER_NAME))
     79        Parameters.Add(new FixedValueParameter<IntValue>(
     80          EVAL_PUSH_LIMIT_PARAMETER_NAME,
     81          EVAL_PUSH_LIMIT_PARAMETER_DESCRIPTION,
    8282          new IntValue(1000)));
    8383
    84       if (!Parameters.ContainsKey(MaxPointsInProgramParameterName))
    85         Parameters.Add(new FixedValueParameter<IntValue>(
    86           MaxPointsInProgramParameterName,
    87           MaxProgramLengthParameterDescription,
     84      if (!Parameters.ContainsKey(MAX_POINTS_IN_PROGRAM_PARAMETER_NAME))
     85        Parameters.Add(new FixedValueParameter<IntValue>(
     86          MAX_POINTS_IN_PROGRAM_PARAMETER_NAME,
     87          MAX_PROGRAM_LENGTH_PARAMETER_DESCRIPTION,
    8888          new IntValue(200)));
    8989
    90       if (!Parameters.ContainsKey(MaxParenthesesCloseParameterName))
    91         Parameters.Add(new FixedValueParameter<IntValue>(
    92           MaxParenthesesCloseParameterName,
    93           MaxParenthesesCloseParameterDescription,
     90      if (!Parameters.ContainsKey(MAX_PARENTHESES_CLOSE_PARAMETER_NAME))
     91        Parameters.Add(new FixedValueParameter<IntValue>(
     92          MAX_PARENTHESES_CLOSE_PARAMETER_NAME,
     93          MAX_PARENTHESES_CLOSE_PARAMETER_DESCRIPTION,
    9494          new IntValue(4)) { Hidden = true });
    9595
    96       if (!Parameters.ContainsKey(ParenthesesCloseBiasLevelParameterName))
     96      if (!Parameters.ContainsKey(PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_NAME))
    9797        Parameters.Add(new FixedValueParameter<DoubleValue>(
    98           ParenthesesCloseBiasLevelParameterName,
    99           ParenthesesCloseBiasLevelParameterDescription,
     98          PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_NAME,
     99          PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_DESCRIPTION,
    100100          new DoubleValue(4)) { Hidden = true });
    101101
    102       if (!Parameters.ContainsKey(TopLevelPushCodeParameterName))
     102      if (!Parameters.ContainsKey(TOP_LEVEL_PUSH_CODE_PARAMETER_NAME))
    103103        Parameters.Add(new FixedValueParameter<BoolValue>(
    104           TopLevelPushCodeParameterName,
    105           TopLevelPushCodeParameterDescription,
     104          TOP_LEVEL_PUSH_CODE_PARAMETER_NAME,
     105          TOP_LEVEL_PUSH_CODE_PARAMETER_DESCRIPTION,
    106106          new BoolValue(true)) { Hidden = true });
    107107
    108       if (!Parameters.ContainsKey(TopLevelPopCodeParameterName))
     108      if (!Parameters.ContainsKey(TOP_LEVEL_POP_CODE_PARAMETER_NAME))
    109109        Parameters.Add(new FixedValueParameter<BoolValue>(
    110           TopLevelPopCodeParameterName,
    111           TopLevelPopCodeParameterDescription,
     110          TOP_LEVEL_POP_CODE_PARAMETER_NAME,
     111          TOP_LEVEL_POP_CODE_PARAMETER_DESCRIPTION,
    112112          new BoolValue(false)) { Hidden = true });
    113113
    114       if (!Parameters.ContainsKey(MaxPointsInRandomInstructionParameterName))
    115         Parameters.Add(new FixedValueParameter<IntValue>(
    116           MaxPointsInRandomInstructionParameterName,
    117           MaxPointsInRandomInstructionParameterDescription,
     114      if (!Parameters.ContainsKey(MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_NAME))
     115        Parameters.Add(new FixedValueParameter<IntValue>(
     116          MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_NAME,
     117          MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_DESCRIPTION,
    118118          new IntValue(50)) { Hidden = true });
    119119
    120       if (!Parameters.ContainsKey(MaxStringLengthParameterName))
    121         Parameters.Add(new FixedValueParameter<IntValue>(
    122           MaxStringLengthParameterName,
     120      if (!Parameters.ContainsKey(MAX_STRING_LENGTH_PARAMETER_NAME))
     121        Parameters.Add(new FixedValueParameter<IntValue>(
     122          MAX_STRING_LENGTH_PARAMETER_NAME,
    123123          new IntValue(1000)) { Hidden = true });
    124124
    125       if (!Parameters.ContainsKey(MaxDepthParameterName))
    126         Parameters.Add(new FixedValueParameter<IntValue>(
    127           MaxDepthParameterName,
     125      if (!Parameters.ContainsKey(MAX_DEPTH_PARAMETER_NAME))
     126        Parameters.Add(new FixedValueParameter<IntValue>(
     127          MAX_DEPTH_PARAMETER_NAME,
    128128          new IntValue(1000)) { Hidden = true });
    129129    }
    130130
    131     public IValueParameter<IEnabledExpressionsConfiguration> InstructionsParameter
    132     {
    133       get { return (IValueParameter<IEnabledExpressionsConfiguration>)Parameters[InstructionsParameterName]; }
    134     }
    135 
    136     public IEnabledExpressionsConfiguration Instructions
     131    public IValueParameter<IExpressionsConfiguration> InstructionsParameter
     132    {
     133      get { return (IValueParameter<IExpressionsConfiguration>)Parameters[INSTRUCTIONS_PARAMETER_NAME]; }
     134    }
     135
     136    public IExpressionsConfiguration Instructions
    137137    {
    138138      get { return InstructionsParameter.Value; }
     
    142142    public IValueParameter<ErcOptions> ErcOptionsParameter
    143143    {
    144       get { return (IValueParameter<ErcOptions>)Parameters[ErcOptionsParameterName]; }
     144      get { return (IValueParameter<ErcOptions>)Parameters[ERC_OPTIONS_PARAMETER_NAME]; }
    145145    }
    146146
     
    181181    public IValueParameter<IntValue> EvalPushLimitParameter
    182182    {
    183       get { return (IValueParameter<IntValue>)Parameters[EvalPushLimitParameterName]; }
     183      get { return (IValueParameter<IntValue>)Parameters[EVAL_PUSH_LIMIT_PARAMETER_NAME]; }
    184184    }
    185185
     
    198198    public IValueParameter<DoubleValue> ParenthesesCloseBiasLevelParameter
    199199    {
    200       get { return (IValueParameter<DoubleValue>)Parameters[ParenthesesCloseBiasLevelParameterName]; }
     200      get { return (IValueParameter<DoubleValue>)Parameters[PARENTHESES_CLOSE_BIAS_LEVEL_PARAMETER_NAME]; }
    201201    }
    202202
     
    212212    public IValueParameter<IntValue> MaxParenthesesCloseParameter
    213213    {
    214       get { return (IValueParameter<IntValue>)Parameters[MaxParenthesesCloseParameterName]; }
     214      get { return (IValueParameter<IntValue>)Parameters[MAX_PARENTHESES_CLOSE_PARAMETER_NAME]; }
    215215    }
    216216
     
    229229    public IValueParameter<IntValue> MaxDepthParameter
    230230    {
    231       get { return (IValueParameter<IntValue>)Parameters[MaxDepthParameterName]; }
     231      get { return (IValueParameter<IntValue>)Parameters[MAX_DEPTH_PARAMETER_NAME]; }
    232232    }
    233233
     
    249249    public IValueParameter<IntValue> MaxPointsInProgramParameter
    250250    {
    251       get { return (IValueParameter<IntValue>)Parameters[MaxPointsInProgramParameterName]; }
     251      get { return (IValueParameter<IntValue>)Parameters[MAX_POINTS_IN_PROGRAM_PARAMETER_NAME]; }
    252252    }
    253253
     
    263263    public IValueParameter<IntValue> MaxVectorLengthParameter
    264264    {
    265       get { return (IValueParameter<IntValue>)Parameters[MaxVectorLengthParameterName]; }
     265      get { return (IValueParameter<IntValue>)Parameters[MAX_VECTOR_LENGTH_PARAMETER_NAME]; }
    266266    }
    267267
     
    277277    public IValueParameter<IntValue> MaxPointsInRandomExpressionParameter
    278278    {
    279       get { return (IValueParameter<IntValue>)Parameters[MaxPointsInRandomInstructionParameterName]; }
     279      get { return (IValueParameter<IntValue>)Parameters[MAX_POINTS_IN_RANDOM_INSTRUCTION_PARAMETER_NAME]; }
    280280    }
    281281
     
    295295    public IValueParameter<BoolValue> TopLevelPushCodeParameter
    296296    {
    297       get { return (IValueParameter<BoolValue>)Parameters[TopLevelPushCodeParameterName]; }
     297      get { return (IValueParameter<BoolValue>)Parameters[TOP_LEVEL_PUSH_CODE_PARAMETER_NAME]; }
    298298    }
    299299
     
    312312    public IValueParameter<BoolValue> TopLevelPopCodeParameter
    313313    {
    314       get { return (IValueParameter<BoolValue>)Parameters[TopLevelPopCodeParameterName]; }
     314      get { return (IValueParameter<BoolValue>)Parameters[TOP_LEVEL_POP_CODE_PARAMETER_NAME]; }
    315315    }
    316316
     
    326326    public IValueParameter<IntValue> MaxStringLengthParameter
    327327    {
    328       get { return (IValueParameter<IntValue>)Parameters[MaxStringLengthParameterName]; }
     328      get { return (IValueParameter<IntValue>)Parameters[MAX_STRING_LENGTH_PARAMETER_NAME]; }
    329329    }
    330330
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExpressionTable.cs

    r15189 r15273  
    2020    private static readonly Dictionary<StackTypes, IList<string>> stackDependencyToNamesTable = new Dictionary<StackTypes, IList<string>>();
    2121    private static readonly Dictionary<Type, PushExpressionAttribute> typeToAttributeTable = new Dictionary<Type, PushExpressionAttribute>();
     22    private static readonly List<Expression> inExpressionTable = new List<Expression>();
    2223
    2324    public static readonly IReadOnlyList<Type> StatelessExpressionTypes;
     
    4344    public static IReadOnlyDictionary<Type, string> TypeToNameTable { get { return typeToNameTable; } }
    4445    public static IReadOnlyDictionary<string, Type> NameToTypeTable { get { return nameToTypeTable; } }
     46    public static IReadOnlyList<Expression> InExpressionTable { get { return inExpressionTable; } }
    4547    public static IReadOnlyDictionary<StackTypes, IList<string>> StackTypeToNamesTable { get { return stackTypeToNamesTable; } }
    4648    public static IReadOnlyDictionary<StackTypes, IList<string>> StackDependencyToNamesTable { get { return stackDependencyToNamesTable; } }
     
    5759        dictionary.Add(type, expression);
    5860
    59         //// do not index hidden expressions like push expression in tables
    60         //if (attribute.IsHidden) continue;
    61 
    6261        indexToNameTable.Add(indexToNameTable.Keys.Count, attribute.Name);
    6362        typeToNameTable.Add(type, attribute.Name);
    6463        nameToTypeTable.Add(attribute.Name, type);
     64
     65        if (attribute.IsInExpression) {
     66          // ReSharper disable once AssignNullToNotNullAttribute
     67          // ReSharper disable once PossibleInvalidOperationException
     68          inExpressionTable.Insert(attribute.InExpressionNr.Value - 1, expression);
     69        }
    6570
    6671        if (!stackTypeToNamesTable.ContainsKey(attribute.StackType)) {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/InExpressions.cs

    r15189 r15273  
    1313
    1414    protected InExpression(int nr) {
    15       this.index = nr - 1;
     15      index = nr - 1;
    1616    }
    1717
     
    2020
    2121    public override bool IsNoop(IInternalPushInterpreter interpreter) {
    22       return false;
     22      var expression = interpreter.InputExpressions[index];
     23
     24      return expression.IsNoop(interpreter);
    2325    }
    2426
    2527    public override void Eval(IInternalPushInterpreter interpreter) {
    26       var inputArgument = interpreter.InputExpressions[index];
     28      var expression = interpreter.InputExpressions[index];
    2729
    28       inputArgument.Eval(interpreter);
     30      expression.Eval(interpreter);
    2931    }
    3032  }
     
    3436    "IN1",
    3537    "Pushes first input parameter.",
    36     isHidden: true)]
     38    isHidden: true,
     39    inExpressionNr: 1)]
    3740  [StorableClass]
    3841  public class In1Expression : InExpression {
     
    4750    "IN2",
    4851    "Pushes second input parameter.",
    49     isHidden: true)]
     52    isHidden: true,
     53    inExpressionNr: 2)]
    5054  [StorableClass]
    5155  public class In2Expression : InExpression {
     
    6064   "IN3",
    6165   "Pushes third input parameter.",
    62     isHidden: true)]
     66    isHidden: true,
     67    inExpressionNr: 3)]
    6368  [StorableClass]
    6469  public class In3Expression : InExpression {
     
    7378    "IN4",
    7479    "Pushes fourth input parameter.",
    75     isHidden: true)]
     80    isHidden: true,
     81    inExpressionNr: 4)]
    7682  [StorableClass]
    7783  public class In4Expression : InExpression {
     
    8692    "IN5",
    8793    "Pushes fifth input parameter.",
    88     isHidden: true)]
     94    isHidden: true,
     95    inExpressionNr: 5)]
    8996  [StorableClass]
    9097  public class In5Expression : InExpression {
     
    99106    "IN6",
    100107    "Pushes sixth input parameter.",
    101     isHidden: true)]
     108    isHidden: true,
     109    inExpressionNr: 6)]
    102110  [StorableClass]
    103111  public class In6Expression : InExpression {
     
    112120    "IN7",
    113121    "Pushes seventh input parameter.",
    114     isHidden: true)]
     122    isHidden: true,
     123    inExpressionNr: 7)]
    115124  [StorableClass]
    116125  public class In7Expression : InExpression {
     
    125134    "IN8",
    126135    "Pushes eighth input parameter.",
    127     isHidden: true)]
     136    isHidden: true,
     137    inExpressionNr: 8)]
    128138  [StorableClass]
    129139  public class In8Expression : InExpression {
     
    138148    "IN9",
    139149    "Pushes nineth input parameter.",
    140     isHidden: true)]
     150    isHidden: true,
     151    inExpressionNr: 9)]
    141152  [StorableClass]
    142153  public class In9Expression : InExpression {
     
    151162    "IN10",
    152163    "Pushes tenth input parameter.",
    153     isHidden: true)]
     164    isHidden: true,
     165    inExpressionNr: 10)]
    154166  [StorableClass]
    155167  public class In10Expression : InExpression {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator/CodeGeneratorUtils.cs

    r15189 r15273  
    77
    88  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc;
     9  using HeuristicLab.Problems.ProgramSynthesis.Base.Extensions;
     10  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
     11  using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator;
    912
    1013  using Stack;
    1114
    1215  internal static class CodeGeneratorUtils {
    13     internal static Expression CreateExpressionOrErc(
     16    private static readonly Expression Noop = ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
     17
     18    internal static Expression MapToExpression(
    1419      IRandom random,
    15       IReadOnlyList<string> enabledExpressions,
    1620      IReadOnlyErcOptions ercOptions,
     21      IReadOnlyExpressionsConfiguration config,
    1722      IDictionary<string, Expression> customExpressions = null) {
    1823      var customCount = customExpressions == null ? 0 : customExpressions.Count;
    19       var index = random.Next(enabledExpressions.Count + customCount);
     24      var enabledExpressionCount = config.EnabledExpressions.Count;
     25      var index = random.Next(enabledExpressionCount + customCount);
    2026
    21       return index >= enabledExpressions.Count
    22         ? customExpressions.Values.ElementAt(index - enabledExpressions.Count)
    23         : CreateExpressionOrErc(index, random, enabledExpressions, ercOptions);
     27      return index >= config.EnabledExpressions.Count
     28        ? customExpressions.Values.ElementAt(index - enabledExpressionCount)
     29        : MapToExpression(index, random, ercOptions, config);
    2430    }
    2531
    26     internal static Expression CreateExpressionOrErc(
     32    internal static Expression MapToExpression(
    2733      int index,
    2834      IRandom random,
    29       IReadOnlyList<string> enabledExpressions,
    30       IReadOnlyErcOptions ercOptions) {
    31       var name = enabledExpressions[index];
     35      IReadOnlyErcOptions ercOptions,
     36      IReadOnlyExpressionsConfiguration config) {
    3237
    33       return CreateExpressionOrErc(name, random, ercOptions);
     38      switch (index) {
     39        case PushSolutionEncoding.Noop:
     40          return Noop;
     41
     42        case PushSolutionEncoding.Erc:
     43          var stackType = config.ExpressionsPerStackCount.RandomWeightedOrDefault(random, pair => pair.Value).Key;
     44
     45          if (stackType == default(StackTypes))
     46            break;
     47
     48          return CreateRandomErcExpression(stackType, random, ercOptions);
     49
     50        case PushSolutionEncoding.In:
     51          if (config.InExpressionCount == 0) break;
     52
     53          var nr = random.Next(0, config.InExpressionCount) + 1;
     54          return ExpressionTable.InExpressionTable[nr];
     55      }
     56
     57      var name = config.EnabledExpressions[index];
     58      return ExpressionTable.GetExpression(name);
    3459    }
    3560
    36     private static Expression CreateExpressionOrErc(
    37       string expressionName,
    38       IRandom random,
    39       IReadOnlyErcOptions ercOptions) {
    40       //var x = random.NextDouble();
    41       //Expression expression = null;
     61    //private static Expression CreateExpressionOrErc(
     62    //  string expressionName,
     63    //  IRandom random,
     64    //  IReadOnlyErcOptions ercOptions) {
     65    //  var x = random.NextDouble();
     66    //  Expression expression = null;
    4267
    43       //if (x < ercOptions.ErcProbability) {
    44       //  var expressionType = ExpressionTable.NameToTypeTable[expressionName];
    45       //  expression = CreateRandomErcExpression(
    46       //      ExpressionTable.TypeToAttributeTable[expressionType].StackType,
    47       //      random,
    48       //      ercOptions);
    49       //}
     68    //  if (x < ercOptions.ErcProbability) {
     69    //    var expressionType = ExpressionTable.NameToTypeTable[expressionName];
     70    //    expression = CreateRandomErcExpression(
     71    //        ExpressionTable.TypeToAttributeTable[expressionType].StackType,
     72    //        random,
     73    //        ercOptions);
     74    //  }
    5075
    51       //if (expression == null || expression is ExecNoopExpression) {
    52       //  expression = ExpressionTable.GetExpression(expressionName);
    53       //}
     76    //  if (expression == null || expression is ExecNoopExpression) {
     77    //    expression = ExpressionTable.GetExpression(expressionName);
     78    //  }
    5479
    55       //return expression;
     80    //  return expression;
     81    //}
    5682
    57       var expression = ExpressionTable.GetExpression(expressionName);
    58 
    59       return expression;
    60     }
    61 
    62     private static readonly Expression Noop = ExpressionTable.GetStatelessExpression<ExecNoopExpression>();
    6383    /// <summary>
    6484    /// Create a ErcExpression whereby the type of the expression conforms to the passed stack type.
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator/LinearCodeGenerator.cs

    r14834 r15273  
    3131      IManagedPool<PooledList<Expression>> expressionListPool = null,
    3232      IRandom random = null,
    33       IReadOnlyPushConfiguration pushConfiguration = null,
     33      IReadOnlyPushConfiguration config = null,
    3434      IDictionary<string, Expression> customExpressions = null) {
    3535      if (maxPoints == 0)
    3636        return new Expression[0];
    3737
    38       random = random ?? new FastRandom();
    39       pushConfiguration = pushConfiguration ?? new PushConfiguration();
     38      random = random ?? new MersenneTwister();
     39      config = config ?? new PushConfiguration();
    4040
    4141      var size = maxPoints <= 1 ? 1 : random.Next(1, maxPoints);
     
    4343
    4444      for (var i = 0; i < size; i++) {
    45         var expression = CodeGeneratorUtils.CreateExpressionOrErc(
     45        var expression = CodeGeneratorUtils.MapToExpression(
    4646          random,
    47           pushConfiguration.EnabledExpressions,
    48           pushConfiguration.ErcOptions,
     47          config.ErcOptions,
     48          config,
    4949          customExpressions);
    5050
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator/RecursiveCodeGenerator.cs

    r15189 r15273  
    4949    private static IEnumerable<Expression> RandomCodeWithSize(int points, IRandom random, IReadOnlyPushConfiguration pushConfiguration, IDictionary<string, Expression> customExpressions = null) {
    5050      if (points == 1) {
    51         return new[] { CodeGeneratorUtils.CreateExpressionOrErc(
     51        return new[] { CodeGeneratorUtils.MapToExpression(
    5252          random,
    53           pushConfiguration.EnabledExpressions,
    5453          pushConfiguration.ErcOptions,
     54          pushConfiguration,
    5555          customExpressions)
    5656        };
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/IndividualExtensions.cs

    r15189 r15273  
    66  using HeuristicLab.Optimization;
    77  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
    8   using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
    98  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    109  using HeuristicLab.Problems.ProgramSynthesis.Push.Generators.CodeGenerator;
    11   using HeuristicLab.Random;
     10  using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator;
    1211
    1312  public static class IndividualExtensions {
    14     public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config, ObjectPool<IRandom> randomPool) {
    15       return individual.IntegerVector().ToPushProgram(config, randomPool);
    16     }
    17 
    18     public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) {
    19       return individual.IntegerVector().ToPushProgram(config);
    20     }
    2113
    2214    public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config, IRandom random) {
    2315      return individual.IntegerVector().ToPushProgram(config, random);
    24     }
    25 
    26     public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config, ObjectPool<IRandom> randomPool) {
    27       var random = randomPool.Allocate();
    28       var seed = vector.GetSeed();
    29 
    30       random.Reset(seed);
    31       var program = vector.ToPushProgram(config, random);
    32       randomPool.Free(random);
    33 
    34       return program;
    35     }
    36 
    37     public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) {
    38       var seed = (uint)vector.GetSeed();
    39       return vector.ToPushProgram(config, new MersenneTwister(seed));
    40     }
    41 
    42     public static int GetSeed(this IntegerVector vector) {
    43       var seed = 17;
    44       for (var i = 0; i < vector.Length; i++)
    45         seed = seed * 23 + vector[i];
    46       return seed;
    4716    }
    4817
     
    5322
    5423      for (var i = vector.Length - 1; i >= 0; i--) {
    55         var expression = CodeGeneratorUtils.CreateExpressionOrErc(
    56           vector[i],
     24        var index = vector[i];
     25
     26        if (index == PushSolutionEncoding.End)
     27          break;
     28
     29        // skip noops
     30        if (index == PushSolutionEncoding.Noop)
     31          continue;
     32
     33        var expression = CodeGeneratorUtils.MapToExpression(
     34          index,
    5735          random,
    58           config.EnabledExpressions,
    59           config.ErcOptions);
     36          config.ErcOptions,
     37          config);
    6038
    6139        expressions.Add(expression);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/InduvidualMapper.cs

    r15189 r15273  
    3939
    4040      for (; currentIndex < vector.Length; currentIndex++) {
    41         var expression = CodeGeneratorUtils.CreateExpressionOrErc(
     41        var expression = CodeGeneratorUtils.MapToExpression(
    4242          vector[currentIndex] % config.EnabledExpressions.Count,
    4343          random,
    44           config.EnabledExpressions,
    45           config.ErcOptions);
     44          config.ErcOptions,
     45          config);
    4646
    4747        var expressionType = expression.GetType();
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/Extensions.cs

    r15189 r15273  
    88
    99  using Attributes;
     10
     11  using HeuristicLab.BenchmarkSuite;
    1012
    1113  using Stack;
     
    6062      }
    6163    }
     64
     65    public static void InitExample(this IPushInterpreter interpreter, Example example) {
     66      interpreter.BooleanStack.Push(example.InputBoolean);
     67      interpreter.IntegerStack.Push(example.InputInteger);
     68      interpreter.FloatStack.Push(example.InputFloat);
     69      interpreter.CharStack.Push(example.InputChar);
     70      interpreter.StringStack.Push(example.InputString);
     71      interpreter.StringVectorStack.Push(example.InputStringVector);
     72      interpreter.IntegerVectorStack.Push(example.InputIntegerVector);
     73      interpreter.FloatVectorStack.Push(example.InputFloatVector);
     74
     75      interpreter.SetInput(
     76        integers: example.InputInteger,
     77        floats: example.InputFloat,
     78        booleans: example.InputBoolean,
     79        chars: example.InputChar,
     80        strings: example.InputString,
     81        integerVectors: example.InputIntegerVector,
     82        floatVectors: example.InputFloatVector,
     83        stringVectors: example.InputStringVector);
     84    }
    6285  }
    6386}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/IPushInterpreter.cs

    r15189 r15273  
    1111
    1212  public interface IPushInterpreter {
    13     IRandom Random { get; set; }
     13    IRandom Random { get; }
    1414    IPushStack<Expression> CodeStack { get; }
    1515    IPushStack<Expression> ExecStack { get; }
     
    2828    IReadOnlyDictionary<StackTypes, IPushStack> Stacks { get; }
    2929    IReadOnlyPushConfiguration Configuration { get; }
    30     void Clear();
    31     void Reset();
     30    void ClearStacks();
     31    void Reset(IRandom random = null);
    3232
    3333    void SetInput(
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PooledPushInterpreter.cs

    r15032 r15273  
    1515    public override void Dispose() {
    1616      base.Dispose();
    17       Clear();
     17      ClearStacks();
    1818      pool.Free(this);
    1919    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreter.cs

    r15189 r15273  
    1919    private Expression currentProgram;
    2020
     21    /// <summary>
     22    /// An interpreter for Push
     23    /// </summary>
     24    /// <param name="config">Determines the runtime behavior of the interpreter</param>
     25    /// <param name="random">Note that random may be reseted</param>
     26    /// <param name="poolContainer">Used to save resources used by the interpreter</param>
    2127    public PushInterpreter(IReadOnlyPushConfiguration config = null, IRandom random = null, InterpreterPoolContainer poolContainer = null) {
    22       Random = random ?? new MersenneTwister();
     28      randomOrigin = random ?? new MersenneTwister();
     29      Random = (IRandom)randomOrigin.Clone();
    2330      Configuration = config ?? new PushConfiguration();
    2431
     
    6976    public IReadOnlyDictionary<StackTypes, IPushStack> Stacks { get; private set; }
    7077
    71     public IRandom Random { get; set; }
     78    private IRandom randomOrigin;
     79    public IRandom Random { get; private set; }
    7280
    7381    public long ExecCounter { get; private set; }
     
    330338
    331339    /// <summary>
    332     /// Reset while interpreter
     340    /// Reset interpreter which clears and reconfigures stacks and local variables
    333341    /// </summary>
    334     public void Reset() {
     342    public void Reset(IRandom random = null) {
     343      if (random != null)
     344        randomOrigin = random;
     345
     346      // Reset Random
     347      Random = (IRandom)randomOrigin.Clone();
     348
    335349      ExecCounter = 0;
    336350      IsAborted = false;
     
    340354
    341355      inputExpressions.Clear();
    342       Clear();
     356      ClearStacks();
    343357      ConfigureStacks();
    344358    }
     
    357371    /// Clears Stacks and custom expressions
    358372    /// </summary>
    359     public void Clear() {
     373    public void ClearStacks() {
    360374      for (var i = 0u; i < supportedStackTypes.Length; i++) {
    361375        var key = supportedStackTypes[i];
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs

    r15189 r15273  
    55  using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
    66  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    7   using HeuristicLab.Random;
    87
    98  public class PushInterpreterPool {
     
    3332    public PooledPushInterpreter Create(IRandom random = null) {
    3433      var interpreter = pool.Allocate();
    35       interpreter.Random = random ?? new MersenneTwister();
    36       interpreter.Reset();
     34      interpreter.Reset(random);
    3735
    3836      return interpreter;
     
    4038
    4139    public void Free(PooledPushInterpreter interpreter) {
    42       interpreter.Random = null;
     40      interpreter.ClearStacks();
    4341      pool.Free(interpreter);
    4442    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/BenchmarkSuitePushSolutionView.cs

    r15189 r15273  
    5353      var example = Evaluator.Data.Examples[exampleComboBox.SelectedIndex];
    5454
    55       interpreter.SetInput(
    56         integers: example.InputInteger,
    57         floats: example.InputFloat,
    58         booleans: example.InputBoolean,
    59         chars: example.InputChar,
    60         strings: example.InputString,
    61         integerVectors: example.InputIntegerVector,
    62         floatVectors: example.InputFloatVector,
    63         stringVectors: example.InputStringVector);
    64 
    65       //interpreter.BooleanStack.Push(example.InputBoolean);
    66       //interpreter.IntegerStack.Push(example.InputInteger);
    67       //interpreter.FloatStack.Push(example.InputFloat);
    68       //interpreter.CharStack.Push(example.InputChar);
    69       //interpreter.StringStack.Push(example.InputString);
    70       //interpreter.IntegerVectorStack.Push(example.InputIntegerVector.Select(x => x.ToList()).ToList());
    71       //interpreter.FloatVectorStack.Push(example.InputFloatVector.Select(x => x.ToList()).ToList());
    72       //interpreter.StringVectorStack.Push(example.InputStringVector.Select(x => x.ToList()).ToList());
    73       //interpreter.BooleanVectorStack.Push(example.InputBooleanVector.Select(x => x.ToList()).ToList());
     55      interpreter.InitExample(example);
    7456    }
    7557
     
    9274    }
    9375
     76
    9477    protected override void OnContentChanged() {
    9578      if (Content == null) return;
     
    10487      }
    10588
    106       interpreter = pool.Create(Content.Random);
     89      var random = Content.GetRandom();
     90      interpreter = pool.Create(random);
    10791      UpdateExamples(Evaluator.Data);
    10892
     
    181165      grid.Columns.Add(relativeDiffColumn);
    182166
    183       using (var pushInterpreter = pool.Create(Content.Random)) {
     167      var random = Content.GetRandom();
     168      using (var pushInterpreter = pool.Create(random)) {
    184169        var rowIndex = 1;
    185170        for (var i = start; i < end; i++, rowIndex++) {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteEvaluator.cs

    r15189 r15273  
    131131      var example = Data.Examples[exampleIndex];
    132132
    133       //interpreter.BooleanStack.Push(example.InputBoolean);
    134       //interpreter.IntegerStack.Push(example.InputInteger);
    135       //interpreter.FloatStack.Push(example.InputFloat);
    136       //interpreter.CharStack.Push(example.InputChar);
    137       //interpreter.StringStack.Push(example.InputString);
    138       //interpreter.StringVectorStack.Push(example.InputStringVector);
    139       //interpreter.IntegerVectorStack.Push(example.InputIntegerVector);
    140       //interpreter.FloatVectorStack.Push(example.InputFloatVector);
    141 
    142       interpreter.SetInput(
    143         integers: example.InputInteger,
    144         floats: example.InputFloat,
    145         booleans: example.InputBoolean,
    146         chars: example.InputChar,
    147         strings: example.InputString,
    148         integerVectors: example.InputIntegerVector,
    149         floatVectors: example.InputFloatVector,
    150         stringVectors: example.InputStringVector);
    151 
     133      interpreter.InitExample(example);
    152134      interpreter.Run(program);
    153135
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteProblem.cs

    r15189 r15273  
    88  using HeuristicLab.BenchmarkSuite.Problems;
    99  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    10   using HeuristicLab.Problems.ProgramSynthesis.Push.Extensions;
    1110
    1211  using Instances;
     
    4948      Description = data.Description;
    5049      BestKnownQuality = data.BestResult;
    51       config.MaxPointsInProgram = data.MaxSize;
    52       config.EvalPushLimit = data.EvalLimit;
    53       config.ErcOptions = data.ErcOptions;
    54       config.FloatStringFormat = data.FloatStringFormat;
     50      Config.MaxPointsInProgram = data.MaxSize;
     51      Config.EvalPushLimit = data.EvalLimit;
     52      Config.ErcOptions = data.ErcOptions;
     53      Config.FloatStringFormat = data.FloatStringFormat;
    5554
    56       config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
    57       data.InitInExpressions(config);
     55      Config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
     56      Config.InitInExpressions(data.TotalInputArgumentCount);
    5857
    5958      Encoding.Bounds[0, 0] = 0;
    60       Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;
     59      Encoding.Bounds[0, 1] = Config.EnabledExpressions.Count;
    6160
    62       InitProgramLength = data.MaxSize / 2;
     61      Encoding.Length = data.MaxSize;
    6362    }
    6463
     
    6766      double bestQuality,
    6867      IRandom random,
    69       IReadOnlyPushConfiguration config,
    70       IPushEvaluator evaluator) {
    71       return new PushBenchmarkSuiteSolution(program, bestQuality, random, (IReadOnlyPushConfiguration)config.Clone(), (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
     68      IReadOnlyPushConfiguration config) {
     69      return new PushBenchmarkSuiteSolution(program, bestQuality, random, config, (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
    7270    }
    7371  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushProblem.cs

    r15189 r15273  
    77  using Configuration;
    88  using Core;
    9   using Data.Pool;
    109  using HeuristicLab.Data;
    1110  using HeuristicLab.Encodings.IntegerVectorEncoding;
     
    1312  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    1413  using HeuristicLab.Problems.ProgramSynthesis.Push.Individual;
    15   using HeuristicLab.Problems.ProgramSynthesis.Push.Problem.BenchmarkSuite;
     14  using HeuristicLab.Problems.ProgramSynthesis.Push.ObjectPools.Random;
     15  using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator;
    1616
    1717  using Interpreter;
     
    1919  using Parameters;
    2020  using Persistence.Default.CompositeSerializers.Storable;
    21   using Random;
    2221
    2322  [StorableClass]
    2423  public abstract class PushProblem : SingleObjectiveBasicProblem<IntegerVectorEncoding> {
    2524    [Storable]
    26     protected readonly PushConfigurationParameterCollection config;
    27     protected PushInterpreterPool pool;
    28     protected readonly ObjectPool<IRandom> randomPool = new ObjectPool<IRandom>(() => new MersenneTwister(), Environment.ProcessorCount * 4);
     25    protected readonly PushConfigurationParameterCollection Config;
     26
     27    protected PushInterpreterPool Pool;
     28    protected readonly SeededRandomPool RandomPool = new SeededRandomPool();
    2929
    3030    [Storable]
    3131    protected readonly IPushEvaluator PushEvaluator;
    3232
    33     private const string BestTrainingSolutionResultName = "Best Solution";
    34     private const string TestQualityResultName = "Test Quality";
    35 
    36     protected PushProblem(PushBenchmarkSuiteEvaluator evaluator) {
    37       config = new PushConfigurationParameterCollection();
     33    private const string BEST_TRAINING_SOLUTION_RESULT_NAME = "Best Solution";
     34    private const string TEST_QUALITY_RESULT_NAME = "Test Quality";
     35
     36    protected PushProblem(IPushEvaluator evaluator) {
     37      Config = new PushConfigurationParameterCollection();
    3838      PushEvaluator = evaluator;
    3939
     
    5252    protected PushProblem(PushProblem original, Cloner cloner)
    5353      : base(original, cloner) {
    54       config = cloner.Clone(original.config);
     54      Config = cloner.Clone(original.Config);
    5555      PushEvaluator = cloner.Clone(original.PushEvaluator);
    5656
     
    6868
    6969    private void InitData() {
    70       pool = new PushInterpreterPool(Environment.ProcessorCount * 2, 4096, 1024, config);
     70      Pool = new PushInterpreterPool(Environment.ProcessorCount * 2, 4096, 1024, Config);
    7171    }
    7272
    7373    private void InitEvents() {
    74       config.EnabledExpressionsChanged += EnabledExpressionsChanged;
     74      Config.EnabledExpressionsChanged += EnabledExpressionsChanged;
     75      Reset += PushProblemReset;
    7576    }
    7677
    7778    private void EnabledExpressionsChanged(object sender, EnabledExpressionsChangedEventArgs e) {
    78       Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;
    79       Encoding.BoundsParameter.Value[0, 1] = config.EnabledExpressions.Count;
    80     }
    81 
    82     public ILookupParameter<IntValue> SeedParamater
    83     {
    84       get { return (ILookupParameter<IntValue>)Parameters["Seed"]; }
    85     }
    86 
    87     #region Parameters
    88     private const string InitProgramLengthParameterName = "InitProgramLength";
    89     private const string InitProgramLengthParameterDescription = "This is the initial size of a push program.";
    90     private const string PushConfigurationParameterName = "PushConfiguration";
     79      Encoding.Bounds[0, 1] = Config.EnabledExpressions.Count;
     80      Encoding.BoundsParameter.Value[0, 1] = Config.EnabledExpressions.Count;
     81    }
     82
     83    private const string PUSH_CONFIGURATION_PARAMETER_NAME = "PushConfiguration";
    9184
    9285    public const string CasesScopeParameterName = "CaseQualities";
     
    9487
    9588    private void InitParameters() {
    96       foreach (var paramater in config.Parameters) {
     89      foreach (var paramater in Config.Parameters) {
    9790        if (!Parameters.ContainsKey(paramater.Name)) {
    9891          Parameters.Add(paramater);
     
    10093      }
    10194
    102       if (!Parameters.ContainsKey(PushConfigurationParameterName))
    103         Parameters.Add(new ValueParameter<IReadOnlyPushConfiguration>(PushConfigurationParameterName, config) {
     95      if (!Parameters.ContainsKey(PUSH_CONFIGURATION_PARAMETER_NAME))
     96        Parameters.Add(new ValueParameter<IReadOnlyPushConfiguration>(PUSH_CONFIGURATION_PARAMETER_NAME, Config) {
    10497          Hidden = true
    10598        });
    10699
    107       if (!Parameters.ContainsKey(InitProgramLengthParameterName)) {
    108         Parameters.Add(new FixedValueParameter<IntValue>(
    109           InitProgramLengthParameterName,
    110           InitProgramLengthParameterDescription,
    111           new IntValue(50)));
    112       }
    113 
    114       Encoding.LengthParameter = InitProgramLengthParameter as IFixedValueParameter<IntValue>;
    115 
    116100      if (!Parameters.ContainsKey(CasesScopeParameterName))
    117101        Parameters.Add(new LookupParameter<BoolArray>(CasesScopeParameterName, "The training cases that have been successfully executed."));
     
    121105    }
    122106
     107    private void PushProblemReset(object sender, EventArgs e) {
     108      // clear pools and free reserved memory
     109      Pool.Clear();
     110      IndividualMapper.Clear();
     111      RandomPool.Clear();
     112
     113      // reset seed
     114      Config.Seed = 0;
     115    }
     116
    123117    protected override void OnReset() {
    124118      base.OnReset();
    125119
    126120      // clear pools and free reserved memory
    127       pool.Clear();
     121      Pool.Clear();
    128122      IndividualMapper.Clear();
     123      RandomPool.Clear();
     124      Config.Seed = 0;
    129125    }
    130126
    131127    private void InitEncoding() {
    132128      Encoding.Bounds[0, 0] = 0;
    133       Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;
    134       Encoding.Length = config.MaxPointsInProgram;
     129      Encoding.Bounds[0, 1] = Config.EnabledExpressions.Count;
     130      Encoding.Length = Config.MaxPointsInProgram;
    135131    }
    136132
    137133    private void InitOperators() {
    138       Operators.Add(new PushExpressionFrequencyAnalyzer());
    139     }
    140 
    141     /// <summary>
    142     ///     This is the inital size of an push program generated by a solution creator
    143     /// </summary>
    144     public IValueParameter<IntValue> InitProgramLengthParameter
    145     {
    146       get { return (IValueParameter<IntValue>)Parameters[InitProgramLengthParameterName]; }
    147     }
    148 
    149     public int InitProgramLength
    150     {
    151       get { return InitProgramLengthParameter.Value.Value; }
    152       set
    153       {
    154         InitProgramLengthParameter.Value.Value = value;
    155       }
    156     }
    157     #endregion
     134
     135      var solutionCreator = Operators.OfType<PushSolutionCreator>().FirstOrDefault();
     136
     137      if (solutionCreator == null) {
     138        solutionCreator = new PushSolutionCreator();
     139        Operators.Add(solutionCreator);
     140      }
     141
     142      solutionCreator.ErcOptions = Config.ErcOptions;
     143
     144      if (!Operators.OfType<PushExpressionFrequencyAnalyzer>().Any()) {
     145        Operators.Add(new PushExpressionFrequencyAnalyzer());
     146      }
     147
     148      SolutionCreator = solutionCreator;
     149    }
    158150
    159151    public override bool Maximization { get { return false; } }
     
    165157      var bestIdx = Array.IndexOf(qualities, bestQuality);
    166158      var vector = individuals[bestIdx].IntegerVector();
    167       var seed = vector.GetSeed();
    168       var rand = randomPool.Allocate();
    169       rand.Reset(seed);
    170 
    171       var program = (PushProgram)vector.ToPushProgram(config, rand).Clone();
     159
     160      var rand = RandomPool.ResetAndAllocate();
     161      var program = (PushProgram)vector.ToPushProgram(Config, rand).Clone();
     162      RandomPool.Free(rand);
     163
     164      rand = RandomPool.ResetAndAllocate();
    172165      var isIndividualBetter = AnalyzeBestTrainingSolution(program, bestQuality, results, rand);
     166      RandomPool.Free(rand);
    173167
    174168      if (isIndividualBetter) {
    175         rand.Reset(seed);
     169        rand = RandomPool.ResetAndAllocate();
    176170        AnalyzeBestTestSolution(program, results, rand);
    177       }
    178 
    179       randomPool.Free(rand);
     171        RandomPool.Free(rand);
     172      }
    180173    }
    181174
    182175    private void AnalyzeBestTestSolution(PushProgram program, ResultCollection results, IRandom random) {
    183       var testResult = PushEvaluator.EvaluateTraining(pool, program, random);
    184 
    185       if (!results.ContainsKey(TestQualityResultName)) {
    186         results.Add(new Result(TestQualityResultName, new DoubleValue(testResult.AvgQuality)));
     176      var testResult = PushEvaluator.EvaluateTraining(Pool, program, random);
     177
     178      if (!results.ContainsKey(TEST_QUALITY_RESULT_NAME)) {
     179        results.Add(new Result(TEST_QUALITY_RESULT_NAME, new DoubleValue(testResult.AvgQuality)));
    187180      } else {
    188         ((DoubleValue)results[TestQualityResultName].Value).Value = testResult.AvgQuality;
     181        ((DoubleValue)results[TEST_QUALITY_RESULT_NAME].Value).Value = testResult.AvgQuality;
    189182      }
    190183    }
    191184
    192185    private bool AnalyzeBestTrainingSolution(PushProgram program, double bestQuality, ResultCollection results, IRandom random) {
    193       if (!results.ContainsKey(BestTrainingSolutionResultName)) {
     186      if (!results.ContainsKey(BEST_TRAINING_SOLUTION_RESULT_NAME)) {
    194187        var solution = CreatePushSolution(
    195188            program,
    196189            bestQuality,
    197             random,
    198             config,
    199             PushEvaluator);
    200 
    201         results.Add(new Result(BestTrainingSolutionResultName, solution));
     190            (IRandom)random.Clone(),
     191            (IReadOnlyPushConfiguration)Config.Clone());
     192
     193        results.Add(new Result(BEST_TRAINING_SOLUTION_RESULT_NAME, solution));
    202194        return true;
    203195      }
    204196
    205       var currentBestQuality = ((PushSolution)results[BestTrainingSolutionResultName].Value).Quality;
     197      var currentBestQuality = ((PushSolution)results[BEST_TRAINING_SOLUTION_RESULT_NAME].Value).Quality;
    206198
    207199      if ((!Maximization && currentBestQuality > bestQuality) ||
    208200           (Maximization && currentBestQuality < bestQuality)) {
    209         results[BestTrainingSolutionResultName].Value = CreatePushSolution(
     201        results[BEST_TRAINING_SOLUTION_RESULT_NAME].Value = CreatePushSolution(
    210202            program,
    211203            bestQuality,
    212204            random,
    213             config,
    214             PushEvaluator);
     205            Config);
    215206        return true;
    216207      }
    217208
    218209      return false;
    219     }
    220 
    221     private EvaluationResult EvaluateIntegerVector(IntegerVector vector) {
    222       var rand = randomPool.Allocate();
    223       var seed = vector.GetSeed();
    224       rand.Reset(seed);
    225 
    226       var program = vector.ToPushProgram(config, rand);
    227       var result = PushEvaluator.EvaluateTraining(pool, program, rand);
    228       randomPool.Free(rand);
    229 
    230       return result;
    231210    }
    232211
     
    235214      double bestQuality,
    236215      IRandom random,
    237       IReadOnlyPushConfiguration config,
    238       IPushEvaluator evaluator);
     216      IReadOnlyPushConfiguration config);
    239217
    240218    public override double Evaluate(Individual individual, IRandom random) {
    241       var vector = individual.IntegerVector();
    242       var result = EvaluateIntegerVector(vector);
     219      // init seed of random pool
     220      //Interlocked.CompareExchange(ref RandomPool.Seed, random.Next(), 0);
     221      //Config.Seed = RandomPool.Seed;
     222
     223      //var rand = RandomPool.ResetAndAllocate();
     224      var program = individual.ToPushProgram(Config, random);
     225      //RandomPool.Free(rand);
     226
     227      //rand = RandomPool.ResetAndAllocate();
     228      var result = PushEvaluator.EvaluateTraining(Pool, program, random);
     229      //RandomPool.Free(rand);
    243230
    244231      individual[CaseQualitiesScopeParameterName] = new DoubleArray(result.ExampleQualities);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushSolution.cs

    r15017 r15273  
    1111    public readonly double Quality;
    1212    [Storable]
    13     public readonly IRandom Random;
     13    protected readonly IRandom Random;
    1414    [Storable]
    1515    public readonly IReadOnlyPushConfiguration Config;
     
    4646    }
    4747
     48    public IRandom GetRandom() {
     49      return (IRandom)Random.Clone();
     50    }
     51
    4852    public virtual PushSolution Simplify() {
    4953      return new PushSolution(Program, Quality, Random, Config, Evaluator, true);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/ExpressionSelectionView.cs

    r15189 r15273  
    1515
    1616  [View("Push Expression Selection Editor")]
    17   [Content(typeof(IEnabledExpressionsConfiguration), true)]
     17  [Content(typeof(IExpressionsConfiguration), true)]
    1818  public partial class ExpressionSelectionView : ItemView {
    1919    public ExpressionSelectionView() {
     
    2424    }
    2525
    26     public new IEnabledExpressionsConfiguration Content
     26    public new IExpressionsConfiguration Content
    2727    {
    28       get { return (IEnabledExpressionsConfiguration)base.Content; }
     28      get { return (IExpressionsConfiguration)base.Content; }
    2929      set
    3030      {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushDebuggerView.cs

    r15032 r15273  
    5454      }
    5555
    56       interpreter = pool.Create(Content.Random);
     56      var random = Content.GetRandom();
     57      interpreter = pool.Create(random);
    5758
    5859      InitDebugLists(Content.Config);
Note: See TracChangeset for help on using the changeset viewer.