[15771] | 1 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
[15275] | 2 | using HeuristicLab.BenchmarkSuite;
|
---|
| 3 | using HeuristicLab.BenchmarkSuite.Problems;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 7 | using HeuristicLab.Problems.Instances;
|
---|
| 8 |
|
---|
| 9 | [StorableClass]
|
---|
| 10 | [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
|
---|
| 11 | [Item("Plush Push Problem", "")]
|
---|
| 12 | public class PlushPushBenchmarkSuiteProblem : PlushPushProblem, IProblemInstanceConsumer<ProblemData> {
|
---|
| 13 | public PlushPushBenchmarkSuiteProblem() : 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 PlushPushBenchmarkSuiteProblem(bool deserializing)
|
---|
| 25 | : base(deserializing) {
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | protected PlushPushBenchmarkSuiteProblem(PlushPushBenchmarkSuiteProblem original, Cloner cloner)
|
---|
| 29 | : base(original, cloner) {
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 33 | return new PlushPushBenchmarkSuiteProblem(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 |
|
---|
[15344] | 41 | Name = "[Push][Plush] " + data.Name;
|
---|
[15275] | 42 | Description = data.Description;
|
---|
| 43 | BestKnownQuality = data.BestResult;
|
---|
[15334] | 44 | Config.MaxProgramLength = data.MaxSize;
|
---|
[15275] | 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 |
|
---|
[15334] | 52 | Encoding.MinLength = 0;
|
---|
| 53 | Encoding.MaxLength = data.MaxSize / 2;
|
---|
[15275] | 54 | }
|
---|
| 55 |
|
---|
| 56 | protected override PushSolution CreatePushSolution(
|
---|
| 57 | PushProgram program,
|
---|
| 58 | double bestQuality,
|
---|
| 59 | IRandom random,
|
---|
| 60 | IReadOnlyPushConfiguration config) {
|
---|
| 61 | return new PushBenchmarkSuiteSolution(program, bestQuality, random, config, (PushBenchmarkSuiteEvaluator)PushEvaluator.Clone());
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|