Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

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