1 | namespace HeuristicLab.Problems.ProgramSynthesis.Push.Problem.BenchmarkSuite {
|
---|
2 | using Common;
|
---|
3 | using Configuration;
|
---|
4 | using Core;
|
---|
5 | using Encodings.IntegerVectorEncoding;
|
---|
6 |
|
---|
7 | using HeuristicLab.BenchmarkSuite;
|
---|
8 | using HeuristicLab.BenchmarkSuite.Problems;
|
---|
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 BenchmarkSuite 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 |
|
---|
46 | config.SetEnabledStacks((StackTypes)data.EnabledDataTypes);
|
---|
47 |
|
---|
48 | Encoding.Bounds[0, 0] = 0;
|
---|
49 | Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;
|
---|
50 | Encoding.Length = config.MaxPointsInProgram;
|
---|
51 | }
|
---|
52 |
|
---|
53 | protected override PushSolution CreatePushSolution(
|
---|
54 | IntegerVector vector,
|
---|
55 | double bestQuality,
|
---|
56 | IRandom random,
|
---|
57 | IReadOnlyPushConfiguration config,
|
---|
58 | IPushEvaluator evaluator) {
|
---|
59 | return new PushBenchmarkSuiteSolution(vector, bestQuality, random, (IReadOnlyPushConfiguration)config.Clone(), (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|