Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/IntegerVectorPushBenchmarkSuiteProblem.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
3  using Common;
4  using Configuration;
5  using Core;
6
7  using HeuristicLab.BenchmarkSuite;
8  using HeuristicLab.BenchmarkSuite.Problems;
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
14  using Instances;
15  using Persistence.Default.CompositeSerializers.Storable;
16  using Stack;
17
18  [StorableClass]
19  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
20  [Item("Integer Vector Push Problem", "")]
21  public class IntegerVectorPushBenchmarkSuiteProblem : IntegerVectorPushProblem, IProblemInstanceConsumer<ProblemData> {
22    public IntegerVectorPushBenchmarkSuiteProblem() : base(new PushBenchmarkSuiteEvaluator()) {
23      Parameters.Add(PushEvaluator.DataParameter);
24      Parameters.Add(PushEvaluator.DataBoundsParameter);
25
26      if (PushEvaluator.Data == null) {
27        var defaultProblem = new NumberIO();
28        Load(defaultProblem.CreateProblemData());
29      }
30    }
31
32    [StorableConstructor]
33    protected IntegerVectorPushBenchmarkSuiteProblem(bool deserializing)
34      : base(deserializing) {
35    }
36
37    protected IntegerVectorPushBenchmarkSuiteProblem(IntegerVectorPushBenchmarkSuiteProblem original, Cloner cloner)
38      : base(original, cloner) {
39    }
40
41    public override IDeepCloneable Clone(Cloner cloner) {
42      return new IntegerVectorPushBenchmarkSuiteProblem(this, cloner);
43    }
44
45    public new PushBenchmarkSuiteEvaluator PushEvaluator { get { return (PushBenchmarkSuiteEvaluator)base.PushEvaluator; } }
46
47    public void Load(ProblemData data) {
48      PushEvaluator.LoadData(data);
49
50      Name = "Push Problem: " + data.Name;
51      Description = data.Description;
52      BestKnownQuality = data.BestResult;
53      Config.MaxProgramLength = data.MaxSize;
54      Config.EvalPushLimit = data.EvalLimit;
55      Config.ErcOptions = data.ErcOptions;
56      Config.FloatStringFormat = data.FloatStringFormat;
57
58      Config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
59      Config.InitInExpressions(data.TotalInputArgumentCount);
60
61      Encoding.Bounds[0, 0] = 0;
62      Encoding.Bounds[0, 1] = Config.EnabledExpressions.Count;
63
64      Encoding.Length = data.MaxSize / 2;
65
66    }
67
68    protected override PushSolution CreatePushSolution(
69      PushProgram program,
70      double bestQuality,
71      IRandom random,
72      IReadOnlyPushConfiguration config) {
73      return new PushBenchmarkSuiteSolution(program, bestQuality, random, config, (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.