namespace HeuristicLab.BenchmarkSuite { using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.ProgramSynthesis.Base.Erc; [StorableClass] public class ProblemData : NamedItem { public ProblemData(ProblemType problemType) { Name = "BenchmarkSuite Problem Data"; ErcOptions = new ErcOptions(); // default does nothing FloatStringFormat = "R"; ProblemType = problemType; } [StorableConstructor] protected ProblemData(bool deserializing) : base(deserializing) { } public ProblemData(ProblemData origin, Cloner cloner) : base(origin, cloner) { TrainingCount = origin.TrainingCount; TestCount = origin.TestCount; BestResult = origin.BestResult; WorstResult = origin.WorstResult; InputArgumentTypes = (ExampleArgumentType[])origin.InputArgumentTypes.Clone(); OutputArgumentTypes = (ExampleArgumentType[])origin.OutputArgumentTypes.Clone(); if (origin.Examples != null) Examples = origin.Examples.Select(cloner.Clone).ToArray(); EnabledDataTypes = origin.EnabledDataTypes; ErcOptions = cloner.Clone(origin.ErcOptions); FloatStringFormat = origin.FloatStringFormat; ProblemType = origin.ProblemType; ProgramExecutionBudget = origin.ProgramExecutionBudget; } [Storable] public readonly ProblemType ProblemType; [Storable] public int TrainingCount { get; set; } [Storable] public int TestCount { get; set; } [Storable] public double BestResult { get; set; } [Storable] public double WorstResult { get; set; } [Storable] public ExampleArgumentType[] InputArgumentTypes { get; set; } [Storable] public ExampleArgumentType[] OutputArgumentTypes { get; set; } public int TotalInputArgumentCount { get { return InputArgumentTypes.Length; } } public int TotalOutputArgumentCount { get { return OutputArgumentTypes.Length; } } public int TotalArgumentCount { get { return InputArgumentTypes.Length + OutputArgumentTypes.Length; } } [Storable] public Example[] Examples { get; set; } [Storable] public DataTypes EnabledDataTypes { get; set; } /// /// Max Size” gives the maximum number of instructions that can appear in an individual’s genome /// [Storable] public int MaxSize { get; set; } /// /// “Eval Limit” is the number of steps of the Push interpreter that are executed before stopping a /// program’s execution; programs halted in this way may still achieve good results if they print or /// return results before they are stopped /// [Storable] public int EvalLimit { get; set; } /// /// Specifies constant values and value ranges required to solve a certain problem /// [Storable] public ErcOptions ErcOptions { get; set; } /// /// Represents the maximum number of programs that will be executed before a run is terminated, which is the product of the maximum generations, the population size, and the size of the training set. /// [Storable] public int ProgramExecutionBudget { get; set; } [Storable] public string FloatStringFormat { get; set; } public override IDeepCloneable Clone(Cloner cloner) { return new ProblemData(this, cloner); } } }