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