Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PlushPushBenchmarkSuiteProblem.cs @ 15275

Last change on this file since 15275 was 15275, checked in by pkimmesw, 7 years ago

#2665 Added PlushEncoding, ZeroErrorDistributionAnalzer

File size: 2.5 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Problem.BenchmarkSuite {
2  using HeuristicLab.BenchmarkSuite;
3  using HeuristicLab.BenchmarkSuite.Problems;
4  using HeuristicLab.Common;
5  using HeuristicLab.Core;
6  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7  using HeuristicLab.Problems.Instances;
8  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
9  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
10  using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
11
12  [StorableClass]
13  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
14  [Item("Plush Push Problem", "")]
15  public class PlushPushBenchmarkSuiteProblem : PlushPushProblem, IProblemInstanceConsumer<ProblemData> {
16    public PlushPushBenchmarkSuiteProblem() : base(new PushBenchmarkSuiteEvaluator()) {
17      Parameters.Add(PushEvaluator.DataParameter);
18      Parameters.Add(PushEvaluator.DataBoundsParameter);
19
20      if (PushEvaluator.Data == null) {
21        var defaultProblem = new NumberIO();
22        Load(defaultProblem.CreateProblemData());
23      }
24    }
25
26    [StorableConstructor]
27    protected PlushPushBenchmarkSuiteProblem(bool deserializing)
28      : base(deserializing) {
29    }
30
31    protected PlushPushBenchmarkSuiteProblem(PlushPushBenchmarkSuiteProblem original, Cloner cloner)
32      : base(original, cloner) {
33    }
34
35    public override IDeepCloneable Clone(Cloner cloner) {
36      return new PlushPushBenchmarkSuiteProblem(this, cloner);
37    }
38
39    public new PushBenchmarkSuiteEvaluator PushEvaluator { get { return (PushBenchmarkSuiteEvaluator)base.PushEvaluator; } }
40
41    public void Load(ProblemData data) {
42      PushEvaluator.LoadData(data);
43
44      Name = "Push Problem: " + data.Name;
45      Description = data.Description;
46      BestKnownQuality = data.BestResult;
47      Config.MaxPointsInProgram = data.MaxSize;
48      Config.EvalPushLimit = data.EvalLimit;
49      Config.ErcOptions = data.ErcOptions;
50      Config.FloatStringFormat = data.FloatStringFormat;
51
52      Config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
53      Config.InitInExpressions(data.TotalInputArgumentCount);
54
55      Encoding.MaxLength = data.MaxSize;
56    }
57
58    protected override PushSolution CreatePushSolution(
59      PushProgram program,
60      double bestQuality,
61      IRandom random,
62      IReadOnlyPushConfiguration config) {
63      return new PushBenchmarkSuiteSolution(program, bestQuality, random, config, (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.