1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.BenchmarkSuite;
|
---|
4 | using HeuristicLab.BenchmarkSuite.Problems;
|
---|
5 | using HeuristicLab.Problems.Instances;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; |
---|
7 | |
---|
8 | namespace 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 | }
|
---|