- Timestamp:
- 12/20/16 22:57:11 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/ArtificialDataDescriptor.cs
r14392 r14513 1 using System.Collections.Generic; 2 using HeuristicLab.Problems.Instances; 1 namespace HeuristicLab.BenchmarkSuite 2 { 3 using System.Collections.Generic; 3 4 4 namespace HeuristicLab.BenchmarkSuite 5 { 6 public abstract class ArtificialDataDescriptor : IDataDescriptor 7 { 8 public abstract string Description { get; } 9 public abstract string Name { get; } 5 using HeuristicLab.Problems.Instances; 10 6 11 protected abstract IEnumerable<Example> GenerateExamples(); 12 } 7 public abstract class ArtificialDataDescriptor : IDataDescriptor 8 { 9 public abstract string Description { get; } 10 11 public abstract string Name { get; } 12 13 protected abstract IEnumerable<Example> GenerateExamples(); 14 } 13 15 } -
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs
r14392 r14513 1 using System.Collections.Generic;2 using HeuristicLab.Core; 3 using HeuristicLab.Random;1 namespace HeuristicLab.BenchmarkSuite 2 { 3 using System.Collections.Generic; 4 4 5 namespace HeuristicLab.BenchmarkSuite 6 { 7 public abstract class BenchmarkSuiteDataDescritpor<T> : ArtificialDataDescriptor 5 using HeuristicLab.Core; 6 using HeuristicLab.Random; 7 8 public abstract class BenchmarkSuiteDataDescritpor<T> : ArtificialDataDescriptor 9 { 10 protected static IRandom rand = new FastRandom(); 11 12 protected abstract IEnumerable<T> GenerateTraining(); 13 14 protected abstract IEnumerable<T> GenerateTest(); 15 16 protected abstract IEnumerable<Example> GenerateExamples(IEnumerable<T> trainingAndTest); 17 18 protected override IEnumerable<Example> GenerateExamples() 8 19 { 9 protected static IRandom rand = new FastRandom();20 var training = this.GenerateTraining(); 10 21 11 protected abstract IEnumerable<T> GenerateTraining(); 12 protected abstract IEnumerable<T> GenerateTest(); 22 training = training.Shuffle(rand); 13 23 14 protected abstract IEnumerable<Example> GenerateExamples(IEnumerable<T> trainingAndTest);24 var test = this.GenerateTest(); 15 25 16 protected override IEnumerable<Example> GenerateExamples()17 {18 var training = GenerateTraining();26 var all = new List<T>(); 27 all.AddRange(training); 28 all.AddRange(test); 19 29 20 training = training.Shuffle(rand); 21 22 var test = GenerateTest(); 23 24 var all = new List<T>(); 25 all.AddRange(training); 26 all.AddRange(test); 27 28 return GenerateExamples(all); 29 } 30 return this.GenerateExamples(all); 30 31 } 32 } 31 33 } -
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Example.cs
r14392 r14513 1 1 namespace HeuristicLab.BenchmarkSuite 2 2 { 3 public class Example 4 { 5 public string Input { get; set; } 6 public string Output { get; set; } 7 } 3 public class Example 4 { 5 public string Input { get; set; } 6 7 public string Output { get; set; } 8 } 8 9 } -
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Problems/CountOdds.cs
r14398 r14513 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 1 namespace HeuristicLab.BenchmarkSuite.Problems 2 { 3 using System.Collections.Generic; 4 using System.Linq; 4 5 5 namespace HeuristicLab.BenchmarkSuite.Problems 6 { 7 public class CountOdds : BenchmarkSuiteDataDescritpor<List<int>> 6 public class CountOdds : BenchmarkSuiteDataDescritpor<List<int>> 7 { 8 public const int MaxOdd = 999; 9 10 public const int MaxEven = 1000; 11 12 public const int MaxRandom = 1000; 13 14 public const int MinRandom = 1000; 15 16 public const int MaxVectorLength = 50; 17 18 public override string Description 8 19 { 9 public const int MaxOdd = 999;10 public const int MaxEven = 1000;11 public const int MaxRandom = 1000;12 public const int MinRandom = 1000;13 public const int MaxVectorLength = 50;20 get 21 { 22 return string.Empty; 23 } 24 } 14 25 15 public override string Description { get { return String.Empty; } } 26 public override string Name 27 { 28 get 29 { 30 return "Count Odds"; 31 } 32 } 16 33 17 public override string Name { get { return "Count Odds"; } } 34 protected override IEnumerable<Example> GenerateExamples(IEnumerable<List<int>> inputData) 35 { 36 foreach (var input in inputData) 37 yield return 38 new Example 39 { 40 Input = string.Format("[{0}]", string.Join(", ", input)), 41 Output = input.Count(x => x % 2 == 1).ToString() 42 }; 43 } 18 44 19 protected override IEnumerable<Example> GenerateExamples(IEnumerable<List<int>> inputData) 20 { 21 foreach (var input in inputData) 22 { 23 yield return new Example() 24 { 25 Input = string.Format("[{0}]", string.Join(", ", input)), 26 Output = input.Count(x => x % 2 == 1).ToString() 27 }; 28 } 29 } 45 protected override IEnumerable<List<int>> GenerateTest() 46 { 47 foreach (var list in this.GetHardcodedTrainingSamples()) yield return list; 30 48 31 protected override IEnumerable<List<int>> GenerateTest() 32 { 33 foreach (var list in GetHardcodedTrainingSamples()) 34 yield return list; 49 foreach (var list in this.GetAllOdd(100)) yield return list; 35 50 36 foreach (var list in GetAllOdd(n: 100)) 37 yield return list; 51 foreach (var list in this.GetAllEven(100)) yield return list; 38 52 39 foreach (var list in GetAllEven(n: 100))40 yield return list;53 foreach (var list in this.GetRandom(1800)) yield return list; 54 } 41 55 42 foreach (var list in GetRandom(n: 1800))43 yield return list;44 }56 protected override IEnumerable<List<int>> GenerateTraining() 57 { 58 foreach (var list in this.GetHardcodedTrainingSamples()) yield return list; 45 59 46 protected override IEnumerable<List<int>> GenerateTraining() 47 { 48 foreach (var list in GetHardcodedTrainingSamples()) 49 yield return list; 60 foreach (var list in this.GetAllOdd(9)) yield return list; 50 61 51 foreach (var list in GetAllOdd(n: 9)) 52 yield return list; 62 foreach (var list in this.GetAllEven(9)) yield return list; 53 63 54 foreach (var list in GetAllEven(n: 9))55 yield return list;64 foreach (var list in this.GetRandom(150)) yield return list; 65 } 56 66 57 foreach (var list in GetRandom(n: 150)) 58 yield return list; 59 } 67 private IEnumerable<List<int>> GetAllOdd(int n) 68 { 69 for (var i = 0; i < n; i++) 70 { 71 var length = rand.Next(0, MaxVectorLength); 72 var vector = new List<int>(length); 60 73 61 private IEnumerable<List<int>> GetAllOdd(int n) 62 { 63 for (var i = 0; i < n; i++) 64 { 65 var length = rand.Next(0, MaxVectorLength); 66 var vector = new List<int>(length); 74 for (var j = 0; j < length; j++) vector.Add(rand.Next(0, MaxOdd) * 2 - MaxOdd); 67 75 68 for (var j = 0; j < length; j++) 69 { 70 vector.Add(rand.Next(0, MaxOdd) * 2 - MaxOdd); 71 } 76 yield return vector; 77 } 78 } 72 79 73 yield return vector; 74 } 75 } 80 private IEnumerable<List<int>> GetAllEven(int n) 81 { 82 for (var i = 0; i < n; i++) 83 { 84 var length = rand.Next(0, MaxVectorLength); 85 var vector = new List<int>(length); 76 86 77 private IEnumerable<List<int>> GetAllEven(int n) 78 { 79 for (var i = 0; i < n; i++) 80 { 81 var length = rand.Next(0, MaxVectorLength); 82 var vector = new List<int>(length); 87 for (var j = 0; j < length; j++) vector.Add(rand.Next(0, MaxEven) * 2 - MaxEven); 83 88 84 for (var j = 0; j < length; j++) 85 { 86 vector.Add(rand.Next(0, MaxEven) * 2 - MaxEven); 87 } 89 yield return vector; 90 } 91 } 88 92 89 yield return vector; 90 } 91 } 93 private IEnumerable<List<int>> GetRandom(int n) 94 { 95 for (var i = 0; i < n; i++) 96 { 97 var length = rand.Next(0, MaxVectorLength); 98 var vector = new List<int>(length); 92 99 93 private IEnumerable<List<int>> GetRandom(int n) 94 { 95 for (var i = 0; i < n; i++) 96 { 97 var length = rand.Next(0, MaxVectorLength); 98 var vector = new List<int>(length); 100 for (var j = 0; j < length; j++) vector.Add(rand.Next(MinRandom, MaxRandom)); 99 101 100 for (var j = 0; j < length; j++) 101 { 102 vector.Add(rand.Next(MinRandom, MaxRandom)); 103 } 102 yield return vector; 103 } 104 } 104 105 105 yield return vector; 106 } 107 } 108 109 private IEnumerable<List<int>> GetHardcodedTrainingSamples() 110 { 111 yield return new List<int>() { }; 112 yield return new List<int>() { -10 }; 113 yield return new List<int>() { -9 }; 114 yield return new List<int>() { -8 }; 115 yield return new List<int>() { -7 }; 116 yield return new List<int>() { -6 }; 117 yield return new List<int>() { -5 }; 118 yield return new List<int>() { -4 }; 119 yield return new List<int>() { -3 }; 120 yield return new List<int>() { -2 }; 121 yield return new List<int>() { -1 }; 122 yield return new List<int>() { -0 }; 123 yield return new List<int>() { 1 }; 124 yield return new List<int>() { 2 }; 125 yield return new List<int>() { 3 }; 126 yield return new List<int>() { 4 }; 127 yield return new List<int>() { 5 }; 128 yield return new List<int>() { 6 }; 129 yield return new List<int>() { 7 }; 130 yield return new List<int>() { 8 }; 131 yield return new List<int>() { 9 }; 132 yield return new List<int>() { 10 }; 133 yield return new List<int>() { -947 }; 134 yield return new List<int>() { -450 }; 135 yield return new List<int>() { 303 }; 136 yield return new List<int>() { 886 }; 137 yield return new List<int>() { 0, 0 }; 138 yield return new List<int>() { 0, 1 }; 139 yield return new List<int>() { 7, 1 }; 140 yield return new List<int>() { -9, -1 }; 141 yield return new List<int>() { -11, 40 }; 142 yield return new List<int>() { 944, 77 }; 143 } 106 private IEnumerable<List<int>> GetHardcodedTrainingSamples() 107 { 108 yield return new List<int>(); 109 yield return new List<int> { -10 }; 110 yield return new List<int> { -9 }; 111 yield return new List<int> { -8 }; 112 yield return new List<int> { -7 }; 113 yield return new List<int> { -6 }; 114 yield return new List<int> { -5 }; 115 yield return new List<int> { -4 }; 116 yield return new List<int> { -3 }; 117 yield return new List<int> { -2 }; 118 yield return new List<int> { -1 }; 119 yield return new List<int> { -0 }; 120 yield return new List<int> { 1 }; 121 yield return new List<int> { 2 }; 122 yield return new List<int> { 3 }; 123 yield return new List<int> { 4 }; 124 yield return new List<int> { 5 }; 125 yield return new List<int> { 6 }; 126 yield return new List<int> { 7 }; 127 yield return new List<int> { 8 }; 128 yield return new List<int> { 9 }; 129 yield return new List<int> { 10 }; 130 yield return new List<int> { -947 }; 131 yield return new List<int> { -450 }; 132 yield return new List<int> { 303 }; 133 yield return new List<int> { 886 }; 134 yield return new List<int> { 0, 0 }; 135 yield return new List<int> { 0, 1 }; 136 yield return new List<int> { 7, 1 }; 137 yield return new List<int> { -9, -1 }; 138 yield return new List<int> { -11, 40 }; 139 yield return new List<int> { 944, 77 }; 144 140 } 141 } 145 142 } -
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Properties/AssemblyInfo.cs
r14392 r14513 1 1 using System.Reflection; 2 using System.Runtime.CompilerServices;3 2 using System.Runtime.InteropServices; 4 3 … … 6 5 // set of attributes. Change these attribute values to modify the information 7 6 // associated with an assembly. 7 8 8 [assembly: AssemblyTitle("HeuristicLab.BenchmarkSuite")] 9 9 [assembly: AssemblyDescription("")] … … 18 18 // to COM components. If you need to access a type in this assembly from 19 19 // COM, set the ComVisible attribute to true on that type. 20 20 21 [assembly: ComVisible(false)] 21 22 22 23 // The following GUID is for the ID of the typelib if this project is exposed to COM 24 23 25 [assembly: Guid("22b5c087-cfc7-4d40-86c6-32fcf2ca921e")] 24 26 … … 33 35 // by using the '*' as shown below: 34 36 // [assembly: AssemblyVersion("1.0.*")] 37 35 38 [assembly: AssemblyVersion("1.0.0.0")] 36 39 [assembly: AssemblyFileVersion("1.0.0.0")]
Note: See TracChangeset
for help on using the changeset viewer.