1 | namespace 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.Expressions;
|
---|
10 | using HeuristicLab.Problems.ProgramSynthesis.Push.Extensions;
|
---|
11 |
|
---|
12 | using Instances;
|
---|
13 | using Persistence.Default.CompositeSerializers.Storable;
|
---|
14 | using Stack;
|
---|
15 |
|
---|
16 | [StorableClass]
|
---|
17 | [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
|
---|
18 | [Item("Push Problem", "")]
|
---|
19 | public class PushBenchmarkSuiteProblem : PushProblem, IProblemInstanceConsumer<ProblemData> {
|
---|
20 | public PushBenchmarkSuiteProblem() : base(new PushBenchmarkSuiteEvaluator()) {
|
---|
21 | Parameters.Add(PushEvaluator.DataParameter);
|
---|
22 | Parameters.Add(PushEvaluator.DataBoundsParameter);
|
---|
23 |
|
---|
24 | if (PushEvaluator.Data == null) {
|
---|
25 | var defaultProblem = new NumberIO();
|
---|
26 | Load(defaultProblem.CreateProblemData());
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | [StorableConstructor]
|
---|
31 | protected PushBenchmarkSuiteProblem(bool deserializing)
|
---|
32 | : base(deserializing) {
|
---|
33 | }
|
---|
34 |
|
---|
35 | protected PushBenchmarkSuiteProblem(PushBenchmarkSuiteProblem original, Cloner cloner)
|
---|
36 | : base(original, cloner) {
|
---|
37 | }
|
---|
38 |
|
---|
39 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
40 | return new PushBenchmarkSuiteProblem(this, cloner);
|
---|
41 | }
|
---|
42 |
|
---|
43 | public new PushBenchmarkSuiteEvaluator PushEvaluator { get { return (PushBenchmarkSuiteEvaluator)base.PushEvaluator; } }
|
---|
44 |
|
---|
45 | public void Load(ProblemData data) {
|
---|
46 | PushEvaluator.LoadData(data);
|
---|
47 |
|
---|
48 | Name = "Push Problem: " + data.Name;
|
---|
49 | Description = data.Description;
|
---|
50 | BestKnownQuality = data.BestResult;
|
---|
51 | config.MaxPointsInProgram = data.MaxSize;
|
---|
52 | config.EvalPushLimit = data.EvalLimit;
|
---|
53 | config.ErcOptions = data.ErcOptions;
|
---|
54 | config.FloatStringFormat = data.FloatStringFormat;
|
---|
55 |
|
---|
56 | config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
|
---|
57 | data.InitInExpressions(config);
|
---|
58 |
|
---|
59 | Encoding.Bounds[0, 0] = 0;
|
---|
60 | Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;
|
---|
61 |
|
---|
62 | InitProgramLength = data.MaxSize / 2;
|
---|
63 | }
|
---|
64 |
|
---|
65 | protected override PushSolution CreatePushSolution(
|
---|
66 | PushProgram program,
|
---|
67 | double bestQuality,
|
---|
68 | IRandom random,
|
---|
69 | IReadOnlyPushConfiguration config,
|
---|
70 | IPushEvaluator evaluator) {
|
---|
71 | return new PushBenchmarkSuiteSolution(program, bestQuality, random, (IReadOnlyPushConfiguration)config.Clone(), (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
|
---|
72 | }
|
---|
73 | }
|
---|
74 | }
|
---|