Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/IntegerVectorPushBenchmarkSuiteProblem.cs @ 15866

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

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

File size: 2.5 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.BenchmarkSuite;
4using HeuristicLab.BenchmarkSuite.Problems;
5using HeuristicLab.Problems.Instances;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Problems.ProgramSynthesis {
9  [StorableClass]
10  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
11  [Item("Integer Vector Push Problem", "")]
12  public class IntegerVectorPushBenchmarkSuiteProblem : IntegerVectorPushProblem, IProblemInstanceConsumer<ProblemData> {
13    public IntegerVectorPushBenchmarkSuiteProblem() : 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 IntegerVectorPushBenchmarkSuiteProblem(bool deserializing)
25      : base(deserializing) {
26    }
27
28    protected IntegerVectorPushBenchmarkSuiteProblem(IntegerVectorPushBenchmarkSuiteProblem original, Cloner cloner)
29      : base(original, cloner) {
30    }
31
32    public override IDeepCloneable Clone(Cloner cloner) {
33      return new IntegerVectorPushBenchmarkSuiteProblem(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][IntVector] " + 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.Bounds[0, 0] = 0;
53      Encoding.Bounds[0, 1] = Config.EnabledExpressions.Count;
54
55      Encoding.Length = data.MaxSize / 2;
56
57    }
58
59    protected override PushSolution CreatePushSolution(
60      PushProgram program,
61      double bestQuality,
62      IRandom random,
63      IReadOnlyPushConfiguration config) {
64      return new PushBenchmarkSuiteSolution(program, bestQuality, random, config, (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
65    }
66  }
67}
Note: See TracBrowser for help on using the repository browser.