Changeset 14744 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite
- Timestamp:
- 03/10/17 21:42:09 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite
- Files:
-
- 8 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 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/BenchmarkSuiteInstanceProvider.cs
r14727 r14744 3 3 4 4 namespace HeuristicLab.BenchmarkSuite { 5 using System.Linq;6 5 7 6 using HeuristicLab.BenchmarkSuite.Problems; 8 7 using HeuristicLab.Problems.Instances; 9 8 10 public class BenchmarkSuiteInstanceProvider : ProblemInstanceProvider< Data> {9 public class BenchmarkSuiteInstanceProvider : ProblemInstanceProvider<IBenchmarkSuiteDataDescriptor> { 11 10 private const string name = "General Program Synthesis Benchmark Suite"; 12 11 private const string referencePublication = … … 53 52 } 54 53 55 public override Data LoadData(IDataDescriptor descriptor) { 56 var benchmarkSuiteDataDescriptor = (IBenchmarkSuiteDataDescriptor)descriptor; 57 58 return benchmarkSuiteDataDescriptor.CreateData(); 54 public override IBenchmarkSuiteDataDescriptor LoadData(IDataDescriptor descriptor) { 55 return (IBenchmarkSuiteDataDescriptor)descriptor; 59 56 } 60 57 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/HeuristicLab.BenchmarkSuite.csproj
r14733 r14744 98 98 <Compile Include="BenchmarkSuiteInstanceProvider.cs" /> 99 99 <Compile Include="IBenchmarkSuiteDataDescriptor.cs" /> 100 <Compile Include="IExampleParser.cs" />101 100 <Compile Include="Plugin.cs" /> 102 <Compile Include="Problems\Data.cs" />103 101 <Compile Include="Problems\Example.cs" /> 104 102 <Compile Include="Problems\ReplaceSpaceWithNewline.cs" /> -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/IBenchmarkSuiteDataDescriptor.cs
r14727 r14744 1 1 namespace HeuristicLab.BenchmarkSuite { 2 2 using HeuristicLab.BenchmarkSuite.Problems; 3 using HeuristicLab.Core; 3 4 using HeuristicLab.Problems.Instances; 4 5 5 public interface IBenchmarkSuiteDataDescriptor : IDataDescriptor { 6 Data CreateData(); 6 public interface IBenchmarkSuiteDataDescriptor : IDataDescriptor, INamedItem { 7 //Data CreateData(); 8 Example[] Examples { get; } 9 10 string Name { get; } 11 string Description { get; } 12 int OriginalTrainingCount { get; } 13 int OriginalTestCount { get; } 14 int BestResult { get; } 15 int WorstResult { get; } 16 int InputArgumentCount { get; } 17 int OutputArgumentCount { get; } 18 int TotalArgumentCount { get; } 19 20 Example ParseExample(string[] input, string[] output); 7 21 } 8 22 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Checksum.cs
r14727 r14744 3 3 using System.Text; 4 4 5 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 7 [StorableClass] 5 8 public class Checksum : BenchmarkSuiteDataDescriptor { 6 9 private const string name = "Checksum"; 7 10 private const string fileName = "Checksum.csv"; 8 11 private const string description = ""; 12 public Checksum() { } 13 14 [StorableConstructor] 15 public Checksum(bool deserializing) : base(deserializing) { } 9 16 10 17 public override string Name { get { return name; } } 11 p ublicoverride string FileName { get { return fileName; } }18 protected override string FileName { get { return fileName; } } 12 19 public override string Description { get { return description; } } 13 p rotectedoverride int InputArgumentCount { get { return 1; } }14 p rotectedoverride int OutputArgumentCount { get { return 1; } }15 p rotectedoverride int OriginalTrainingCount { get { return 228; } }16 p rotectedoverride int OriginalTestCount { get { return 1254; } }17 p rotectedoverride int BestResult { get { return 0; } }18 p rotectedoverride int WorstResult { get { return byte.MaxValue; } }20 public override int InputArgumentCount { get { return 1; } } 21 public override int OutputArgumentCount { get { return 1; } } 22 public override int OriginalTrainingCount { get { return 228; } } 23 public override int OriginalTestCount { get { return 1254; } } 24 public override int BestResult { get { return 0; } } 25 public override int WorstResult { get { return byte.MaxValue; } } 19 26 20 27 public override Example ParseExample(string[] input, string[] output) { -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/CountOdds.cs
r14727 r14744 1 1 namespace HeuristicLab.BenchmarkSuite.Problems { 2 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 2 3 4 [StorableClass] 3 5 public class CountOdds : BenchmarkSuiteDataDescriptor { 4 6 private const string name = "Count Odds"; … … 6 8 private const string description = ""; 7 9 10 public CountOdds() { } 11 12 [StorableConstructor] 13 public CountOdds(bool deserializing) : base(deserializing) { } 14 8 15 public override string Name { get { return name; } } 9 public override string FileName { get { return fileName; } }10 16 public override string Description { get { return description; } } 11 protected override int InputArgumentCount { get { return 1; } } 12 protected override int OutputArgumentCount { get { return 1; } } 13 protected override int OriginalTrainingCount { get { return 200; } } 14 protected override int OriginalTestCount { get { return 2000; } } 15 protected override int BestResult { get { return 0; } } 16 protected override int WorstResult { get { return 50; } } 17 protected override string FileName { get { return fileName; } } 18 public override int InputArgumentCount { get { return 1; } } 19 public override int OutputArgumentCount { get { return 1; } } 20 public override int OriginalTrainingCount { get { return 200; } } 21 public override int OriginalTestCount { get { return 2000; } } 22 public override int BestResult { get { return 0; } } 23 public override int WorstResult { get { return 50; } } 17 24 18 25 public override Example ParseExample(string[] input, string[] output) { -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Example.cs
r14733 r14744 1 1 namespace HeuristicLab.BenchmarkSuite.Problems { 2 using System; 2 3 3 4 using HeuristicLab.Common; … … 23 24 24 25 public void CopyTo(Example example) { 25 example.InputArgs = this.InputArgs;26 example.OutputArgs = this.OutputArgs;26 Array.Copy(InputArgs, example.InputArgs, InputArgs.Length); 27 Array.Copy(OutputArgs, example.OutputArgs, OutputArgs.Length); 27 28 28 example.InputBoolean = this.InputBoolean;29 example.InputInt = this.InputInt;30 example.InputFloat = this.InputFloat;29 Array.Copy(InputBoolean, example.InputBoolean, InputBoolean.Length); 30 Array.Copy(InputInt, example.InputInt, InputInt.Length); 31 Array.Copy(InputFloat, example.InputFloat, InputFloat.Length); 31 32 32 example.OutputBoolean = this.OutputBoolean;33 example.OutputInt = this.OutputInt;34 example.OutputFloat = this.OutputFloat;33 Array.Copy(OutputBoolean, example.OutputBoolean, OutputBoolean.Length); 34 Array.Copy(OutputInt, example.OutputInt, OutputInt.Length); 35 Array.Copy(OutputFloat, example.OutputFloat, OutputFloat.Length); 35 36 } 36 37 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Views/DataEditorView.cs
r14727 r14744 2 2 3 3 namespace HeuristicLab.BenchmarkSuite.Views { 4 5 using HeuristicLab.BenchmarkSuite.Problems;6 4 using HeuristicLab.Core.Views; 7 5 using HeuristicLab.MainForm; 8 6 9 7 [View("Push Expression Selection Editor")] 10 [Content(typeof( Data), true)]8 [Content(typeof(IBenchmarkSuiteDataDescriptor), true)] 11 9 public partial class DataEditorView : NamedItemView { 12 10 public DataEditorView() { … … 35 33 36 34 try { 37 var newExample = Content. ExampleParser.ParseExample(inputArgs, outputArgs);35 var newExample = Content.ParseExample(inputArgs, outputArgs); 38 36 newExample.CopyTo(example); 39 37 } … … 48 46 } 49 47 50 public new DataContent48 public new IBenchmarkSuiteDataDescriptor Content 51 49 { 52 get { return ( Data)base.Content; }50 get { return (IBenchmarkSuiteDataDescriptor)base.Content; } 53 51 set 54 52 { … … 64 62 65 63 protected override void OnContentChanged() { 66 const string inputPrefix = "in_";67 const string outputPrefix = "out_";68 69 64 dataGridView.Columns.Clear(); 70 65 dataGridView.Rows.Clear();
Note: See TracChangeset
for help on using the changeset viewer.