Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Example.cs @ 18242

Last change on this file since 18242 was 15017, checked in by pkimmesw, 7 years ago

#2665 Fixed Benchmark Problem Definition, Converted LoopExpressions to stateless expressions, Added several unit test to ensure funcionality, Fixed UI bugs

File size: 5.4 KB
Line 
1namespace HeuristicLab.BenchmarkSuite {
2  using System;
3
4  using HeuristicLab.Common;
5  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6
7  [StorableClass]
8  public class Example : DeepCloneable {
9    private static readonly long[] emptyIntegers = new long[0];
10    private static readonly double[] emptyFloats = new double[0];
11    private static readonly bool[] emptyBooleans = new bool[0];
12    private static readonly char[] emptyChars = new char[0];
13    private static readonly string[] emptyStrings = new string[0];
14    private static readonly long[][] emptyIntegerVectors = new long[0][];
15    private static readonly double[][] emptyFloatVectors = new double[0][];
16    private static readonly bool[][] emptyBooleanVectors = new bool[0][];
17    private static readonly string[][] emptyStringVectors = new string[0][];
18
19    public Example() {
20      InputArgs = emptyStrings;
21      OutputArgs = emptyStrings;
22
23      InputInteger = emptyIntegers;
24      InputFloat = emptyFloats;
25      InputBoolean = emptyBooleans;
26      InputChar = emptyChars;
27      InputString = emptyStrings;
28      InputIntegerVector = emptyIntegerVectors;
29      InputFloatVector = emptyFloatVectors;
30      InputBooleanVector = emptyBooleanVectors;
31      InputStringVector = emptyStringVectors;
32
33      OutputInteger = emptyIntegers;
34      OutputFloat = emptyFloats;
35      OutputBoolean = emptyBooleans;
36      OutputChar = emptyChars;
37      OutputString = emptyStrings;
38      OutputIntegerVector = emptyIntegerVectors;
39      OutputFloatVector = emptyFloatVectors;
40      OutputBooleanVector = emptyBooleanVectors;
41      OutputStringVector = emptyStringVectors;
42      OutputPrint = string.Empty;
43      OutputFloatPrecision = 15;
44      OutputFloatVectorPrecision = 15;
45    }
46
47    public Example(Example origin, Cloner cloner) : base(origin, cloner) {
48      InputArgs = (string[])origin.InputArgs.Clone();
49      OutputArgs = (string[])origin.OutputArgs.Clone();
50
51      InputBoolean = (bool[])origin.InputBoolean.Clone();
52      InputInteger = (long[])origin.InputInteger.Clone();
53      InputFloat = (double[])origin.InputFloat.Clone();
54      InputChar = (char[])origin.InputChar.Clone();
55      InputString = (string[])origin.InputString.Clone();
56      InputIntegerVector = (long[][])origin.InputIntegerVector.Clone();
57      InputFloatVector = (double[][])origin.InputFloatVector.Clone();
58      InputBooleanVector = (bool[][])origin.InputBooleanVector.Clone();
59      InputStringVector = (string[][])origin.InputStringVector.Clone();
60
61      OutputBoolean = (bool[])origin.OutputBoolean.Clone();
62      OutputInteger = (long[])origin.OutputInteger.Clone();
63      OutputFloat = (double[])origin.OutputFloat.Clone();
64      OutputChar = (char[])origin.OutputChar.Clone();
65      OutputString = (string[])origin.OutputString.Clone();
66      OutputIntegerVector = (long[][])origin.OutputIntegerVector.Clone();
67      OutputFloatVector = (double[][])origin.OutputFloatVector.Clone();
68      OutputBooleanVector = (bool[][])origin.OutputBooleanVector.Clone();
69      OutputStringVector = (string[][])origin.OutputStringVector.Clone();
70      OutputPrint = origin.OutputPrint;
71      OutputPrintLineCount = origin.OutputPrintLineCount;
72      OutputFloatPrecision = origin.OutputFloatPrecision;
73      OutputFloatVectorPrecision = origin.OutputFloatVectorPrecision;
74    }
75
76    [StorableConstructor]
77    public Example(bool deserializing) { }
78
79    [Storable]
80    public string[] InputArgs { get; set; }
81    [Storable]
82    public string[] OutputArgs { get; set; }
83
84    [Storable]
85    public long[] InputInteger { get; set; }
86    [Storable]
87    public double[] InputFloat { get; set; }
88    [Storable]
89    public bool[] InputBoolean { get; set; }
90    [Storable]
91    public char[] InputChar { get; set; }
92    [Storable]
93    public string[] InputString { get; set; }
94    [Storable]
95    public long[][] InputIntegerVector { get; set; }
96    [Storable]
97    public double[][] InputFloatVector { get; set; }
98    [Storable]
99    public bool[][] InputBooleanVector { get; set; }
100    [Storable]
101    public string[][] InputStringVector { get; set; }
102
103    [Storable]
104    public long[] OutputInteger { get; set; }
105    [Storable]
106    public double[] OutputFloat { get; set; }
107    [Storable]
108    public bool[] OutputBoolean { get; set; }
109    [Storable]
110    public char[] OutputChar { get; set; }
111    [Storable]
112    public string[] OutputString { get; set; }
113    [Storable]
114    public long[][] OutputIntegerVector { get; set; }
115    [Storable]
116    public double[][] OutputFloatVector { get; set; }
117    [Storable]
118    public bool[][] OutputBooleanVector { get; set; }
119    [Storable]
120    public string[][] OutputStringVector { get; set; }
121    [Storable]
122    private string outputPrint;
123    private static readonly string[] NewLineSeparator = { "\r\n", "\n" };
124    public string OutputPrint
125    {
126      get { return outputPrint; }
127      set
128      {
129        outputPrint = value;
130        OutputPrintLineCount = value != null ? value.Split(NewLineSeparator, StringSplitOptions.None).Length : 0;
131      }
132    }
133
134    [Storable]
135    public int OutputPrintLineCount { get; private set; }
136
137    [Storable]
138    public int OutputFloatPrecision { get; set; }
139    [Storable]
140    public int OutputFloatVectorPrecision { get; set; }
141
142    public override IDeepCloneable Clone(Cloner cloner) {
143      return new Example(this, cloner);
144    }
145  }
146}
Note: See TracBrowser for help on using the repository browser.