Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/17 19:34:13 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed analyzer, fixed Plush encoding + operators, adpated print evaluation according to McPhee

Location:
branches/PushGP/HeuristicLab.PushGP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP

    • Property svn:ignore set to
      *.user
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Analyzer/PushExpressionFrequencyAnalyzer.cs

    r15273 r15289  
    11namespace HeuristicLab.Problems.ProgramSynthesis.Push.Analyzer {
    22  using System;
     3  using System.Collections.Generic;
    34  using System.Linq;
    45
     
    1415  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
    1516  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
     17  using HeuristicLab.Problems.ProgramSynthesis.Push.Encoding;
    1618  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    1719  using HeuristicLab.Problems.ProgramSynthesis.Push.Individual;
    18   using HeuristicLab.Problems.ProgramSynthesis.Push.ObjectPools.Random;
    1920
    2021  /// <summary>
     
    2425  [StorableClass]
    2526  public class PushExpressionFrequencyAnalyzer : SingleSuccessorOperator, IPushExpressionAnalyzer {
    26     private readonly SeededRandomPool randomPool = new SeededRandomPool();
    2727
    2828    private const string PUSH_CONFIGURATION_PARAMETER_NAME = "PushConfiguration";
     
    4040      Parameters.Add(new LookupParameter<IReadOnlyPushConfiguration>(PUSH_CONFIGURATION_PARAMETER_NAME, "The current specified push configuration."));
    4141      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>(INTEGER_VECTOR_PARAMETER_NAME, "The integer vectors to analyze."));
     42      Parameters.Add(new ScopeTreeLookupParameter<PlushVector>("Plush", "The plush vectors to analyze."));
    4243      Parameters.Add(new LookupParameter<DataTable>(EXPRESSION_FREQUENCIES_PARAMETER_NAME, "The data table to store the instruction frequencies."));
    4344      Parameters.Add(new LookupParameter<ResultCollection>(RESULTS_PARAMETER_NAME, "The result collection where the symbol frequencies should be stored."));
     
    6061    {
    6162      get { return (ILookupParameter<IReadOnlyPushConfiguration>)Parameters[PUSH_CONFIGURATION_PARAMETER_NAME]; }
     63    }
     64
     65    public IScopeTreeLookupParameter<PlushVector> PlushVectorParameter
     66    {
     67      get { return (IScopeTreeLookupParameter<PlushVector>)Parameters["Plush"]; }
    6268    }
    6369
     
    95101    public override IOperation Apply() {
    96102      var config = PushConfigurationParameter.ActualValue;
    97       var integerVectors = IntegerVectorParameter.ActualValue;
    98103
    99       randomPool.Seed = config.Seed;
     104      IReadOnlyList<PushProgram> pushPrograms = null;
    100105
    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       });
     106      if (IntegerVectorParameter.ActualValue.Length > 0) {
     107        pushPrograms = IntegerVectorParameter.ActualValue.Select(iv => iv.ToPushProgram(config)).ToList();
     108      } else if (PlushVectorParameter.ActualValue.Length > 0) {
     109        pushPrograms = PlushVectorParameter.ActualValue.Select(pv => pv.PushProgram).ToList();
     110      } else {
     111        // nothing to do
     112        return base.Apply();
     113      }
    108114
    109115      var results = ResultsParameter.ActualValue;
     
    136142          group => group.Count());
    137143
    138       var totalNumberofExpressions = Math.Max(1.0, expressionFrequencies.Values.Sum());
     144      var totalNumberOfExpressions = Math.Max(1.0, expressionFrequencies.Values.Sum());
    139145
    140146      // all rows must have the same number of values so we can just take the first
     
    152158        }
    153159
    154         frequencies.Rows[pair.Key].Values.Add(Math.Round(pair.Value / totalNumberofExpressions, 3));
     160        frequencies.Rows[pair.Key].Values.Add(Math.Round(pair.Value / totalNumberOfExpressions, 3));
    155161      }
    156162
Note: See TracChangeset for help on using the changeset viewer.