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