Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/17 21:42:09 (8 years ago)
Author:
pkimmesw
Message:

#2665 Renamings due to typos, ManagedPool tests, Skip Noops in Debugger

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushEncoding.cs

    r14727 r14744  
    3737
    3838  public static class IndividualExtensionMethods {
    39     public static PushProgram PushProgram(this Individual individual, IList<string> enabledExpressions) {
    40       return MapToProgram(individual.IntegerVector(), enabledExpressions);
     39    public static PushProgram PushProgram(this Individual individual, IReadOnlyList<string> enabledExpressions) {
     40      return individual.IntegerVector().MapToPushProgram(enabledExpressions);
    4141    }
    4242
    43     private static PushProgram MapToProgram(IntegerVector vector, IList<string> enabledExpressions) {
     43    public static PushProgram MapToPushProgram(this IntegerVector vector, IReadOnlyList<string> enabledExpressions) {
    4444      var expressions = vector
    4545        .Select(i => ExpressionTable.GetExpression(enabledExpressions[i]))
    4646        .ToArray();
    4747
    48       return new PushProgram(expressions);
     48      return new Expressions.PushProgram(expressions);
    4949    }
    5050  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushProblem.cs

    r14733 r14744  
    44  using System.Collections.Generic;
    55  using System.Linq;
    6   using BenchmarkSuite.Problems;
    76  using Common;
    87  using Configuration;
     
    109  using Encodings.IntegerVectorEncoding;
    1110  using Expressions;
     11
     12  using HeuristicLab.BenchmarkSuite;
    1213  using HeuristicLab.Data;
    1314  using Instances;
     
    2122  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
    2223  [Item("Push Problem", "")]
    23   public class PushProblem : SingleObjectiveBasicProblem<IntegerVectorEncoding>, IProblemInstanceConsumer<Data> {
     24  public class PushProblem : SingleObjectiveBasicProblem<IntegerVectorEncoding>, IProblemInstanceConsumer<IBenchmarkSuiteDataDescriptor> {
    2425    [Storable]
    2526    private readonly PushConfiguration config;
     
    4950      this.InitEvents();
    5051    }
    51 
    5252
    5353    [StorableHook(HookType.AfterDeserialization)]
     
    102102      var bounds = new IntMatrix(1, 3, new[] { "Training Start", "Training End | Test Start", "Test End" });
    103103      bounds.ItemChanged += (s, e) => {
    104         if (Data == null)
     104        if (this.DataDescriptor == null)
    105105          return;
    106106
    107         var max = Data.OriginalTestCount + Data.OriginalTrainingCount - 1;
     107        var max = this.DataDescriptor.OriginalTestCount + this.DataDescriptor.OriginalTrainingCount - 1;
    108108        bounds[0, 0] = Math.Min(Math.Max(bounds[0, 0], 0), max);
    109109        bounds[0, 2] = Math.Max(Math.Min(bounds[0, 2], max), 0);
     
    174174        new IntValue(config.MaxPointsInRandomExpression)) { Hidden = true });
    175175
    176       Parameters.Add(new ValueParameter<Data>(DataParameterName, DataParameterDescription));
     176      Parameters.Add(new ValueParameter<IBenchmarkSuiteDataDescriptor>(DataParameterName, DataParameterDescription));
    177177
    178178      Encoding.Bounds[0, 0] = 0;
     
    204204    }
    205205
    206     public IValueParameter<Data> DataParameter
    207     {
    208       get { return (IValueParameter<Data>)Parameters[DataParameterName]; }
    209     }
    210 
    211     public Data Data
     206    public IValueParameter<IBenchmarkSuiteDataDescriptor> DataParameter
     207    {
     208      get { return (IValueParameter<IBenchmarkSuiteDataDescriptor>)Parameters[DataParameterName]; }
     209    }
     210
     211    public IBenchmarkSuiteDataDescriptor DataDescriptor
    212212    {
    213213      get { return DataParameter.Value; }
     
    394394      var bestIdx = Array.IndexOf(qualities, bestQuality);
    395395      var bestIndividual = individuals[bestIdx];
    396       var program = bestIndividual.PushProgram(config.EnabledExpressions);
    397       var solution = new PushSolution(program, bestQuality, Data, random, pool);
     396      var solution = new PushSolution(bestIndividual.IntegerVector(), bestQuality, DataDescriptor, random, config);
    398397
    399398      if (!results.ContainsKey(bestSolutionResultName)) {
     
    405404
    406405    public override double Evaluate(Individual individual, IRandom random) {
    407       var program = individual.PushProgram(config.EnabledExpressions);
     406
     407      var program = individual.PushProgram(config.EnabledExpressions as IReadOnlyList<string>);
    408408      var expandExpression = new ExecExpandExpression(program);
    409409      var results = new List<double>();
     
    411411      using (var interpreter = pool.GetInstance(random)) {
    412412        for (var i = DataBounds[0, 0]; i < DataBounds[0, 1]; i++) {
    413           var example = Data.Examples[i];
     413          var example = this.DataDescriptor.Examples[i];
    414414
    415415          interpreter.BooleanStack.Push(example.InputBoolean);
     
    419419          interpreter.Run(expandExpression);
    420420
    421           var diff = GetDiff(example.OutputInt, interpreter.IntegerStack, Data.WorstResult, LongDiffer) +
    422                      GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, DoubleDiffer) +
    423                      GetDiff(example.OutputBoolean, interpreter.BooleanStack, Data.WorstResult, BooleanDiffer);
     421          var diff = GetDiff(example.OutputInt, interpreter.IntegerStack, this.DataDescriptor.WorstResult, LongDiffer) +
     422                     GetDiff(example.OutputFloat, interpreter.FloatStack, this.DataDescriptor.WorstResult, DoubleDiffer) +
     423                     GetDiff(example.OutputBoolean, interpreter.BooleanStack, this.DataDescriptor.WorstResult, BooleanDiffer);
    424424
    425425          results.Add(diff);
     
    466466    }
    467467
    468     public void Load(Data data) {
    469       Data = data;
    470       BestKnownQuality = data.BestResult;
     468    public void Load(IBenchmarkSuiteDataDescriptor descriptor) {
     469      this.DataDescriptor = descriptor;
     470      BestKnownQuality = descriptor.BestResult;
    471471
    472472      DataBounds[0, 0] = 0;
    473       DataBounds[0, 2] = Data.OriginalTrainingCount + Data.OriginalTestCount;
    474       DataBounds[0, 1] = Data.OriginalTrainingCount;
     473      DataBounds[0, 2] = this.DataDescriptor.OriginalTrainingCount + this.DataDescriptor.OriginalTestCount;
     474      DataBounds[0, 1] = this.DataDescriptor.OriginalTrainingCount;
    475475    }
    476476  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushSolution.cs

    r14733 r14744  
    11namespace HeuristicLab.Problems.ProgramSynthesis.Push.Problem {
    2   using HeuristicLab.BenchmarkSuite.Problems;
     2  using HeuristicLab.BenchmarkSuite;
    33  using HeuristicLab.Common;
    44  using HeuristicLab.Core;
     5  using HeuristicLab.Encodings.IntegerVectorEncoding;
     6  using HeuristicLab.Optimization;
    57  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    68  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
    79  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    8   using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
    910
    1011  [StorableClass]
    1112  public class PushSolution : NamedItem {
     13    [Storable]
    1214    public readonly double Quality;
    13     public readonly PushProgram Program;
    14     public readonly Data Data;
     15    [Storable]
     16    public readonly IntegerVector IntegerVector;
     17    [Storable]
     18    public readonly IBenchmarkSuiteDataDescriptor DataDescriptor;
     19    [Storable]
    1520    public readonly IRandom Random;
    16     public readonly PushInterpreterPool Pool;
     21    [Storable]
     22    public readonly IReadonlyPushConfiguration Config;
    1723
    18     public PushSolution(PushProgram program, double quality, Data data,
    19       IRandom random, PushInterpreterPool pool)
     24    public PushSolution(IntegerVector integerVector, double quality, IBenchmarkSuiteDataDescriptor dataDescriptor, IRandom random, IReadonlyPushConfiguration config)
    2025      : base("Solution", "A push solution.") {
    21       Program = program;
     26      IntegerVector = integerVector;
    2227      Quality = quality;
    23       Data = data;
     28      DataDescriptor = dataDescriptor;
    2429      Random = random;
    25       Pool = pool;
     30      Config = config;
    2631    }
    2732
    2833    public PushSolution(PushSolution origin, Cloner cloner) : base(origin, cloner) {
    29       Program = origin.Program;
     34      IntegerVector = origin.IntegerVector;
    3035      Quality = origin.Quality;
    3136    }
Note: See TracChangeset for help on using the changeset viewer.