Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PlushPushBenchmarkSuiteProblem.cs @ 17511

Last change on this file since 17511 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

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