Changeset 14777 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite
- Timestamp:
- 03/23/17 01:11:18 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite
- Files:
-
- 11 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs
r14744 r14777 1 1 namespace HeuristicLab.BenchmarkSuite { 2 using System;3 2 using System.Collections.Generic; 4 3 using System.IO; … … 8 7 using System.Text.RegularExpressions; 9 8 9 using HeuristicLab.BenchmarkSuite.ERC; 10 10 using HeuristicLab.BenchmarkSuite.Problems; 11 using HeuristicLab.Common;12 using HeuristicLab.Core;13 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;14 11 15 12 using Microsoft.VisualBasic.FileIO; 16 13 17 14 18 [StorableClass] 19 public abstract class BenchmarkSuiteDataDescriptor : NamedItem, IBenchmarkSuiteDataDescriptor { 15 public abstract class BenchmarkSuiteDataDescriptor : IBenchmarkSuiteDataDescriptor { 20 16 private const string InstanceArchiveName = "HeuristicLab.BenchmarkSuite.Data.BenchmarkExamples.zip"; 21 17 private const string ResourcePath = @".*\.Data\."; 22 18 private const string ExampleSeparator = ","; 23 19 24 private const char ArrayValueSeparator = ' ';25 private static readonly char[] ArraySymbolTrim = { '[', ']' };26 27 protected BenchmarkSuiteDataDescriptor() { }28 29 [StorableConstructor]30 protected BenchmarkSuiteDataDescriptor(bool deserializing) : base(deserializing) { }31 32 33 [Storable]34 20 private Example[] examples; 35 21 public Example[] Examples … … 41 27 } 42 28 43 public new abstract string Name { get; } 29 public Data CreateProblemData() { 30 return new Data { 31 Name = Name, 32 Description = Description, 33 Examples = Examples.ToArray(), 34 BestResult = BestResult, 35 WorstResult = WorstResult, 36 InputArgumentTypes = InputArgumentTypes, 37 OutputArgumentTypes = OutputArgumentTypes, 38 OriginalTestCount = OriginalTestCount, 39 OriginalTrainingCount = OriginalTrainingCount, 40 EnabledDataTypes = EnabledDataTypes, 41 EvalLimit = EvalLimit, 42 MaxGenerations = MaxGenerations, 43 MaxSize = MaxSize, 44 ProgEvalBudget = ProgEvalBudget, 45 ProblemErcOptions = ProblemErcOptions, 46 }; 47 } 48 49 public abstract string Name { get; } 50 public abstract string Description { get; } 44 51 protected abstract string FileName { get; } 45 public new abstract string Description { get; }46 52 public abstract int OriginalTrainingCount { get; } 47 53 public abstract int OriginalTestCount { get; } 48 54 public abstract int BestResult { get; } 49 55 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; } } 56 public abstract ExampleArgumentType[] InputArgumentTypes { get; } 57 public abstract ExampleArgumentType[] OutputArgumentTypes { get; } 58 public abstract ProblemErcOptions ProblemErcOptions { get; } 59 public abstract DataTypes EnabledDataTypes { get; } 60 public abstract int MaxSize { get; } 61 public abstract int EvalLimit { get; } 62 public abstract int MaxGenerations { get; } 63 public abstract int ProgEvalBudget { get; } 53 64 54 65 public abstract Example ParseExample(string[] input, string[] output); … … 68 79 var fields = parser.ReadFields(); 69 80 70 if (fields.Length != TotalArgumentCount)81 if (fields.Length != InputArgumentTypes.Length + OutputArgumentTypes.Length) 71 82 throw new InvalidDataException("Number of values do not fit"); 72 83 73 var input = fields.Take(InputArgument Count).ToArray();74 var output = fields.Skip( InputArgumentCount).ToArray();84 var input = fields.Take(InputArgumentTypes.Length).ToArray(); 85 var output = fields.Skip(OutputArgumentTypes.Length).ToArray(); 75 86 76 87 yield return ParseExample(input, output); … … 86 97 .SingleOrDefault(x => Regex.Match(x, ResourcePath + fileName).Success); 87 98 } 88 89 protected static double[] ConvertDoubles(string input) {90 return ConvertMultiple(input, double.Parse);91 }92 93 protected static double ConvertDouble(string input) {94 return double.Parse(input);95 }96 97 protected static long[] ConvertIntegers(string input) {98 return ConvertMultiple(input, long.Parse);99 }100 101 protected static long ConvertInteger(string input) {102 103 return string.IsNullOrEmpty(input) ? default(long) : long.Parse(input);104 }105 106 protected static T[] ConvertMultiple<T>(string input, Func<string, T> converter) {107 return input108 .Trim(ArraySymbolTrim)109 .Split(ArrayValueSeparator)110 .Where(s => !string.IsNullOrWhiteSpace(s))111 .Select(converter)112 .ToArray();113 }114 115 protected static IEnumerable<string> SplitByNewLine(string input) {116 return input.Split(new[] { Environment.NewLine, "\n", "\r\n" }, StringSplitOptions.None);117 }118 119 private static string[] trueFormats = new[] { "true", "t", "1" };120 private static string[] falseFormats = new[] { "false", "f", "0" };121 122 protected static bool ConvertBool(string input) {123 var str = input.ToLower();124 125 if (trueFormats.Contains(str)) return true;126 if (falseFormats.Contains(str)) return false;127 throw new InvalidDataException(string.Format("Unable to parse {0} as boolean", str));128 }129 130 public override IDeepCloneable Clone(Cloner cloner) {131 return this;132 }133 99 } 134 100 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/BenchmarkSuiteInstanceProvider.cs
r14744 r14777 7 7 using HeuristicLab.Problems.Instances; 8 8 9 public class BenchmarkSuiteInstanceProvider : ProblemInstanceProvider< IBenchmarkSuiteDataDescriptor> {9 public class BenchmarkSuiteInstanceProvider : ProblemInstanceProvider<Data> { 10 10 private const string name = "General Program Synthesis Benchmark Suite"; 11 11 private const string referencePublication = … … 36 36 yield return new CountOdds(); 37 37 //yield return new CollatzNumbers(); 38 yield return new Checksum();38 //yield return new Checksum(); 39 39 //yield return new CompareStringLengths(); 40 40 //yield return new Digits(); … … 52 52 } 53 53 54 public override IBenchmarkSuiteDataDescriptor LoadData(IDataDescriptor descriptor) { 55 return (IBenchmarkSuiteDataDescriptor)descriptor; 54 public override Data LoadData(IDataDescriptor descriptor) { 55 var benchmarkSuiteDataDescriptor = (IBenchmarkSuiteDataDescriptor)descriptor; 56 57 return benchmarkSuiteDataDescriptor.CreateProblemData(); 56 58 } 57 59 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Example.cs
r14727 r14777 1 namespace HeuristicLab.BenchmarkSuite 2 { 3 public class Example 4 { 5 public string Input { get; set; } 1 namespace HeuristicLab.BenchmarkSuite { 2 using System.Linq; 6 3 7 public string Output { get; set; } 4 using HeuristicLab.Common; 5 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 7 [StorableClass] 8 public class Example : DeepCloneable { 9 public Example() { 10 this.InputInt = new long[0]; 11 this.InputFloat = new double[0]; 12 this.InputBoolean = new bool[0]; 13 this.OutputInt = this.InputInt; 14 this.OutputFloat = this.InputFloat; 15 this.OutputBoolean = this.InputBoolean; 16 } 17 18 public Example(Example origin, Cloner cloner) : base(origin, cloner) { 19 origin.CopyTo(this); 20 } 21 22 [StorableConstructor] 23 public Example(bool deserializing) { } 24 25 public void CopyTo(Example example) { 26 example.InputArgs = InputArgs.ToArray(); 27 example.OutputArgs = OutputArgs.ToArray(); 28 29 example.InputBoolean = InputBoolean.ToArray(); 30 example.InputInt = InputInt.ToArray(); 31 example.InputFloat = InputFloat.ToArray(); 32 33 example.OutputBoolean = OutputBoolean.ToArray(); 34 example.OutputInt = OutputInt.ToArray(); 35 example.OutputFloat = OutputFloat.ToArray(); 36 } 37 38 [Storable] 39 public string[] InputArgs { get; set; } 40 [Storable] 41 public string[] OutputArgs { get; set; } 42 43 [Storable] 44 public long[] InputInt { get; set; } 45 [Storable] 46 public double[] InputFloat { get; set; } 47 [Storable] 48 public bool[] InputBoolean { get; set; } 49 [Storable] 50 public char[] InputChar { get; set; } 51 [Storable] 52 public string[] InputString { get; set; } 53 54 [Storable] 55 public long[] OutputInt { get; set; } 56 [Storable] 57 public double[] OutputFloat { get; set; } 58 [Storable] 59 public bool[] OutputBoolean { get; set; } 60 [Storable] 61 public char[] OutputChar { get; set; } 62 [Storable] 63 public string[] OutputString { get; set; } 64 65 public override IDeepCloneable Clone(Cloner cloner) { 66 return new Example(this, cloner); 67 } 8 68 } 9 69 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/HeuristicLab.BenchmarkSuite.csproj
r14744 r14777 47 47 <SpecificVersion>False</SpecificVersion> 48 48 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath> 49 </Reference> 50 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 51 <SpecificVersion>False</SpecificVersion> 52 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 49 53 </Reference> 50 54 <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 97 101 <Compile Include="BenchmarkSuiteDataDescriptor.cs" /> 98 102 <Compile Include="BenchmarkSuiteInstanceProvider.cs" /> 103 <Compile Include="DataTypes.cs" /> 104 <Compile Include="ERC\BooleanErcOptions.cs" /> 105 <Compile Include="ERC\ProblemErcOptions.cs" /> 106 <Compile Include="ERC\ErcOption.cs" /> 107 <Compile Include="ERC\ErcOptionRange.cs" /> 108 <Compile Include="ERC\StringErcOptions.cs" /> 109 <Compile Include="ExampleArgumentConverter.cs" /> 99 110 <Compile Include="IBenchmarkSuiteDataDescriptor.cs" /> 100 111 <Compile Include="Plugin.cs" /> 101 <Compile Include="Problems\Example.cs" /> 112 <Compile Include="Problems\Data.cs" /> 113 <Compile Include="Example.cs" /> 114 <Compile Include="ExampleArgumentType.cs" /> 102 115 <Compile Include="Problems\ReplaceSpaceWithNewline.cs" /> 103 116 <Compile Include="Problems\PigLatin.cs" /> … … 116 129 <Compile Include="Problems\CountOdds.cs" /> 117 130 <Compile Include="Properties\AssemblyInfo.cs" /> 131 <Compile Include="Views\ViewHelper.cs" /> 118 132 <Compile Include="Views\DataEditorView.cs"> 119 133 <SubType>UserControl</SubType> -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/IBenchmarkSuiteDataDescriptor.cs
r14744 r14777 1 1 namespace HeuristicLab.BenchmarkSuite { 2 2 using HeuristicLab.BenchmarkSuite.Problems; 3 using HeuristicLab.Core;4 3 using HeuristicLab.Problems.Instances; 5 4 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); 5 public interface IBenchmarkSuiteDataDescriptor : IDataDescriptor { 6 Data CreateProblemData(); 21 7 } 22 8 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Checksum.cs
r14744 r14777 1 namespace HeuristicLab.BenchmarkSuite.Problems {2 using System;3 using System.Text;1 //namespace HeuristicLab.BenchmarkSuite.Problems { 2 // using System; 3 // using System.Text; 4 4 5 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 5 // public class Checksum : BenchmarkSuiteDataDescriptor { 6 // private const string name = "Checksum"; 7 // private const string fileName = "Checksum.csv"; 8 // private const string description = ""; 9 // private readonly ExampleArgumentType[] inputArgumentTypes = { ExampleArgumentType.IntegerCollection }; 10 // private readonly ExampleArgumentType[] outputArgumentTypes = { ExampleArgumentType.IntegerCollection }; 6 11 7 [StorableClass] 8 public class Checksum : BenchmarkSuiteDataDescriptor { 9 private const string name = "Checksum"; 10 private const string fileName = "Checksum.csv"; 11 private const string description = ""; 12 public Checksum() { } 12 // public override string Name { get { return name; } } 13 // protected override string FileName { get { return fileName; } } 14 // public override string Description { get { return description; } } 15 // public override ExampleArgumentType[] InputArgumentTypes { get { return inputArgumentTypes; } } 16 // public override ExampleArgumentType[] OutputArgumentTypes { get { return outputArgumentTypes; } } 17 // public override int OriginalTrainingCount { get { return 228; } } 18 // public override int OriginalTestCount { get { return 1254; } } 19 // public override int BestResult { get { return 0; } } 20 // public override int WorstResult { get { return byte.MaxValue; } } 13 21 14 [StorableConstructor] 15 public Checksum(bool deserializing) : base(deserializing) { } 16 17 public override string Name { get { return name; } } 18 protected override string FileName { get { return fileName; } } 19 public override string Description { get { return description; } } 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; } } 26 27 public override Example ParseExample(string[] input, string[] output) { 28 return new Example { 29 InputArgs = input, 30 OutputArgs = output, 31 InputInt = Array.ConvertAll(Encoding.ASCII.GetBytes(input[0]), c => (long)c), 32 OutputInt = Array.ConvertAll(Encoding.ASCII.GetBytes(output[0]), c => (long)c) 33 }; 34 } 35 } 36 } 22 // public override Example ParseExample(string[] input, string[] output) { 23 // return new Example { 24 // InputArgs = input, 25 // OutputArgs = output, 26 // InputInt = Array.ConvertAll(Encoding.ASCII.GetBytes(input[0]), c => (long)c), 27 // OutputInt = Array.ConvertAll(Encoding.ASCII.GetBytes(output[0]), c => (long)c) 28 // }; 29 // } 30 // } 31 //} -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/CountOdds.cs
r14744 r14777 1 1 namespace HeuristicLab.BenchmarkSuite.Problems { 2 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 2 using HeuristicLab.BenchmarkSuite.ERC; 3 using HeuristicLab.Data; 3 4 4 [StorableClass]5 5 public class CountOdds : BenchmarkSuiteDataDescriptor { 6 6 private const string name = "Count Odds"; 7 7 private const string fileName = "CountOdds.csv"; 8 8 private const string description = ""; 9 private readonly ExampleArgumentType[] inputArgumentTypes = { ExampleArgumentType.IntegerCollection }; 10 private readonly ExampleArgumentType[] outputArgumentTypes = { ExampleArgumentType.Integer }; 9 11 10 public CountOdds() { } 11 12 [StorableConstructor] 13 public CountOdds(bool deserializing) : base(deserializing) { } 12 private readonly DataTypes enabledDataTypeses = DataTypes.Exec | DataTypes.Integer | DataTypes.Boolean | DataTypes.IntegerVector; 13 private readonly ProblemErcOptions problemErcOptions = new ProblemErcOptions { 14 IntegerErcRange = new ErcOptionRange<IntValue>( 15 new IntValue(-1000), 16 new IntValue(1000), 17 new IntValue(0), 18 new IntValue(1), 19 new IntValue(2)) 20 }; 14 21 15 22 public override string Name { get { return name; } } 16 23 public override string Description { get { return description; } } 17 24 protected override string FileName { get { return fileName; } } 18 public override int InputArgumentCount { get { return 1; } }19 public override int OutputArgumentCount { get { return 1; } }25 public override ExampleArgumentType[] InputArgumentTypes { get { return inputArgumentTypes; } } 26 public override ExampleArgumentType[] OutputArgumentTypes { get { return outputArgumentTypes; } } 20 27 public override int OriginalTrainingCount { get { return 200; } } 21 28 public override int OriginalTestCount { get { return 2000; } } 22 29 public override int BestResult { get { return 0; } } 23 30 public override int WorstResult { get { return 50; } } 31 public override ProblemErcOptions ProblemErcOptions { get { return this.problemErcOptions; } } 32 public override DataTypes EnabledDataTypes { get { return this.enabledDataTypeses; } } 33 public override int MaxSize { get { return 500; } } 34 public override int EvalLimit { get { return 1500; } } 35 public override int MaxGenerations { get { return 300; } } 36 public override int ProgEvalBudget { get { return 60000000; } } 24 37 25 38 public override Example ParseExample(string[] input, string[] output) { … … 27 40 InputArgs = input, 28 41 OutputArgs = output, 29 InputInt = ConvertIntegers(input[0]),30 OutputInt = ConvertIntegers(output[0])42 InputInt = ExampleArgumentConverter.ConvertIntegers(input[0]), 43 OutputInt = ExampleArgumentConverter.ConvertIntegers(output[0]) 31 44 }; 32 45 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Views/DataEditorView.Designer.cs
r14727 r14777 33 33 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 34 34 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 35 this.nameTextBox.Size = new System.Drawing.Size( 302, 20);35 this.nameTextBox.Size = new System.Drawing.Size(758, 20); 36 36 // 37 37 // infoLabel 38 38 // 39 this.infoLabel.Location = new System.Drawing.Point( 366, 3);39 this.infoLabel.Location = new System.Drawing.Point(822, 3); 40 40 // 41 41 // dataGridView -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Views/DataEditorView.cs
r14744 r14777 2 2 3 3 namespace HeuristicLab.BenchmarkSuite.Views { 4 5 using HeuristicLab.BenchmarkSuite.Problems; 4 6 using HeuristicLab.Core.Views; 5 7 using HeuristicLab.MainForm; 6 8 7 9 [View("Push Expression Selection Editor")] 8 [Content(typeof( IBenchmarkSuiteDataDescriptor), true)]10 [Content(typeof(Data), true)] 9 11 public partial class DataEditorView : NamedItemView { 12 private const string ValueSeparator = ", "; 13 10 14 public DataEditorView() { 11 15 InitializeComponent(); … … 20 24 var row = dataGridView.Rows[e.RowIndex]; 21 25 22 var inputArgs = new string[Content.InputArgument Count];23 for (var i = 0; i < Content.InputArgument Count; i++) {26 var inputArgs = new string[Content.InputArgumentTypes.Length]; 27 for (var i = 0; i < Content.InputArgumentTypes.Length; i++) { 24 28 inputArgs[i] = row.Cells[i].Value.ToString(); 25 29 } 26 30 27 var outputArgs = new string[Content.OutputArgument Count];28 for (var i = 0; i < Content.OutputArgument Count; i++) {29 outputArgs[i] = row.Cells[Content.InputArgument Count+ i].Value.ToString();31 var outputArgs = new string[Content.OutputArgumentTypes.Length]; 32 for (var i = 0; i < Content.OutputArgumentTypes.Length; i++) { 33 outputArgs[i] = row.Cells[Content.InputArgumentTypes.Length + i].Value.ToString(); 30 34 } 31 35 … … 33 37 34 38 try { 35 var newExample = Content.ParseExample(inputArgs, outputArgs);39 var newExample = ParseExample(inputArgs, Content.InputArgumentTypes, outputArgs, Content.OutputArgumentTypes); 36 40 newExample.CopyTo(example); 37 41 } … … 40 44 41 45 // reset entry 42 row.Cells[e.ColumnIndex].Value = e.ColumnIndex < Content.InputArgument Count46 row.Cells[e.ColumnIndex].Value = e.ColumnIndex < Content.InputArgumentTypes.Length 43 47 ? example.InputArgs[e.ColumnIndex] 44 : example.OutputArgs[e.ColumnIndex - Content.InputArgument Count];48 : example.OutputArgs[e.ColumnIndex - Content.InputArgumentTypes.Length]; 45 49 } 46 50 } 47 51 48 public new IBenchmarkSuiteDataDescriptor Content 52 private Example ParseExample(string[] inputArgs, ExampleArgumentType[] inputArgTypes, string[] outputArgs, ExampleArgumentType[] outputArgTypes) { 53 var example = new Example(); 54 55 example.InputArgs = new string[inputArgs.Length]; 56 for (var i = 0; i < inputArgs.Length; i++) { 57 var arg = inputArgs[i]; 58 var type = inputArgTypes[i]; 59 60 switch (type) { 61 case ExampleArgumentType.Bool: 62 example.InputBoolean = new[] { ExampleArgumentConverter.ConvertBoolean(arg) }; 63 example.InputArgs[i] = arg; 64 break; 65 case ExampleArgumentType.Integer: 66 example.InputInt = new[] { ExampleArgumentConverter.ConvertInteger(arg) }; 67 example.InputArgs[i] = arg; 68 break; 69 case ExampleArgumentType.IntegerCollection: 70 example.InputInt = ExampleArgumentConverter.ConvertIntegers(arg); 71 example.InputArgs[i] = string.Join(ValueSeparator, example.InputInt); 72 break; 73 case ExampleArgumentType.Float: 74 example.InputFloat = new[] { ExampleArgumentConverter.ConvertDouble(arg) }; 75 example.InputArgs[i] = arg; 76 break; 77 case ExampleArgumentType.FloatCollection: 78 example.InputFloat = ExampleArgumentConverter.ConvertDoubles(arg); 79 example.InputArgs[i] = string.Join(ValueSeparator, example.InputFloat); 80 break; 81 } 82 } 83 84 example.OutputArgs = new string[outputArgs.Length]; 85 for (var i = 0; i < outputArgs.Length; i++) { 86 var arg = outputArgs[i]; 87 var type = outputArgTypes[i]; 88 89 switch (type) { 90 case ExampleArgumentType.Bool: 91 example.OutputBoolean = new[] { ExampleArgumentConverter.ConvertBoolean(arg) }; 92 example.OutputArgs[i] = arg; 93 break; 94 case ExampleArgumentType.Integer: 95 example.OutputInt = new[] { ExampleArgumentConverter.ConvertInteger(arg) }; 96 example.OutputArgs[i] = arg; 97 break; 98 case ExampleArgumentType.IntegerCollection: 99 example.OutputInt = ExampleArgumentConverter.ConvertIntegers(arg); 100 example.OutputArgs[i] = string.Join(ValueSeparator, example.OutputInt); 101 break; 102 case ExampleArgumentType.Float: 103 example.OutputFloat = new[] { ExampleArgumentConverter.ConvertDouble(arg) }; 104 example.OutputArgs[i] = arg; 105 break; 106 case ExampleArgumentType.FloatCollection: 107 example.OutputFloat = ExampleArgumentConverter.ConvertDoubles(arg); 108 example.OutputArgs[i] = string.Join(ValueSeparator, example.OutputFloat); 109 break; 110 } 111 } 112 113 return example; 114 } 115 116 public new Data Content 49 117 { 50 get { return ( IBenchmarkSuiteDataDescriptor)base.Content; }118 get { return (Data)base.Content; } 51 119 set 52 120 { … … 69 137 } 70 138 139 this.nameTextBox.Text = Content.Name; 140 71 141 var cellTemplate = new DataGridViewTextBoxCell(); 72 142 73 for (var i = 1; i <= Content.InputArgumentCount; i++) { 143 for (var i = 0; i < Content.InputArgumentTypes.Length; i++) { 144 var headerTypeName = ViewHelper.GetHeaderTypeName(Content.InputArgumentTypes[i]); 74 145 var column = new DataGridViewColumn { 75 HeaderText = string.Format("Input {0} ", i),146 HeaderText = string.Format("Input {0} : {1}", i + 1, headerTypeName), 76 147 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, 77 148 CellTemplate = cellTemplate … … 81 152 } 82 153 83 for (var i = 1; i <= Content.OutputArgumentCount; i++) { 154 for (var i = 0; i < Content.OutputArgumentTypes.Length; i++) { 155 var headerTypeName = ViewHelper.GetHeaderTypeName(Content.OutputArgumentTypes[i]); 84 156 var column = new DataGridViewColumn { 85 HeaderText = string.Format("Output {0} ", i),157 HeaderText = string.Format("Output {0} : {1}", i + 1, headerTypeName), 86 158 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, 87 159 CellTemplate = cellTemplate … … 97 169 row.CreateCells(dataGridView); 98 170 99 for (var i = 0; i < Content.InputArgument Count; i++) {100 row.Cells[i].Value = example.InputArgs[i];171 for (var i = 0; i < Content.InputArgumentTypes.Length; i++) { 172 row.Cells[i].Value = ViewHelper.StringifyInput(Content.InputArgumentTypes[i], example, ValueSeparator); 101 173 } 102 174 103 for (var i = 0; i < Content.OutputArgument Count; i++) {104 row.Cells[Content.InputArgument Count + i].Value = example.OutputArgs[i];175 for (var i = 0; i < Content.OutputArgumentTypes.Length; i++) { 176 row.Cells[Content.InputArgumentTypes.Length + i].Value = ViewHelper.StringifyOutput(Content.OutputArgumentTypes[i], example, ValueSeparator); 105 177 } 106 178
Note: See TracChangeset
for help on using the changeset viewer.