Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/02/16 18:09:47 (8 years ago)
Author:
gkronber
Message:

#2371: added constructors to allow specification of random seeds for randomly generated regression problem instances (primarily for unit tests)

Location:
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionEight.cs

    r14185 r14228  
    4646    protected override int TestPartitionEnd { get { return 520; } }
    4747
     48    public int Seed { get; }
     49
     50    public NguyenFunctionEight() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionEight(int seed) : base() {
     52      Seed = seed;
     53    }
     54
    4855    protected override List<List<double>> GenerateValues() {
    4956      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, 0, 4).ToList());
     57      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, 0, 4).ToList());
    5158
    5259      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionEleven.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4546    protected override int TestPartitionStart { get { return 20; } }
    4647    protected override int TestPartitionEnd { get { return 1020; } }
     48    public int Seed { get; }
    4749
     50    public NguyenFunctionEleven() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionEleven(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 1).ToList());
    51       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 1).ToList());
     56      var rand = new MersenneTwister((uint)Seed);
     57
     58      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 1).ToList());
     59      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 1).ToList());
    5260
    5361      double x, y;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionFive.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionFive() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionFive(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionFour.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionFour() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionFour(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionNine.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4546    protected override int TestPartitionStart { get { return 20; } }
    4647    protected override int TestPartitionEnd { get { return 1020; } }
     48    public int Seed { get; }
    4749
     50    public NguyenFunctionNine() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionNine(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 1).ToList());
    51       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 1).ToList());
     56      var rand = new MersenneTwister((uint)Seed);
     57
     58      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 1).ToList());
     59      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 1).ToList());
    5260
    5361      double x, y;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionOne.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionOne() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionOne(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionSeven.cs

    r14185 r14228  
    4646    protected override int TestPartitionEnd { get { return 520; } }
    4747
     48    public int Seed { get; }
     49
     50    public NguyenFunctionSeven() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionSeven(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, 0, 2).ToList());
     56      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, 0, 2).ToList());
    5157
    5258      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionSix.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionSix() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionSix(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
     
    5459      for (int i = 0; i < data[0].Count; i++) {
    5560        x = data[0][i];
    56         results.Add(Math.Sin(x) + Math.Sin(x + x*x));
     61        results.Add(Math.Sin(x) + Math.Sin(x + x * x));
    5762      }
    5863      data.Add(results);
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionTen.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4546    protected override int TestPartitionStart { get { return 20; } }
    4647    protected override int TestPartitionEnd { get { return 1020; } }
     48    public int Seed { get; }
    4749
     50    public NguyenFunctionTen() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionTen(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
    51       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
     56      var rand = new MersenneTwister((uint)Seed);
     57
     58      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
     59      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
    5260
    5361      double x, y;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionThree.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionThree() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionThree(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionTwelve.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4546    protected override int TestPartitionStart { get { return 20; } }
    4647    protected override int TestPartitionEnd { get { return 1020; } }
     48    public int Seed { get; }
    4749
     50    public NguyenFunctionTwelve() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionTwelve(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
    51       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
     56      var rand = new MersenneTwister((uint)Seed);
     57
     58      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
     59      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
    5260
    5361      double x, y;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenFunctionTwo.cs

    r14185 r14228  
    4545    protected override int TestPartitionStart { get { return 20; } }
    4646    protected override int TestPartitionEnd { get { return 520; } }
     47    public int Seed { get; }
    4748
     49    public NguyenFunctionTwo() : this((int)System.DateTime.Now.Ticks) { }
     50    public NguyenFunctionTwo(int seed) : base() {
     51      Seed = seed;
     52    }
    4853    protected override List<List<double>> GenerateValues() {
    4954      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(520, -1, 1).ToList());
     55      data.Add(ValueGenerator.GenerateUniformDistributedValues(Seed, 520, -1, 1).ToList());
    5156
    5257      double x;
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Nguyen/NguyenInstanceProvider.cs

    r14185 r14228  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Random;
    2425
    2526namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    3738      get { return "McDermott et al., 2012 \"Genetic Programming Needs Better Benchmarks\", in Proc. of GECCO 2012."; }
    3839    }
     40    public int Seed { get; }
     41
     42    public NguyenInstanceProvider() : this((int)System.DateTime.Now.Ticks) { }
     43    public NguyenInstanceProvider(int seed) : base() {
     44      Seed = seed;
     45    }
    3946
    4047    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    4148      List<IDataDescriptor> descriptorList = new List<IDataDescriptor>();
    42       descriptorList.Add(new NguyenFunctionOne());
    43       descriptorList.Add(new NguyenFunctionTwo());
    44       descriptorList.Add(new NguyenFunctionThree());
    45       descriptorList.Add(new NguyenFunctionFour());
    46       descriptorList.Add(new NguyenFunctionFive());
    47       descriptorList.Add(new NguyenFunctionSix());
    48       descriptorList.Add(new NguyenFunctionSeven());
    49       descriptorList.Add(new NguyenFunctionEight());
    50       descriptorList.Add(new NguyenFunctionNine());
    51       descriptorList.Add(new NguyenFunctionTen());
    52       descriptorList.Add(new NguyenFunctionEleven());
    53       descriptorList.Add(new NguyenFunctionTwelve());
     49      var rand = new MersenneTwister((uint)Seed);
     50      descriptorList.Add(new NguyenFunctionOne(rand.Next()));
     51      descriptorList.Add(new NguyenFunctionTwo(rand.Next()));
     52      descriptorList.Add(new NguyenFunctionThree(rand.Next()));
     53      descriptorList.Add(new NguyenFunctionFour(rand.Next()));
     54      descriptorList.Add(new NguyenFunctionFive(rand.Next()));
     55      descriptorList.Add(new NguyenFunctionSix(rand.Next()));
     56      descriptorList.Add(new NguyenFunctionSeven(rand.Next()));
     57      descriptorList.Add(new NguyenFunctionEight(rand.Next()));
     58      descriptorList.Add(new NguyenFunctionNine(rand.Next()));
     59      descriptorList.Add(new NguyenFunctionTen(rand.Next()));
     60      descriptorList.Add(new NguyenFunctionEleven(rand.Next()));
     61      descriptorList.Add(new NguyenFunctionTwelve(rand.Next()));
    5462      return descriptorList;
    5563    }
Note: See TracChangeset for help on using the changeset viewer.