Changeset 14744 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs
- Timestamp:
- 03/10/17 21:42:09 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs
r14727 r14744 9 9 10 10 using HeuristicLab.BenchmarkSuite.Problems; 11 using HeuristicLab.Common; 12 using HeuristicLab.Core; 13 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 11 14 12 15 using Microsoft.VisualBasic.FileIO; 13 16 14 public abstract class BenchmarkSuiteDataDescriptor : IBenchmarkSuiteDataDescriptor, IExampleParser {15 protected const string InstanceArchiveName = "HeuristicLab.BenchmarkSuite.Data.BenchmarkExamples.zip";16 protected const string ResourcePath = @".*\.Data\.";17 protected const string ExampleSeparator = ",";18 17 19 protected const char ArrayValueSeparator = ' '; 20 protected static readonly char[] ArraySymbolTrim = { '[', ']' }; 18 [StorableClass] 19 public abstract class BenchmarkSuiteDataDescriptor : NamedItem, IBenchmarkSuiteDataDescriptor { 20 private const string InstanceArchiveName = "HeuristicLab.BenchmarkSuite.Data.BenchmarkExamples.zip"; 21 private const string ResourcePath = @".*\.Data\."; 22 private const string ExampleSeparator = ","; 21 23 22 private readonly Lazy<Data> data;23 private readonly Lazy<Example[]> examples;24 private const char ArrayValueSeparator = ' '; 25 private static readonly char[] ArraySymbolTrim = { '[', ']' }; 24 26 25 protected BenchmarkSuiteDataDescriptor() { 26 examples = new Lazy<Example[]>(ParseData().ToArray, false); 27 protected BenchmarkSuiteDataDescriptor() { } 28 29 [StorableConstructor] 30 protected BenchmarkSuiteDataDescriptor(bool deserializing) : base(deserializing) { } 31 32 33 [Storable] 34 private Example[] examples; 35 public Example[] Examples 36 { 37 get 38 { 39 return this.examples ?? (this.examples = this.ParseData().ToArray()); 40 } 27 41 } 28 42 29 protected Example[] Examples { get { return examples.Value; } } 30 31 public abstract string Name { get; } 32 public abstract string FileName { get; } 33 public abstract string Description { get; } 34 protected abstract int OriginalTrainingCount { get; } 35 protected abstract int OriginalTestCount { get; } 36 protected abstract int BestResult { get; } 37 protected abstract int WorstResult { get; } 38 protected abstract int InputArgumentCount { get; } 39 protected abstract int OutputArgumentCount { get; } 40 protected int TotalArgumentCount { get { return InputArgumentCount + OutputArgumentCount; } } 43 public new abstract string Name { get; } 44 protected abstract string FileName { get; } 45 public new abstract string Description { get; } 46 public abstract int OriginalTrainingCount { get; } 47 public abstract int OriginalTestCount { get; } 48 public abstract int BestResult { get; } 49 public abstract int WorstResult { get; } 50 public abstract int InputArgumentCount { get; } 51 public abstract int OutputArgumentCount { get; } 52 public int TotalArgumentCount { get { return InputArgumentCount + OutputArgumentCount; } } 41 53 42 54 public abstract Example ParseExample(string[] input, string[] output); 43 44 public Data CreateData() {45 return new Data(46 BestResult,47 WorstResult,48 OriginalTestCount,49 OriginalTrainingCount,50 InputArgumentCount,51 OutputArgumentCount,52 Examples,53 this);54 }55 55 56 56 private IEnumerable<Example> ParseData() { … … 127 127 throw new InvalidDataException(string.Format("Unable to parse {0} as boolean", str)); 128 128 } 129 130 public override IDeepCloneable Clone(Cloner cloner) { 131 return this; 132 } 129 133 } 130 134 }
Note: See TracChangeset
for help on using the changeset viewer.