Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Views/ViewHelper.cs @ 14909

Last change on this file since 14909 was 14909, checked in by pkimmesw, 8 years ago

#2665 Fixed VectorExpression errors, Fixed BenchmarkSuite Problem Data View issues

File size: 3.8 KB
Line 
1namespace HeuristicLab.BenchmarkSuite.Views {
2  using System.Linq;
3
4  public static class ViewHelper {
5    public static string StringifyInput(ExampleArgumentType type, Example example, string valueSeparator) {
6      switch (type) {
7        case ExampleArgumentType.Integer: return string.Join(valueSeparator, example.InputInteger);
8        case ExampleArgumentType.IntegerVector: return "[" + string.Join("], [", example.InputIntegerVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
9
10        case ExampleArgumentType.Float: return string.Join(valueSeparator, example.InputFloat);
11        case ExampleArgumentType.FloatVector: return "[" + string.Join("], [", example.InputFloatVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
12
13        case ExampleArgumentType.Boolean: return string.Join(valueSeparator, example.InputBoolean);
14        case ExampleArgumentType.Char: return string.Join(valueSeparator, example.InputChar);
15
16        case ExampleArgumentType.String: return string.Join(valueSeparator, example.InputString);
17        case ExampleArgumentType.StringVector: return "[" + string.Join("], [", example.InputStringVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
18        default: return string.Empty;
19      }
20    }
21
22    public static string StringifyOutput(ExampleArgumentType type, Example example, string valueSeparator) {
23      switch (type) {
24        case ExampleArgumentType.Integer: return string.Join(valueSeparator, example.OutputInteger);
25        case ExampleArgumentType.IntegerVector: return "[" + string.Join("], [", example.OutputIntegerVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
26
27        case ExampleArgumentType.Float: return string.Join(valueSeparator, example.OutputFloat);
28        case ExampleArgumentType.FloatVector: return "[" + string.Join("], [", example.OutputFloatVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
29
30        case ExampleArgumentType.Boolean: return string.Join(valueSeparator, example.OutputBoolean);
31        case ExampleArgumentType.Char: return string.Join(valueSeparator, example.OutputChar);
32
33        case ExampleArgumentType.String: return string.Join(valueSeparator, example.OutputString);
34        case ExampleArgumentType.Print: return string.Join(valueSeparator, example.OutputPrint);
35        case ExampleArgumentType.StringVector: return "[" + string.Join("], [", example.OutputStringVector.Select(vector => string.Join(valueSeparator, vector))) + "]";
36
37        default: return string.Empty;
38      }
39    }
40
41    private const string IntegerColumnHeader = "int";
42    private const string IntegersColumnHeader = "int[]";
43    private const string DoubleColumnHeader = "float";
44    private const string DoublesColumnHeader = "float[]";
45    private const string BooleanColumnHeader = "bool";
46    private const string CharColumnHeader = "char";
47    private const string StringColumnHeader = "string";
48    private const string PrintColumnHeader = "print";
49    private const string StringsColumnHeader = "string[]";
50    public static string GetHeaderTypeName(ExampleArgumentType type) {
51      switch (type) {
52        case ExampleArgumentType.Integer: return IntegerColumnHeader;
53        case ExampleArgumentType.Float: return DoubleColumnHeader;
54        case ExampleArgumentType.Boolean: return BooleanColumnHeader;
55        case ExampleArgumentType.Char: return CharColumnHeader;
56        case ExampleArgumentType.String: return StringColumnHeader;
57        case ExampleArgumentType.Print: return PrintColumnHeader;
58        case ExampleArgumentType.IntegerVector: return IntegersColumnHeader;
59        case ExampleArgumentType.FloatVector: return DoublesColumnHeader;
60        case ExampleArgumentType.StringVector: return StringsColumnHeader;
61        default: return string.Empty;
62      }
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.