Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteProblem.cs @ 14952

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

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

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