Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.